Changeset 301
- Timestamp:
- 03/29/05 06:18:43 (4 years ago)
- Files:
-
- todo2/trunk/src/Manager.cc (modified) (4 diffs)
- todo2/trunk/src/Manager.h (modified) (1 diff)
- todo2/trunk/src/PropertyMap.cc (modified) (2 diffs)
- todo2/trunk/src/PropertyMap.h (modified) (2 diffs)
- todo2/trunk/src/PropertyValidator.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
todo2/trunk/src/Manager.cc
r300 r301 107 107 Terminal terminal; 108 108 Args args; 109 // vector<string> modules = trim(split(",", get("frontends")));110 111 109 Validator validator = new PropertyValidator(); 112 110 … … 130 128 set("frontends", "console"); 131 129 132 set("expression.filter", "!completed");133 130 set("priority.-2", "verylow"); 134 131 set("priority.-1", "low"); … … 500 497 lt_dlhandle Manager::loadModule(string module) { 501 498 const string mpath = get("module-path"); 502 const string file = mpath + (mpath[mpath.size() - 1] == '/' ? "" : "/")+ module + ".so";499 const string file = crash::normalisepath(mpath) + "/" + module + ".so"; 503 500 lt_dlhandle h; 504 501 … … 527 524 } 528 525 529 bool Manager::haveContactMethod(std::string contactmethod) {526 ContactMethod *Manager::contactMethod(std::string contactmethod) { 530 527 for (vector<ContactMethod*>::iterator i = mcontactmethods.begin(); i != mcontactmethods.end(); ++i) 531 528 if ((*i)->name() == contactmethod) 532 return true;533 return false;529 return *i; 530 return 0; 534 531 } 535 532 todo2/trunk/src/Manager.h
r300 r301 58 58 std::string priority(int priority) const; 59 59 60 bool haveContactMethod(std::string contactmethod);60 ContactMethod *contactMethod(std::string contactmethod); 61 61 62 62 std::vector<Module*> moduleList() const { return mmodules; } todo2/trunk/src/PropertyMap.cc
r299 r301 46 46 ifstream in(file.c_str()); 47 47 string line, section; 48 unsigned lineno = 0; 48 49 49 while (getline(in, line) ) {50 while (getline(in, line), ++lineno) { 50 51 if (line.find('#') != string::npos) 51 52 line = line.substr(0, line.find('#')); … … 60 61 const string key = section + trim(line.substr(0, line.find('='))); 61 62 62 set(key, ltrim(line.substr(line.find('=') + 1))); 63 try { 64 set(key, ltrim(line.substr(line.find('=') + 1))); 65 } catch (InvalidValue &e) { 66 throw InvalidValue(string(e.what()) + ", at " + file + ":" + to_string(lineno)); 67 } 63 68 DEBUG(10, "loaded property '" << key << "' with value '" << get(key) << "'"); 64 69 } todo2/trunk/src/PropertyMap.h
r299 r301 19 19 public : 20 20 SUBCLASS_DEFAULT_EXCEPTION 21 SUBCLASS_NAMED_EXCEPTION(InvalidValue, Exception) 21 22 22 23 class Value { … … 115 116 void set(std::string key, const std::string &value) { 116 117 if (mvalidator && !mvalidator->validate(key, value)) 117 throw Exception("invalid value '" + value + "' for property '" + key + "'");118 throw InvalidValue("invalid value '" + value + "' for property '" + key + "'"); 118 119 mkv[key] = value; 119 120 } todo2/trunk/src/PropertyValidator.h
r299 r301 17 17 ~PropertyValidator(); 18 18 19 /** Register a new type with the validator. */ 19 20 void type(const std::string &type, const std::string &pattern, const std::string &help = "No help available."); 21 /** Register a new property with the validator. */ 20 22 void property(const std::string &key, const std::string &type, const std::string &help = "No help available."); 21 23
