Xmipp  v3.23.11-Nereus
Arguments parsing
Collaboration diagram for Arguments parsing:

Read lists

These functions try to read N values of the desired type into the given structure (either a STL vector of any numerical type by adding the read values at the end or a Matrix1D of any numerical type and then the values are written at PHYSICAL positions 0 ... N-1, the Matrix1D must be big enough to hold all the data since it is not resized internally.

If it is not possible to read all parameters an exception is thrown. You can provide the exception in the function call but there are default values. These functions are based in those for reading single values, so it might be possible that these other functions throw other exceptions.

The different elements of the list are selected using the tokenizing functions (different elements in the string are separated by spaces), so after the application of this function to the input string, this is modified and NULL characters are introduced as delimiters of the elements.

The following code is an example of doing so:

getline(in_stream, line);
readFloatList(line, 10, v1); // Read 10 values from line in v1
readFloatList(NULL, 10, v2); // Read NEXT!! 10 values in v2
template<typename T >
void readFloatList (const char *str, int N, std::vector< T > &v)
 
template<typename T >
void readFloatList (const std::string &str, size_t &i, int N, std::vector< T > &v)
 
template<typename T >
void readFloatList (const char *str, int N, Matrix1D< T > &v, ErrorType _errno=ERR_VALUE_INCORRECT, std::string errmsg="Error reading floating list", int exit=0)
 

Functions for parsing the command line

These functions help you to manage the command line parameters

const char * getParameter (int argc, const char **argv, const char *param, const char *option=NULL)
 
bool getTwoDoubleParams (int argc, const char **argv, const char *param, double &v1, double &v2, double v1_def, double v2_def)
 
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)
 
bool checkParameter (int argc, const char **argv, const char *param)
 
int paremeterPosition (int argc, const char **argv, const char *param)
 
int numComponents (const std::string &str)
 
Matrix1D< double > getVectorParameter (int argc, const char **argv, const char *param, int dim=2)
 
Matrix1D< double > getVectorParameter (FILE *fh, const char *param, int dim=2)
 
void generateCommandLine (const std::string &command_line, int &argcp, char **&argvp, char *&copy)
 
bool generateCommandLine (FILE *fh, const char *param, int &argcp, char **&argvp, char *&copy)
 
std::string getParameter (FILE *fh, const char *param, int skip=0, const char *option=NULL)
 
bool checkParameter (FILE *fh, const char *param)
 

Detailed Description

This set of functions are designed for make easier checking and reading parameters from a string. The single value readings don't modify the value of the input string, while the multiple value readings do. In general, the reading is oriented to be done with a chain of strtok (a general C function), for this reason the string itself is modified by the successive calls to strtok.

The second group (list reading) uses tokens internally, while in the single read functions the token must be given by hand. Anyway, it is not so difficult to read a set of fields from a line with all the normal checks we would like (existence of a parameter, checking for numerical correctness...)

The following is an example of its use. This code tries to read a number, a character and a list of numbers from a line. In the example you can also see how to write code for the different error handling methods.

std::string line;
int key, param_no;
std::vector< float > data;
try
{
key = textToFloat(firstToken(line), 1602, "Error reading key");
param_no = textToInt(nextToken(), 1602, "Error reading number parameters");
readFloatList(NULL, param_no, data, 1602, "Error reading doc file line");
}
catch (XmippError XE)
{
std::cout << XE;
DL.line_type = 0;
REPORT_ERROR(1602, "Line is discarded");
}

Function Documentation

◆ checkParameter() [1/2]

bool checkParameter ( int  argc,
const char **  argv,
const char *  param 
)

Get boolean parameters from the command line.

This function assumes that the command line is structured in such a way that for each parameter a block like "-param" is defined. The label "param" can be substituted by any other one you like. It might be used to look for a boolean parameter, for instance:

-verbose means that verbose functionality is set (TRUE)
verbose = checkParameter(argc, argv, "-verbose"));
// checks if "-verbose" was supplied in the command line. If -verbose was
// supplied the function returns TRUE (1), otherwise returns FALSE (0)

Definition at line 97 of file args.cpp.

