00001 #include "OBTXMLConfigurationFileParser.h" 00002 #include "OBTConfigurationItem.h" 00003 #include "OBTtinyxml.h" 00004 00005 using namespace OBT ; 00006 00007 //------------------------------------------------------------------------- 00008 // XMLConfigurationFileParser() 00009 //------------------------------------------------------------------------- 00010 XMLConfigurationFileParser::XMLConfigurationFileParser( const char* name, ConfigurationItem& configurationItem ) 00011 : 00012 AbstractConfigurationFileParser( name, configurationItem ) 00013 { 00014 TiXmlDocument document ; 00015 if ( document.LoadFile( name ) ) 00016 { 00017 AddChildren( configurationItem, document.RootElement() ) ; 00018 } 00019 } 00020 00021 //------------------------------------------------------------------------- 00022 // ~XMLConfigurationFileParser() 00023 //------------------------------------------------------------------------- 00024 XMLConfigurationFileParser::~XMLConfigurationFileParser() 00025 { 00026 } 00027 00028 //------------------------------------------------------------------------- 00029 // AddChildren 00030 //------------------------------------------------------------------------- 00031 void 00032 XMLConfigurationFileParser::AddChildren( ConfigurationItem& root, TiXmlElement* element ) 00033 { 00034 while ( element != NULL ) 00035 { 00036 ConfigurationItem item( element->Value() ) ; 00037 item.setLine( element->Row() ) ; 00038 item.setColumn( element->Column() ) ; 00039 item.setText( element->GetText() ) ; 00040 00041 TiXmlAttribute* attribute( element->FirstAttribute() ) ; 00042 while ( attribute != NULL ) 00043 { 00044 item.addArgument( attribute->Name(), attribute->Value() ) ; 00045 attribute = attribute->Next() ; 00046 } 00047 00048 AddChildren( item, element->FirstChildElement() ) ; 00049 root.addChild( item ) ; 00050 element = element->NextSiblingElement() ; 00051 } 00052 } 00053