From f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Apr 2007 03:49:53 +0000 Subject: Ok, no code is left in src, it's all in src/old. We'll gradually move code back into src as it's fixed and re-org'd. This includes tests, which, I may write a unit test system into libbu++ just to make my life easier. --- src/old/configmanagerbase.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/old/configmanagerbase.cpp (limited to 'src/old/configmanagerbase.cpp') diff --git a/src/old/configmanagerbase.cpp b/src/old/configmanagerbase.cpp new file mode 100644 index 0000000..ac55fe0 --- /dev/null +++ b/src/old/configmanagerbase.cpp @@ -0,0 +1,63 @@ +#include +#include +#include "xmlnode.h" +#include "xmlfilereader.h" +#include "configmanagerbase.h" + +ConfigManagerBase::ConfigManagerBase() +{ +} + +ConfigManagerBase::~ConfigManagerBase() +{ +} + +void ConfigManagerBase::addSearchPath( const std::string &sPath ) +{ + lSearchPath.push_back( sPath ); +} + +void ConfigManagerBase::loadConfig( const std::string &sFileName, const char *lpProfile ) +{ + // Try a few locations... + std::list::const_iterator i; + for( i = lSearchPath.begin(); i != lSearchPath.end(); i++ ) + { + if( parseConfig( (*i + sFileName).c_str(), lpProfile ) ) + { + break; + } + } +} + +bool ConfigManagerBase::parseConfig( const char *lpFileName, const char *lpProfile ) +{ + XmlNode *pRoot, *pCur; + XmlFileReader doc( lpFileName ); + + pRoot = doc.getRoot(); + if( pRoot == NULL ) + { + return false; + } + + if( strcmp("config", pRoot->getName() ) ) + { + return false; + } + + for( int j = 0;; j++ ) + { + pCur = pRoot->getChild( "profile", j ); + if( pCur == NULL ) + return false; + + if( !strcmp( pCur->getProperty("id"), lpProfile ) ) + { + return processProfile( pCur ); + } + } + + return false; +} + -- cgit v1.2.3