Changeset 301

Show
Ignore:
Timestamp:
03/29/05 06:18:43 (4 years ago)
Author:
athomas
Message:

Commit before experimenting with more generic properties.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • todo2/trunk/src/Manager.cc

    r300 r301  
    107107        Terminal terminal; 
    108108        Args args; 
    109 //      vector<string> modules = trim(split(",", get("frontends"))); 
    110  
    111109        Validator validator = new PropertyValidator(); 
    112110                 
     
    130128                set("frontends", "console"); 
    131129 
    132                 set("expression.filter", "!completed"); 
    133130                set("priority.-2", "verylow"); 
    134131                set("priority.-1", "low"); 
     
    500497lt_dlhandle Manager::loadModule(string module) { 
    501498const string mpath = get("module-path"); 
    502 const string file = mpath + (mpath[mpath.size() - 1] == '/' ? "" : "/") + module + ".so"; 
     499const string file = crash::normalisepath(mpath) + "/" + module + ".so"; 
    503500lt_dlhandle h; 
    504501 
     
    527524} 
    528525 
    529 bool Manager::haveContactMethod(std::string contactmethod) { 
     526ContactMethod *Manager::contactMethod(std::string contactmethod) { 
    530527        for (vector<ContactMethod*>::iterator i = mcontactmethods.begin(); i != mcontactmethods.end(); ++i) 
    531528                if ((*i)->name() == contactmethod) 
    532                         return true
    533         return false
     529                        return *i
     530        return 0
    534531} 
    535532 
  • todo2/trunk/src/Manager.h

    r300 r301  
    5858                std::string priority(int priority) const; 
    5959 
    60                 bool haveContactMethod(std::string contactmethod); 
     60                ContactMethod *contactMethod(std::string contactmethod); 
    6161 
    6262                std::vector<Module*> moduleList() const { return mmodules; } 
  • todo2/trunk/src/PropertyMap.cc

    r299 r301  
    4646ifstream in(file.c_str()); 
    4747string line, section; 
     48unsigned lineno = 0; 
    4849 
    49         while (getline(in, line)) { 
     50        while (getline(in, line), ++lineno) { 
    5051                if (line.find('#') != string::npos) 
    5152                        line = line.substr(0, line.find('#')); 
     
    6061                const string key = section + trim(line.substr(0, line.find('='))); 
    6162 
    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                        } 
    6368                        DEBUG(10, "loaded property '" << key << "' with value '" << get(key) << "'"); 
    6469                } 
  • todo2/trunk/src/PropertyMap.h

    r299 r301  
    1919        public : 
    2020                SUBCLASS_DEFAULT_EXCEPTION 
     21                SUBCLASS_NAMED_EXCEPTION(InvalidValue, Exception) 
    2122 
    2223                class Value { 
     
    115116                void set(std::string key, const std::string &value) { 
    116117                        if (mvalidator && !mvalidator->validate(key, value)) 
    117                                 throw Exception("invalid value '" + value + "' for property '" + key + "'"); 
     118                                throw InvalidValue("invalid value '" + value + "' for property '" + key + "'"); 
    118119                        mkv[key] = value; 
    119120                } 
  • todo2/trunk/src/PropertyValidator.h

    r299 r301  
    1717                ~PropertyValidator(); 
    1818 
     19                /**     Register a new type with the validator. */ 
    1920                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. */ 
    2022                void property(const std::string &key, const std::string &type, const std::string &help = "No help available."); 
    2123