roadrunner  2.6.0
Fast simulator for SBML models
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 #include <filesystem>
19 
20 
21 namespace rr
22 {
23 
24 using std::vector;
25 using std::string;
26 using std::set;
27 //namespace fs = std::filesystem ;
28 
29 RR_DECLSPEC bool cleanFolder(const std::string& folder, const std::string& baseName, const std::vector<std::string>& extensions);
30 RR_DECLSPEC std::string getTime();
31 RR_DECLSPEC std::string getDateTime();
32 RR_DECLSPEC std::string getMD5(const std::string& text);
33 RR_DECLSPEC std::string getSBMLMD5(const std::string& text, int modelGenOpt);
34 RR_DECLSPEC void sleep(int ms);
35 
36 //Misc.
40 RR_DECLSPEC std::ptrdiff_t indexOf(const std::vector<std::string>& vec, const std::string& elem );
41 RR_DECLSPEC bool isNaN(const double& aNum);
42 RR_DECLSPEC bool isNullOrEmpty(const std::string& str); //Can't be null, but empty
43 RR_DECLSPEC void pause(bool doIt = true, const std::string& msg = "");
44 
45 //String utilities
46 RR_DECLSPEC std::string removeTrailingSeparator(const std::string& fldr, const char sep = gPathSeparator);//"\\");
47 
48 //File Utilities
49 RR_DECLSPEC size_t populateFileSet(const std::string& modelsFolder, std::set<std::string>& models);
50 
51 
61 //RR_DECLSPEC bool fileExists(const std::string& fileN, int fileMode=0);
62 //
63 //RR_DECLSPEC bool folderExists(const std::string& folderN);
64 RR_DECLSPEC bool createFolder(const std::string& path);
65 
66 RR_DECLSPEC std::string getParentFolder(const std::string& path);
67 RR_DECLSPEC std::string getCurrentExeFolder();
68 
74 RR_DECLSPEC std::string getCurrentSharedLibDir();
75 
82 RR_DECLSPEC std::string getTempDir();
83 
85 // * Join two file paths together.
86 // */
87 //RR_DECLSPEC std::string joinPath(const std::string& p1, const std::string& p2,
88 // const char pathSeparator = gPathSeparator);
89 //
91 // * join three file paths together.
92 // */
93 //RR_DECLSPEC std::string joinPath(const std::string& p1, const std::string& p2,
94 // const std::string& p3, const char pathSeparator = gPathSeparator);
95 //
96 //RR_DECLSPEC std::string joinPath(const std::string& p1, const std::string& p2,
97 // const std::string& p3, const std::string& p4, const char pathSeparator =
98 // gPathSeparator);
99 //
100 //RR_DECLSPEC std::string joinPath(const std::string& p1, const std::string& p2,
101 // const std::string& p3, const std::string& p4, const std::string& p5,
102 // const char pathSeparator = gPathSeparator);
103 
104 
105 RR_DECLSPEC std::string getCWD();
106 RR_DECLSPEC const char getPathSeparator();
107 
108 RR_DECLSPEC std::vector<std::string> getLinesInFile(std::filesystem::path fName);
109 RR_DECLSPEC std::string getFileContent(std::filesystem::path fName);
110 RR_DECLSPEC void createTestSuiteFileNameParts(int caseNr, const std::string& postFixPart, std::string& FilePath, std::string& modelFileName, std::string& settingsFileName, std::string& descriptionFileName);
111 RR_DECLSPEC std::string getTestSuiteSubFolderName(int caseNr);
112 
113 RR_DECLSPEC bool hasUnimplementedTags(const std::string& descriptionFileName, const std::string& integrator);
114 
115 RR_DECLSPEC bool isSemiStochasticTest(const std::string& descriptionFileName);
116 
117 RR_DECLSPEC bool isFBCTest(const std::string& descriptionFileName);
118 
119 //CArray utilities
120 RR_DECLSPEC bool copyCArrayToStdVector(const int* src, std::vector<int>& dest, int size);
121 RR_DECLSPEC bool copyCArrayToStdVector(const double* src, std::vector<double>& dest, int size);
122 RR_DECLSPEC bool copyValues(std::vector<double>& dest, double* source, const int& nrVals, const int& startIndex);
123 RR_DECLSPEC bool copyCArrayToStdVector(const bool* src, std::vector<bool>& dest, int size);
124 RR_DECLSPEC bool copyStdVectorToCArray(const std::vector<double>& src, double* dest, int size);
125 RR_DECLSPEC bool copyStdVectorToCArray(const std::vector<bool>& src, bool* dest, int size);
126 RR_DECLSPEC double* createVector(const std::vector<double>& vec);
127 RR_DECLSPEC std::vector<double> createVector(const double* src, const int& size);
128 
129 #if defined(_WIN32) || defined(__WIN32__)
130 RR_DECLSPEC HINSTANCE loadDLL(const std::string& dll);
131 RR_DECLSPEC bool unLoadDLL(HINSTANCE dllHandle);
132 RR_DECLSPEC FARPROC getFunctionPtr(const std::string& funcName, HINSTANCE DLLHandle);
133 RR_DECLSPEC std::string getWINAPIError(DWORD errorCode, LPTSTR lpszFunction);
134 #endif
135 
136 #undef CreateFile
137 RR_DECLSPEC bool createFile(const std::string& fName, std::ios_base::openmode mode = std::ios::trunc );
138 
139 
140 
147 RR_DECLSPEC int64_t getMicroSeconds();
148 
149 } // rr Namespace
150 #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 content of a file.