MRPT logo

mrpt::utils::CConfigFileBase Class Reference

This class allows loading and storing values and vectors of different types from a configuration text, which can be implemented as a ".ini" file, a memory-stored string, etc. More...

#include <mrpt/utils/CConfigFileBase.h>

Inheritance diagram for mrpt::utils::CConfigFileBase:

mrpt::utils::CConfigFile mrpt::utils::CConfigFileMemory

List of all members.

Public Member Functions

virtual ~CConfigFileBase ()
 Virtual destructor.
virtual void getAllSections (vector_string &sections) const =0
 Returns a list with all the section names.
bool sectionExists (const std::string &section_name) const
 Checks if a given section exists (name is case insensitive).
void write (const std::string &section, const std::string &name, double value)
 Save a configuration parameter of type "double".
void write (const std::string &section, const std::string &name, float value)
 Save a configuration parameter of type "float".
void write (const std::string &section, const std::string &name, int value)
 Save a configuration parameter of type "int".
void write (const std::string &section, const std::string &name, const std::string &value)
 Save a configuration parameter of type "string".
void write (const std::string &section, const std::string &name, const std::vector< int > &value)
 Save a configuration parameter of type "std::vector<int>".
void write (const std::string &section, const std::string &name, const std::vector< unsigned int > &value)
 Save a configuration parameter of type "std::vector<unsigned int>".
void write (const std::string &section, const std::string &name, const std::vector< float > &value)
 Save a configuration parameter of type "std::vector<float>".
void write (const std::string &section, const std::string &name, const std::vector< double > &value)
 Save a configuration parameter of type "std::vector<double>".
void write (const std::string &section, const std::string &name, const std::vector< bool > &value)
 Save a configuration parameter of type "std::vector<bool>".
double read_double (const std::string &section, const std::string &name, double defaultValue, bool failIfNotFound=false) const
 Reads a configuration parameter of type "double"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

float read_float (const std::string &section, const std::string &name, float defaultValue, bool failIfNotFound=false) const
 Reads a configuration parameter of type "float"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

bool read_bool (const std::string &section, const std::string &name, bool defaultValue, bool failIfNotFound=false) const
 Reads a configuration parameter of type "bool", codified as "1"/"0" for true/false, repectively.
int read_int (const std::string &section, const std::string &name, int defaultValue, bool failIfNotFound=false) const
 Reads a configuration parameter of type "int"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

uint64_t read_uint64_t (const std::string &section, const std::string &name, uint64_t defaultValue, bool failIfNotFound) const
 Reads a configuration parameter of type "uint64_t": As in all other methods, the numeric value can be in decimal or hexadecimal with the prefix "0x"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

