<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>Async: Async::Config Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.2-20100208 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li class="current"><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> <li><a href="functions.html"><span>Class Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="namespaceAsync.html">Async</a>::<a class="el" href="classAsync_1_1Config.html">Config</a> </div> </div> <div class="contents"> <h1>Async::Config Class Reference</h1><!-- doxytag: class="Async::Config" --> <p>A class for reading configuration files that is on the famous INI file format. <a href="#_details">More...</a></p> <p><code>#include <<a class="el" href="AsyncConfig_8h_source.html">AsyncConfig.h</a>></code></p> <p><a href="classAsync_1_1Config-members.html">List of all members.</a></p> <h2>Public Member Functions</h2> <ul> <li><a class="el" href="classAsync_1_1Config.html#a0cccf9936e65b4f41242bfc39431e3ec">Config</a> (void) <dl class="el"><dd class="mdescRight">Default constuctor. <a href="#a0cccf9936e65b4f41242bfc39431e3ec"></a><br/></dl><li><a class="el" href="classAsync_1_1Config.html#ab1c5ec13ce9498c2413210eed1c86f41">~Config</a> (void) <dl class="el"><dd class="mdescRight">Destructor. <a href="#ab1c5ec13ce9498c2413210eed1c86f41"></a><br/></dl><li>bool <a class="el" href="classAsync_1_1Config.html#aad37b24a2922879f791763c571e86b8d">open</a> (const std::string &name) <dl class="el"><dd class="mdescRight">Open the given config file. <a href="#aad37b24a2922879f791763c571e86b8d"></a><br/></dl><li>bool <a class="el" href="classAsync_1_1Config.html#a26db674a7fded5cb520b9f4e251f2c45">getValue</a> (const std::string &section, const std::string &tag, std::string &value) <dl class="el"><dd class="mdescRight">Get the value of the given configuration variable. <a href="#a26db674a7fded5cb520b9f4e251f2c45"></a><br/></dl><li>std::list< std::string > <a class="el" href="classAsync_1_1Config.html#abb2a7b16592573b6229e71741205a11f">listSection</a> (const std::string &section) <dl class="el"><dd class="mdescRight">Return the name of all the tags in the given section. <a href="#abb2a7b16592573b6229e71741205a11f"></a><br/></dl></ul> <hr/><a name="_details"></a><h2>Detailed Description</h2> <p>A class for reading configuration files that is on the famous INI file format. </p> <dl class="author"><dt><b>Author:</b></dt><dd>Tobias Blomberg </dd></dl> <dl class="date"><dt><b>Date:</b></dt><dd>2004-03-17</dd></dl> <p>This class is used to read configuration files that is on the famous MS Windows INI file format. An example of a configuration file and how to use the class is shown below.</p> <div class="fragment"><pre class="fragment">[SECTION1] VALUE1=The value VALUE2=<span class="stringliteral">"Hello, "</span> <span class="stringliteral">"multi line "</span> <span class="stringliteral">"value!"</span> [SECTION2] VALUE1=<span class="stringliteral">"Whatever you want"</span> </pre></div><div class="fragment"><pre class="fragment"><span class="preprocessor">#include <iostream></span> <span class="preprocessor">#include <string></span> <span class="preprocessor">#include <cstdlib></span> <span class="preprocessor">#include <<a class="code" href="AsyncConfig_8h.html" title="A class for reading configuration files that is on the famous INI file format.">AsyncConfig.h</a>></span> <span class="keyword">using namespace </span>std; <span class="keyword">using namespace </span>Async; <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv) { <a class="code" href="classAsync_1_1Config.html#a0cccf9936e65b4f41242bfc39431e3ec" title="Default constuctor.">Config</a> cfg; <span class="keywordflow">if</span> (!cfg.open(<span class="stringliteral">"test.cfg"</span>)) { cerr << <span class="stringliteral">"*** Error: Could not open config file test.cfg\n"</span>; exit(1); } <span class="keywordtype">string</span> value; <span class="keywordflow">if</span> (cfg.getValue(<span class="stringliteral">"SECTION1"</span>, <span class="stringliteral">"VALUE2"</span>, value)) { cout << <span class="stringliteral">">>> value="</span> << value << endl; } <span class="keywordflow">else</span> { cerr << <span class="stringliteral">"*** Error: Could not find config variable SECTION1/VALUE2\n"</span>; exit(1); } } </pre></div> <dl><dt><b>Examples: </b></dt><dd> <p><a class="el" href="AsyncConfig__demo_8cpp-example.html#_a0">AsyncConfig_demo.cpp</a>.</p> </dd> </dl> <p>Definition at line <a class="el" href="AsyncConfig_8h_source.html#l00134">134</a> of file <a class="el" href="AsyncConfig_8h_source.html">AsyncConfig.h</a>.</p> <hr/><h2>Constructor & Destructor Documentation</h2> <a class="anchor" id="a0cccf9936e65b4f41242bfc39431e3ec"></a><!-- doxytag: member="Async::Config::Config" ref="a0cccf9936e65b4f41242bfc39431e3ec" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Async::Config::Config </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Default constuctor. </p> </div> </div> <a class="anchor" id="ab1c5ec13ce9498c2413210eed1c86f41"></a><!-- doxytag: member="Async::Config::~Config" ref="ab1c5ec13ce9498c2413210eed1c86f41" args="(void)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">Async::Config::~Config </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Destructor. </p> </div> </div> <hr/><h2>Member Function Documentation</h2> <a class="anchor" id="a26db674a7fded5cb520b9f4e251f2c45"></a><!-- doxytag: member="Async::Config::getValue" ref="a26db674a7fded5cb520b9f4e251f2c45" args="(const std::string &section, const std::string &tag, std::string &value)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool Async::Config::getValue </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"> <em>section</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const std::string & </td> <td class="paramname"> <em>tag</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">std::string & </td> <td class="paramname"> <em>value</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p>Get the value of the given configuration variable. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>section</em> </td><td>The name of the section where the configuration variable is located </td></tr> <tr><td valign="top"></td><td valign="top"><em>tag</em> </td><td>The name of the configuration variable to get </td></tr> <tr><td valign="top"></td><td valign="top"><em>value</em> </td><td>The value is returned in this argument. Any previous contents is wiped </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>Returns <em>true</em> on success or else <em>false</em> on failure </dd></dl> <dl><dt><b>Examples: </b></dt><dd><a class="el" href="AsyncConfig__demo_8cpp-example.html#a2">AsyncConfig_demo.cpp</a>.</dd> </dl> </div> </div> <a class="anchor" id="abb2a7b16592573b6229e71741205a11f"></a><!-- doxytag: member="Async::Config::listSection" ref="abb2a7b16592573b6229e71741205a11f" args="(const std::string &section)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">std::list<std::string> Async::Config::listSection </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"> <em>section</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Return the name of all the tags in the given section. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>section</em> </td><td>The name of the section where the configuration variables are located </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>Returns the list of tags in the given section </dd></dl> </div> </div> <a class="anchor" id="aad37b24a2922879f791763c571e86b8d"></a><!-- doxytag: member="Async::Config::open" ref="aad37b24a2922879f791763c571e86b8d" args="(const std::string &name)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">bool Async::Config::open </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"> <em>name</em></td> <td> ) </td> <td></td> </tr> </table> </div> <div class="memdoc"> <p>Open the given config file. </p> <dl><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>name</em> </td><td>The name of the configuration file to open </td></tr> </table> </dd> </dl> <dl class="return"><dt><b>Returns:</b></dt><dd>Returns <em>true</em> on success or else <em>false</em>. </dd></dl> <dl><dt><b>Examples: </b></dt><dd><a class="el" href="AsyncConfig__demo_8cpp-example.html#a1">AsyncConfig_demo.cpp</a>.</dd> </dl> </div> </div> <hr/>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="AsyncConfig_8h_source.html">AsyncConfig.h</a></li> </ul> </div> <hr class="footer"/><address style="text-align: right;"><small>Generated by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.2-20100208 </small></address> </body> </html>