]>
Dogcows Code - chaz/yoink/blob - src/Moof/Settings.hh
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
10 **************************************************************************/
12 #ifndef _MOOF_SETTINGS_HH_
13 #define _MOOF_SETTINGS_HH_
17 * Load, store, save program settings.
23 #include <boost/algorithm/string.hpp>
25 #include <Moof/Log.hh>
26 #include <Moof/Script.hh>
38 mScript
.importBaseLibrary();
39 importLogFunctions(mScript
);
44 void parseArgs(int argc
, char* argv
[]);
46 void loadFromFiles(const std::string
& path
);
47 void loadFromFiles(const std::vector
<std::string
>& path
);
49 void clear(); // remove all settings
51 void saveAs(const std::string
& path
);
55 bool get(const std::string
& key
, T
& value
) const;
59 mutable Script mScript
;
61 std::string mUserFile
;
66 bool Settings::get(const std::string
& key
, T
& value
) const
68 Script::Slot top
= mScript
[-1];
69 Script::Slot globals
= mScript
.getGlobalTable();
71 std::vector
<std::string
> fields
;
72 boost::split(fields
, key
, boost::is_any_of("."));
76 std::vector
<std::string
>::iterator it
;
77 for (it
= fields
.begin(); it
!= fields
.end(); ++it
)
90 bool got
= top
.get(value
);
96 extern Settings settings
;
101 #endif // _MOOF_SETTINGS_HH_
This page took 0.0359 seconds and 4 git commands to generate.