Changeset 11329
- Timestamp:
- 07/10/11 22:20:49 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Configuration.h
r11247 r11329 2 2 #define FACT_Configuration 3 3 4 #include <iostream> 4 5 #include <boost/program_options.hpp> 5 6 … … 124 125 return Has("print-all") || Has("print") || Has("print-default") || 125 126 Has("print-database") || Has("print-config") || 126 Has("print-environment") || Has("print-unk own") ||127 Has("print-environment") || Has("print-unknown") || 127 128 Has("print-options"); 128 129 } … … 130 131 // Simplified access to the parsed options 131 132 template<class T> 132 T Get(const char *var) const { return Has(var) ? fVariables[var].as<T>() : T(); }133 T Get(const char *var) const { return fVariables[var].as<T>(); } 133 134 bool Has(const char *var) const { return fVariables.count(var)>0; } 135 136 template<class T> 137 std::map<std::string, T> GetMap(const std::string &var) const 138 { 139 const size_t len = var.length(); 140 141 std::map<std::string, T> rc; 142 for (std::map<std::string, boost::program_options::variable_value>::const_iterator it=fVariables.begin(); 143 it!=fVariables.end(); it++) 144 if (it->first.substr(0, len)==var) 145 rc[it->first] = it->second.as<T>(); 146 147 return rc; 148 } 149 150 template<class T> 151 std::vector<std::string> GetKeys(const std::string &var) const 152 { 153 const size_t len = var.length(); 154 155 std::vector<std::string> rc; 156 for (std::map<std::string, boost::program_options::variable_value>::const_iterator it=fVariables.begin(); 157 it!=fVariables.end(); it++) 158 if (it->first.substr(0, len)==var) 159 rc.push_back(it->first); 160 161 return rc; 162 } 134 163 135 164 const std::string &GetName() const { return fName; }
Note:
See TracChangeset
for help on using the changeset viewer.