OBTAbstractConfigurationFileParser.cpp

Go to the documentation of this file.
00001 #include "OBTAbstractConfigurationFileParser.h"
00002 #include "OBTConfigurationTree.h"
00003 
00004 #include <cstring>
00005 #include <fstream>
00006 
00007 using namespace OBT ;
00008 
00009 //-------------------------------------------------------------------------
00010 // AbstractConfigurationFileParser()
00011 //-------------------------------------------------------------------------
00012 AbstractConfigurationFileParser::AbstractConfigurationFileParser( const char* fileName, ConfigurationItem& configurationItem )
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 }
00035 
00036 //-------------------------------------------------------------------------
00037 // ~AbstractConfigurationFileParser()
00038 //-------------------------------------------------------------------------
00039 AbstractConfigurationFileParser::~AbstractConfigurationFileParser()
00040 {
00041 }
00042 
00043 //-------------------------------------------------------------------------
00044 // touchChild()
00045 //-------------------------------------------------------------------------
00046 ConfigurationItem& 
00047 AbstractConfigurationFileParser::touchChild( ConfigurationItem& configurationItem, unsigned int childNumber )
00048 {
00049         return configurationItem.touchChild( childNumber ) ;
00050 }
00051 
00052 //-------------------------------------------------------------------------
00053 // getRoot()
00054 //-------------------------------------------------------------------------
00055 ConfigurationItem& 
00056 AbstractConfigurationFileParser::touchRoot()
00057 {
00058         return Singleton< ConfigurationTree >::getInstance().touchRoot() ;
00059 }
00060 

Generated on Wed Oct 1 11:34:04 2008 for OBT by  doxygen 1.5.3