98 {
99  int i = 0;
100 
101  while ((i < argc) && (strcmp(param, argv[i]) != 0))
102  i++;
103 
104  if (i < argc)
105  return(true);
106  else
107  return(false);
108 }
#define i
struct _parameter * param

◆ checkParameter() [2/2]

bool checkParameter ( FILE *  fh,
const char *  param 
)

Check if a parameter is present in a file.

The same as the previous function, but this function only reports if a parameter is present or not in a file. Notice that boolean parameters must be defined as "parameter=". If after the parameter, "no" comes then this function returns FALSE

Definition at line 434 of file args.cpp.

435 {
436  long actual_pos = ftell(fh);
437  fseek(fh, 0, SEEK_SET);
438 
439  char line[201];
440  bool found = false;
441  std::string retval;
442 
443  // Read lines
444  while (fgets(line, 200, fh) != NULL)
445  {
446  if (line[0] == 0)
447  continue;
448  if (line[0] == '#')
449  continue;
450  if (line[0] == '\n')
451  continue;
452 
453  int i = 0;
454  while (line[i] != 0 && line[i] != '=')
455  i++;
456  if (line[i] == '=')
457  {
458  line[i] = 0;
459  if (strcmp(line, param) == 0)
460  {
461  retval = line + i + 1;
462  found = true;
463  break;
464  }
465  }
466  }
467  fseek(fh, actual_pos, SEEK_SET);
468  return found && retval != "No" && retval != "NO" && retval != "no";
469 }
#define i
struct _parameter * param

◆ generateCommandLine() [1/2]

void generateCommandLine ( const std::string &  command_line,
int &  argcp,
char **&  argvp,
char *&  copy 
)

Generate argc and argv for a string.

Given a string this function makes a copy of the string and divides it into tokens such that they can be used as argc and argv, as if it were a command line.

The string copy remains in "copy" and it can be freed by disposing this variable.

argvp[0] (normally the program name) is set to any value, in this case to "autom", standing for "automatically generated".

argcp==0 if now valid command line is provided, ie, the line is empty or only with blanks.

Next time the function is called it checks that argv and copy are empty (pointing to NULL), if they aren't then firstly the associated memory is freed.

int argcp;
char** argvp;
char* copy;
copy = NULL;
argvp = NULL;
string command_line = "-i input_file -o output_file";
generateCommandLine(command_line, argcp, &argvp, &copy);
if (argcp != 0)
read_parameters(argcp, argvp);

Definition at line 238 of file args.cpp.

240 {
241  int L = command_line.length();
242 
243  // Some initialization
244  if (L == 0)
245  {
246  argcp = 0;
247  return;
248  }
249  if (command_line[0] == '\n')
250  {
251  argcp = 0;
252  return;
253  }
254 
255  // Check that argvp and copy are empty
256  if (argvp != NULL)
257  delete argvp;
258  if (copy != NULL)
259  delete[] copy;
260 
261  // Copy command line
262  copy = new char[L+1];
263  int i = 0;
264  while (i < L && command_line[i] != '\n')
265  {
266  copy[i] = command_line[i];
267  i++;
268  }
269  L = i;
270  copy[L] = '\0';
271 
272  // Now count how many different words are there
273  int words;
274  int state;
275  if (copy[0] == ' ')
276  {
277  state = OUTSIDE_WORD;
278  words = 0;
279  }
280  else
281  {
282  state = INSIDE_WORD;
283  words = 1;
284  }
285  i = 1;
286  while (i < L)
287  {
288  if (state == OUTSIDE_WORD && copy[i] != ' ')
289  {
290  state = INSIDE_WORD;
291  words++;
292  }
293  if (state == INSIDE_WORD && copy[i] == ' ')
294  state = OUTSIDE_WORD;
295  i++;
296  }
297 
298  // Resize argv and cut words
299  argvp = new char *[words+1];
300  argvp[0] = new char[6];
301  strcpy(argvp[0], "autom");
302  if (copy[0] == ' ')
303  {
304  state = OUTSIDE_WORD;
305  argcp = 1;
306  }
307  else
308  {
309  state = INSIDE_WORD;
310  argvp[1] = &(copy[0]);
311  argcp = 2;
312  }
313  i = 1;
314  while (i < L)
315  {
316  if (state == OUTSIDE_WORD && copy[i] != ' ')
317  {
318  state = INSIDE_WORD;
319  argvp[argcp] = &(copy[i]);
320  argcp++;
321  }
322  if (state == INSIDE_WORD && copy[i] == ' ')
323  {
324  state = OUTSIDE_WORD;
325  copy[i] = '\0';
326  }
327  i++;
328  }
329 }
#define i
#define INSIDE_WORD
Definition: args.cpp:236
#define OUTSIDE_WORD
Definition: args.cpp:237

