libroadrunner C API
rrc_utilities.h
Go to the documentation of this file.
1 
42 #ifndef rrc_utilitiesH
43 #define rrc_utilitiesH
44 #include "rrc_exporter.h"
45 #include "rrc_types.h"
46 #include "rrc_exporter.h"
47 #include "rrc_macros.h"
48 //---------------------------------------------------------------------------
49 
50 #if defined(__cplusplus)
51 namespace rrc
52 {
53 extern "C"
54 {
55 #endif
56 
60 extern char* gLastError;
61 
65 extern char* gInstallFolder;
66 
67 //Error/Warning Messages
71 extern const char* ALLOCATE_API_ERROR_MSG;
72 
76 extern const char* INVALID_HANDLE_ERROR_MSG;
77 
84 C_DECL_SPEC char* rrcCallConv getFileContent(const char* fName);
85 
92 C_DECL_SPEC char* rrcCallConv createText(const char* text);
93 
100 C_DECL_SPEC char* rrcCallConv createTextMemory(const int count);
101 
102 // --------------------------------------------------------------------
103 // List support routines
104 // --------------------------------------------------------------------
105 
133 C_DECL_SPEC RRListPtr rrcCallConv createRRList(void);
134 
139 C_DECL_SPEC void rrcCallConv freeRRList (RRListPtr list);
140 
148 C_DECL_SPEC int rrcCallConv getListLength (RRListPtr myList);
149 
150 
158 C_DECL_SPEC RRListItemPtr rrcCallConv createIntegerItem (int value);
159 
167 C_DECL_SPEC RRListItemPtr rrcCallConv createDoubleItem (double value);
168 
176 C_DECL_SPEC RRListItemPtr rrcCallConv createStringItem (char* value);
177 
185 C_DECL_SPEC RRListItemPtr rrcCallConv createListItem (struct RRList* value);
186 
201 C_DECL_SPEC int rrcCallConv addItem (RRListPtr list, RRListItemPtr *item);
202 
203 
213 C_DECL_SPEC RRListItemPtr rrcCallConv getListItem (RRListPtr list, int index);
214 
222 C_DECL_SPEC int rrcCallConv isListItemInteger (RRListItemPtr item);
223 
231 C_DECL_SPEC int rrcCallConv isListItemDouble (RRListItemPtr item);
232 
240 C_DECL_SPEC int rrcCallConv isListItemString (RRListItemPtr item);
241 
249 C_DECL_SPEC int rrcCallConv isListItemList (RRListItemPtr item);
250 
259 C_DECL_SPEC int rrcCallConv isListItem (RRListItemPtr item, enum ListItemType itemType);
260 
269 C_DECL_SPEC int rrcCallConv getIntegerListItem (RRListItemPtr item, int *value);
270 
279 C_DECL_SPEC int rrcCallConv getDoubleListItem (RRListItemPtr item, double *value);
280 
288 C_DECL_SPEC char* rrcCallConv getStringListItem (RRListItemPtr item);
289 
290 
298 C_DECL_SPEC RRListPtr rrcCallConv getList(RRListItemPtr item);
299 
300 // --------------------------------------------------------------------------------
301 // Free memory functions
302 // --------------------------------------------------------------------------------
303 
308 C_DECL_SPEC int rrcCallConv freeRRCData(RRCDataPtr handle);
309 
314 C_DECL_SPEC int rrcCallConv freeText(char* text);
315 
316 
321 //C_DECL_SPEC int rrcCallConv freeStringList(RRStringListHandle sl);
322 
327 C_DECL_SPEC int rrcCallConv freeStringArray(RRStringArrayPtr sl);
328 
333 C_DECL_SPEC int rrcCallConv freeVector(RRVectorPtr vector);
334 
339 C_DECL_SPEC int rrcCallConv freeMatrix(RRDoubleMatrixPtr matrix);
340 
341 // --------------------------------------------------------------------------------
342 // Helper Methods
343 // --------------------------------------------------------------------------------
344 
356 C_DECL_SPEC int rrcCallConv getVectorLength (RRVectorPtr vector);
357 
369 C_DECL_SPEC RRVectorPtr rrcCallConv createVector (int size);
370 
384 C_DECL_SPEC int rrcCallConv getVectorElement (RRVectorPtr vector, int index, double* value);
385 
386 
400 C_DECL_SPEC int rrcCallConv setVectorElement (RRVectorPtr vector, int index, double value);
401 
413 C_DECL_SPEC RRDoubleMatrixPtr rrcCallConv createRRMatrix (int r, int c);
414 
426 C_DECL_SPEC int rrcCallConv getMatrixNumRows (RRDoubleMatrixPtr m);
427 
439 C_DECL_SPEC int rrcCallConv getMatrixNumCols (RRDoubleMatrixPtr m);
440 
458 C_DECL_SPEC int rrcCallConv getMatrixElement (RRDoubleMatrixPtr m, int r, int c, double* value);
459 
477 C_DECL_SPEC int rrcCallConv setMatrixElement (RRDoubleMatrixPtr m, int r, int c, double value);
478 
479 
497 C_DECL_SPEC int rrcCallConv getComplexMatrixElement (RRComplexMatrixPtr m, int r, int c, RRComplexPtr value);
498 
499 
517 C_DECL_SPEC int rrcCallConv setComplexMatrixElement (RRComplexMatrixPtr m, int r, int c, RRComplexPtr value);
518 
519 
529 C_DECL_SPEC int rrcCallConv getRRDataNumRows (RRCDataPtr rrData);
530 
540 C_DECL_SPEC int rrcCallConv getRRDataNumCols (RRCDataPtr rrData);
541 
556 C_DECL_SPEC int rrcCallConv getRRCDataElement (RRCDataPtr rrData, int r, int c, double *value);
557 
570 C_DECL_SPEC char* rrcCallConv getRRDataColumnLabel (RRCDataPtr rrData, int column);
571 
572 // --------------------------------------------------------------------------------
573 // Convert data to string functions
574 // --------------------------------------------------------------------------------
575 
581 C_DECL_SPEC char* rrcCallConv vectorToString(const RRVectorPtr vec);
582 
588 C_DECL_SPEC char* rrcCallConv complexVectorToString(const RRComplexVectorPtr vec);
589 
595 C_DECL_SPEC char* rrcCallConv rrCDataToString(const RRCDataPtr rrData);
596 
602 C_DECL_SPEC char* rrcCallConv matrixToString(const RRDoubleMatrixPtr mat);
603 
609 C_DECL_SPEC char* rrcCallConv complexMatrixToString(const RRComplexMatrixPtr mat);
610 
616 C_DECL_SPEC int rrcCallConv getNumberOfStringElements(const RRStringArrayPtr list);
617 
623 C_DECL_SPEC char* rrcCallConv getStringElement (RRStringArrayPtr list, int index);
624 
630 C_DECL_SPEC char* rrcCallConv stringArrayToString(const RRStringArrayPtr list);
631 
637 C_DECL_SPEC char* rrcCallConv listToString(const RRListPtr list);
638 
639 
640 //======================== DATA WRITING ROUTINES =============================
648 C_DECL_SPEC int rrcCallConv writeRRData(RRHandle handle, const char* fileNameAndPath);
649 
650 
652 // TEST UTILITY functions (to be documented later. Only for internal testing)
660 C_DECL_SPEC int rrcCallConv compileSource(RRHandle handle, const char* sourceFileNameAndPath);
661 
662 
663 #if defined(__cplusplus)
664 
665 } //namespace
666 } //Extern "C"
667 #endif
668 
669 #endif
C_DECL_SPEC int rrcCallConv freeRRCData(RRCDataPtr handle)
Free the memory associated to a RRCData object.
C_DECL_SPEC int rrcCallConv freeStringArray(RRStringArrayPtr sl)
Free RRStringListHandle structures.
C_DECL_SPEC int rrcCallConv freeVector(RRVectorPtr vector)
Free RRVectorHandle structures.
C_DECL_SPEC int rrcCallConv freeMatrix(RRDoubleMatrixPtr matrix)
Free RRDoubleMatrixPtr structures.
C_DECL_SPEC int rrcCallConv freeText(char *text)
Free char* generated by library routines.
C_DECL_SPEC int rrcCallConv getMatrixNumRows(RRDoubleMatrixPtr m)
Retrieve the number of rows in the given matrix.
C_DECL_SPEC int rrcCallConv compileSource(RRHandle handle, const char *sourceFileNameAndPath)
Compiles source code.
C_DECL_SPEC int rrcCallConv writeRRData(RRHandle handle, const char *fileNameAndPath)
Writes RoadRunner data to file.
C_DECL_SPEC int rrcCallConv getMatrixElement(RRDoubleMatrixPtr m, int r, int c, double *value)
Retrieve an element at a given row and column from a matrix type variable.
C_DECL_SPEC int rrcCallConv getMatrixNumCols(RRDoubleMatrixPtr m)
Retrieve the number of columns in the given matrix.
C_DECL_SPEC int rrcCallConv getRRDataNumCols(RRCDataPtr rrData)
Retrieve the number of columns in the given rrData data (returned form simulate(RRHandle handle))
C_DECL_SPEC int rrcCallConv setComplexMatrixElement(RRComplexMatrixPtr m, int r, int c, RRComplexPtr value)
Set an element at a given row and column with a given value in a complex matrix type variable.
C_DECL_SPEC RRVectorPtr rrcCallConv createVector(int size)
Create a new vector with a given size.
C_DECL_SPEC int rrcCallConv getVectorLength(RRVectorPtr vector)
Get the number of elements in a vector type.
C_DECL_SPEC char *rrcCallConv getRRDataColumnLabel(RRCDataPtr rrData, int column)
Retrieves a label for a given column in a rrData type variable.
C_DECL_SPEC int rrcCallConv getComplexMatrixElement(RRComplexMatrixPtr m, int r, int c, RRComplexPtr value)
Retrieve an element at a given row and column from a complex matrix type variable.
C_DECL_SPEC int rrcCallConv setVectorElement(RRVectorPtr vector, int index, double value)
Set a particular element in a vector.
C_DECL_SPEC int rrcCallConv getVectorElement(RRVectorPtr vector, int index, double *value)
Get a particular element from a vector.
C_DECL_SPEC RRDoubleMatrixPtr rrcCallConv createRRMatrix(int r, int c)
Create an empty matrix of size r by c.
C_DECL_SPEC int rrcCallConv getRRCDataElement(RRCDataPtr rrData, int r, int c, double *value)
Retrieves an element at a given row and column from a RoadRunner data type variable.
C_DECL_SPEC int rrcCallConv getRRDataNumRows(RRCDataPtr rrData)
Retrieve the number of rows in the given RoadRunner numerical data (returned from simulate(RRHandle h...
C_DECL_SPEC int rrcCallConv setMatrixElement(RRDoubleMatrixPtr m, int r, int c, double value)
Set an element at a given row and column with a given value in a matrix type variable.
C_DECL_SPEC RRListPtr rrcCallConv createRRList(void)
Create a new list.
C_DECL_SPEC RRListItemPtr rrcCallConv getListItem(RRListPtr list, int index)
Returns the index^th item from the list.
C_DECL_SPEC char *rrcCallConv getStringListItem(RRListItemPtr item)
Returns the string from a list item.
C_DECL_SPEC RRListItemPtr rrcCallConv createIntegerItem(int value)
Create a list item to store an integer.
C_DECL_SPEC int rrcCallConv getIntegerListItem(RRListItemPtr item, int *value)
Returns the integer from a list item.
C_DECL_SPEC int rrcCallConv isListItemString(RRListItemPtr item)
Returns true or false if the list item is a character array.
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 int rrcCallConv isListItemDouble(RRListItemPtr item)
Returns true or false if the list item is a double.
C_DECL_SPEC RRListItemPtr rrcCallConv createDoubleItem(double value)
Create a list item to store a double value.
C_DECL_SPEC int rrcCallConv isListItem(RRListItemPtr item, enum ListItemType itemType)
Returns true or false if the list item is the given itemType.
C_DECL_SPEC RRListItemPtr rrcCallConv createListItem(struct RRList *value)
Create a list item to store a list.
C_DECL_SPEC int rrcCallConv getDoubleListItem(RRListItemPtr item, double *value)
Returns the double from a list item.
C_DECL_SPEC RRListItemPtr rrcCallConv createStringItem(char *value)
Create a list item to store a pointer to a char*.
C_DECL_SPEC int rrcCallConv isListItemList(RRListItemPtr item)
Returns true or false if the list item is a list itself.
C_DECL_SPEC int rrcCallConv getListLength(RRListPtr myList)
Returns the length of a given list.
C_DECL_SPEC int rrcCallConv isListItemInteger(RRListItemPtr item)
Returns true or false if the list item is an integer.
C_DECL_SPEC RRListPtr rrcCallConv getList(RRListItemPtr item)
Returns a list from a list item if it contains a list.
C_DECL_SPEC void rrcCallConv freeRRList(RRListPtr list)
Free RRListPtr structure, i.e destroy a list.
C_DECL_SPEC int rrcCallConv getNumberOfStringElements(const RRStringArrayPtr list)
Returns the length of a string array.
C_DECL_SPEC char *rrcCallConv getStringElement(RRStringArrayPtr list, int index)
Returns the indexth element from the string array in the argument value.
C_DECL_SPEC char *rrcCallConv matrixToString(const RRDoubleMatrixPtr mat)
Returns a matrix in string form.
C_DECL_SPEC char *rrcCallConv stringArrayToString(const RRStringArrayPtr list)
Returns a string list in string form.
C_DECL_SPEC char *rrcCallConv listToString(const RRListPtr list)
Returns a list in string form.
C_DECL_SPEC char *rrcCallConv rrCDataToString(const RRCDataPtr rrData)
Returns a rrCData struct in string form.
C_DECL_SPEC char *rrcCallConv complexMatrixToString(const RRComplexMatrixPtr mat)
Returns a complex matrix in string form.
C_DECL_SPEC char *rrcCallConv complexVectorToString(const RRComplexVectorPtr vec)
Returns a complex vector in string form.
C_DECL_SPEC char *rrcCallConv vectorToString(const RRVectorPtr vec)
Returns a vector in string form.
roadRunner C wrappers 2012
roadRunner C wrappers 2012
roadRunner C wrappers 2012
void * RRHandle
Void pointer to a RoadRunner instance.
Definition: rrc_types.h:50
ListItemType
The list type supports strings, integers, double and lists.
Definition: rrc_types.h:121
const char * ALLOCATE_API_ERROR_MSG
Global parameter holding message for an un-allocated wrappers.
char * gLastError
Global parameter holding last error, if any.
C_DECL_SPEC char *rrcCallConv createTextMemory(const int count)
Creates memory for holding a string.
C_DECL_SPEC char *rrcCallConv createText(const char *text)
Creates memory for holding a string.
C_DECL_SPEC char *rrcCallConv getFileContent(const char *fName)
Retrieves the the content of a file.
char * gInstallFolder
Global parameter holding C wrappers install folder.
const char * INVALID_HANDLE_ERROR_MSG
Global parameter holding message when an invalid is handed to a function.
Structure for the result type from the simulate calls. The client is responsible for freeing the RRCD...
Definition: rrc_types.h:111
Structure for a complex number.
Definition: rrc_types.h:84
Structure for a simple complex Matrix type.
Definition: rrc_types.h:101
Structure for a simple complex Vector type.
Definition: rrc_types.h:92
Structure for a simple double Matrix type.
Definition: rrc_types.h:74
A list type, stores int, double, strings and lists.
Definition: rrc_types.h:148
A single list element type.
Definition: rrc_types.h:133
Structure for a simple vector of strings.
Definition: rrc_types.h:66
Structure for a simple vector of doubles.
Definition: rrc_types.h:58