C API Documentation
rrUtils.h
1 #ifndef rrUtilsH
2 #define rrUtilsH
3 
4 #if defined(_WIN32) || defined(__WIN32__)
5 #define NOMINMAX
6 #include <windows.h>
7 #endif
8 
9 #include <float.h> //ms compatible IEEE functions, e.g. _isnan
10 #include <vector>
11 #include <string>
12 #include <iostream>
13 #include <set>
14 #include "rrExporter.h"
15 #include "rrConstants.h"
16 #include "rrStringUtils.h"
17 #include <stdint.h>
18 
19 
20 namespace rr
21 {
22 
23 using std::vector;
24 using std::string;
25 using std::set;
26 
27 RR_DECLSPEC bool cleanFolder(const string& folder, const string& baseName, const std::vector<std::string>& extensions);
28 RR_DECLSPEC string getTime();
29 RR_DECLSPEC string getDateTime();
30 RR_DECLSPEC string getMD5(const string& text);
31 RR_DECLSPEC void sleep(int ms);
32 
33 //Misc.
37 RR_DECLSPEC std::ptrdiff_t indexOf(const std::vector<std::string>& vec, const std::string& elem );
38 RR_DECLSPEC bool isNaN(const double& aNum);
39 RR_DECLSPEC bool isNullOrEmpty(const string& str); //Can't be null, but empty
40 RR_DECLSPEC void pause(bool doIt = true, const string& msg = "");
41 
42 //String utilities
43 RR_DECLSPEC string removeTrailingSeparator(const string& fldr, const char sep = gPathSeparator);//"\\");
44 
45 //File Utilities
46 RR_DECLSPEC size_t populateFileSet(const string& modelsFolder, set<string>& models);
47 
48 
58 RR_DECLSPEC bool fileExists(const string& fileN, int fileMode=0);
59 
60 RR_DECLSPEC bool folderExists(const string& folderN);
61 RR_DECLSPEC bool createFolder(const string& path);
62 
63 RR_DECLSPEC string getParentFolder(const string& path);
64 RR_DECLSPEC string getCurrentExeFolder();
65 
71 RR_DECLSPEC std::string getCurrentSharedLibDir();
72 
79 RR_DECLSPEC std::string getTempDir();
80 
84 RR_DECLSPEC std::string joinPath(const string& p1, const string& p2,
85  const char pathSeparator = gPathSeparator);
86 
90 RR_DECLSPEC std::string joinPath(const string& p1, const string& p2,
91  const string& p3, const char pathSeparator = gPathSeparator);
92 
93 RR_DECLSPEC std::string joinPath(const string& p1, const string& p2,
94  const string& p3, const string& p4, const char pathSeparator =
95  gPathSeparator);
96 
97 RR_DECLSPEC std::string joinPath(const string& p1, const string& p2,
98  const string& p3, const string& p4, const string& p5,
99  const char pathSeparator = gPathSeparator);
100 
101 
102 RR_DECLSPEC string getCWD();
103 RR_DECLSPEC const char getPathSeparator();
104 
105 RR_DECLSPEC vector<string> getLinesInFile(const string& fName);
106 RR_DECLSPEC string getFileContent(const string& fName);
107 RR_DECLSPEC void createTestSuiteFileNameParts(int caseNr, const string& postFixPart, string& FilePath, string& modelFileName, string& settingsFileName, string& descriptionFileName);
108 RR_DECLSPEC string getTestSuiteSubFolderName(int caseNr);
109 
110 RR_DECLSPEC bool hasUnimplementedTags(const string& descriptionFileName);
111 
112 RR_DECLSPEC bool isSemiStochasticTest(const string& descriptionFileName);
113 
114 RR_DECLSPEC bool isFBCTest(const string& descriptionFileName);
115 
116 //CArray utilities
117 RR_DECLSPEC bool copyCArrayToStdVector(const int* src, vector<int>& dest, int size);
118 RR_DECLSPEC bool copyCArrayToStdVector(const double* src, vector<double>& dest, int size);
119 RR_DECLSPEC bool copyValues(vector<double>& dest, double* source, const int& nrVals, const int& startIndex);
120 RR_DECLSPEC bool copyCArrayToStdVector(const bool* src, vector<bool>& dest, int size);
121 RR_DECLSPEC bool copyStdVectorToCArray(const vector<double>& src, double* dest, int size);
122 RR_DECLSPEC bool copyStdVectorToCArray(const vector<bool>& src, bool* dest, int size);
123 RR_DECLSPEC double* createVector(const vector<double>& vec);
124 RR_DECLSPEC vector<double> createVector(const double* src, const int& size);
125 
126 #if defined(_WIN32) || defined(__WIN32__)
127 RR_DECLSPEC HINSTANCE loadDLL(const string& dll);
128 RR_DECLSPEC bool unLoadDLL(HINSTANCE dllHandle);
129 RR_DECLSPEC FARPROC getFunctionPtr(const string& funcName, HINSTANCE DLLHandle);
130 RR_DECLSPEC string getWINAPIError(DWORD errorCode, LPTSTR lpszFunction);
131 #endif
132 
133 #undef CreateFile
134 RR_DECLSPEC bool createFile(const string& fName, std::ios_base::openmode mode = std::ios::trunc );
135 
136 
137 
144 RR_DECLSPEC int64_t getMicroSeconds();
145 
146 } // rr Namespace
147 #endif
C_DECL_SPEC RRVectorPtr rrcCallConv createVector(int size)
Create a new vector with a given size.
C_DECL_SPEC char *rrcCallConv getFileContent(const char *fName)
Retrieves the the content of a file.