-/* $Id$
-
-This file is part of builder
-Copyright © 2006-2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#ifndef CONFIG_H_
#define CONFIG_H_
class Config
{
public:
- /**
- A single configuration option.
- */
+ /** A single configuration option. */
struct Option
{
std::string name;
Option(const std::string &, const std::string &, const std::string &);
};
+
typedef std::map<std::string, Option> OptionMap;
+ typedef std::map<std::string, std::string> InputOptions;
- Config(SourcePackage &);
- 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;
- void select_last_profile();
- void select_profile(const std::string &);
- bool update(const StringMap &);
- void finish();
- void save() const;
private:
- class Loader: public Msp::DataFile::Loader
+ class Loader: public Msp::DataFile::ObjectLoader<Config>
{
public:
Loader(Config &);
private:
- Config &conf;
-
void option(const std::string &, const std::string &);
};
- SourcePackage &package;
- OptionMap options;
+ SourcePackage &package;
+ OptionMap options;
+ InputOptions pending_options;
Msp::Time::TimeStamp mtime;
- bool freeze_mtime;
+ bool changed;
+public:
+ Config(SourcePackage &);
+
+ /** Adds a configuration option with name, default value and description. */
+ void add_option(const std::string &, const std::string &, const std::string &);
+
+ /** Gets a configuration option by name. */
+ const Option &get_option(const std::string &) const;
+
+ const OptionMap &get_options() const { return options; }
+ const Msp::Time::TimeStamp &get_mtime() const { return mtime; }
+
+ /** Checks whether an option exists. */
+ bool is_option(const std::string &) const;
+
+ void save() const;
bool set_option(const std::string &, const std::string &);
void load();
};