regify utility  2.0.0-0
Typed List API

This API is useful for scalar types such as int, long or bool. More...

Macros

#define ruListRemoveTo(rl, rle, dest)   ruListRemoveDataTo(rl, &(rle), (ptr*)&(dest))
 Remove and return the current list element from list. More...
 
#define ruListRemoveIdxTo(rl, index, dest)   ruListRemoveIdxDataTo(rl, index, (ptr*)&(dest))
 Remove and return the list element at index position from list. More...
 
#define ruListPopTo(rl, dest)   ruListPopDataTo(rl, (ptr*)&(dest))
 Return first element of the list. More...
 
#define ruListTryPopTo(rl, timeoutMs, dest)   ruListTryPopDataTo(rl, timeoutMs, (ptr*)&(dest))
 Tries to return first element of the list. More...
 
#define ruIterTo(re, dest)   ruListNextDataTo(&(re), (ptr*)&(dest))
 Returns the next element data in the given list to iterate over. More...
 
#define ruListIdxTo(rl, index, dest)   ruListIdxDataTo(rl, index, (ptr*)&(dest))
 Returns the data payload of the element at given 0 based index casted to type. More...
 

Functions

RUAPI int32_t ruListRemoveDataTo (ruList rl, ruListElmt *rle, ptr *dest)
 Remove and return the current list element from list. More...
 
RUAPI int32_t ruListRemoveIdxDataTo (ruList rl, int32_t index, ptr *dest)
 Remove and return the list element at index position from list. More...
 
RUAPI int32_t ruListPopDataTo (ruList rl, ptr *dest)
 Return first element of the list. More...
 
RUAPI int32_t ruListTryPopDataTo (ruList rl, msec_t timeoutMs, ptr *dest)
 Tries to return first element of the list. More...
 
RUAPI int32_t ruListNextDataTo (ruListElmt *re, ptr *dest)
 Returns the data payload of the next list element. More...
 
RUAPI int32_t ruListIdxDataTo (ruList rl, int32_t index, ptr *dest)
 Returns the data payload of the element at given 0 based index. More...
 

Detailed Description

This API is useful for scalar types such as int, long or bool.

Example of typed use:

// error checking left out for brevity
bool b1 = false;
bool b2 = true;
ruListAppend(rl, &b1);
ruListAppend(rl, &b2);
bool vbool;
for (ruIterTo(li, vbool); li; ruIterTo(li, vbool)) {
printf("%d\n", vbool);
}
rl = ruListFree(rl);
ruListAppend(rl, "foo");
ruListAppend(rl, "bar");
li = ruListIter(rl);
for (ruIterTo(li, vstr); li; ruIterTo(li, vstr)) {
printf("%s\n", vstr);
}
rl = ruListFree(rl);
#define ruListAppend(rl, data)
Calls ruListAppendPtr but handles the void* cast.
Definition: list.h:190
void * ruIterator
Opaque pointer to list iterator object. See List Collection.
Definition: list.h:115
RUAPI ruList ruListFree(ruList rl)
Frees the given list object.
RUAPI ruList ruListNew(ruType valueType)
Creates a new list object. To be freed with ruListFree.
void * ruList
Opaque pointer to list object. See List Collection.
Definition: list.h:103
#define ruListIter(rl)
Returns the first element in the given list to iterate over.
Definition: list.h:344
#define ruIterTo(re, dest)
Returns the next element data in the given list to iterate over.
Definition: list.h:577
const char * perm_chars
A permanent NULL terminated string pointer.
Definition: regify-util.h:176
RUAPI ruType ruTypeBool(void)
Returns an ruType used for booleans.
RUAPI ruType ruTypeStrDup(void)
Returns an ruType used for transient strings.

Macro Definition Documentation

◆ ruIterTo

#define ruIterTo (   re,
  dest 
)    ruListNextDataTo(&(re), (ptr*)&(dest))

Returns the next element data in the given list to iterate over.

Parameters
reCurrent list element to get the follower of.
destWhere the returned object will be stored as its given type. (casts added).
Returns
regify error code of this operation. RUE_OK on success RUE_FILE_NOT_FOUND on empty list RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListIdxTo

#define ruListIdxTo (   rl,
  index,
  dest 
)    ruListIdxDataTo(rl, index, (ptr*)&(dest))

Returns the data payload of the element at given 0 based index casted to type.

Parameters
rlList from which to return the element data payload.
indexIndex of the element in question. 0 is the first element.
destWhere the returned object will be stored as its given type (without casts).
Returns
regify error code of this operation. RUE_OK on success RUE_FILE_NOT_FOUND on empty list RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListPopTo

