#include <map>
#include <string>
-#include "option.h"
+#include <msp/parser/loader.h>
+#include <msp/path/path.h>
+#include <msp/time/timestamp.h>
typedef std::map<std::string, std::string> RawOptionMap;
+/**
+Manages configuration for a package. A configuration may have an arbitary
+amount of options, as well as a modification time (mtime).
+*/
class Config
{
public:
+ /**
+ A single configuration option.
+ */
struct Option
{
std::string name;
void add_option(const std::string &, const std::string &, const std::string &);
const Option &get_option(const std::string &) const;
+ const OptionMap &get_options() const { return options; }
+ const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
bool is_option(const std::string &) const;
- bool process(const RawOptionMap &);
- void load(const std::string &);
+ void select_last_profile();
+ void select_profile(const std::string &);
+ bool update(const RawOptionMap &);
+ void set_source(const Msp::Path::Path &s) { source=s; }
+ void save() const;
private:
- OptionMap options;
+ class Loader: public Msp::Parser::Loader
+ {
+ public:
+ Loader(Config &);
+ private:
+ Config &conf;
+
+ void option(const std::string &, const std::string &);
+ };
+
+ Msp::Path::Path source;
+ OptionMap options;
+ Msp::Time::TimeStamp mtime;
+
+ bool set_option(const std::string &, const std::string &);
+ void load();
};
#endif