libroadrunner C API
Functions
List handling routines

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

Functions

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

◆ addItem()

C_DECL_SPEC int rrcCallConv 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);
C_DECL_SPEC RRListPtr rrcCallConv createRRList(void)
Create a new list.
C_DECL_SPEC RRListItemPtr rrcCallConv createIntegerItem(int value)
Create a list item to store an integer.
void * RRHandle
Void pointer to a RoadRunner instance.
Definition: rrc_types.h:50
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

◆ createDoubleItem()

C_DECL_SPEC RRListItemPtr rrcCallConv 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

◆ createIntegerItem()

C_DECL_SPEC RRListItemPtr rrcCallConv 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

◆ createListItem()

C_DECL_SPEC RRListItemPtr rrcCallConv 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

◆ createRRList()

C_DECL_SPEC RRListPtr rrcCallConv 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));
C_DECL_SPEC RRListItemPtr rrcCallConv getListItem(RRListPtr list, int index)
Returns the index^th item from the list.
C_DECL_SPEC int rrcCallConv addItem(RRListPtr list, RRListItemPtr *item)
Add a list item to a list and return index to the added item.
C_DECL_SPEC RRListItemPtr rrcCallConv createDoubleItem(double value)
Create a list item to store a double value.
C_DECL_SPEC RRListItemPtr rrcCallConv createListItem(struct RRList *value)
Create a list item to store a list.
C_DECL_SPEC void rrcCallConv freeRRList(RRListPtr list)
Free RRListPtr structure, i.e destroy a list.
C_DECL_SPEC char *rrcCallConv listToString(const RRListPtr list)
Returns a list in string form.
Returns
Returns null if fails, otherwise returns a pointer to a new list structure

◆ createStringItem()

C_DECL_SPEC RRListItemPtr rrcCallConv 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

◆ getDoubleListItem()

C_DECL_SPEC int rrcCallConv 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

◆ getIntegerListItem()

C_DECL_SPEC int rrcCallConv 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

◆ getList()

C_DECL_SPEC RRListPtr rrcCallConv 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

◆ getListItem()

C_DECL_SPEC RRListItemPtr rrcCallConv 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

◆ getListLength()

C_DECL_SPEC int rrcCallConv getListLength ( RRListPtr  myList)

Returns the length of a given list.

Parameters
[in]myListThe list to retrieve the length from
Returns
Length of list

◆ getStringListItem()

C_DECL_SPEC char* rrcCallConv 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

◆ isListItem()

C_DECL_SPEC int rrcCallConv 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

◆ isListItemDouble()

C_DECL_SPEC int rrcCallConv 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

◆ isListItemInteger()

C_DECL_SPEC int rrcCallConv 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

◆ isListItemList()

C_DECL_SPEC int rrcCallConv 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

◆ isListItemString()

C_DECL_SPEC int rrcCallConv 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