69 for (
const auto& it : params)
73 string parn = it.first;
83 pos2 = parn.find(g, pos1);
84 if (pos2 == string::npos)
89 pos1 = pos2 + g.length();
92 ((g.length() == 0) || (pos1 == parn.length()) || (parn.rfind(g) == parn.length() - g.length())))
103 for (
size_t i = 0; i < params.size(); i++)
107 string parn = params.at(i);
117 pos2 = parn.find(g, pos1);
118 if (pos2 == string::npos)
123 pos1 = pos2 + g.length();
126 ((g.length() == 0) || (pos1 == parn.length()) || (parn.rfind(g) == parn.length() - g.length())))
127 retv.push_back(parn);
136 const string& parameter,
137 const map<string, string>& params,
140 const string& suffix,
141 bool suffixIsOptional,
142 const string& defaultPath,
145 string filePath = getStringParameter(parameter, params, defaultPath, suffix, suffixIsOptional, warn);
148 if (filePath ==
"none" && isRequired)
150 throw Exception(
"You must specify a file for this parameter: " + parameter + (suffixIsOptional ?
"" : suffix));
152 if (filePath ==
"none")
156 throw Exception(
"File does not exists: " + filePath);
164 const string& parameterName,
165 const map<string, string>& params,
167 const string& suffix,
168 bool suffixIsOptional,
171 double dParam = defaultValue;
172 if (parameterExists(parameterName + suffix, params))
176 else if (suffixIsOptional && parameterExists(parameterName, params))
180 else if (warn <= warningLevel)
182 displayWarning(
"Parameter " + parameterName + suffix +
" not specified. Default used instead: " +
TextTools::toString(defaultValue));
190 const string& parameterName,
191 const map<string, string>& params,
193 const string& suffix,
194 bool suffixIsOptional,
197 int iParam = defaultValue;
198 if (parameterExists(parameterName + suffix, params))
202 else if (suffixIsOptional && parameterExists(parameterName, params))
206 else if (warn <= warningLevel)
208 displayWarning(
"Parameter " + parameterName + suffix +
" not specified. Default used instead: " +
TextTools::toString(defaultValue));
217 const string& parameterName,
218 const map<string, string>& params,
220 const string& suffix,
221 bool suffixIsOptional,
225 bool bParam = defaultValue;
226 if (parameterExists(parameterName + suffix, params))
228 sParam = params.at(parameterName + suffix);
230 else if (suffixIsOptional && parameterExists(parameterName, params))
232 sParam = params.at(parameterName);
236 if (warn <= warningLevel)
238 displayWarning(
"Parameter " + parameterName +
" not specified. Default used instead: " +
TextTools::toString(defaultValue));
242 if ((sParam ==
"true")
243 || (sParam ==
"TRUE")
252 else if ((sParam ==
"false")
253 || (sParam ==
"FALSE")
263 throw Exception(
"ApplicationTools::getBooleanParameter. Wrong description:" + sParam);
273 (*message << text).endLine();
279 (*error <<
"ERROR!!! " << text).endLine();
285 (*warning <<
"WARNING!!! " << text).endLine();
292 *message << TextTools::resizeRight(text, static_cast<size_t>(
static_cast<float>(terminalWidth) * terminalSplit - 1),
'.') <<
": ";
303 (*message <<
"Done.").endLine();
314 size_t width =
static_cast<size_t>(
static_cast<float>(terminalWidth) * terminalSplit - 2);
315 string gauge = string(
static_cast<size_t>((1. *
static_cast<double>(iter) /
static_cast<double>(total)) *
static_cast<double>(width)), symbol);
317 size_t step =
static_cast<size_t>(ceil(1. *
static_cast<double>(total) /
static_cast<double>(width)));
318 size_t x = iter % step;
321 string fill = string(width - gauge.length(),
' ');
323 if (mes.size() > terminalWidth - gauge.size())
325 if (x == 0 || iter == total)
327 *message <<
'\r' + info + gauge; message->flush();
340 size_t fill =
static_cast<size_t>(
static_cast<float>(terminalWidth) * terminalSplit) - (total - 1) / step - 1;
347 *message << symbol; message->flush();
358 string chars =
"-/-\\";
362 unsigned int i = iter % 4;
384 double nsec = difftime(endTime, startTime);
385 double nmin = floor(nsec / 60.);
386 double nhou = floor(nmin / 60.);
387 double nday = floor(nhou / 24.);
388 nhou = nhou - nday * 24;
389 nmin = nmin - (nday * 24 + nhou) * 60;
390 nsec = nsec - ((nday * 24 + nhou) * 60 + nmin) * 60;
391 *message << msg <<
" ";
392 *message << nday <<
"d, ";
393 *message << nhou <<
"h, ";
394 *message << nmin <<
"m, ";
395 *message << nsec <<
"s.";
406 return difftime(endTime, startTime);
Exception base class. Overload exception constructor (to control the exceptions mechanism)....
const std::string & nextToken()
Get the next available token. If no token is availbale, throw an Exception.
bool hasMoreToken() const
Tell if some tokens are still available.
int toInt(const std::string &s, char scientificNotation)
Convert from string to int.
double toDouble(const std::string &s, char dec, char scientificNotation)
Convert from string to double.
std::string resizeLeft(const std::string &s, std::size_t newSize, char fill)
std::string toString(T t)
General template method to convert to a string.
std::string resizeRight(const std::string &s, std::size_t newSize, char fill)