aboutsummaryrefslogtreecommitdiff
path: root/src/old/configmanagerbase.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-04-03 03:49:53 +0000
committerMike Buland <eichlan@xagasoft.com>2007-04-03 03:49:53 +0000
commitf4c20290509d7ed3a8fd5304577e7a4cc0b9d974 (patch)
tree13cdf64f7cf134f397a7165b7a3fe0807e37026b /src/old/configmanagerbase.cpp
parent74d4c8cd27334fc7204d5a8773deb3d424565778 (diff)
downloadlibbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.gz
libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.bz2
libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.tar.xz
libbu++-f4c20290509d7ed3a8fd5304577e7a4cc0b9d974.zip
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.
Diffstat (limited to 'src/old/configmanagerbase.cpp')
-rw-r--r--src/old/configmanagerbase.cpp63
1 files changed, 63 insertions, 0 deletions
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 @@
1#include <stdlib.h>
2#include <string.h>
3#include "xmlnode.h"
4#include "xmlfilereader.h"
5#include "configmanagerbase.h"
6
7ConfigManagerBase::ConfigManagerBase()
8{
9}
10
11ConfigManagerBase::~ConfigManagerBase()
12{
13}
14
15void ConfigManagerBase::addSearchPath( const std::string &sPath )
16{
17 lSearchPath.push_back( sPath );
18}
19
20void ConfigManagerBase::loadConfig( const std::string &sFileName, const char *lpProfile )
21{
22 // Try a few locations...
23 std::list<std::string>::const_iterator i;
24 for( i = lSearchPath.begin(); i != lSearchPath.end(); i++ )
25 {
26 if( parseConfig( (*i + sFileName).c_str(), lpProfile ) )
27 {
28 break;
29 }
30 }
31}
32
33bool ConfigManagerBase::parseConfig( const char *lpFileName, const char *lpProfile )
34{
35 XmlNode *pRoot, *pCur;
36 XmlFileReader doc( lpFileName );
37
38 pRoot = doc.getRoot();
39 if( pRoot == NULL )
40 {
41 return false;
42 }
43
44 if( strcmp("config", pRoot->getName() ) )
45 {
46 return false;
47 }
48
49 for( int j = 0;; j++ )
50 {
51 pCur = pRoot->getChild( "profile", j );
52 if( pCur == NULL )
53 return false;
54
55 if( !strcmp( pCur->getProperty("id"), lpProfile ) )
56 {
57 return processProfile( pCur );
58 }
59 }
60
61 return false;
62}
63