#include <OBTAbstractConfigurationFileParser.h>
Public Member Functions | |
virtual | ~AbstractConfigurationFileParser () |
Protected Member Functions | |
AbstractConfigurationFileParser (const char *fileName, ConfigurationItem &configurationItem=touchRoot()) | |
const char * | getBuffer () const |
unsigned long | getBufferSize () const |
Static Protected Member Functions | |
static ConfigurationItem & | touchChild (ConfigurationItem &configurationItem, unsigned int childNumber) |
static ConfigurationItem & | touchRoot () |
Private Member Functions | |
AbstractConfigurationFileParser (const AbstractConfigurationFileParser &fileParser) | |
const AbstractConfigurationFileParser & | operator= (const AbstractConfigurationFileParser &fileParser) |
Private Attributes | |
std::string | _buffer |
file buffer | |
ConfigurationItem & | _configurationItem |
subroot of the configurationParameters tree to populate |
This class groups together common functionnalities for configuration file parsers, i.e. being able to use a file in order to fill a ConfigurationItems tree. This reduces the dependencies between an application and the configuration file format; currently, the only supported file format by OBT is XML, as handled by the XMLConfigurationFileParser. However, if another file format was to be chosen, we would only have to define a new class for this format.
Definition at line 23 of file OBTAbstractConfigurationFileParser.h.
AbstractConfigurationFileParser::~AbstractConfigurationFileParser | ( | ) | [virtual] |
AbstractConfigurationFileParser::AbstractConfigurationFileParser | ( | const char * | fileName, | |
ConfigurationItem & | configurationItem = touchRoot() | |||
) | [protected] |
constructor
Definition at line 12 of file OBTAbstractConfigurationFileParser.cpp.
References _buffer, and TRACE_ERROR.
00013 : 00014 _configurationItem( configurationItem ), 00015 _buffer() 00016 { 00017 if ( ( fileName == NULL ) || ( strlen( fileName ) == 0 ) ) 00018 { 00019 TRACE_ERROR( "filename missing" ) ; 00020 } 00021 else 00022 { 00023 std::ifstream file( fileName ) ; 00024 if ( file.is_open() ) 00025 { 00026 getline( file, _buffer, static_cast<char>( file.eof() ) ) ; 00027 file.close() ; 00028 } 00029 else 00030 { 00031 TRACE_ERROR( "Could not open file " << fileName ) ; 00032 } 00033 } 00034 }
OBT::AbstractConfigurationFileParser::AbstractConfigurationFileParser | ( | const AbstractConfigurationFileParser & | fileParser | ) | [private] |
copy constructor
const char * OBT::AbstractConfigurationFileParser::getBuffer | ( | ) | const [inline, protected] |
Get accessor to the file buffer
Definition at line 88 of file OBTAbstractConfigurationFileParser.h.
References _buffer.
00089 { 00090 return _buffer.c_str() ; 00091 }
unsigned long OBT::AbstractConfigurationFileParser::getBufferSize | ( | ) | const [inline, protected] |
Get accessor to the file buffer size
Definition at line 97 of file OBTAbstractConfigurationFileParser.h.
References _buffer.
00098 { 00099 return static_cast<unsigned long>( _buffer.length() ) ; 00100 }
ConfigurationItem & AbstractConfigurationFileParser::touchChild | ( | ConfigurationItem & | configurationItem, | |
unsigned int | childNumber | |||
) | [static, protected] |
allows the descendants of AbstractConfigurationFileParser to access the protected getChild method of ConfigurationItem
configurationItem | parent | |
childNumber | number of the child to return |
Definition at line 47 of file OBTAbstractConfigurationFileParser.cpp.
References OBT::ConfigurationItem::touchChild().
00048 { 00049 return configurationItem.touchChild( childNumber ) ; 00050 }
ConfigurationItem & AbstractConfigurationFileParser::touchRoot | ( | ) | [static, protected] |
allows the descendants of AbstractConfigurationFileParser to access the protected touchRoot method of ConfigurationParameters
Definition at line 56 of file OBTAbstractConfigurationFileParser.cpp.
00057 { 00058 return Singleton< ConfigurationTree >::getInstance().touchRoot() ; 00059 }
const AbstractConfigurationFileParser& OBT::AbstractConfigurationFileParser::operator= | ( | const AbstractConfigurationFileParser & | fileParser | ) | [private] |
assignment operator
std::string OBT::AbstractConfigurationFileParser::_buffer [private] |
file buffer
Definition at line 78 of file OBTAbstractConfigurationFileParser.h.
Referenced by AbstractConfigurationFileParser(), getBuffer(), and getBufferSize().
subroot of the configurationParameters tree to populate
Definition at line 81 of file OBTAbstractConfigurationFileParser.h.