X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fconfig.cpp;h=69abe9d0b51b929d84a50ee08f3e9d7ef2bbb673;hb=HEAD;hp=de6b9bce34525c0f86e4dd4f2b3a306840807649;hpb=97001ddfa2463e6a3526eff772962acdad45f995;p=builder.git diff --git a/source/config.cpp b/source/config.cpp deleted file mode 100644 index de6b9bc..0000000 --- a/source/config.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include -#include -#include -#include -#include "config.h" - -using namespace std; -using namespace Msp; - -void Config::add_option(const string &n, const string &v, const string &d) -{ - options.insert(OptionMap::value_type(n, Option(n, v, d))); -} - -const Config::Option &Config::get_option(const string &name) const -{ - OptionMap::const_iterator i=options.find(name); - if(i==options.end()) - throw Exception("Tried to access nonexistent option "+name); - - return i->second; -} - -bool Config::is_option(const string &name) const -{ - return options.count(name); -} - -bool Config::process(const RawOptionMap &opts) -{ - bool changed=false; - for(RawOptionMap::const_iterator i=opts.begin(); i!=opts.end(); ++i) - { - OptionMap::iterator j=options.find(i->first); - if(j!=options.end()) - { - if(i->second!=j->second.value) - changed=true; - j->second.value=i->second; - } - } - - if(changed) - mtime=Time::now(); - - return changed; -} - -void Config::load(const Path::Path &fn) -{ - ifstream in(fn.str().c_str()); - if(!in) return; - - struct stat st; - Path::stat(fn, st); - mtime=Time::TimeStamp::from_unixtime(st.st_mtime); -} - -Config::Option::Option(const string &n, const string &v, const string &d): - name(n), - defv(v), - descr(d), - value(v) -{ }