blob: 4b94cc6b29f9806e9fe5686a4e1b78a4ab4152e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#include <stdlib.h>
#include <string.h>
#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 char *lpProfile )
{
// Try a few locations...
std::list<std::string>::const_iterator i;
for( i = lSearchPath.begin(); i != lSearchPath.end(); i++ )
{
if( parseConfig( (*i).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;
}
|