std::string read_string (const std::string &section, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
 Reads a configuration parameter of type "string"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

std::string read_string_first_word (const std::string &section, const std::string &name, const std::string &defaultValue, bool failIfNotFound=false) const
 Reads a configuration parameter of type "string", and keeps only the first word (this can be used to eliminate possible comments at the end of the line)
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

void read_vector (const std::string &section, const std::string &name, const std::vector< uint32_t > &defaultValue, std::vector< uint32_t > &outValues, bool failIfNotFound=false) const
 Reads a configuration parameter of type "std::vector<unsigned int>"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

void read_vector (const std::string &section, const std::string &name, const std::vector< int32_t > &defaultValue, std::vector< int32_t > &outValues, bool failIfNotFound=false) const
 Reads a configuration parameter of type "std::vector<int>"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

void read_vector (const std::string &section, const std::string &name, const std::vector< uint64_t > &defaultValue, std::vector< uint64_t > &outValues, bool failIfNotFound=false) const
 Reads a configuration parameter of type "std::vector<unsigned int>"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

void read_vector (const std::string &section, const std::string &name, const std::vector< int64_t > &defaultValue, std::vector< int64_t > &outValues, bool failIfNotFound=false) const
 Reads a configuration parameter of type "std::vector<int>"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

void read_vector (const std::string &section, const std::string &name, const std::vector< float > &defaultValue, std::vector< float > &outValues, bool failIfNotFound=false) const
 Reads a configuration parameter of type "std::vector<float>"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

void read_vector (const std::string &section, const std::string &name, const std::vector< double > &defaultValue, std::vector< double > &outValues, bool failIfNotFound=false) const
 Reads a configuration parameter of type "std::vector<double>"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

void read_vector (const std::string &section, const std::string &name, const std::vector< bool > &defaultValue, std::vector< bool > &outValues, bool failIfNotFound=false) const
 Reads a configuration parameter of type "std::vector<bool>"
Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.


Protected Member Functions

virtual void writeString (const std::string &section, const std::string &name, const std::string &str)=0
 A virtual method to write a generic string.
virtual std::string readString (const std::string &section, const std::string &name, const std::string &defaultStr, bool failIfNotFound=false) const =0
 A virtual method to read a generic string.


Detailed Description

This class allows loading and storing values and vectors of different types from a configuration text, which can be implemented as a ".ini" file, a memory-stored string, etc.

.. This is a virtual class, use only as a pointer to an implementation of one of the derived classes.

Definition at line 43 of file CConfigFileBase.h.


Constructor & Destructor Documentation

virtual mrpt::utils::CConfigFileBase::~CConfigFileBase (  )  [inline, virtual]

Virtual destructor.

..

Definition at line 62 of file CConfigFileBase.h.


Member Function Documentation

virtual void mrpt::utils::CConfigFileBase::getAllSections ( vector_string sections  )  const [pure virtual]

Returns a list with all the section names.

Implemented in mrpt::utils::CConfigFile, and mrpt::utils::CConfigFileMemory.

bool mrpt::utils::CConfigFileBase::read_bool ( const std::string &  section,
const std::string &  name,
bool  defaultValue,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "bool", codified as "1"/"0" for true/false, repectively.

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true. Otherwise the "defaultValue" is returned.

double mrpt::utils::CConfigFileBase::read_double ( const std::string &  section,
const std::string &  name,
double  defaultValue,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "double"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

float mrpt::utils::CConfigFileBase::read_float ( const std::string &  section,
const std::string &  name,
float  defaultValue,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "float"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

int mrpt::utils::CConfigFileBase::read_int ( const std::string &  section,
const std::string &  name,
int  defaultValue,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "int"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

std::string mrpt::utils::CConfigFileBase::read_string ( const std::string &  section,
const std::string &  name,
const std::string &  defaultValue,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "string"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

std::string mrpt::utils::CConfigFileBase::read_string_first_word ( const std::string &  section,
const std::string &  name,
const std::string &  defaultValue,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "string", and keeps only the first word (this can be used to eliminate possible comments at the end of the line)

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

uint64_t mrpt::utils::CConfigFileBase::read_uint64_t ( const std::string &  section,
const std::string &  name,
uint64_t  defaultValue,
bool  failIfNotFound 
) const

Reads a configuration parameter of type "uint64_t": As in all other methods, the numeric value can be in decimal or hexadecimal with the prefix "0x"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

void mrpt::utils::CConfigFileBase::read_vector ( const std::string &  section,
const std::string &  name,
const std::vector< bool > &  defaultValue,
std::vector< bool > &  outValues,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "std::vector<bool>"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

void mrpt::utils::CConfigFileBase::read_vector ( const std::string &  section,
const std::string &  name,
const std::vector< double > &  defaultValue,
std::vector< double > &  outValues,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "std::vector<double>"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

void mrpt::utils::CConfigFileBase::read_vector ( const std::string &  section,
const std::string &  name,
const std::vector< float > &  defaultValue,
std::vector< float > &  outValues,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "std::vector<float>"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

void mrpt::utils::CConfigFileBase::read_vector ( const std::string &  section,
const std::string &  name,
const std::vector< int64_t > &  defaultValue,
std::vector< int64_t > &  outValues,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "std::vector<int>"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

void mrpt::utils::CConfigFileBase::read_vector ( const std::string &  section,
const std::string &  name,
const std::vector< uint64_t > &  defaultValue,
std::vector< uint64_t > &  outValues,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "std::vector<unsigned int>"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

void mrpt::utils::CConfigFileBase::read_vector ( const std::string &  section,
const std::string &  name,
const std::vector< int32_t > &  defaultValue,
std::vector< int32_t > &  outValues,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "std::vector<int>"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

void mrpt::utils::CConfigFileBase::read_vector ( const std::string &  section,
const std::string &  name,
const std::vector< uint32_t > &  defaultValue,
std::vector< uint32_t > &  outValues,
bool  failIfNotFound = false 
) const

Reads a configuration parameter of type "std::vector<unsigned int>"

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true.

Otherwise the "defaultValue" is returned.

virtual std::string mrpt::utils::CConfigFileBase::readString ( const std::string &  section,
const std::string &  name,
const std::string &  defaultStr,
bool  failIfNotFound = false 
) const [protected, pure virtual]

A virtual method to read a generic string.

Exceptions:
std::exception If the key name is not found and "failIfNotFound" is true. Otherwise the "defaultValue" is returned.

Implemented in mrpt::utils::CConfigFile, and mrpt::utils::CConfigFileMemory.

bool mrpt::utils::CConfigFileBase::sectionExists ( const std::string &  section_name  )  const

Checks if a given section exists (name is case insensitive).

void mrpt::utils::CConfigFileBase::write ( const std::string &  section,
const std::string &  name,
const std::vector< bool > &  value 
)

Save a configuration parameter of type "std::vector<bool>".

void mrpt::utils::CConfigFileBase::write ( const std::string &  section,
const std::string &  name,
const std::vector< double > &  value 
)

Save a configuration parameter of type "std::vector<double>".

void mrpt::utils::CConfigFileBase::write ( const std::string &  section,
const std::string &  name,
const std::vector< float > &  value 
)

Save a configuration parameter of type "std::vector<float>".

void mrpt::utils::CConfigFileBase::write ( const std::string &  section,
const std::string &  name,
const std::vector< unsigned int > &  value 
)

Save a configuration parameter of type "std::vector<unsigned int>".

void mrpt::utils::CConfigFileBase::write ( const std::string &  section,
const std::string &  name,
const std::vector< int > &  value 
)

Save a configuration parameter of type "std::vector<int>".

void mrpt::utils::CConfigFileBase::write ( const std::string &  section,
const std::string &  name,
const std::string &  value 
)

Save a configuration parameter of type "string".

void mrpt::utils::CConfigFileBase::write ( const std::string &  section,
const std::string &  name,
int  value 
)

Save a configuration parameter of type "int".

void mrpt::utils::CConfigFileBase::write ( const std::string &  section,
const std::string &  name,
float  value 
)

Save a configuration parameter of type "float".

void mrpt::utils::CConfigFileBase::write ( const std::string &  section,
const std::string &  name,
double  value 
)

Save a configuration parameter of type "double".

virtual void mrpt::utils::CConfigFileBase::writeString ( const std::string &  section,
const std::string &  name,
const std::string &  str 
) [protected, pure virtual]

A virtual method to write a generic string.

Implemented in mrpt::utils::CConfigFile, and mrpt::utils::CConfigFileMemory.




Page generated by Doxygen 1.5.8 for MRPT 0.6.5 SVN:exported at Mon Jan 12 13:00:16 UTC 2009