◆ generateCommandLine() [2/2]

bool generateCommandLine ( FILE *  fh,
const char *  param,
int &  argcp,
char **&  argvp,
char *&  copy 
)

Generate articial command line from a file.

The copy variable must be destroyed outside by "delete copy". This function takes "input_file=<input_file>" and turns it into "-input_file <input_file>" The appropriate argc, argv are also returned.

Returns TRUE if the parameter is found in the file, and FALSE if it is not

Definition at line 332 of file args.cpp.

334 {
335  long actual_pos = ftell(fh);
336  fseek(fh, 0, SEEK_SET);
337 
338  char line[201];
339  char *retval;
340  bool found = false;
341 
342  // Read lines
343  while (fgets(line, 200, fh) != NULL && !found)
344  {
345  if (line[0] == 0)
346  continue;
347  if (line[0] == '#')
348  continue;
349  if (line[0] == ';')
350  continue;
351  if (line[0] == '\n')
352  continue;
353 
354  int i = 0;
355  while (line[i] != 0 && line[i] != '=')
356  i++;
357  if (line[i] == '=')
358  {
359  line[i] = 0;
360  if (strcmp(line, param) == 0)
361  {
362  retval = line + i + 1;
363  found = true;
364  break;
365  }
366  }
367  }
368  fseek(fh, actual_pos, SEEK_SET);
369  if (!found)
370  return false;
371 
372  std::string artificial_line;
373  artificial_line = (std::string)"-" + param + " " + retval;
374  generateCommandLine(artificial_line, argcp, argvp, copy);
375  return true;
376 }
#define i
struct _parameter * param
void generateCommandLine(const std::string &command_line, int &argcp, char **&argvp, char *&copy)
Definition: args.cpp:238

◆ getParameter() [1/2]

const char* getParameter ( int  argc,
const char **  argv,
const char *  param,
const char *  option = NULL 
)

Get parameters from the command line.

This function assumes that the command line is structured in such a way that for each parameter a block like "-param <param_value>" is defined. The label "param" can be substituted by any other one you like. If the parameter is optional then this function allows you to define a default value. If no default value is supplied and the parameter is not specified in the command line, then an exception is thrown. You may change the default exception.

You may also indicate that in case of error no exception is raised and force the program to abort (use the exit variable).

