6 #include <msp/datafile/loader.h>
7 #include <msp/fs/path.h>
8 #include <msp/time/timestamp.h>
13 Manages configuration for a package. A configuration may have an arbitary
14 amount of options, as well as a modification time (mtime).
19 /** A single configuration option. */
23 std::string default_value;
24 std::string description;
27 Option(const std::string &, const std::string &, const std::string &);
30 typedef std::map<std::string, Option> OptionMap;
31 typedef std::map<std::string, std::string> InputOptions;
34 class Loader: public Msp::DataFile::ObjectLoader<Config>
39 void option(const std::string &, const std::string &);
42 SourcePackage &package;
44 InputOptions pending_options;
45 Msp::Time::TimeStamp mtime;
49 Config(SourcePackage &);
51 /** Adds a configuration option with name, default value and description. */
52 void add_option(const std::string &, const std::string &, const std::string &);
54 bool set_option(const std::string &, const std::string &);
56 /** Checks whether an option exists. */
57 bool is_option(const std::string &) const;
59 /** Gets a configuration option by name. */
60 const Option &get_option(const std::string &) const;
62 const OptionMap &get_options() const { return options; }
63 const Msp::Time::TimeStamp &get_mtime() const { return mtime; }