paramxx  1.0.7
ParFile Class Reference

#include <ParFile.h>

Public Member Functions

 ~ParFile ()
 
 ParFile ()
 
 ParFile (int argc, char **argv, const char *file=NULL) throw ( ParFileException, Exception )
 
string get_filename ()
 
void init_ParFile (int argc, char **argv, const char *file=NULL) throw ( ParFileException, Exception )
 
Parget_par (const char *name) const throw ( ParFileException )
 Get the pointer to the parameter. More...
 
void print (ostream &os) const
 
bool pgetb (const char *name) const throw ( ParFileException )
 
double pgetd (const char *name) const throw ( ParFileException )
 
int pgeti (const char *name) const throw ( ParFileException )
 
long pgetl (const char *name) const throw ( ParFileException )
 
void pgetstr (const char *name, char result[], size_t size) const throw ( ParFileException )
 
string pgetstring (const char *name) const throw ( ParFileException )
 
void pget (const char *name, bool &result) const throw ( ParFileException )
 Same functionality as ParFile::pgetb. More...
 
void pget (const char *name, double &result) const throw ( ParFileException )
 Same functionality as ParFile::pgetd. More...
 
void pget (const char *name, int &result) const throw ( ParFileException )
 Same functionality as ParFile::pgeti. More...
 
void pget (const char *name, long &result) const throw ( ParFileException )
 Same functionality as ParFile::pgetl. More...
 
void pget (const char *name, char result[], size_t) const throw ( ParFileException )
 Same functionality as ParFile::pgetstr. More...
 
void pget (const char *name, string &rult) const throw ( ParFileException )
 Same functionality as ParFile::pgetstring. More...
 
int traverse (int(*fct)(Par *)) const
 

Static Public Member Functions

static int is_blank (const char *str)
 
static int is_comment (const char *str, char delimit='#')
 

Friends

ostream & operator<< (ostream &os, ParFile &parFile)
 
ostream & operator<< (ostream &os, ParFile *parFile)
 

Detailed Description

To get the parameters in the parameter file.

Constructor & Destructor Documentation

◆ ~ParFile()

ParFile::~ParFile ( )

The destructor.

◆ ParFile() [1/2]

ParFile::ParFile ( )
inline

The default constructor.

◆ ParFile() [2/2]

ParFile::ParFile ( int  argc,
char **  argv,
const char *  file = NULL 
)
throw ( ParFileException,
Exception
)

The constructor to load the parameter file and parse the command line args. Calling this constructor is equivalent to call the default constructor then call the init_ParFile method.

Parameters
argcThe number of parameters from the command line.
argvThe command line arguments.
fileThe specific file to use.
Returns
void
Exceptions
ParFileException

Member Function Documentation

◆ get_filename()

string ParFile::get_filename ( )
inline

Get the parameter filename.

Returns
The name of the parameter file.

◆ get_par()

Par * ParFile::get_par ( const char *  name) const
throw (ParFileException
)

Get the pointer to the parameter.

◆ init_ParFile()

void ParFile::init_ParFile ( int  argc,
char **  argv,
const char *  file = NULL 
)
throw ( ParFileException,
Exception
)

Load the appropiate parameter file and parse the command line args.

Parameters
argcThe number of parameters from the command line.
argvThe command line arguments.
fileThe specific file to use.
Returns
void
Exceptions
ParFileException

References NameAttributeValue::get_name().

◆ is_comment()

int ParFile::is_comment ( const char *  str,
char  delimit = '#' 
)
static

if the first character is #, or the line is blank, then the line is a comment

◆ pget() [1/6]

void ParFile::pget ( const char *  name,
bool &  result 
) const
throw (ParFileException
)

Same functionality as ParFile::pgetb.

◆ pget() [2/6]

void ParFile::pget ( const char *  name,
double &  result 
) const
throw (ParFileException
)

Same functionality as ParFile::pgetd.

◆ pget() [3/6]

void ParFile::pget ( const char *  name,
int &  result 
) const
throw (ParFileException
)

Same functionality as ParFile::pgeti.

◆ pget() [4/6]

void ParFile::pget ( const char *  name,
long &  result 
) const
throw (ParFileException
)

Same functionality as ParFile::pgetl.

◆ pget() [5/6]

void ParFile::pget ( const char *  name,
char  result[],
size_t  size 
) const
throw (ParFileException
)

Same functionality as ParFile::pgetstr.

◆ pget() [6/6]

void ParFile::pget ( const char *  name,
string &  rult 
) const
throw (ParFileException
)

Same functionality as ParFile::pgetstring.

◆ pgetb()

bool ParFile::pgetb ( const char *  name) const
throw (ParFileException
)

To get a parameter of type boolean.

Parameters
nameThe name of the parameter to retrieve its value
Returns
The value of the parameter name.
Exceptions
ParFileException

References Par::pgetb().

◆ pgetd()

double ParFile::pgetd ( const char *  name) const
throw (ParFileException
)

To get a parameter of type double.

Parameters
nameThe name of the parameter to retrieve its value
Returns
The value of the parameter name.
Exceptions
ParFileException

References Par::pgetd().

◆ pgeti()

int ParFile::pgeti ( const char *  name) const
throw (ParFileException
)

To get a parameter of type long.

Parameters
nameThe name of the parameter to retrieve its value
Returns
The value of the parameter name.
Exceptions
ParFileException

References Par::pgeti().

◆ pgetl()

long ParFile::pgetl ( const char *  name) const
throw (ParFileException
)

To get a parameter of type long.

Parameters
nameThe name of the parameter to retrieve its value
Returns
The value of the parameter name.
Exceptions
ParFileException

References Par::pgetl().

◆ pgetstr()

void ParFile::pgetstr ( const char *  name,
char  result[],
size_t  size 
) const
throw (ParFileException
)

To get a parameter of type char[]. The length of the result in the following function must be at least size+1

Parameters
nameThe name of the parameter to retrieve its value
Returns
The value of the parameter name.
Exceptions
ParFileException

References Par::pgetstring().

◆ pgetstring()

string ParFile::pgetstring ( const char *  name) const
throw (ParFileException
)

To get a parameter of type string.

Parameters
nameThe name of the parameter to retrieve its value
Returns
The value of the parameter name.
Exceptions
ParFileException

References Par::get_mode(), NameAttributeValue::get_name(), NameAttributeValue::get_value(), and Par::pgetstring().

◆ print()

void ParFile::print ( ostream &  os) const

Loop over the parameters to call the print method for each parameter. The individual parameter will print its content in the form: name,type,mode,val,min,max,prompt

Parameters
osThe stream to print the content of the parameter file.

References NameAttributeValue::get_name(), Par::get_prompt(), NameAttributeValue::get_value(), and Par::PARTYPE.

◆ traverse()

int ParFile::traverse ( int(*)(Par *)  fct) const

Traverse the parameters list and invoke the function fct, if fct returns a non-zero the traversal is aborted and the fct return value is returned.

Friends And Related Function Documentation

◆ operator<< [1/2]

ostream& operator<< ( ostream &  os,
ParFile parFile 
)
friend

This operator outputs the contents of the object.

◆ operator<< [2/2]

ostream& operator<< ( ostream &  os,
ParFile parFile 
)
friend

This operator outputs the contents of the object.


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