5 #ifndef MERCURYDPM_COMMANDLINE_HELPERS_H
6 #define MERCURYDPM_COMMANDLINE_HELPERS_H
31 for (
int i = 0;
i < argc-1; ++
i) {
32 if (varName == argv[
i]) {
34 logger(
INFO,
"readFromCommandLine: % set to % ", varName.substr(nDashes),
value);
39 logger(
INFO,
"readFromCommandLine: % set to default value % ", varName.substr(nDashes),
value);
43 template<
typename T,
size_t n>
47 for (
int i = 0;
i < argc-1; ++
i) {
48 if (varName == argv[
i]) {
50 std::stringstream
out;
56 logger(
INFO,
"readArrayFromCommandLine: % set to % ", varName.substr(nDashes),
out.str());
61 std::stringstream
out;
63 logger(
INFO,
"readArrayFromCommandLine: % set to default value % ", varName.substr(nDashes),
out.str());
71 for (
int i = 0;
i < argc-1; ++
i) {
72 if (varName == argv[
i]) {
75 std::stringstream
out;
76 for (
int j =
i+1;
j < argc && argv[
j][0] !=
'-'; ++
j) {
77 values.push_back(atof(argv[
j]));
78 out << values.back() <<
' ';
80 logger(
INFO,
"readVectorFromCommandLine: % set to % ", varName.substr(nDashes),
out.str());
85 std::stringstream
out;
86 for (
auto&
v: values)
out <<
v <<
' ';
87 logger(
INFO,
"readVectorFromCommandLine: % set to default value % ", varName.substr(nDashes),
out.str());
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
RealScalar s
Definition: level1_cplx_impl.h:130
#define INFO(i)
Definition: mumps_solver.h:54
squared absolute value
Definition: GlobalFunctions.h:87
Definition: CommandLineHelpers.h:11
bool removeFromCommandline(int &argc, char *argv[], const std::string &varName, int nArgs)
May be used to hide arguments from argc and argv.
Definition: CommandLineHelpers.cc:41
std::size_t countLeadingDashes(const std::string &s)
Counts the leading dash ('-') characters in a string.
Definition: CommandLineHelpers.cc:12
std::array< T, n > readArrayFromCommandLine(int argc, char *argv[], const std::string &varName, std::array< T, n > value)
Definition: CommandLineHelpers.h:44
bool readFromCommandLine(int argc, char *argv[], const std::string &varName)
Returns true if command line arguments contain varName, false else.
Definition: CommandLineHelpers.cc:99
std::vector< T > readVectorFromCommandLine(int argc, char *argv[], const std::string &varName, size_t n, std::vector< T > values)
Definition: CommandLineHelpers.h:68
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
std::ofstream out("Result.txt")
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2