libRoadRunner C API  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
List handling routines

Some methods return lists (heterogeneous arrayts of data), these routines make it easier to manipulate listse. More...

Functions

RRListPtr createRRList (void)
 Create a new list. More...
 
void freeRRList (RRListPtr list)
 Free RRListPtr structure, i.e destroy a list.
 
int getListLength (RRListPtr myList)
 Returns the length of a given list. More...
 
RRListItemPtr createIntegerItem (int value)
 Create a list item to store an integer. More...
 
RRListItemPtr createDoubleItem (double value)
 Create a list item to store a double value. More...
 
RRListItemPtr createStringItem (char *value)
 Create a list item to store a pointer to a char*. More...
 
RRListItemPtr createListItem (struct RRList *value)
 Create a list item to store a list. More...
 
int addItem (RRListPtr list, RRListItemPtr *item)
 Add a list item to a list and return index to the added item. More...
 
RRListItemPtr getListItem (RRListPtr list, int index)
 Returns the index^th item from the list. More...
 
bool isListItemInteger (RRListItemPtr item)
 Returns true or false if the list item is an integer. More...
 
bool isListItemDouble (RRListItemPtr item)
 Returns true or false if the list item is a double. More...
 
bool isListItemString (RRListItemPtr item)
 Returns true or false if the list item is a character array. More...
 
bool isListItemList (RRListItemPtr item)
 Returns true or false if the list item is a list itself. More...
 
bool isListItem (RRListItemPtr item, enum ListItemType itemType)
 Returns true or false if the list item is the given itemType. More...
 
bool getIntegerListItem (RRListItemPtr item, int *value)
 Returns the integer from a list item. More...
 
bool getDoubleListItem (RRListItemPtr item, double *value)
 Returns the double from a list item. More...
 
char * getStringListItem (RRListItemPtr item)
 Returns the string from a list item. More...
 
RRListPtr getList (RRListItemPtr item)
 Returns a list from a list item if it contains a list. More...
 

Detailed Description

Some methods return lists (heterogeneous arrayts of data), these routines make it easier to manipulate listse.

Function Documentation

int addItem ( RRListPtr  list,
RRListItemPtr item 
)

Add a list item to a list and return index to the added item.

x = createRRList(RRHandle handle);
item1 = createIntegerItem (4);
add (x, item1);
Parameters
[in]listThe list to store the item in
[in]itemThe list item to store in the list
Returns
The index to where the list item was added
RRListItemPtr createDoubleItem ( double  value)

Create a list item to store a double value.

Parameters
[in]valueThe double to store in the list item
Returns
A pointer to the list item
RRListItemPtr createIntegerItem ( int  value)

Create a list item to store an integer.

Parameters
[in]valueThe integer to store in the list item
Returns
A pointer to the list item
RRListItemPtr createListItem ( struct RRList value)

Create a list item to store a list.

Parameters
[in]valueThe list to store in the list item
Returns
A pointer to the list item
RRListPtr createRRList ( void  )

Create a new list.

A list is a container for storing list items. List items can represent integers, double, strings and lists. To populate a list, create list items of the appropriate type and add them to the list

Example, build the list [123, [3.1415926]]

l = createRRList(RRHandle handle);
item = createIntegerItem (123);
addItem (l, item);
item1 = createListItem(RRHandle handle);
item2 = createDoubleItem (3.1415926);
addItem (item1, item2);
addItem (l, item1);
item = getListItem (l, 0);
printf ("item = %d\n", item->data.iValue);
printf (listToString (l));
Returns
Returns null if fails, otherwise returns a pointer to a new list structure
RRListItemPtr createStringItem ( char *  value)

Create a list item to store a pointer to a char*.

Parameters
[in]valueThe string to store in the list item
Returns
A pointer to the list item
bool getDoubleListItem ( RRListItemPtr  item,
double *  value 
)

Returns the double from a list item.

Parameters
[in]itemThe list item to work with
[out]valueThe double value returned by the method
Returns
Returns true is successful, else false
bool getIntegerListItem ( RRListItemPtr  item,
int *  value 
)

Returns the integer from a list item.

Parameters
[in]itemThe list item to work with
[out]valueThe integer value returned by the method
Returns
Returns true is successful, else false
RRListPtr getList ( RRListItemPtr  item)

Returns a list from a list item if it contains a list.

Parameters
[in]itemThe list item to retrieve the list type from
Returns
Returns NULL if item isn't a list, otherwise it returns a list from the item
RRListItemPtr getListItem ( RRListPtr  list,
int  index 
)

Returns the index^th item from the list.

Parameters
[in]listThe list to retrieve the list item from
[in]indexThe index list item we are interested in
Returns
A pointer to the retrieved list item
int getListLength ( RRListPtr  myList)

Returns the length of a given list.

Parameters
[in]myListThe list to retrieve the length from
Returns
Length of list
char* getStringListItem ( RRListItemPtr  item)

Returns the string from a list item.

Parameters
[in]itemThe list item to work with
Returns
Returns NULL if it fails, otherwise returns a pointer to the string
bool isListItem ( RRListItemPtr  item,
enum ListItemType  itemType 
)

Returns true or false if the list item is the given itemType.

Parameters
[in]itemThe list
[in]itemTypeThe list item type to check for
Returns
If true, then the list item holds a list
bool isListItemDouble ( RRListItemPtr  item)

Returns true or false if the list item is a double.

Parameters
[in]itemThe list
Returns
If true, then the list item holds a double
bool isListItemInteger ( RRListItemPtr  item)

Returns true or false if the list item is an integer.

Parameters
[in]itemThe list
Returns
If true, then the list item holds an integer
bool isListItemList ( RRListItemPtr  item)

Returns true or false if the list item is a list itself.

Parameters
[in]itemThe list
Returns
If true, then the list item holds a list
bool isListItemString ( RRListItemPtr  item)

Returns true or false if the list item is a character array.

Parameters
[in]itemThe list
Returns
If true, then the list item holds an characeter array