/[projects]/smsdaemon/ConfigFile.cpp
ViewVC logotype

Diff of /smsdaemon/ConfigFile.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 146 by torben, Sun Dec 7 20:06:12 2008 UTC revision 201 by torben, Thu Dec 18 23:19:08 2008 UTC
# Line 61  bool ConfigFile::Open(std::string const& Line 61  bool ConfigFile::Open(std::string const&
61                  name  = trim(line.substr(0,posEqual));                  name  = trim(line.substr(0,posEqual));
62                  value = trim(line.substr(posEqual+1));                  value = trim(line.substr(posEqual+1));
63    
64                    content_.insert(std::make_pair(inSection+SEPERATOR+name,Value(value)));
                 content_[inSection+SEPERATOR+name]=Value(value);  
65          }          }
66          return true;          return true;
67  }  }
# Line 70  bool ConfigFile::Open(std::string const& Line 69  bool ConfigFile::Open(std::string const&
69  Value const& ConfigFile::GetValue(std::string const& section, std::string const& entry) const  Value const& ConfigFile::GetValue(std::string const& section, std::string const& entry) const
70  {  {
71    
72          std::map<std::string,Value>::const_iterator ci = content_.find(section + SEPERATOR + entry);          content_iterator ci = content_.find(section + SEPERATOR + entry);
73    
74          if (ci == content_.end()) throw "does not exist";          if (ci == content_.end()) throw "does not exist";
75    
76          return ci->second;          return ci->second;
77  }  }
78    
79    std::vector<Value> ConfigFile::GetValues(std::string const& section, std::string const& entry) const
80    {
81            std::vector<Value> values;
82            std::string search = section + SEPERATOR + entry;
83            std::pair<content_iterator, content_iterator> range = content_.equal_range(search);
84    
85            for (content_iterator it=range.first; it != range.second; ++it)
86            {
87                    values.push_back( it->second );
88            }
89            return values;
90    }
91    
92  Value const& ConfigFile::GetValue(std::string const& section, std::string const& entry, double value)  Value const& ConfigFile::GetValue(std::string const& section, std::string const& entry, double value)
93  {  {
94          try          try
# Line 85  Value const& ConfigFile::GetValue(std::s Line 97  Value const& ConfigFile::GetValue(std::s
97          }          }
98          catch (const char *)          catch (const char *)
99          {          {
100                  return content_.insert(std::make_pair(section+SEPERATOR+entry, Value(value))).first->second;                  return content_.insert(std::make_pair(section+SEPERATOR+entry, Value(value)))->second;
101          }          }
102  }  }
103    
# Line 97  Value const& ConfigFile::GetValue(std::s Line 109  Value const& ConfigFile::GetValue(std::s
109          }          }
110          catch (const char *)          catch (const char *)
111          {          {
112                  return content_.insert(std::make_pair(section+SEPERATOR+entry, Value(value))).first->second;                  return content_.insert(std::make_pair(section+SEPERATOR+entry, Value(value)))->second;
113          }          }
114  }  }
115    

Legend:
Removed from v.146  
changed lines
  Added in v.201

  ViewVC Help
Powered by ViewVC 1.1.20