m_param = textToFloat(getParameter(argc, argv, "-m"));
// Get compulsory parameter "-m"
m_param = textToFloat(getParameter(argc, argv, "-m","2.65"));
// Optional parameter, if no parameter is given it takes 2.65 by default
m_param = textToFloat(getParameter(argc, argv, "-m", NULL, 6001, "-m parameter not \
found. I'm going out", TRUE);
// Compulsory parameter, if not found give an special error message and exit
// the program

Definition at line 30 of file args.cpp.

31 {
32  int i = 0;
33 
34  while ((i < argc) && (strcmp(param, argv[i])))
35  i++;
36  if (i < argc - 1)
37  return(argv[i+1]);
38  else
39  if (option == NULL)
41 
42  return((char *) option);
43 }
Argument missing.
Definition: xmipp_error.h:114
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define i
struct _parameter * param

◆ getParameter() [2/2]

std::string getParameter ( FILE *  fh,
const char *  param,
int  skip = 0,
const char *  option = NULL 
)

Get parameter from file.

Parameters are supposed to be identified with an =, so any line which doesn't contain an = character cannot contain a parameter. The left part of the "=" is the identifier, and the right part the value. The value is returned without any extra space, if it is compound of several words, then the spaces in between are simplified to a single blank space.

The file position inside the file is not moved and comments are allowed starting with "#" and ";".

Parameter skip controls the number of these parameters to skip before returning the value, ie, if there are several "parameter=" tags in a file and you want the first one then you should skip 0, if you want the second the skip=1, ...

The meaning and use of the exit, errors and optional value is the same as in the command line getParameter

Definition at line 379 of file args.cpp.

380 {
381  long actual_pos = ftell(fh);
382  fseek(fh, 0, SEEK_SET);
383 
384  char line[201];
385  std::string retval;
386  bool found = false;
387  int skipped = 0;
388 
389  // Read lines
390  while (fgets(line, 200, fh) != NULL && !found)
391  {
392  if (line[0] == 0)
393  continue;
394  if (line[0] == '#')
395  continue;
396  if (line[0] == ';')
397  continue;
398  if (line[0] == '\n')
399  continue;
400 
401  int i = 0;
402  char *line_wo_spaces = line;
403  while (*line_wo_spaces == ' ' || *line_wo_spaces == '\t')
404  line_wo_spaces++;
405  while (line_wo_spaces[i] != 0 && line_wo_spaces[i] != '=')
406  i++;
407  if (line_wo_spaces[i] == '=')
408  {
409  line_wo_spaces[i] = 0;
410  if (strcmp(line_wo_spaces, param) == 0)
411  {
412  if (skipped == skip)
413  {
414  retval = line_wo_spaces + i + 1;
415  found = true;
416  break;
417  }
418  else
419  skipped++;
420  }
421  }
422  }
423  fseek(fh, actual_pos, SEEK_SET);
424  if (!found)
425  if (option == NULL)
427  else
428  return option;
429  else
430  return removeSpaces(retval);
431 }
String removeSpaces(const String &_str)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define i
Incorrect argument received.
Definition: xmipp_error.h:113
struct _parameter * param

◆ getThreeDoubleParams()

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 
)

Get 3 float parameters after a flag from the command line.

An exception is thrown if there are not enough parameters after the flag, if the message is empty then "Not enough parameters after <param>" is shown. The default values must be provided. TRUE is returned if the two values have been found

Definition at line 70 of file args.cpp.

73 {
74  bool retval;
75  int i = paremeterPosition(argc, argv, param);
76  if (i != -1)
77  {
78  if (i + 3 >= argc)
80  (std::string)"Not enough arguments after " + *param);
81  v1 = textToFloat(argv[i+1]);
82  v2 = textToFloat(argv[i+2]);
83  v3 = textToFloat(argv[i+3]);
84  retval = true;
85  }
86  else
87  {
88  v1 = v1_def;
89  v2 = v2_def;
90  v3 = v3_def;
91  retval = false;
92  }
93  return retval;
94 }
Argument missing.
Definition: xmipp_error.h:114
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
int paremeterPosition(int argc, const char **argv, const char *param)
Definition: args.cpp:111
#define i
double v1
float textToFloat(const char *str)
struct _parameter * param

◆ getTwoDoubleParams()

bool getTwoDoubleParams ( int  argc,
const char **  argv,
const char *  param,
double &  v1,
double &  v2,
double  v1_def,
double  v2_def 
)

Get two float parameters after a flag from the command line.

An exception is thrown if there are not enough parameters after the flag, if the message is empty then "Not enough parameters after <param>" is shown. The default values must be provided. TRUE is returned if the two values have been found

Definition at line 46 of file args.cpp.

48 {
49  bool retval;
50  int i = paremeterPosition(argc, argv, param);
51  if (i != -1)
52  {
53  if (i + 2 >= argc)
55  (std::string)"Not enough arguments after " + *param);
56  v1 = textToFloat(argv[i+1]);
57  v2 = textToFloat(argv[i+2]);
58  retval = true;
59  }
60  else
61  {
62  v1 = v1_def;
63  v2 = v2_def;
64  retval = false;
65  }
66  return retval;
67 }
Argument missing.
Definition: xmipp_error.h:114
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
int paremeterPosition(int argc, const char **argv, const char *param)
Definition: args.cpp:111
#define i
double v1
float textToFloat(const char *str)
struct _parameter * param

◆ getVectorParameter() [1/2]

