]> git.tdb.fi Git - builder.git/blob - source/config.h
9747d99aae0ee339a1878a8be3e72c7d60489e09
[builder.git] / source / config.h
1 #ifndef CONFIG_H_
2 #define CONFIG_H_
3
4 #include <map>
5 #include <string>
6 #include <msp/parser/loader.h>
7 #include <msp/path/path.h>
8 #include <msp/time/timestamp.h>
9 #include "option.h"
10
11 typedef std::map<std::string, std::string> RawOptionMap;
12
13 class Config
14 {
15 public:
16         struct Option
17         {
18                 std::string name;
19                 std::string defv;
20                 std::string descr;
21                 std::string value;
22
23                 Option(const std::string &, const std::string &, const std::string &);
24         };
25         typedef std::map<std::string, Option> OptionMap;
26
27         void add_option(const std::string &, const std::string &, const std::string &);
28         const Option &get_option(const std::string &) const;
29         const OptionMap &get_options() const          { return options; }
30         const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
31         bool is_option(const std::string &) const;
32         bool process(const RawOptionMap &);
33         void load(const Msp::Path::Path &); 
34         void save(const Msp::Path::Path &) const;
35 private:
36         class Loader: public Msp::Parser::Loader
37         {
38         public:
39                 Loader(Config &);
40         private:
41                 Config &conf;
42                 
43                 void option(const std::string &, const std::string &);
44         };
45         
46         OptionMap options;
47         Msp::Time::TimeStamp mtime;
48 };
49
50 #endif