-
Notifications
You must be signed in to change notification settings - Fork 1
/
XMLConfigExample.cpp
45 lines (39 loc) · 1022 Bytes
/
XMLConfigExample.cpp
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
#include<iostream>
#include<string>
#include "XMLConfig.h"
using namespace std;
int main(int argc, char* argv[])
{
// Case 1 : A valid xml file.
XMLConfig configManager("test.xml", "ApplicationSettings", "root");
try
{
configManager.readConfigFile();
}
catch(const runtime_error& error)
{
std::cout << error.what() << std::endl;
}
std::map<std::string, std::string> mapItems = configManager.getConfigMap();
if(configManager.isConfigValid())
{
for(auto& iter : mapItems)
std::cout << iter.first << " , " << iter.second << std::endl;
}
std::cout << "size of the map = " << mapItems.size() << std::endl;
// Case 2 : An invalid case of a non existing file.
XMLConfig configManager2("tiko.xml", "ApplicationSettings", "root");
try
{
configManager2.readConfigFile();
}
catch(const runtime_error& error)
{
std::cout << error.what() << std::endl;
}
if(!configManager2.isConfigValid())
{
std::cout << "Invalid configuration file. Please investigate" << std::endl;
}
return(0);
}