38 #ifndef ASYNC_CONFIG_INCLUDED
39 #define ASYNC_CONFIG_INCLUDED
151 bool open(
const std::string& name);
165 const std::string &
getValue(
const std::string& section,
166 const std::string& tag)
const;
180 bool getValue(
const std::string& section,
const std::string& tag,
181 std::string& value)
const;
203 template <
typename Rsp>
204 bool getValue(
const std::string& section,
const std::string& tag,
205 Rsp &rsp,
bool missing_ok =
false)
const
208 if (!
getValue(section, tag, str_val) && missing_ok)
212 std::stringstream ssval(str_val);
214 ssval >> tmp >> std::ws;
215 if (ssval.fail() || !ssval.eof())
244 template <
typename Rsp>
245 bool getValue(
const std::string& section,
const std::string& tag,
246 const Rsp& min,
const Rsp& max, Rsp &rsp,
247 bool missing_ok =
false)
const
250 if (!
getValue(section, tag, str_val) && missing_ok)
254 std::stringstream ssval(str_val);
256 ssval >> tmp >> std::ws;
257 if (ssval.fail() || !ssval.eof() || (tmp < min) || (tmp > max))
271 std::list<std::string>
listSection(
const std::string& section);
274 typedef std::map<std::string, std::string> Values;
275 typedef std::map<std::string, Values> Sections;
280 bool parseCfgFile(
void);
281 char *trimSpaces(
char *line);
282 char *parseSection(
char *line);
283 char *parseDelimitedString(
char *str,
char begin_tok,
char end_tok);
284 bool parseValueLine(
char *line, std::string& tag, std::string& value);
285 char *parseValue(
char *value);
286 char *translateEscapedChars(
char *val);
Config(void)
Default constuctor.
bool getValue(const std::string §ion, const std::string &tag, const Rsp &min, const Rsp &max, Rsp &rsp, bool missing_ok=false) const
Get a range checked variable value.
const std::string & getValue(const std::string §ion, const std::string &tag) const
Return the string value of the given configuration variable.
bool getValue(const std::string §ion, const std::string &tag, Rsp &rsp, bool missing_ok=false) const
Get the value of the given configuration variable.
bool open(const std::string &name)
Open the given config file.
std::list< std::string > listSection(const std::string §ion)
Return the name of all the tags in the given section.
A class for reading INI-formatted configuration files.