Matrix1D< double > getVectorParameter ( int  argc,
const char **  argv,
const char *  param,
int  dim = 2 
)

Get float vector.

A vector is defined as a "[x,y,z, ...]" of any dimension (by default 2D vectors are read). The vector must not contain blank spaces.

a = getVectorParameter(argc, argv, "-a", 3); // a 3D vector called "-a".

The vector is internally resized properly. If the dimension is -1 then all the vector components are read disregarding their dimensionality, ie,-1 is used to read vectors of an unknown dimension. If the parameter is not found when no dimensionality is given an empty vector is returned but no exception is thrown. If there is no dimensionality and a single parameter is behind the flag then no brackets are needed

Definition at line 138 of file args.cpp.

139 {
140  Matrix1D<double> aux;
141  bool count_dimensionality = (dim == -1);
142 
143  // Find and form vector
144  int pos = paremeterPosition(argc, argv, param);
145  if (pos == -1 || (pos + 1 == argc))
146  {
147  if (count_dimensionality)
148  return aux;
149  else
151  }
152  pos++;
153  if (*(argv[pos]) != '[')
154  {
155  double d = textToFloat(argv[pos]);
156  aux.resize(1);
157  aux(0) = d;
158  return aux;
159  }
160 
161  std::string vector;
162  bool finished = false;
163  while (!finished)
164  {
165  vector += argv[pos];
166  if (vector[vector.length()-1] == ']')
167  finished = true;
168  if (++pos == argc && !finished)
170  }
171 
172  // Remove brackets
173  vector = vector.substr(1, vector.length() - 2);
174 
175  // Count dimensionality
176  int start_copy = 0, end_copy;
177  if (count_dimensionality)
178  {
179  dim = 0;
180  start_copy = 0;
181  do
182  {
183  end_copy = vector.find(',', start_copy);
184  if (end_copy == -1)
185  break;
186  start_copy = end_copy + 1;
187  dim++;
188  }
189  while (1);
190  dim++;
191  }
192 
193  // Read different vector elements
194  int i = 0;
195  start_copy = 0;
196  aux.resize(dim);
197  while (i < dim - 1)
198  {
199  // Find colon
200  end_copy = vector.find(',', start_copy);
201  // Store number
202  aux(i) = textToFloat(vector.substr(start_copy, end_copy));
203 
204  // Prepare for next iteration
205  i++;
206  start_copy = end_copy + 1;
207  }
208 
209  // Copy last element
210  aux(i) = textToFloat(vector.substr(start_copy, vector.length()));
211 
212  return aux;
213 }
Argument missing.
Definition: xmipp_error.h:114
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
int paremeterPosition(int argc, const char **argv, const char *param)
Definition: args.cpp:111
#define i
doublereal * d
float textToFloat(const char *str)
Incorrect argument received.
Definition: xmipp_error.h:113
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
struct _parameter * param

◆ getVectorParameter() [2/2]

Matrix1D<double> getVectorParameter ( FILE *  fh,
const char *  param,
int  dim = 2 
)

Get float vector.

Same as the previous function but from a file.

Definition at line 216 of file args.cpp.

217 {
218  int argcp;
219  char **argvp = NULL;
220  char *copy = NULL;
221  Matrix1D<double> retval;
222  if (!generateCommandLine(fh, param, argcp, argvp, copy))
223  {
224  if (dim != -1)
226  }
227  else
228  {
229  retval = getVectorParameter(argcp, (const char **)argvp, ((std::string)"-" + param).c_str(), dim);
230  delete[] copy;
231  }
232  return retval;
233 }
Matrix1D< double > getVectorParameter(int argc, const char **argv, const char *param, int dim)
Definition: args.cpp:138
Argument missing.
Definition: xmipp_error.h:114
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
struct _parameter * param
void generateCommandLine(const std::string &command_line, int &argcp, char **&argvp, char *&copy)
Definition: args.cpp:238

◆ numComponents()

int numComponents ( const std::string &  str)

Return the number of components of a vector argument.

A vector argument is defined as [x,y,z,...]. It returns 0 if the string does not contain a vector

Definition at line 125 of file args.cpp.

