/[projects]/smsdaemon/ConfigFile.h
ViewVC logotype

Contents of /smsdaemon/ConfigFile.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 146 - (show annotations) (download)
Sun Dec 7 20:06:12 2008 UTC (15 years, 5 months ago) by torben
File MIME type: text/plain
File size: 1111 byte(s)
Added configuration module

1 #ifndef __CONFIG_FILE_H__
2 #define __CONFIG_FILE_H__
3
4 /* Usage
5 * ConfigFile cf("config.txt");
6 *
7 * std::string foo;
8 * std::string water;
9 * double four;
10 *
11 * foo = cf.Value("section_1","foo" );
12 * water = cf.Value("section_2","water");
13 * four = cf.Value("section_2","four" );
14 *
15 * std::cout << foo << std::endl;
16 * std::cout << water << std::endl;
17 * std::cout << four << std::endl;
18 *
19 * From a config file like this:
20 *
21 * [section_1]
22 * foo = bar
23 * water= h2o
24 *
25 * [section_2]
26 * foo = foo
27 * water= wet
28 * four = 4.2
29 */
30
31
32
33
34 #include <string>
35 #include <map>
36 #include "Value.h"
37
38 class ConfigFile
39 {
40 //std::map<std::string,Chameleon> content_;
41 std::map<std::string,Value> content_;
42
43 public:
44 ConfigFile();
45 ConfigFile(std::string const& configFile);
46 bool Open(std::string const& configFile);
47
48 Value const& GetValue(std::string const& section, std::string const& entry) const;
49
50 Value const& GetValue(std::string const& section, std::string const& entry, double value);
51 Value const& GetValue(std::string const& section, std::string const& entry, std::string const& value);
52 };
53
54 #endif

  ViewVC Help
Powered by ViewVC 1.1.20