41 #ifndef _APPLICATIONTOOLS_H_
42 #define _APPLICATIONTOOLS_H_
44 #include "../Io/FileTools.h"
45 #include "../Io/OutputStream.h"
46 #include "../Text/TextTools.h"
47 #include "../Text/StringTokenizer.h"
48 #include "../Text/NestedStringTokenizer.h"
140 static bool parameterExists(
const std::string& parameterName, std::map<std::string, std::string>& params);
154 const std::string& parameterName,
155 std::map<std::string, std::string>& params,
157 const std::string& suffix =
"",
158 bool suffixIsOptional =
true,
173 const std::string& parameterName,
174 std::map<std::string, std::string>& params,
176 const std::string& suffix =
"",
177 bool suffixIsOptional =
true,
192 const std::string& parameterName,
193 std::map<std::string, std::string>& params,
194 const std::string& defaultValue,
195 const std::string& suffix =
"",
196 bool suffixIsOptional =
true,
211 const std::string& parameterName,
212 std::map<std::string, std::string>& params,
214 const std::string& suffix =
"",
215 bool suffixIsOptional =
true,
230 const std::string& parameterName,
231 std::map<std::string, std::string>& params,
233 const std::string& suffix =
"",
234 bool suffixIsOptional =
true,
237 T tParam = defaultValue;
240 tParam = TextTools::to<T>(params[parameterName + suffix]);
244 tParam = TextTools::to<T>(params[parameterName]);
269 const std::string& parameter,
270 std::map<std::string, std::string>& params,
271 bool isRequired =
true,
272 bool mustExist =
true,
273 const std::string& suffix =
"",
274 bool suffixIsOptional =
false) throw (
Exception);
289 const std::
string& parameterName,
290 std::map<std::
string, std::
string>& params,
292 const std::
string& defaultValue,
293 const std::
string& suffix = "",
294 bool suffixIsOptional = true,
297 std::string s =
getStringParameter(parameterName, params, defaultValue, suffix, suffixIsOptional, warn);
299 if (s[0] ==
'(' && s[s.size() - 1] ==
')') {
301 s = s.substr(1, s.size() - 2);
307 for (
size_t i = 0; i < n; i++)
309 v[i] = TextTools::fromString<T>(st.
nextToken());
331 const std::string& parameterName,
332 std::map<std::string, std::string>& params,
335 const std::string& defaultValue,
336 const std::string& suffix =
"",
337 bool suffixIsOptional =
true,
340 std::string s =
getStringParameter(parameterName, params, defaultValue, suffix, suffixIsOptional, warn);
344 for (
size_t i = 0; i < n; i++)
347 std::string::size_type pos = token.find(rangeOperator);
348 if (pos == std::string::npos)
349 v.push_back(TextTools::fromString<T>(token));
352 T d1 = TextTools::fromString<T>(token.substr(0, pos));
353 T d2 = TextTools::fromString<T>(token.substr(pos + 1));
354 for (T j = d1; j < d2; j++)
399 static void displayTask(
const std::string& text,
bool eof =
false);
433 displayResult(text, result ? std::string(
"yes") : std::string(
"no"));
457 static void displayGauge(
size_t iter,
size_t total,
char symbol=
'>',
const std::string& mes=
"");
513 #endif //_APPLICATIONTOOLS_H_