126 {
127  int imax = str.length();
128  int retval = 0;
129  if (str[0] != '[' && str[imax-1] != ']')
130  return retval;
131  for (int i = 0; i < imax; i++)
132  if (str[i] == ',')
133  retval++;
134  return retval + 1;
135 }
#define i

◆ paremeterPosition()

int paremeterPosition ( int  argc,
const char **  argv,
const char *  param 
)

Returns the position where the given parameter is in the command line.

This function assumes that the command line is structured in such a way that for each parameter a block like "-param" is defined. The label "param" can be substituted by any other one you like. It returns -1 if the parameter is not found. It is used to look for parameters having a list of values behind, for instance:

-ang rot tilt psi
i = paremeterPosition(argc, argv, "-ang"));
// This condition checks if 3 arguments where introduced after -ang parameter
// (assuming that the -ang argument is the last one in the string)
if (i+3 >= argc)
EXIT_ERROR(1, "Not enough parameters behind -ang");
ang1 = argv[i+1];
ang2 = argv[i+2];
ang3 = argv[i+3];

Definition at line 111 of file args.cpp.

112 {
113  int i = 0;
114 
115  while ((i < argc) && (strcmp(param, argv[i])))
116  i++;
117 
118  if (i < argc - 1)
119  return i;
120  else
121  return -1;
122 }
#define i
struct _parameter * param

◆ readFloatList() [1/3]

template<typename T >
void readFloatList ( const char *  str,
int  N,
std::vector< T > &  v 
)

List to STL vector.

Definition at line 104 of file args.h.

106 {
107  T valueF;
108  char* token;
109 
110  token = firstToken(str);
111  for (int i = 0; i < N; i++)
112  {
113  if (token == NULL)
114  REPORT_ERROR(ERR_VALUE_INCORRECT, "Cannot convert string into a list of numbers");
115 
116  valueF = (T) textToFloat(token);
117  v.push_back(valueF);
118 
119  if (i != N - 1)
120  token = nextToken();
121  }
122 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define i
float textToFloat(const char *str)
char * firstToken(const char *str)
String nextToken(const String &str, size_t &i)
Incorrect value received.
Definition: xmipp_error.h:195

◆ readFloatList() [2/3]

template<typename T >
void readFloatList ( const std::string &  str,
size_t &  i,
int  N,
std::vector< T > &  v 
)

List to STL vector.

Definition at line 127 of file args.h.

131 {
132  T valueF;
133  std::string token;
134 
135  token = nextToken(str, i);
136  for (int j = 0; j < N; j++)
137  {
138  if (token == "")
139  REPORT_ERROR(ERR_VALUE_INCORRECT, "Cannot convert string into list of floats");
140  valueF = (T) textToFloat(token.c_str());
141  v.push_back(valueF);
142 
143  if (j != N - 1)
144  token = nextToken(str, i);
145  }
146 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define i
float textToFloat(const char *str)
#define j
String nextToken(const String &str, size_t &i)
Incorrect value received.
Definition: xmipp_error.h:195

◆ readFloatList() [3/3]

template<typename T >
void readFloatList ( const char *  str,
int  N,
Matrix1D< T > &  v,
ErrorType  _errno = ERR_VALUE_INCORRECT,
std::string  errmsg = "Error reading floating list",
int  exit = 0 
)

Read list into a Matrix1D.

Definition at line 151 of file args.h.

157 {
158  T valueF;
159  char* token;
160 
161  token = firstToken(str);
162  for (int i = 0; i < N; i++)
163  {
164  if (token == NULL)
165  {
166  // CO: Should not report other error than the required one
167  // std::cout << "Read float list: Number of true parameters doesn't coincide\n";
168  REPORT_ERROR(_errno, errmsg);
169  }
170 
171  try
172  {
173  valueF = (T) textToFloat(token);
174  }
175  catch (XmippError)
176  {
177  REPORT_ERROR(_errno, errmsg);
178  }
179 
180  v(i) = valueF;
181  if (i != N - 1)
182  token = nextToken();
183  }
184 }
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define i
float textToFloat(const char *str)
char * firstToken(const char *str)
String nextToken(const String &str, size_t &i)