cxcparamx-2.0  2.0.3
cxcparamx::simple Class Reference

#include <cxcparamx/simple.h>

Public Types

using pParamFileImpl = std::unique_ptr< ParamFileImpl, void(*)(ParamFileImpl *)>
 

Public Member Functions

 simple (int argc, char **argv, const string &mode="rw")
 Constructor with file name taken from argv[0]. More...
 
 simple (const string &filename, int argc, char **argv, const string &mode="rw")
 Constructor with explicit parameter file name. More...
 
void get (const string &name, float &value) const
 Retrieve a parameter value into a float. More...
 
void get (const string &name, double &value) const
 Retrieve a parameter value into a double. More...
 
void get (const string &name, short &value) const
 Retrieve a parameter value into a short. More...
 
void get (const string &name, int &value) const
 Retrieve a parameter value into an int. More...
 
void get (const string &name, long &value) const
 Retrieve a parameter value into a long. More...
 
void get (const string &name, bool &value) const
 Retrieve a parameter value into an bool. More...
 
void get (const string &name, string &value) const
 Retrieve a parameter value into an string. More...
 
float getf (const string &name) const
 Return a parameter value as a float. More...
 
double getd (const string &name) const
 Return a parameter value as a double. More...
 
short gets (const string &name) const
 Return a parameter value as a short. More...
 
int geti (const string &name) const
 Return a parameter value as an int. More...
 
long getl (const string &name) const
 Return a parameter value as a long. More...
 
bool getb (const string &name) const
 Return a parameter value as an bool. More...
 
string getstr (const string &name) const
 Return a parameter value as an string. More...
 
bool access (const string &name) const
 

Detailed Description

A simple wrapper class providing polymorphic attribute retrieval.

Instantiating the class opens the parameter file; the file is closed during object destruction.

Constructor & Destructor Documentation

◆ simple() [1/2]

cxcparamx::simple::simple ( int  argc,
char **  argv,
const string &  mode = "rw" 
)

Constructor with file name taken from argv[0].

Parameters
[in]argcthe number of elements in argv
[in]argvtypically, the command line arguments vector passed to main*
[in]modemode with which to open the file

◆ simple() [2/2]

cxcparamx::simple::simple ( const string &  in_filename,
int  argc,
char **  argv,
const string &  mode = "rw" 
)

Constructor with explicit parameter file name.

Parameters
[in]filenamethe parameter file name
[in]argcthe number of elements in argv
argvtypically, the command line arguments vector passed to main
[in]modemode with which to open the file

Member Function Documentation

◆ get() [1/7]

void cxcparamx::simple::get ( const string &  name,
float &  value 
) const

Retrieve a parameter value into a float.

Parameters
[in]nameparameter name
[out]valuereturned value
Exceptions
Exceptionif parameter is not found

◆ get() [2/7]

void cxcparamx::simple::get ( const string &  name,
double &  value 
) const

Retrieve a parameter value into a double.

Parameters
[in]nameparameter name
[out]valuereturned value
Exceptions
Exceptionif parameter is not found

◆ get() [3/7]

void cxcparamx::simple::get ( const string &  name,
short &  value 
) const

Retrieve a parameter value into a short.

Parameters
[in]nameparameter name
[out]valuereturned value
Exceptions
Exceptionif parameter is not found

◆ get() [4/7]

void cxcparamx::simple::get ( const string &  name,
int &  value 
) const

Retrieve a parameter value into an int.

Parameters
[in]nameparameter name
[out]valuereturned value
Exceptions
Exceptionif parameter is not found

◆ get() [5/7]

void cxcparamx::simple::get ( const string &  name,
long &  value 
) const

Retrieve a parameter value into a long.

Parameters
[in]nameparameter name
[out]valuereturned value
Exceptions
Exceptionif parameter is not found

◆ get() [6/7]

void cxcparamx::simple::get ( const string &  name,
bool &  value 
) const

Retrieve a parameter value into an bool.

Parameters
[in]nameparameter name
[out]valuereturned value
Exceptions
Exceptionif parameter is not found

◆ get() [7/7]

void cxcparamx::simple::get ( const string &  name,
string &  value 
) const

Retrieve a parameter value into an string.

Parameters
[in]nameparameter name
[out]valuereturned value
Exceptions
Exceptionif parameter is not found

◆ getb()

bool cxcparamx::simple::getb ( const string &  name) const

Return a parameter value as an bool.

Parameters
[in]nameparameter name
Exceptions
Exceptionif parameter is not found

◆ getd()

double cxcparamx::simple::getd ( const string &  name) const

Return a parameter value as a double.

Parameters
[in]nameparameter name
Exceptions
Exceptionif parameter is not found

◆ getf()

float cxcparamx::simple::getf ( const string &  name) const

Return a parameter value as a float.

Parameters
[in]nameparameter name
Exceptions
Exceptionif parameter is not found

◆ geti()

int cxcparamx::simple::geti ( const string &  name) const

Return a parameter value as an int.

Parameters
[in]nameparameter name
Exceptions
Exceptionif parameter is not found

◆ getl()

long cxcparamx::simple::getl ( const string &  name) const

Return a parameter value as a long.

Parameters
[in]nameparameter name
Exceptions
Exceptionif parameter is not found

◆ gets()

short cxcparamx::simple::gets ( const string &  name) const

Return a parameter value as a short.

Parameters
[in]nameparameter name
Exceptions
Exceptionif parameter is not found

◆ getstr()

string cxcparamx::simple::getstr ( const string &  name) const

Return a parameter value as an string.

Parameters
[in]nameparameter name
Exceptions
Exceptionif parameter is not found

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