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. */
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 /** Gets a configuration option by name. */
56 const Option &get_option(const std::string &) const;
58 const OptionMap &get_options() const { return options; }
59 const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
61 /** Checks whether an option exists. */
62 bool is_option(const std::string &) const;
64 /** Processes options from the given raw option map. Nonexistent options
65 are ignored. If any options were changed, the mtime of the configuration is
66 updated to the current time. Return value indicates whether any options
68 bool update(const StringMap &);
70 /** Expands any variable references in options. */
74 bool set_option(const std::string &, const std::string &);