9 #include <unordered_map>
11 #include "rrConstants.h"
12 #include "rrExporter.h"
21 RR_DECLSPEC
char *
createText(
const std::string &str);
23 RR_DECLSPEC
char *
createText(
const int &count);
25 RR_DECLSPEC
bool freeText(
char *str);
27 RR_DECLSPEC std::string replaceWord(
const std::string &str1,
const std::string &str2,
const std::string &theString);
29 RR_DECLSPEC
bool convertFunctionCallToUseVarArgsSyntax(
const std::string &funcName, std::string &expression);
31 RR_DECLSPEC std::string removeChars(
const std::string &str,
const std::string &chars);
33 RR_DECLSPEC
bool isUnwantedChar(
char ch);
34 RR_DECLSPEC
size_t findMatchingRightParenthesis(
const std::string &expression,
const size_t startFrom);
36 RR_DECLSPEC
int getNumberOfFunctionArguments(
const std::string &expression);
38 RR_DECLSPEC std::string tabs(
const int &nr);
40 RR_DECLSPEC std::string NL();
42 RR_DECLSPEC std::string toUpperOrLowerCase(
const std::string &inStr,
int (*func)(
int));
44 RR_DECLSPEC std::string toUpper(
const std::string &str);
46 RR_DECLSPEC std::string toLower(
const std::string &str);
48 RR_DECLSPEC std::string getFilePath(
const std::string &fileN);
50 RR_DECLSPEC std::string getFileName(
const std::string &fileN);
52 RR_DECLSPEC std::string getFileNameNoExtension(
const std::string &fileN);
54 RR_DECLSPEC std::string getFileExtension(
const std::string &fileN);
56 RR_DECLSPEC std::string changeFileExtensionTo(
const std::string &theFileName,
const std::string &newExtension);
58 RR_DECLSPEC
int compareNoCase(
const std::string &str1,
const std::string &str2);
60 RR_DECLSPEC std::string trim(
const std::string &str,
const char &toTrim);
66 RR_DECLSPEC std::string &trim(std::string &str);
72 RR_DECLSPEC std::string <rim(std::string &str);
78 RR_DECLSPEC std::string &rtrim(std::string &str);
80 RR_DECLSPEC
bool startsWith(
const std::string &src,
const std::string &sub);
82 RR_DECLSPEC
bool endsWith(
const std::string &src,
const std::string &sub);
85 RR_DECLSPEC std::string intToStr(
const int &nt);
87 RR_DECLSPEC
int strToInt(
const std::string &nt);
89 RR_DECLSPEC std::string dblToStr(
const double &nt);
91 RR_DECLSPEC
double strToDbl(
const std::string &nt);
93 RR_DECLSPEC std::vector<std::string> splitString(
const std::string &text,
const std::string &separators);
95 RR_DECLSPEC std::vector<std::string> splitString(
const std::string &input,
const char &delimiters);
97 RR_DECLSPEC
int toInt(
const std::string &str);
99 RR_DECLSPEC
bool toBool(
const std::string &str);
101 RR_DECLSPEC
double toDouble(
const std::string &str);
103 RR_DECLSPEC std::vector<double> toDoubleVector(
const std::string &str);
105 RR_DECLSPEC complex<double> toComplex(
const std::string &str);
107 RR_DECLSPEC std::string toString(
const bool &b);
109 RR_DECLSPEC std::string toString(
const double &d,
const std::string &format = gDoubleFormat);
111 RR_DECLSPEC std::string
112 toString(
const unsigned int &n,
const std::string &format = gIntFormat,
const int nBase = 10);
114 RR_DECLSPEC std::string toString(
const int &n,
const std::string &format = gIntFormat,
const int nBase = 10);
116 RR_DECLSPEC std::string toString(
const long n,
const int nBase = 10);
118 RR_DECLSPEC std::string toString(
const unsigned long n,
const int nBase = 10);
120 RR_DECLSPEC std::string toString(
const unsigned short n,
const int nBase = 10);
122 RR_DECLSPEC std::string toString(
const short n,
const int nBase = 10);
124 RR_DECLSPEC std::string toString(
const char n);
126 RR_DECLSPEC std::string toString(
const unsigned char n);
128 RR_DECLSPEC std::string toString(
const std::string &s);
130 RR_DECLSPEC std::string toString(
const char *str);
132 RR_DECLSPEC std::string toString(
const std::vector<std::string> &vec,
const std::string &sep =
", ");
134 RR_DECLSPEC std::string toStringSize(
size_t n);
136 RR_DECLSPEC std::string format(
const std::string &src,
const int &arg);
138 RR_DECLSPEC std::string format(
const std::string &str,
const int &arg1);
141 RR_DECLSPEC std::string format(
const std::string &src,
const std::string &arg);
143 RR_DECLSPEC std::string
144 format(
const std::string &src,
const std::string &arg1,
const std::string &arg2,
const std::string &arg3);
146 RR_DECLSPEC std::string format(
const std::string &src,
const std::string &arg1,
const std::string &arg2);
148 RR_DECLSPEC std::string format(
const std::string &src,
const std::string &arg1,
const int &arg2);
150 RR_DECLSPEC std::string
151 format(
const std::string &src,
const std::string &arg1,
const int &arg2,
const std::string &arg3);
153 RR_DECLSPEC std::string format(
const std::string &str1,
const std::string &str2);
155 RR_DECLSPEC std::string format(
const std::string &str1,
const std::string &arg1,
const std::string &arg2);
157 RR_DECLSPEC std::string format(
const std::string &str1,
const std::string &arg1,
const int &arg2);
159 RR_DECLSPEC std::string
160 format(
const std::string &str1,
const std::string &arg1,
const int &arg2,
const std::string &arg3);
162 RR_DECLSPEC std::string
163 format(
const std::string &str1,
const std::string &arg1,
const std::string &arg2,
const std::string &arg3);
165 RR_DECLSPEC std::string
166 format(
const std::string &str1,
const std::string &arg1,
const std::string &arg2,
const std::string &arg3,
167 const std::string &arg4);
169 RR_DECLSPEC std::string
170 format(
const std::string &str1,
const std::string &arg1,
const std::string &arg2,
const std::string &arg3,
171 const std::string &arg4,
const std::string &arg5);
173 RR_DECLSPEC std::string format(
const std::string &str1,
const unsigned int &arg1,
const std::string &arg2);
175 RR_DECLSPEC std::string
176 format(
const std::string &str1,
const unsigned int &arg1,
const std::string &arg2,
const std::string &arg3);
178 RR_DECLSPEC std::string
179 format(
const std::string &str1,
const unsigned int &arg1,
const unsigned int &arg2,
const std::string &arg3,
180 const std::string &arg4);
182 RR_DECLSPEC std::string append(
const std::string &str);
184 RR_DECLSPEC std::string append(
const int &str);
186 RR_DECLSPEC std::string append(
const unsigned int &str);
188 RR_DECLSPEC std::string append(
const std::string &s1,
const std::string &s2);
190 RR_DECLSPEC std::string append(
const std::string &s1,
const std::string &s2,
const std::string &s3);
192 RR_DECLSPEC std::string append(
const std::string &s1,
const unsigned int &s2,
const std::string &s3);
194 RR_DECLSPEC std::string
195 append(
const std::string &s1,
const unsigned int &s2,
const std::string &s3,
const std::string &s4);
197 RR_DECLSPEC std::string
198 substitute(
const std::string &src,
const std::string &thisOne,
const std::string &withThisOne,
199 const int &howMany = -1);
201 RR_DECLSPEC std::string
202 substitute(
const std::string &src,
const std::string &thisOne,
const int &withThisOne,
const int &howMany = -1);
204 RR_DECLSPEC std::string removeNewLines(
const std::string &str,
const int &howMany = -1);
213 inline void saveBinary(std::ostream &out,
const T &t) {
214 out.write((
char *) &t,
sizeof(T));
218 inline void saveBinary(std::ostream &out, T *t) {
219 out.write((
char *) t,
sizeof(T));
223 inline void saveBinary(std::ostream &out,
const std::string &s) {
224 saveBinary(out, s.size());
225 out.write(s.c_str(), s.size());
229 inline void saveBinary(std::ostream &out,
const std::vector<T> &v) {
230 saveBinary(out, v.size());
236 template<
typename K,
typename V>
237 inline void saveBinary(std::ostream &out,
const std::map<K, V> &m) {
238 saveBinary(out, m.size());
239 for (std::pair<K, V> p : m) {
240 saveBinary(out, p.first);
241 saveBinary(out, p.second);
245 template<
typename K,
typename V>
246 inline void saveBinary(std::ostream &out,
const std::unordered_map<K, V> &m) {
247 saveBinary(out, m.size());
248 for (std::pair<K, V> p : m) {
249 saveBinary(out, p.first);
250 saveBinary(out, p.second);
255 inline void saveBinary(std::ostream &out,
const std::set<T> &s) {
256 saveBinary(out, s.size());
263 inline void saveBinary<rr::Setting>(std::ostream &out,
const rr::Setting &var) {
264 saveBinary(out, var.
type());
265 switch (var.
type()) {
267 saveBinary(out, var.
get<
bool>());
270 saveBinary(out, var.
get<
char>());
272 case Setting::DOUBLE:
273 saveBinary(out, var.
get<
double>());
276 saveBinary(out, var.
get<
float>());
279 saveBinary(out, var.
get<std::int32_t>());
282 saveBinary(out, var.
get<std::int64_t>());
284 case Setting::STRING:
285 saveBinary(out, var.
get<std::string>());
288 saveBinary(out, var.
get<
unsigned char>());
290 case Setting::UINT32:
291 saveBinary(out, var.
get<std::uint32_t>());
293 case Setting::UINT64:
294 saveBinary(out, var.
get<std::uint64_t>());
296 case Setting::DOUBLEVECTOR:
297 saveBinary(out, var.
get<std::vector<double>>());
310 inline void loadBinary(std::istream &in, T &t) {
312 in.read((
char *) &temp,
sizeof(T));
317 inline void loadBinary(std::istream &in, T* t) {
318 in.read((
char *) t,
sizeof(T));
322 inline void loadBinary(std::istream &in, std::string &s) {
324 loadBinary(in, ssize);
326 in.read(&s[0], ssize);
330 inline void loadBinary(std::istream &in, std::vector<T> &v) {
332 loadBinary(in, vsize);
334 for (
int i = 0; i < vsize; i++) {
336 loadBinary(in, next);
341 template<
typename K,
typename V>
342 inline void loadBinary(std::istream &in, std::map<K, V> &m) {
344 loadBinary(in, msize);
346 for (
int i = 0; i < msize; i++) {
355 template<
typename K,
typename V>
356 inline void loadBinary(std::istream &in, std::unordered_map<K, V> &m) {
358 loadBinary(in, msize);
360 for (
int i = 0; i < msize; i++) {
370 inline void loadBinary(std::istream &in, std::set<T> &s) {
372 loadBinary(in, ssize);
374 for (
int i = 0; i < ssize; i++) {
376 loadBinary(in, next);
382 inline void loadBinary<rr::Setting>(std::istream &in,
rr::Setting &var) {
385 std::vector<double> vectorVal;
386 loadBinary(in, type);
392 loadBinary(in, boolVal);
393 var = Setting(boolVal);
397 loadBinary(in, charVal);
398 var = Setting(charVal);
400 case Setting::DOUBLE:
402 loadBinary(in, doubleVal);
403 var = Setting(doubleVal);
407 loadBinary(in, floatVal);
408 var = Setting(floatVal);
411 std::int32_t int32Val;
412 loadBinary(in, int32Val);
413 var = Setting(int32Val);
416 std::int64_t int64Val;
417 loadBinary(in, int64Val);
418 var = Setting(int64Val);
420 case Setting::STRING:
421 loadBinary(in, strVal);
422 var = Setting(strVal);
425 unsigned char ucharVal;
426 loadBinary(in, ucharVal);
427 var = Setting(ucharVal);
429 case Setting::UINT32:
430 std::uint32_t uint32Val;
431 loadBinary(in, uint32Val);
432 var = Setting(uint32Val);
434 case Setting::UINT64:
435 std::uint64_t uint64Val;
436 loadBinary(in, uint64Val);
437 var = Setting(uint64Val);
439 case Setting::DOUBLEVECTOR:
440 loadBinary(in, vectorVal);
441 var = Setting(vectorVal);
Store a roadrunner option (or setting) as a Variant type.
Definition: Setting.h:78
TypeId type() const
returns the type of std::variant contained within this Setting.
Definition: Setting.cpp:22
SettingType get()
return the value held by this Setting as a type SettingType.
Definition: Setting.h:197
TypeId
types that correspond to the index of the position of the type in the variant template.
Definition: Setting.h:132
C_DECL_SPEC int rrcCallConv freeText(char *text)
Free char* generated by library routines.
C_DECL_SPEC char *rrcCallConv createText(const char *text)
Creates memory for holding a string.