libRoadRunner C API  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 bool rrcCallConv isListItemInteger (RRListItemPtr item);
223 
231 C_DECL_SPEC bool rrcCallConv isListItemDouble (RRListItemPtr item);
232 
240 C_DECL_SPEC bool rrcCallConv isListItemString (RRListItemPtr item);
241 
249 C_DECL_SPEC bool rrcCallConv isListItemList (RRListItemPtr item);
250 
259 C_DECL_SPEC bool rrcCallConv isListItem (RRListItemPtr item, enum ListItemType itemType);
260 
269 C_DECL_SPEC bool rrcCallConv getIntegerListItem (RRListItemPtr item, int *value);
270 
279 C_DECL_SPEC bool 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 bool rrcCallConv freeRRCData(RRCDataPtr handle);
309 
314 C_DECL_SPEC bool rrcCallConv freeText(char* text);
315 
316 
321 //C_DECL_SPEC bool rrcCallConv freeStringList(RRStringListHandle sl);
322 
327 C_DECL_SPEC bool rrcCallConv freeStringArray(RRStringArrayPtr sl);
328 
333 C_DECL_SPEC bool rrcCallConv freeVector(RRVectorPtr vector);
334 
339 C_DECL_SPEC bool rrcCallConv freeMatrix(RRDoubleMatrixPtr matrix);
340 
346 C_DECL_SPEC void rrcCallConv pause(void);
347 
348 // --------------------------------------------------------------------------------
349 // Helper Methods
350 // --------------------------------------------------------------------------------
351 
363 C_DECL_SPEC int rrcCallConv getVectorLength (RRVectorPtr vector);
364 
376 C_DECL_SPEC RRVectorPtr rrcCallConv createVector (int size);
377 
391 C_DECL_SPEC bool rrcCallConv getVectorElement (RRVectorPtr vector, int index, double* value);
392 
393 
407 C_DECL_SPEC bool rrcCallConv setVectorElement (RRVectorPtr vector, int index, double value);
408 
420 C_DECL_SPEC RRDoubleMatrixPtr rrcCallConv createRRMatrix (int r, int c);
421 
433 C_DECL_SPEC int rrcCallConv getMatrixNumRows (RRDoubleMatrixPtr m);
434 
446 C_DECL_SPEC int rrcCallConv getMatrixNumCols (RRDoubleMatrixPtr m);
447 
465 C_DECL_SPEC bool rrcCallConv getMatrixElement (RRDoubleMatrixPtr m, int r, int c, double* value);
466 
484 C_DECL_SPEC bool rrcCallConv setMatrixElement (RRDoubleMatrixPtr m, int r, int c, double value);
485 
486 
504 C_DECL_SPEC bool rrcCallConv getComplexMatrixElement (RRComplexMatrixPtr m, int r, int c, RRComplexPtr value);
505 
506 
524 C_DECL_SPEC bool rrcCallConv setComplexMatrixElement (RRComplexMatrixPtr m, int r, int c, RRComplexPtr value);
525 
532 C_DECL_SPEC RRCDataPtr rrcCallConv createRRCData(RRDataHandle rrData);
533 
543 C_DECL_SPEC int rrcCallConv getRRDataNumRows (RRCDataPtr rrData);
544 
554 C_DECL_SPEC int rrcCallConv getRRDataNumCols (RRCDataPtr rrData);
555 
570 C_DECL_SPEC bool rrcCallConv getRRCDataElement (RRCDataPtr rrData, int r, int c, double *value);
571 
584 C_DECL_SPEC char* rrcCallConv getRRDataColumnLabel (RRCDataPtr rrData, int column);
585 
586 // --------------------------------------------------------------------------------
587 // Convert data to string functions
588 // --------------------------------------------------------------------------------
589 
595 C_DECL_SPEC char* rrcCallConv vectorToString(const RRVectorPtr vec);
596 
602 C_DECL_SPEC char* rrcCallConv complexVectorToString(const RRComplexVectorPtr vec);
603 
609 C_DECL_SPEC char* rrcCallConv rrDataToString(RRDataHandle rrData);
610 
616 C_DECL_SPEC char* rrcCallConv rrCDataToString(const RRCDataPtr rrData);
617 
623 C_DECL_SPEC char* rrcCallConv matrixToString(const RRDoubleMatrixPtr mat);
624 
630 C_DECL_SPEC char* rrcCallConv complexMatrixToString(const RRComplexMatrixPtr mat);
631 
637 C_DECL_SPEC int rrcCallConv getNumberOfStringElements(const RRStringArrayPtr list);
638 
644 C_DECL_SPEC char* rrcCallConv getStringElement (RRStringArrayPtr list, int index);
645 
651 C_DECL_SPEC char* rrcCallConv stringArrayToString(const RRStringArrayPtr list);
652 
658 C_DECL_SPEC char* rrcCallConv listToString(const RRListPtr list);
659 
660 
661 //======================== DATA WRITING ROUTINES =============================
669 C_DECL_SPEC bool rrcCallConv writeRRData(RRHandle handle, const char* fileNameAndPath);
670 
671 
673 // TEST UTILITY functions (to be documented later. Only for internal testing)
681 C_DECL_SPEC bool rrcCallConv compileSource(RRHandle handle, const char* sourceFileNameAndPath);
682 
683 
684 #if defined(__cplusplus)
685 
686 } //namespace
687 } //Extern "C"
688 #endif
689 
690 #endif
bool 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...
Structure for a complex number.
Definition: rrc_types.h:85
char * createTextMemory(const int count)
Creates memory for holding a string.
Definition: rrc_utilities.cpp:57
Structure for a simple vector of strings.
Definition: rrc_types.h:67
void freeRRList(RRListPtr list)
Free RRListPtr structure, i.e destroy a list.
Definition: rrc_utilities.cpp:81
char * getStringElement(RRStringArrayPtr list, int index)
Returns the indexth element from the string array in the argument value.
Definition: rrc_utilities.cpp:630
char * getRRDataColumnLabel(RRCDataPtr rrData, int column)
Retrieves a label for a given column in a rrData type variable.
Definition: rrc_utilities.cpp:592
bool freeRRCData(RRCDataPtr handle)
Free the memory associated to a RRCData object.
Definition: rrc_utilities.cpp:308
bool isListItemList(RRListItemPtr item)
Returns true or false if the list item is a list itself.
Definition: rrc_utilities.cpp:180
roadRunner C API 2012
RRCDataPtr createRRCData(RRDataHandle rrData)
Create a RoadRunner C data structure (RRCDataPtr) from RoadRunner data.
Definition: rrc_utilities.cpp:62
bool getComplexMatrixElement(RRComplexMatrixPtr m, int r, int c, RRComplexPtr value)
Retrieve an element at a given row and column from a complex matrix type variable.
Definition: rrc_utilities.cpp:510
int getNumberOfStringElements(const RRStringArrayPtr list)
Returns the length of a string array.
Definition: rrc_utilities.cpp:622
int getVectorLength(RRVectorPtr vector)
Get the number of elements in a vector type.
Definition: rrc_utilities.cpp:375
RRListItemPtr createStringItem(char *value)
Create a list item to store a pointer to a char*.
Definition: rrc_utilities.cpp:121
int getListLength(RRListPtr myList)
Returns the length of a given list.
Definition: rrc_utilities.cpp:226
RRListPtr getList(RRListItemPtr item)
Returns a list from a list item if it contains a list.
Definition: rrc_utilities.cpp:216
bool freeVector(RRVectorPtr vector)
Free RRVectorHandle structures.
Definition: rrc_utilities.cpp:350
bool isListItemString(RRListItemPtr item)
Returns true or false if the list item is a character array.
Definition: rrc_utilities.cpp:175
RRListItemPtr createIntegerItem(int value)
Create a list item to store an integer.
Definition: rrc_utilities.cpp:105
char * rrDataToString(RRDataHandle rrData)
Returns a rrData object in string form.
Definition: rrc_utilities.cpp:670
ListItemType
The list type supports strings, integers, double and lists.
Definition: rrc_types.h:123
char * vectorToString(const RRVectorPtr vec)
Returns a vector in string form.
Definition: rrc_utilities.cpp:775
bool getRRCDataElement(RRCDataPtr rrData, int r, int c, double *value)
Retrieves an element at a given row and column from a RoadRunner data type variable.
Definition: rrc_utilities.cpp:572
bool freeStringArray(RRStringArrayPtr sl)
Free RRStringListHandle structures.
Definition: rrc_utilities.cpp:333
bool isListItemInteger(RRListItemPtr item)
Returns true or false if the list item is an integer.
Definition: rrc_utilities.cpp:165
bool freeText(char *text)
Free char* generated by library routines.
Definition: rrc_utilities.cpp:325
bool freeMatrix(RRDoubleMatrixPtr matrix)
Free RRDoubleMatrixPtr structures.
Definition: rrc_utilities.cpp:296
char * complexVectorToString(const RRComplexVectorPtr vec)
Returns a complex vector in string form.
Definition: rrc_utilities.cpp:801
RRListPtr createRRList(void)
Create a new list.
Definition: rrc_utilities.cpp:73
char * getFileContent(const char *fName)
Retrieves the the content of a file.
Definition: rrc_utilities.cpp:44
Structure for a simple vector of doubles.
Definition: rrc_types.h:59
char * stringArrayToString(const RRStringArrayPtr list)
Returns a string list in string form.
Definition: rrc_utilities.cpp:648
Structure for a simple double Matrix type.
Definition: rrc_types.h:75
bool compileSource(RRHandle handle, const char *sourceFileNameAndPath)
Compiles source code.
Definition: rrc_utilities.cpp:52
char * createText(const char *text)
Creates memory for holding a string.
Definition: rrc_utilities.cpp:39
int addItem(RRListPtr list, RRListItemPtr *item)
Add a list item to a list and return index to the added item.
Definition: rrc_utilities.cpp:139
roadRunner C API 2012
void * RRHandle
Void pointer to a RoadRunner instance.
Definition: rrc_types.h:50
void pause(void)
pause If your program is running in a console, pause() will stop execution and wait for one keybord s...
Definition: rrc_utilities.cpp:362
RRVectorPtr createVector(int size)
Create a new vector with a given size.
Definition: rrc_utilities.cpp:367
Structure for a simple complex Matrix type.
Definition: rrc_types.h:102
const char * ALLOCATE_API_ERROR_MSG
Global parameter holding message for an un-allocated API.
Definition: rrc_utilities.cpp:33
int getRRDataNumCols(RRCDataPtr rrData)
Retrieve the number of columns in the given rrData data (returned form simulat(RRHandle handle)) ...
Definition: rrc_utilities.cpp:562
bool writeRRData(RRHandle handle, const char *fileNameAndPath)
Writes RoadRunner data to file.
Definition: rrc_utilities.cpp:612
RRListItemPtr getListItem(RRListPtr list, int index)
Returns the index^th item from the list.
Definition: rrc_utilities.cpp:185
RRListItemPtr createDoubleItem(double value)
Create a list item to store a double value.
Definition: rrc_utilities.cpp:113
bool getVectorElement(RRVectorPtr vector, int index, double *value)
Get a particular element from a vector.
Definition: rrc_utilities.cpp:388
bool getDoubleListItem(RRListItemPtr item, double *value)
Returns the double from a list item.
Definition: rrc_utilities.cpp:200
Structure for the result type from the simulate calls.
Definition: rrc_types.h:112
bool 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.
Definition: rrc_utilities.cpp:490
char * getStringListItem(RRListItemPtr item)
Returns the string from a list item.
Definition: rrc_utilities.cpp:211
A list type, stores int, double, strings and lists.
Definition: rrc_types.h:149
char * complexMatrixToString(const RRComplexMatrixPtr mat)
Returns a complex matrix in string form.
Definition: rrc_utilities.cpp:747
Structure for a simple complex Vector type.
Definition: rrc_types.h:93
int getMatrixNumCols(RRDoubleMatrixPtr m)
Retrieve the number of columns in the given matrix.
Definition: rrc_utilities.cpp:459
A single list element type.
Definition: rrc_types.h:134
bool getIntegerListItem(RRListItemPtr item, int *value)
Returns the integer from a list item.
Definition: rrc_utilities.cpp:190
RRListItemPtr createListItem(struct RRList *value)
Create a list item to store a list.
Definition: rrc_utilities.cpp:129
char * listToString(const RRListPtr list)
Returns a list in string form.
Definition: rrc_utilities.cpp:231
int getRRDataNumRows(RRCDataPtr rrData)
Retrieve the number of rows in the given RoadRunner numberical data (returned from simulate(RRHandle ...
Definition: rrc_utilities.cpp:552
void * RRDataHandle
Void pointer to a RoadRunner data instance.
Definition: rrc_types.h:53
bool isListItemDouble(RRListItemPtr item)
Returns true or false if the list item is a double.
Definition: rrc_utilities.cpp:170
roadRunner C API 2012
char * matrixToString(const RRDoubleMatrixPtr mat)
Returns a matrix in string form.
Definition: rrc_utilities.cpp:719
bool isListItem(RRListItemPtr item, enum ListItemType itemType)
Returns true or false if the list item is the given itemType.
Definition: rrc_utilities.cpp:221
RRDoubleMatrixPtr createRRMatrix(int r, int c)
Create an empty matrix of size r by c.
Definition: rrc_utilities.cpp:430
char * gLastError
Global parameter holding last error, if any.
Definition: rrc_utilities.cpp:35
bool getMatrixElement(RRDoubleMatrixPtr m, int r, int c, double *value)
Retrieve an element at a given row and column from a matrix type variable.
Definition: rrc_utilities.cpp:470
const char * INVALID_HANDLE_ERROR_MSG
Global parameter holding message when an invalid is handed to a function.
Definition: rrc_utilities.cpp:34
char * rrCDataToString(const RRCDataPtr rrData)
Returns a rrCData struct in string form.
Definition: rrc_utilities.cpp:681
int getMatrixNumRows(RRDoubleMatrixPtr m)
Retrieve the number of rows in the given matrix.
Definition: rrc_utilities.cpp:449
bool setVectorElement(RRVectorPtr vector, int index, double value)
Set a particular element in a vector.
Definition: rrc_utilities.cpp:408
char * gInstallFolder
Global parameter holding C API install folder.
Definition: rrc_utilities.cpp:37