regify utility  2.0.0-0
types.h
1 /*
2  * Copyright regify
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 #ifndef REGIFY_UTIL_TYPES_H
23 #define REGIFY_UTIL_TYPES_H
24 /* Only need to export C interface if used by C++ source code */
25 #ifdef __cplusplus
26 extern "C" {
27 #endif /* __cplusplus */
40 typedef ru_uint (*ruHashFunc)(trans_ptr key);
41 
45 typedef bool (*ruMatchFunc)(trans_ptr testKey, trans_ptr existingKey);
46 
50 typedef int32_t (*ruCompFunc) (trans_ptr a, trans_ptr b);
51 
57 typedef ptr (*ruCloneFunc)(ptr val);
58 
66 typedef int32_t (*ruPtr2TypeFunc)(ptr src, ptr* dst);
67 
68 
77 typedef void* ru_Int64;
78 
86 
93 RUAPI bool ruInt64Match(trans_ptr s1, trans_ptr s2);
94 
103 RUAPI int32_t ruInt64Comp(trans_ptr testVal, trans_ptr existingVal);
104 
110 RUAPI ru_Int64 ruInt64(ptr val);
111 
118 RUAPI int32_t ruRefPtrInt64(ptr src, ptr* dst);
119 
136 RUAPI ruType ruTypeInt64(void);
151 
158 RUAPI bool ruLongMatch(trans_ptr s1, trans_ptr s2);
159 
168 RUAPI int32_t ruLongComp(trans_ptr testVal, trans_ptr existingVal);
169 
175 RUAPI ptr ruLongRefPtr(ptr in);
176 
183 RUAPI int32_t ruRefPtrLong(ptr src, ptr* dst);
184 
200 RUAPI ruType ruTypeLong(void);
216 
223 RUAPI bool ruInt32Match(trans_ptr testKey, trans_ptr existingKey);
224 
233 RUAPI int32_t ruInt32Comp(trans_ptr testVal, trans_ptr existingVal);
234 
241 
248 RUAPI int32_t ruRefPtrInt32(ptr src, ptr* dst);
249 
254 RUAPI ruType ruTypeInt32(void);
270 
277 RUAPI bool ruInt16Match(trans_ptr testKey, trans_ptr existingKey);
278 
287 RUAPI int32_t ruInt16Comp(trans_ptr testVal, trans_ptr existingVal);
288 
295 
302 RUAPI int32_t ruRefPtrInt16(ptr src, ptr* dst);
303 
308 RUAPI ruType ruTypeInt16(void);
324 
331 RUAPI bool ruInt8Match(trans_ptr testKey, trans_ptr existingKey);
332 
341 RUAPI int32_t ruInt8Comp(trans_ptr testVal, trans_ptr existingVal);
342 
348 RUAPI ptr ruInt8RefPtr(ptr in);
349 
356 RUAPI int32_t ruRefPtrInt8(ptr src, ptr* dst);
357 
362 RUAPI ruType ruTypeInt8(void);
379 
386 RUAPI bool ruBoolMatch(trans_ptr testKey, trans_ptr existingKey);
387 
396 RUAPI int32_t ruBoolComp(trans_ptr testVal, trans_ptr existingVal);
397 
403 RUAPI ptr ruBoolRefPtr(ptr in);
404 
411 RUAPI int32_t ruRefPtrBool(ptr src, ptr* dst);
412 
418 RUAPI ruType ruTypeBool(void);
435 
442 RUAPI bool ruPtrMatch(trans_ptr s1, trans_ptr s2);
443 
452 RUAPI int32_t ruPtrComp(trans_ptr testVal, trans_ptr existingVal);
453 
470 RUAPI ruType ruTypeIntPtr(void);
488 
495 RUAPI bool ruStrMatch(trans_ptr s1, trans_ptr s2);
496 
505 RUAPI int32_t ruStrComp(trans_ptr testVal, trans_ptr existingVal);
506 
527 RUAPI ruType ruTypeStrRef(void);
528 
546 RUAPI ruType ruTypeStrDup(void);
547 
567 RUAPI ruType ruTypeStrFree(void);
575 RUAPI ruType ruTypePtrFree(void);
576 
616  ruClearFunc free, ruCloneFunc in, ruPtr2TypeFunc out);
617 
626 
634 
644 
649 #endif //REGIFY_UTIL_TYPES_H
ptr(* ruClearFunc)(ptr o)
Signature of a generic free function returning NULL.
Definition: regify-util.h:356
const void * trans_ptr
A transient pointer.
Definition: regify-util.h:287
uintptr_t ru_uint
A pointer sized unsigned integer type for collections like ruMap or ruList.
Definition: regify-util.h:333
void * ptr
A generic pointer.
Definition: regify-util.h:304
RUAPI ruType ruTypeClone(ruType tp)
Returns a copy of the given ruType.
RUAPI ruType ruTypePtr(ruClearFunc free)
Creates a custom ruTypeIntPtr specification.
RUAPI ruType ruTypeFree(ruType tp)
Frees given custom ruType.
void * ruType
An opaque type representing a type specification.
Definition: regify-util.h:344
int32_t(* ruCompFunc)(trans_ptr a, trans_ptr b)
Signature of a generic comparator function for sorting.
Definition: types.h:50
bool(* ruMatchFunc)(trans_ptr testKey, trans_ptr existingKey)
Function signature of a matching function for ruMap or ruSet keys.
Definition: types.h:45
ru_uint(* ruHashFunc)(trans_ptr key)
Function signature of a hashing function for ruMap or ruSet keys.
Definition: types.h:40
RUAPI ruType ruTypePtrFree(void)
Returns an ruType used for malloced types that use standard free.
int32_t(* ruPtr2TypeFunc)(ptr src, ptr *dst)
Signature of a function that stores the value of the first pointer in a certain type by de-referencin...
Definition: types.h:66
ptr(* ruCloneFunc)(ptr val)
Signature of a generic clone function. This is the signature of the in function in ruTypeNew.
Definition: types.h:57
RUAPI ruType ruTypeNew(ruHashFunc hash, ruMatchFunc match, ruCompFunc comp, ruClearFunc free, ruCloneFunc in, ruPtr2TypeFunc out)
Creates a custom type specification usable as a map key.
RUAPI ptr ruBoolRefPtr(ptr in)
Returns the content of the given boolean address as pointer.
RUAPI int32_t ruRefPtrBool(ptr src, ptr *dst)
Copies the boolean stored in src to dst.
RUAPI int32_t ruBoolComp(trans_ptr testVal, trans_ptr existingVal)
boolean comparator function for the ruType system
RUAPI ruType ruTypeBool(void)
Returns an ruType used for booleans.
RUAPI bool ruBoolMatch(trans_ptr testKey, trans_ptr existingKey)
Convenience boolean match function for Maps.
RUAPI ru_uint ruBoolHash(trans_ptr key)
Returns a hash for given boolean number.
RUAPI bool ruInt16Match(trans_ptr testKey, trans_ptr existingKey)
Convenience 16 bit integer match function for Maps.
RUAPI int32_t ruInt16Comp(trans_ptr testVal, trans_ptr existingVal)
16 bit integer comparator function for the ruType system
RUAPI ruType ruTypeInt16(void)
Returns an ruType used for 16 bit integers.
RUAPI ptr ruInt16RefPtr(ptr in)
Returns the content of the given 16 bit integer address as pointer.
RUAPI int32_t ruRefPtrInt16(ptr src, ptr *dst)
Copies the 16 bit integer stored in src to dst.
RUAPI ru_uint ruInt16Hash(trans_ptr key)
Returns a hash for given 16 bit integer number.
RUAPI int32_t ruRefPtrInt32(ptr src, ptr *dst)
Copies the 32 bit integer stored in src to dst.
RUAPI ru_uint ruInt32Hash(trans_ptr key)
Returns a hash for given 32 bit integer number.
RUAPI ruType ruTypeInt32(void)
Returns an ruType used for 32 bit integers.
RUAPI ptr ruInt32RefPtr(ptr in)
Returns the content of the given 32 bit integer address as pointer.
RUAPI bool ruInt32Match(trans_ptr testKey, trans_ptr existingKey)
Convenience 32 bit integer match function for Maps.
RUAPI int32_t ruInt32Comp(trans_ptr testVal, trans_ptr existingVal)
32 bit integer comparator function for the ruType system
RUAPI int32_t ruInt64Comp(trans_ptr testVal, trans_ptr existingVal)
64 bit integer comparator function for the ruType system
RUAPI bool ruInt64Match(trans_ptr s1, trans_ptr s2)
Convenience 64 bit integer match function for Maps.
RUAPI int32_t ruRefPtrInt64(ptr src, ptr *dst)
Copies the 64 bit integer stored in src to dst.
RUAPI ruType ruTypeInt64(void)
Returns an ruType used for 64 bit integers.
RUAPI ru_Int64 ruInt64(ptr val)
Allocates given 64 bit integer on the heap and returns the pointer.
RUAPI ru_uint ruInt64Hash(trans_ptr key)
Returns a hash for given 64 bit integer number.
void * ru_Int64
A pointer to an allocated 64 bit int. Free with ruFree.
Definition: types.h:77
RUAPI ptr ruInt8RefPtr(ptr in)
Returns the content of the given 8 bit integer address as pointer.
RUAPI bool ruInt8Match(trans_ptr testKey, trans_ptr existingKey)
Convenience 8 bit integer match function for Maps.
RUAPI int32_t ruRefPtrInt8(ptr src, ptr *dst)
Copies the 8 bit integer stored in src to dst.
RUAPI int32_t ruInt8Comp(trans_ptr testVal, trans_ptr existingVal)
8 bit integer comparator function for the ruType system
RUAPI ru_uint ruInt8Hash(trans_ptr key)
Returns a hash for given 8 bit integer number.
RUAPI ruType ruTypeInt8(void)
Returns an ruType used for 8 bit integers.
RUAPI ru_uint ruPtrHash(trans_ptr key)
Returns a hash for given pointer size integer number.
RUAPI int32_t ruPtrComp(trans_ptr testVal, trans_ptr existingVal)
Pointer size integer comparator function for the ruType system.
RUAPI bool ruPtrMatch(trans_ptr s1, trans_ptr s2)
Convenience pointer size integer match function for Maps.
RUAPI ruType ruTypeIntPtr(void)
Returns an ruType used for pointer size integers. Example:
RUAPI bool ruLongMatch(trans_ptr s1, trans_ptr s2)
Convenience long integer match function for Maps.
RUAPI ru_uint ruLongHash(trans_ptr key)
Returns a hash for given long integer number.
RUAPI ruType ruTypeLong(void)
Returns an ruType used for long integers. Example:
RUAPI int32_t ruRefPtrLong(ptr src, ptr *dst)
Copies the long integer stored in src to dst.
RUAPI ptr ruLongRefPtr(ptr in)
Returns the content of the given long integer address as pointer.
RUAPI int32_t ruLongComp(trans_ptr testVal, trans_ptr existingVal)
long integer comparator function for the ruType system
RUAPI ruType ruTypeStrRef(void)
Returns an ruType used for permanent strings.
RUAPI bool ruStrMatch(trans_ptr s1, trans_ptr s2)
Convenience match function for Maps.
RUAPI ru_uint ruStrHash(trans_ptr key)
Returns a hash for given string.
RUAPI int32_t ruStrComp(trans_ptr testVal, trans_ptr existingVal)
String comparator function for the ruType system.
RUAPI ruType ruTypeStrDup(void)
Returns an ruType used for transient strings.
RUAPI ruType ruTypeStrFree(void)
Returns an ruType used for externally allocated string.