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" 50 #include "../Numeric/Matrix/Matrix.h" 147 static bool parameterExists(
const std::string& parameterName, std::map<std::string, std::string>& params);
149 static bool parameterExists(
const std::string& parameterName, std::vector<std::string>& params);
160 static std::vector<std::string>
matchingParameters(
const std::string& pattern, std::map<std::string, std::string>& params);
162 static std::vector<std::string>
matchingParameters(
const std::string& pattern, std::vector<std::string>& params);
176 const std::string& parameterName,
177 std::map<std::string, std::string>& params,
179 const std::string& suffix =
"",
180 bool suffixIsOptional =
true,
195 const std::string& parameterName,
196 std::map<std::string, std::string>& params,
198 const std::string& suffix =
"",
199 bool suffixIsOptional =
true,
214 const std::string& parameterName,
215 std::map<std::string, std::string>& params,
216 const std::string& defaultValue,
217 const std::string& suffix =
"",
218 bool suffixIsOptional =
true,
233 const std::string& parameterName,
234 std::map<std::string, std::string>& params,
236 const std::string& suffix =
"",
237 bool suffixIsOptional =
true,
252 const std::string& parameterName,
253 std::map<std::string, std::string>& params,
255 const std::string& suffix =
"",
256 bool suffixIsOptional =
true,
259 T tParam = defaultValue;
262 tParam = TextTools::to<T>(params[parameterName + suffix]);
266 tParam = TextTools::to<T>(params[parameterName]);
294 const std::string& parameter,
295 std::map<std::string, std::string>& params,
296 bool isRequired =
true,
297 bool mustExist =
true,
298 const std::string& suffix =
"",
299 bool suffixIsOptional =
false,
300 const std::string& defaultPath =
"none",
316 const
std::
string& parameterName,
317 std::map<
std::
string,
std::
string>& params,
319 const
std::
string& defaultValue,
320 const
std::
string& suffix = "",
321 bool suffixIsOptional = true,
324 std::string s =
getStringParameter(parameterName, params, defaultValue, suffix, suffixIsOptional, warn);
326 if (s[0] ==
'(' && s[s.size() - 1] ==
')') {
328 s = s.substr(1, s.size() - 2);
334 for (
size_t i = 0; i < n; i++)
336 v[i] = TextTools::fromString<T>(st.
nextToken());
358 const std::string& parameterName,
359 std::map<std::string, std::string>& params,
362 const std::string& defaultValue,
363 const std::string& suffix =
"",
364 bool suffixIsOptional =
true,
367 std::string s =
getStringParameter(parameterName, params, defaultValue, suffix, suffixIsOptional, warn);
368 if (s[0] ==
'(' && s[s.size() - 1] ==
')') {
370 s = s.substr(1, s.size() - 2);
376 for (
size_t i = 0; i < n; i++)
379 std::string::size_type pos = token.find(rangeOperator);
380 if (pos == std::string::npos)
381 v.push_back(TextTools::fromString<T>(token));
384 T d1 = TextTools::fromString<T>(token.substr(0, pos));
385 T d2 = TextTools::fromString<T>(token.substr(pos + 1));
386 for (T j = d1; j < d2; j++)
418 const std::string& parameterName,
419 std::map<std::string, std::string>& params,
421 const std::string& defaultValue,
422 const std::string& suffix =
"",
423 bool suffixIsOptional =
true,
428 std::string s =
getStringParameter(parameterName, params, defaultValue, suffix, suffixIsOptional, warn);
430 if (s[0] ==
'(' && s[s.size() - 1] ==
')') {
432 s = s.substr(1, s.size() - 2);
445 for (
size_t i = 0; i < n; i++)
447 v[i] = TextTools::fromString<T>(st2.
nextToken());
492 static void displayTask(
const std::string& text,
bool eof =
false);
526 displayResult(text, result ? std::string(
"yes") : std::string(
"no"));
550 static void displayGauge(
size_t iter,
size_t total,
char symbol=
'>',
const std::string& mes=
"");
606 #endif //_APPLICATIONTOOLS_H_
This class allows to perform a correspondence analysis.
bool hasMoreToken() const
Tell if some tokens are still available.
static std::string resizeRight(const std::string &s, size_t newSize, char fill=' ')
Send a string of size 'newSize', which is a copy of 's' truncated or filled with character 'fill' at ...
const std::string & nextToken()
Get the next available token. If no token is availbale, throw an Exception.
static std::string toString(T t)
General template method to convert to a string.
size_t numberOfRemainingTokens() const
Tell how many tokens are available.
static bool isEmpty(const std::string &s)
Tell if a string is empty.
const std::string & nextToken()
Get the next available token. If no token is availbale, throw an Exception.
void addRow(const std::vector< Scalar > &newRow)
An improved tokenizer for strings.