InputParser Class Reference

LibRPA: InputParser Class Reference
LibRPA

Class to parse parameters from string. More...

#include <inputfile.h>

Public Member Functions

 InputParser (const std::string &ps)
 
std::string get_params () const
 
void load (const std::string &ps)
 
void parse_double (const std::string &vname, double &var, double de, int &flag)
 parse single double value to var
 
void parse_int (const std::string &vname, int &var, int de, int &flag)
 parse single integer value to var
 
void parse_string (const std::string &vname, std::string &var, const std::string &de, int &flag)
 parse single string to var
 
void parse_bool (const std::string &vname, bool &var, const bool &de, int &flag)
 parse single bool to var
 

Static Public Attributes

static const std::string KV_SEP = "="
 separator between the parameter key and value
 
static const std::string COMMENTS_IDEN = "[#!]"
 comments identifier to trim
 

Detailed Description

Class to parse parameters from string.

Member functions prefixed with parse_ have a int argument at last. This flag is to indicate whether parsing is succesful. The meaning of return value:

  • 0: succesful
  • 1: failed to find the parameter string, or the parameter value is empty
  • 2: find the parameter string, but fail to convert the value to requested type

When multiple matches are found, the last one will be used.

Only successful parse will lead to value change of the variable. Otherwise the default value will be used.


The documentation for this class was generated from the following files: