6 #include <msp/datafile/loader.h>
7 #include <msp/fs/path.h>
8 #include <msp/time/timestamp.h>
10 #include "libbuilder_api.h"
15 Manages configuration for a package. A configuration may have an arbitary
16 amount of options, as well as a modification time (mtime).
18 class LIBBUILDER_API Config
21 /** A single configuration option. */
22 struct LIBBUILDER_API Option: public Feature
26 Option(const Feature &);
29 using InputOptions = std::map<std::string, std::string>;
32 class Loader: public Msp::DataFile::ObjectLoader<Config>
37 void option(const std::string &, const std::string &);
40 SourcePackage &package;
41 std::map<std::string, Option> options;
42 InputOptions pending_options;
43 Msp::Time::TimeStamp mtime;
44 mutable bool changed = false;
47 Config(SourcePackage &p): package(p) { }
49 /** Adds a configuration option based on a feature. */
50 const Option &add_option(const Feature &);
52 bool set_option(const std::string &, const std::string &);
54 /** Checks whether an option exists. */
55 bool is_option(const std::string &) const;
57 /** Gets a configuration option by name. */
58 const Option &get_option(const std::string &) const;
60 const std::map<std::string, Option> &get_options() const { return options; }
61 const Msp::Time::TimeStamp &get_mtime() const { return mtime; }