10 const char *
id,
const char *procOrRole,
const char *
type,
const char *
value,
const char *delimeter) {
12 this->procOrRole = procOrRole;
14 this->scalarOrVector =
value;
15 this->delim = delimeter;
18 Parameter::Parameter(
const char *
id,
19 const char *procOrRole,
22 const vector<string> &
rows,
23 const char *delimeter) {
25 this->procOrRole = procOrRole;
28 map<int, string> colIndexToName;
30 unsigned long nItems = 0;
32 for (
const char *
item = strtok_r(
copy.get(), delimeter, &saveptr);
item !=
nullptr;
33 item = strtok_r(
nullptr, delimeter, &saveptr), nItems++) {
35 size_t pos = 0, len = strlen(
item);
38 while (len > 0 && isspace(
item[--len]))
42 colIndexToName.insert(make_pair(nItems,
str));
43 columnNameToIndex.insert(make_pair(
str, nItems));
45 throw runtime_error(
"Duplicate column name: '" +
str +
"'");
48 for (
unsigned int r = 0;
r <
rows.size();
r++) {
50 for (
unsigned int pos = 0;
pos < nItems;
pos++) {
51 char *
item = strtok_r((
pos == 0 ?
copy.get() :
nullptr), delimeter, &saveptr);
53 throw runtime_error(
"Too few elements in '" +
rows[
r] +
"'");
56 size_t p = 0, len = strlen(
item);
57 while (
p < len && isspace(
item[
p]))
59 while (len > 0 && isspace(
item[--len]))
64 if (strtok_r(
nullptr, delimeter, &saveptr) !=
nullptr)
65 throw runtime_error(
"Too many elements in '" +
rows[
r] +
"', expected " + to_string(nItems));
68 this->delim = delimeter;
74 char *endptr =
nullptr;
75 long long retval = strtoll(
arg, &endptr, 0);
79 throw runtime_error(
"Cannot convert '" +
string(
arg) +
"' to integral type");
85 if (strlen(
arg) > 3) {
87 if (strstr(
arg,
"true") !=
nullptr && strstr(
arg,
"false") ==
nullptr)
90 if (strstr(
arg,
"true") ==
nullptr && strstr(
arg,
"false") !=
nullptr)
94 char *endptr =
nullptr;
95 long retval = strtol(
arg, &endptr, 0);
99 throw runtime_error(
"Cannot convert '" +
string(
arg) +
"' to boolean");
121 char *endptr =
nullptr;
122 long double retval = strtold(
arg, &endptr);
126 throw runtime_error(
"Cannot convert '" +
string(
arg) +
"' to floating point type");
139 char *endptr =
nullptr;
140 unsigned long long retval = strtoull(
arg, &endptr, 0);
144 throw runtime_error(
"Cannot convert '" +
string(
arg) +
"' to unsigned integral type");