regify utility  2.0.0-0

This section contains collection support for single byte strings such as char*. More...

Functions

RUAPI ru_uint ruStrHash (trans_ptr key)
 Returns a hash for given string. More...
 
RUAPI bool ruStrMatch (trans_ptr s1, trans_ptr s2)
 Convenience match function for Maps. More...
 
RUAPI int32_t ruStrComp (trans_ptr testVal, trans_ptr existingVal)
 String comparator function for the ruType system. More...
 
RUAPI ruType ruTypeStrRef (void)
 Returns an ruType used for permanent strings. More...
 
RUAPI ruType ruTypeStrDup (void)
 Returns an ruType used for transient strings. More...
 
RUAPI ruType ruTypeStrFree (void)
 Returns an ruType used for externally allocated string. More...
 

Detailed Description

This section contains collection support for single byte strings such as char*.

Function Documentation

◆ ruStrComp()

RUAPI int32_t ruStrComp ( trans_ptr  testVal,
trans_ptr  existingVal 
)

String comparator function for the ruType system.

Parameters
testValValue to compare against existing value.
existingValThe existing value to compare testVal to.
Returns
-1 if testVal is less existingVal, 1 if testVal is greater existingVal or 0 in case both of them are equal.

◆ ruStrHash()

RUAPI ru_uint ruStrHash ( trans_ptr  key)

Returns a hash for given string.

This function is useful for Maps.

Parameters
keyString to hash.
Returns
The hash of the given string or 0 if NULL was given.

◆ ruStrMatch()

RUAPI bool ruStrMatch ( trans_ptr  s1,
trans_ptr  s2 
)

Convenience match function for Maps.

Parameters
s1First comparison string.
s2Second comparison string.
Returns
true if ruStrCmp returns 0

◆ ruTypeStrDup()

RUAPI ruType ruTypeStrDup ( void  )

Returns an ruType used for transient strings.

Example:

// error checking left out for brevity
ruMapPut(rm, "23", "42");
perm_chars r = NULL;
ruMapGet(rm, "23", &r);
printf("k: '23' v: %ld\n", r);
RUAPI ruMap ruMapNew(ruType keyType, ruType valueType)
Creates a new ruMap based on the given specifications.
RUAPI ruMap ruMapFree(ruMap rm)
Frees the given map and its members.
#define ruMapGet(rm, key, val)
Runs ruMapGetValue with a ptr cast.
Definition: map.h:134
#define ruMapPut(map, key, val)
Runs ruMapPutData with ptr casts.
Definition: map.h:75
void * ruMap
An opaque type representing a map object.
Definition: map.h:33
const char * perm_chars
A permanent NULL terminated string pointer.
Definition: regify-util.h:176
RUAPI ruType ruTypeStrDup(void)
Returns an ruType used for transient strings.

Given keys will be copied when added and freed on removal or ruMapFree.

Returns
Duplicating string type specification. Caller need not free.

◆ ruTypeStrFree()

RUAPI ruType ruTypeStrFree ( void  )

Returns an ruType used for externally allocated string.

Example:

// error checking left out for brevity
ruMapPut(rm, k, v);
perm_chars r = NULL;
ruMapGet(rm, "23", &r);
printf("k: '23' v: '%s'\n", r);
char * alloc_chars
An allocated NULL terminated string pointer.
Definition: regify-util.h:199
RUAPI char * ruStrDup(const char *str)
Returns a copy of given string.
RUAPI ruType ruTypeStrFree(void)
Returns an ruType used for externally allocated string.

Given keys will not be copied when added but freed on removal or ruMapFree.

Returns
Freeable string type specification. Caller need not free.

◆ ruTypeStrRef()

RUAPI ruType ruTypeStrRef ( void  )

Returns an ruType used for permanent strings.

Example:

// error checking left out for brevity
perm_chars k1 = "23";
perm_chars v1 = "42";
ruMapPut(rm, k1, v1);
perm_chars r = NULL;
ruMapGet(rm, "23", &r);
printf("k: '23' v: '%s'\n", r);
RUAPI ruType ruTypeStrRef(void)
Returns an ruType used for permanent strings.

Given keys will neither be copied nor freed and must exist for the duration of the map using them.

Returns
Permanent string type specification. Caller need not free.