32 for (
const auto& it : params)
36 string parn = it.first;
46 pos2 = parn.find(g, pos1);
47 if (pos2 == string::npos)
52 pos1 = pos2 + g.length();
55 ((g.length() == 0) || (pos1 == parn.length()) || (parn.rfind(g) == parn.length() - g.length())))
66 for (
size_t i = 0; i < params.size(); i++)
70 string parn = params.at(i);
80 pos2 = parn.find(g, pos1);
81 if (pos2 == string::npos)
86 pos1 = pos2 + g.length();
89 ((g.length() == 0) || (pos1 == parn.length()) || (parn.rfind(g) == parn.length() - g.length())))
99 const string& parameter,
100 const map<string, string>& params,
103 const string& suffix,
104 bool suffixIsOptional,
105 const string& defaultPath,
108 string filePath = getStringParameter(parameter, params, defaultPath, suffix, suffixIsOptional, warn);
111 if (filePath ==
"none" && isRequired)
113 throw Exception(
"You must specify a file for this parameter: " + parameter + (suffixIsOptional ?
"" : suffix));
115 if (filePath ==
"none")
119 throw Exception(
"File does not exists: " + filePath);
127 const string& parameterName,
128 const map<string, string>& params,
130 const string& suffix,
131 bool suffixIsOptional,
134 double dParam = defaultValue;
135 if (parameterExists(parameterName + suffix, params))
139 else if (suffixIsOptional && parameterExists(parameterName, params))
143 else if (warn <= warningLevel)
145 displayWarning(
"Parameter " + parameterName + suffix +
" not specified. Default used instead: " +
TextTools::toString(defaultValue));
153 const string& parameterName,
154 const map<string, string>& params,
156 const string& suffix,
157 bool suffixIsOptional,
160 int iParam = defaultValue;
161 if (parameterExists(parameterName + suffix, params))
165 else if (suffixIsOptional && parameterExists(parameterName, params))
169 else if (warn <= warningLevel)
171 displayWarning(
"Parameter " + parameterName + suffix +
" not specified. Default used instead: " +
TextTools::toString(defaultValue));
180 const string& parameterName,
181 const map<string, string>& params,
183 const string& suffix,
184 bool suffixIsOptional,
188 bool bParam = defaultValue;
189 if (parameterExists(parameterName + suffix, params))
191 sParam = params.at(parameterName + suffix);
193 else if (suffixIsOptional && parameterExists(parameterName, params))
195 sParam = params.at(parameterName);
199 if (warn <= warningLevel)
201 displayWarning(
"Parameter " + parameterName +
" not specified. Default used instead: " +
TextTools::toString(defaultValue));
205 if ((sParam ==
"true")
206 || (sParam ==
"TRUE")
215 else if ((sParam ==
"false")
216 || (sParam ==
"FALSE")
226 throw Exception(
"ApplicationTools::getBooleanParameter. Wrong description:" + sParam);
236 (*message << text).endLine();
242 (*error <<
"ERROR!!! " << text).endLine();
248 (*warning <<
"WARNING!!! " << text).endLine();
255 *message << TextTools::resizeRight(text, static_cast<size_t>(
static_cast<float>(terminalWidth) * terminalSplit - 1),
'.') <<
": ";
266 (*message <<
"Done.").endLine();
277 size_t width =
static_cast<size_t>(
static_cast<float>(terminalWidth) * terminalSplit - 2);
278 string gauge = string(static_cast<size_t>((1. * static_cast<double>(iter) / static_cast<double>(total)) * static_cast<double>(width)), symbol);
280 size_t step =
static_cast<size_t>(ceil(1. * static_cast<double>(total) / static_cast<double>(width)));
281 size_t x = iter % step;
284 string fill = string(width - gauge.length(),
' ');
286 if (mes.size() > terminalWidth - gauge.size())
288 if (x == 0 || iter == total)
290 *message <<
'\r' + info + gauge; message->flush();
303 size_t fill =
static_cast<size_t>(
static_cast<float>(terminalWidth) * terminalSplit) - (total - 1) / step - 1;
310 *message << symbol; message->flush();
321 string chars =
"-/-\\";
325 unsigned int i = iter % 4;
347 double nsec = difftime(endTime, startTime);
348 double nmin = floor(nsec / 60.);
349 double nhou = floor(nmin / 60.);
350 double nday = floor(nhou / 24.);
351 nhou = nhou - nday * 24;
352 nmin = nmin - (nday * 24 + nhou) * 60;
353 nsec = nsec - ((nday * 24 + nhou) * 60 + nmin) * 60;
354 *message << msg <<
" ";
355 *message << nday <<
"d, ";
356 *message << nhou <<
"h, ";
357 *message << nmin <<
"m, ";
358 *message << nsec <<
"s.";
369 return difftime(endTime, startTime);
std::string resizeRight(const std::string &s, std::size_t newSize, char fill)
double toDouble(const std::string &s, char dec, char scientificNotation)
Convert from string to double.
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.
std::string resizeLeft(const std::string &s, std::size_t newSize, char fill)
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
int toInt(const std::string &s, char scientificNotation)
Convert from string to int.
std::string toString(T t)
General template method to convert to a string.