]> git.tdb.fi Git - builder.git/blob - source/config.h
Package configuration is cached
[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 Msp::Time::TimeStamp &get_mtime() const { return mtime; }
30         bool is_option(const std::string &) const;
31         bool process(const RawOptionMap &);
32         void load(const Msp::Path::Path &); 
33         void save(const Msp::Path::Path &) const;
34 private:
35         class Loader: public Msp::Parser::Loader
36         {
37         public:
38                 Loader(Config &);
39         private:
40                 Config &conf;
41                 
42                 void option(const std::string &, const std::string &);
43         };
44         
45         OptionMap options;
46         Msp::Time::TimeStamp mtime;
47 };
48
49 #endif