38 #ifndef ASYNC_CONFIG_INCLUDED
39 #define ASYNC_CONFIG_INCLUDED
152 bool open(
const std::string& name);
166 const std::string &
getValue(
const std::string& section,
167 const std::string& tag)
const;
181 bool getValue(
const std::string& section,
const std::string& tag,
182 std::string& value)
const;
204 template <
typename Rsp>
205 bool getValue(
const std::string& section,
const std::string& tag,
206 Rsp &rsp,
bool missing_ok =
false)
const
209 if (!
getValue(section, tag, str_val))
213 std::stringstream ssval(str_val);
220 if (ssval.fail() || !ssval.eof())
248 template <
template <
typename,
typename>
class Container,
250 bool getValue(
const std::string& section,
const std::string& tag,
251 Container<Value, std::allocator<Value> > &c,
252 bool missing_ok =
false)
const
255 if (!
getValue(section, tag, str_val))
264 std::stringstream ssval(str_val);
303 template <
typename Rsp>
304 bool getValue(
const std::string& section,
const std::string& tag,
305 const Rsp& min,
const Rsp& max, Rsp &rsp,
306 bool missing_ok =
false)
const
309 if (!
getValue(section, tag, str_val))
313 std::stringstream ssval(str_val);
320 if (ssval.fail() || !ssval.eof() || (tmp < min) || (tmp > max))
334 std::list<std::string>
listSection(
const std::string& section);
349 void setValue(
const std::string& section,
const std::string& tag,
350 const std::string& value);
353 typedef std::map<std::string, std::string> Values;
354 typedef std::map<std::string, Values> Sections;
359 bool parseCfgFile(
void);
360 char *trimSpaces(
char *line);
361 char *parseSection(
char *line);
362 char *parseDelimitedString(
char *str,
char begin_tok,
char end_tok);
363 bool parseValueLine(
char *line, std::string& tag, std::string& value);
364 char *parseValue(
char *value);
365 char *translateEscapedChars(
char *val);
Config(void)
Default constuctor.
void setValue(const std::string §ion, const std::string &tag, const std::string &value)
Set the value of a configuration variable.
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 getValue(const std::string §ion, const std::string &tag, Container< Value, std::allocator< Value > > &c, bool missing_ok=false) const
Get the value of the given config variable into container.
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.
Namespace for the asynchronous programming classes.