30 const char *
getParameter(
int argc,
const char **argv,
const char *
param,
const char *option)
34 while ((i < argc) && (strcmp(param, argv[i])))
42 return((
char *) option);
47 double &
v1,
double &v2,
double v1_def,
double v2_def)
55 (std::string)
"Not enough arguments after " + *param);
71 double &
v1,
double &v2,
double &v3,
72 double v1_def,
double v2_def,
double v3_def)
80 (std::string)
"Not enough arguments after " + *param);
101 while ((i < argc) && (strcmp(param, argv[i]) != 0))
115 while ((i < argc) && (strcmp(param, argv[i])))
127 int imax = str.length();
129 if (str[0] !=
'[' && str[imax-1] !=
']')
131 for (
int i = 0;
i < imax;
i++)
141 bool count_dimensionality = (dim == -1);
145 if (pos == -1 || (pos + 1 == argc))
147 if (count_dimensionality)
153 if (*(argv[pos]) !=
'[')
162 bool finished =
false;
166 if (vector[vector.length()-1] ==
']')
168 if (++pos == argc && !finished)
173 vector = vector.substr(1, vector.length() - 2);
176 int start_copy = 0, end_copy;
177 if (count_dimensionality)
183 end_copy = vector.find(
',', start_copy);
186 start_copy = end_copy + 1;
200 end_copy = vector.find(
',', start_copy);
202 aux(i) =
textToFloat(vector.substr(start_copy, end_copy));
206 start_copy = end_copy + 1;
210 aux(i) =
textToFloat(vector.substr(start_copy, vector.length()));
229 retval =
getVectorParameter(argcp, (
const char **)argvp, ((std::string)
"-" + param).c_str(), dim);
236 #define INSIDE_WORD 1 237 #define OUTSIDE_WORD 2 239 char ** &argvp,
char* ©)
241 int L = command_line.length();
249 if (command_line[0] ==
'\n')
262 copy =
new char[L+1];
264 while (i < L && command_line[i] !=
'\n')
266 copy[
i] = command_line[
i];
299 argvp =
new char *[words+1];
300 argvp[0] =
new char[6];
301 strcpy(argvp[0],
"autom");
310 argvp[1] = &(copy[0]);
319 argvp[argcp] = &(copy[
i]);
333 char ** &argvp,
char* ©)
335 long actual_pos = ftell(fh);
336 fseek(fh, 0, SEEK_SET);
343 while (fgets(line, 200, fh) != NULL && !found)
355 while (line[i] != 0 && line[i] !=
'=')
360 if (strcmp(line, param) == 0)
362 retval = line + i + 1;
368 fseek(fh, actual_pos, SEEK_SET);
372 std::string artificial_line;
373 artificial_line = (std::string)
"-" + param +
" " + retval;
381 long actual_pos = ftell(fh);
382 fseek(fh, 0, SEEK_SET);
390 while (fgets(line, 200, fh) != NULL && !found)
402 char *line_wo_spaces = line;
403 while (*line_wo_spaces ==
' ' || *line_wo_spaces ==
'\t')
405 while (line_wo_spaces[i] != 0 && line_wo_spaces[i] !=
'=')
407 if (line_wo_spaces[i] ==
'=')
409 line_wo_spaces[
i] = 0;
410 if (strcmp(line_wo_spaces, param) == 0)
414 retval = line_wo_spaces + i + 1;
423 fseek(fh, actual_pos, SEEK_SET);
436 long actual_pos = ftell(fh);
437 fseek(fh, 0, SEEK_SET);
444 while (fgets(line, 200, fh) != NULL)
454 while (line[i] != 0 && line[i] !=
'=')
459 if (strcmp(line, param) == 0)
461 retval = line + i + 1;
467 fseek(fh, actual_pos, SEEK_SET);
468 return found && retval !=
"No" && retval !=
"NO" && retval !=
"no";
Matrix1D< double > getVectorParameter(int argc, const char **argv, const char *param, int dim)
bool checkParameter(int argc, const char **argv, const char *param)
String removeSpaces(const String &_str)
#define REPORT_ERROR(nerr, ErrormMsg)
int paremeterPosition(int argc, const char **argv, const char *param)
int numComponents(const std::string &str)
const char * getParameter(int argc, const char **argv, const char *param, const char *option)
float textToFloat(const char *str)
Incorrect argument received.
void resize(size_t Xdim, bool copy=true)
bool getThreeDoubleParams(int argc, const char **argv, const char *param, double &v1, double &v2, double &v3, double v1_def, double v2_def, double v3_def)
struct _parameter * param
bool getTwoDoubleParams(int argc, const char **argv, const char *param, double &v1, double &v2, double v1_def, double v2_def)
void generateCommandLine(const std::string &command_line, int &argcp, char **&argvp, char *©)