Changeset 692 for mylib/trunk/rconfig
- Timestamp:
- 01/07/08 18:28:27 (2 years ago)
- Location:
- mylib/trunk/rconfig
- Files:
-
- 2 modified
-
rconfig.cpp (modified) (2 diffs)
-
rconfig.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mylib/trunk/rconfig/rconfig.cpp
r691 r692 201 201 } 202 202 203 template <class T> 204 static void addvar_uninitialised(const char* cname, T& var, const char* initval, const char* context) { 205 std::string name(cname); 206 if (IDEBUG) { 207 std::cerr.setf(std::ios_base::left, std::ios_base::adjustfield); 208 std::cerr 209 << "(cfg) " << std::setw(15) << DEMANGLE(T) 210 << ' ' << std::setw(30) << name 211 << " = " << std::setw(20) << initval; 212 if (context) 213 std::cerr << " (" << context << ")"; 214 std::cerr << std::endl; 215 216 } 217 varmap->insert(VARMAP::value_type(name, make_varreader(var, name))); 218 } 219 203 220 /** Add a VarReaderV to the map of variables we want to look for */ 204 221 template <class T> … … 285 302 addvar(name, ref, context); 286 303 } 304 305 void rcfile_tellstr(const char* name, std::string &ref, const char* defval, const char* context) { 306 addvar_uninitialised(name, ref, defval, context); 307 } 308 287 309 /* 288 310 void rcfile_tell(const char* name, std::vector<bool> &ref) { -
mylib/trunk/rconfig/rconfig.h
r691 r692 67 67 void rcfile_tell(const char* name, unsigned &ref, const char* context = 0); 68 68 void rcfile_tell(const char* name, std::string &ref, const char* context = 0); 69 void rcfile_tellstr(const char* name, std::string &ref, const char* defval = 0, const char* context = 0); 69 70 //void rcfile_tell(const char* name, std::vector<bool> &ref); 70 71 void rcfile_tell(const char* name, std::vector<int> &ref, const char* context = 0); … … 75 76 //@} 76 77 77 template<class T >78 T rcfile_initwrap(const char* name, T& ref, const T& initval, const char* context = 0) {79 ref = initval; 78 template<class T, class V> 79 T rcfile_initwrap(const char* name, T& ref, const V& initval, const char* context = 0) { 80 ref = initval; //this only works for primitive types 80 81 rcfile_tell(name, ref, context); 82 return initval; 83 } 84 85 template<class V> 86 std::string rcfile_initwrap(const char* name, std::string& ref, const V& initval, const char* context = 0) { 87 rcfile_tellstr(name, ref, initval, context); 81 88 return initval; 82 89 }