#define ruListPopTo (   rl,
  dest 
)    ruListPopDataTo(rl, (ptr*)&(dest))

Return first element of the list.

Parameters
rlList to pop object from.
destOptional. Where the returned object will be stored as its given type. (casts added)
Returns
regify error code of this operation. RUE_OK on success RUE_FILE_NOT_FOUND on empty list RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListRemoveIdxTo

#define ruListRemoveIdxTo (   rl,
  index,
  dest 
)    ruListRemoveIdxDataTo(rl, index, (ptr*)&(dest))

Remove and return the list element at index position from list.

Parameters
rlList to remove object from.
index0(first)/-1(last) position of the element to remove in the list.
destOptional. Where the returned object will be stored as its given type. (casts added)
Returns
regify error code of this operation. RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListRemoveTo

#define ruListRemoveTo (   rl,
  rle,
  dest 
)    ruListRemoveDataTo(rl, &(rle), (ptr*)&(dest))

Remove and return the current list element from list.

Parameters
rlList to remove object from.
rleElement to remove, will be set to the previous element to allow for deletion during iteration.
destOptional. Where the returned object will be stored as its given type. (casts added)
Returns
regify error code of this operation. RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListTryPopTo

#define ruListTryPopTo (   rl,
  timeoutMs,
  dest 
)    ruListTryPopDataTo(rl, timeoutMs, (ptr*)&(dest))

Tries to return first element of the list.

Parameters
rlList to pop object from.
timeoutMsThe number of milliseconds to wait for an entry before returning. Setting this to 0 will return after the first check.
destOptional. Where the returned object will be stored as its given type. (casts added)
Returns
regify error code of this operation. RUE_OK on success RUE_FILE_NOT_FOUND on empty list RUE_USER_ABORT when a threaded list has quit else a regify error code.

Function Documentation

◆ ruListIdxDataTo()

RUAPI int32_t ruListIdxDataTo ( ruList  rl,
int32_t  index,
ptr dest 
)

Returns the data payload of the element at given 0 based index.

Parameters
rlList from which to return the element data payload.
indexIndex of the element in question. 0 is the first element. -1 is the last element.
destWhere the returned object will be stored as its given type.
Returns
regify error code of this operation. RUE_OK on success RUE_FILE_NOT_FOUND on empty list RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListNextDataTo()

RUAPI int32_t ruListNextDataTo ( ruListElmt re,
ptr dest 
)

Returns the data payload of the next list element.

Parameters
reAddress of current list element to be updated with the next one.
destOptional. Where the returned object will be stored as its given type.
Returns
regify error code of this operation. RUE_OK on success RUE_FILE_NOT_FOUND on empty list RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListPopDataTo()

RUAPI int32_t ruListPopDataTo ( ruList  rl,
ptr dest 
)

Return first element of the list.

Parameters
rlList to pop object from.
destOptional. Where the returned object will be stored as its given type.
Returns
regify error code of this operation. RUE_OK on success RUE_FILE_NOT_FOUND on empty list RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListRemoveDataTo()

RUAPI int32_t ruListRemoveDataTo ( ruList  rl,
ruListElmt rle,
ptr dest 
)

Remove and return the current list element from list.

Parameters
rlList to remove object from.
rlePointer to element to remove, will be set to the previous element to allow for deletion during iteration.
destOptional. Where the returned object will be stored as its given type. When not set object will be freed.
Returns
regify error code of this operation. RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListRemoveIdxDataTo()

RUAPI int32_t ruListRemoveIdxDataTo ( ruList  rl,
int32_t  index,
ptr dest 
)

Remove and return the list element at index position from list.

Parameters
rlList to remove object from.
index0(first)/-1(last) position of the element to remove in the list.
destOptional. Where the returned object will be stored as its given type. When not set object will be freed.
Returns
regify error code of this operation. RUE_OK on success RUE_USER_ABORT when a threaded list has quit else a regify error code.

◆ ruListTryPopDataTo()

RUAPI int32_t ruListTryPopDataTo ( ruList  rl,
msec_t  timeoutMs,
ptr dest 
)

Tries to return first element of the list.

Parameters
rlList to pop object from.
timeoutMsThe number of milliseconds to wait for an entry before returning. Setting this to 0 will return after the first check.
destOptional. Where the returned object will be stored as its given type.
Returns
regify error code of this operation. RUE_OK on success RUE_FILE_NOT_FOUND on empty list RUE_USER_ABORT when a threaded list has quit else a regify error code.