forked from arnaudmorin/libgtop11dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Configuration.hpp
75 lines (42 loc) · 1.8 KB
/
Configuration.hpp
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
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef __CONFIGURATION_H__
#define __CONFIGURATION_H__
#include <map>
#include <string>
//namespace Gemalto
//{
// A entry is a map of {key,value} pair
typedef std::pair<std::string, std::string> TEntryPair;
// A section is a map of {key,value} pairs (an entry)
typedef std::map<std::string, std::string> TSection;
typedef TSection::iterator TSectionIterator;
// A Configuration is a map of sections
typedef std::map<std::string, TSection> TConfiguration;
typedef TConfiguration::iterator TConfigurationIterator;
typedef std::pair<std::string, TSection> TConfigurationPair;
/*
*/
class Configuration
{
public:
Configuration( ); // Constructor is hidden
void load( const std::string& szConfigurationFileName );
void getValue( const std::string& sectionName, const std::string& parameterName, std::string &result );
void getConfigurationFilePath( std::string &result );
bool checkSection( const std::string& sectionName );
void print( );
private:
std::string m_szConfigurationfilePath;
TConfiguration m_configuration;
void strip( const std::string& str, std::string &result, const std::string& what = " \t\0\n" );
bool parse( const std::string& configurationFileName );
std::string::size_type findComment( const std::string& str );
bool findTag( std::string::size_type& start, std::string::size_type& end, const std::string& str );
bool isSection( const std::string& str );
bool isKey( const std::string& str );
void getKeyName( const std::string& str, std::string &result );
void getKeyValue( const std::string& str, std::string &result );
void getSectionName( const std::string& str, std::string &result );
void suppressAllOccurencesOfThisCharacter( const std::string& s, char c, std::string& result );
};
//} //namespace
#endif // __CONFIGURATION_H__