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

Some methods return lists (heterogeneous arrays of data), these routines make it easier to manipulate lists. 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...
 
int isListItemInteger (RRListItemPtr item)
 Returns true or false if the list item is an integer. More...
 
int isListItemDouble (RRListItemPtr item)
 Returns true or false if the list item is a double. More...
 
int isListItemString (RRListItemPtr item)
 Returns true or false if the list item is a character array. More...
 
int isListItemList (RRListItemPtr item)
 Returns true or false if the list item is a list itself. More...
 
int isListItem (RRListItemPtr item, enum ListItemType itemType)
 Returns true or false if the list item is the given itemType. More...
 
int getIntegerListItem (RRListItemPtr item, int *value)
 Returns the integer from a list item. More...
 
int 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 arrays of data), these routines make it easier to manipulate lists.

Function Documentation

int addItem ( RRListPtr  list,
RRListItemPtr item 
)

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

1 x = createRRList(RRHandle handle);
2 item1 = createIntegerItem (4);
3 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]]

1 l = createRRList(RRHandle handle);
2 item = createIntegerItem (123);
3 addItem (l, item);
4 item1 = createListItem(RRHandle handle);
5 item2 = createDoubleItem (3.1415926);
6 addItem (item1, item2);
7 addItem (l, item1);
8 
9 item = getListItem (l, 0);
10 printf ("item = %d\n", item->data.iValue);
11 
12 printf (listToString (l));
13 freeRRList (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
int 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
int 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
int 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
int 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
int 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
int 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
int 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 character array