6 #include <msp/datafile/loader.h>
7 #include <msp/fs/path.h>
8 #include <msp/time/timestamp.h>
14 Manages configuration for a package. A configuration may have an arbitary
15 amount of options, as well as a modification time (mtime).
20 /** A single configuration option. */
24 std::string default_value;
25 std::string description;
28 Option(const std::string &, const std::string &, const std::string &);
31 typedef std::map<std::string, Option> OptionMap;
32 typedef std::map<std::string, std::string> InputOptions;
35 class Loader: public Msp::DataFile::ObjectLoader<Config>
40 void option(const std::string &, const std::string &);
43 SourcePackage &package;
45 InputOptions pending_options;
46 Msp::Time::TimeStamp mtime;
50 Config(SourcePackage &);
52 /** Adds a configuration option with name, default value and description. */
53 void add_option(const std::string &, const std::string &, const std::string &);
55 bool set_option(const std::string &, const std::string &);
57 /** Checks whether an option exists. */
58 bool is_option(const std::string &) const;
60 /** Gets a configuration option by name. */
61 const Option &get_option(const std::string &) const;
63 const OptionMap &get_options() const { return options; }
64 const Msp::Time::TimeStamp &get_mtime() const { return mtime; }