IT++ Logo Newcom Logo

itpp::Parser Class Reference
[Argument Parser]

Argument Parser Class. More...

#include <itpp/base/parser.h>

List of all members.

Public Member Functions

 Parser ()
 Default Constructor.
 Parser (const std::string &filename)
 Constructor. Sets input file name.
 Parser (int argc, char *argv[])
 Constructor. Uses argc and argv (command line arguments).
 Parser (const std::string &filename, int argc, char *argv[])
 Constructor. Sets input file name and uses argc and argv (command line arguments).
 Parser (const Array< std::string > &setup)
 Constructor. Sets and Array of strings.
void init (const std::string &filename)
 Initialization function. Sets input file name.
void init (int argc, char *argv[])
 Initialization function. Uses argc and argv (command line arguments).
void init (const std::string &filename, int argc, char *argv[])
 Initialization function. Sets input file name and uses argc and argv (command line arguments).
void init (const Array< std::string > &setup)
 Initialization function. Sets and Array of strings.
void set_silentmode (bool v=true)
 Sets silent mode if true, or verbose mode if false.
bool exist (const std::string &name)
 Check is name exists in the file. Returns true if the name is found and false otherwise.
template<class T>
bool get (T &var, const std::string &name, int num=-1)
 Get variable value if name can be found (and return true), otherwise keep old value (and return false).
bool get_bool (const std::string &name, int num=-1)
 Interpret variable name as a bool.
int get_int (const std::string &name, int num=-1)
 Interpret variable name as an integer.
double get_double (const std::string &name, int num=-1)
 Interpret variable name as a double.
std::string get_string (const std::string &name, int num=-1)
 Interpret variable name as a string.
vec get_vec (const std::string &name, int num=-1)
 Interpret variable name as a vec.
ivec get_ivec (const std::string &name, int num=-1)
 Interpret variable name as a ivec.
svec get_svec (const std::string &name, int num=-1)
 Interpret variable name as a svec.
bvec get_bvec (const std::string &name, int num=-1)
 Interpret variable name as a bvec.
mat get_mat (const std::string &name, int num=-1)
 Interpret variable name as a mat.
imat get_imat (const std::string &name, int num=-1)
 Interpret variable name as a imat.
smat get_smat (const std::string &name, int num=-1)
 Interpret variable name as a smat.
bmat get_bmat (const std::string &name, int num=-1)
 Interpret variable name as a bmat.
template<>
bool get (std::string &var, const std::string &name, int num)


Detailed Description

Argument Parser Class.

Author:
Thomas Eriksson and Pal Frenger (Thanks to Svante Signell for valuable input)
This class parses strings to variables. The syntax is compatible with Matlab and Octave. It can be used in several different ways. See the Detailed Description in the Argument Parser module.

Definition at line 105 of file parser.h.


Constructor & Destructor Documentation

itpp::Parser::Parser (  ) 

Default Constructor.

Definition at line 44 of file parser.cpp.

itpp::Parser::Parser ( const std::string &  filename  ) 

Constructor. Sets input file name.

Definition at line 49 of file parser.cpp.

References init().

itpp::Parser::Parser ( int  argc,
char *  argv[] 
)

Constructor. Uses argc and argv (command line arguments).

Definition at line 55 of file parser.cpp.

References init().

itpp::Parser::Parser ( const std::string &  filename,
int  argc,
char *  argv[] 
)

Constructor. Sets input file name and uses argc and argv (command line arguments).

Definition at line 61 of file parser.cpp.

References init().

itpp::Parser::Parser ( const Array< std::string > &  setup  ) 

Constructor. Sets and Array of strings.

Definition at line 67 of file parser.cpp.

References init().


Member Function Documentation

void itpp::Parser::init ( const std::string &  filename  ) 

Initialization function. Sets input file name.

Definition at line 253 of file parser.cpp.

References it_assert, itpp::Array< T >::set_size(), and itpp::Array< T >::size().

Referenced by Parser().

void itpp::Parser::init ( int  argc,
char *  argv[] 
)

Initialization function. Uses argc and argv (command line arguments).

Definition at line 270 of file parser.cpp.

References itpp::Array< T >::set_size().

void itpp::Parser::init ( const std::string &  filename,
int  argc,
char *  argv[] 
)

Initialization function. Sets input file name and uses argc and argv (command line arguments).

Definition at line 281 of file parser.cpp.

References it_assert, itpp::Array< T >::set_size(), and itpp::Array< T >::size().

void itpp::Parser::init ( const Array< std::string > &  setup  ) 

Initialization function. Sets and Array of strings.

Definition at line 305 of file parser.cpp.

void itpp::Parser::set_silentmode ( bool  v = true  ) 

Sets silent mode if true, or verbose mode if false.

Definition at line 311 of file parser.cpp.

bool itpp::Parser::exist ( const std::string &  name  ) 

Check is name exists in the file. Returns true if the name is found and false otherwise.

Definition at line 316 of file parser.cpp.

template<class T>
bool itpp::Parser::get ( T &  var,
const std::string &  name,
int  num = -1 
)

Get variable value if name can be found (and return true), otherwise keep old value (and return false).

Definition at line 202 of file parser.h.

bool itpp::Parser::get_bool ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a bool.

Definition at line 347 of file parser.cpp.

References it_error.

int itpp::Parser::get_int ( const std::string &  name,
int  num = -1 
)

Interpret variable name as an integer.

Definition at line 357 of file parser.cpp.

References it_error.

double itpp::Parser::get_double ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a double.

Definition at line 367 of file parser.cpp.

References it_error.

std::string itpp::Parser::get_string ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a string.

Definition at line 377 of file parser.cpp.

References it_error.

vec itpp::Parser::get_vec ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a vec.

Definition at line 387 of file parser.cpp.

References it_error.

ivec itpp::Parser::get_ivec ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a ivec.

Definition at line 397 of file parser.cpp.

References it_error.

svec itpp::Parser::get_svec ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a svec.

Definition at line 407 of file parser.cpp.

References it_error.

bvec itpp::Parser::get_bvec ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a bvec.

Definition at line 417 of file parser.cpp.

References it_error.

mat itpp::Parser::get_mat ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a mat.

Definition at line 427 of file parser.cpp.

References it_error.

imat itpp::Parser::get_imat ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a imat.

Definition at line 437 of file parser.cpp.

References it_error.

smat itpp::Parser::get_smat ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a smat.

Definition at line 447 of file parser.cpp.

References it_error.

bmat itpp::Parser::get_bmat ( const std::string &  name,
int  num = -1 
)

Interpret variable name as a bmat.

Definition at line 457 of file parser.cpp.

References it_error.


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

Generated on Thu Apr 19 14:18:38 2007 for IT++ by Doxygen 1.5.1