Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > os > by-pkgid > 9c481c872fb0ae0cbadccdc2f4a18ab6 > files > 100

libasync-devel-0.17.0-5.fc14.x86_64.rpm

<!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: AsyncConfig_demo.cpp</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&nbsp;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><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>
<div class="contents">
<h1>AsyncConfig_demo.cpp</h1><p>An example of how to use the Config class</p>
<div class="fragment"><pre class="fragment"><span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include &lt;string&gt;</span>
<span class="preprocessor">#include &lt;cstdlib&gt;</span>

<span class="preprocessor">#include &lt;<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>&gt;</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 name="_a0"></a><a class="code" href="classAsync_1_1Config.html" title="A class for reading configuration files that is on the famous INI file format.">Config</a> cfg;
  <span class="keywordflow">if</span> (!cfg.<a name="a1"></a><a class="code" href="classAsync_1_1Config.html#aad37b24a2922879f791763c571e86b8d" title="Open the given config file.">open</a>(<span class="stringliteral">&quot;test.cfg&quot;</span>))
  {
    cerr &lt;&lt; <span class="stringliteral">&quot;*** Error: Could not open config file test.cfg\n&quot;</span>;
    exit(1);
  }

  <span class="keywordtype">string</span> value;
  <span class="keywordflow">if</span> (cfg.<a name="a2"></a><a class="code" href="classAsync_1_1Config.html#a26db674a7fded5cb520b9f4e251f2c45" title="Get the value of the given configuration variable.">getValue</a>(<span class="stringliteral">&quot;SECTION1&quot;</span>, <span class="stringliteral">&quot;VALUE2&quot;</span>, value))
  {
    cout &lt;&lt; <span class="stringliteral">&quot;&gt;&gt;&gt; value=&quot;</span> &lt;&lt; value &lt;&lt; endl;
  }
  <span class="keywordflow">else</span>
  {
    cerr &lt;&lt; <span class="stringliteral">&quot;*** Error: Could not find config variable SECTION1/VALUE2\n&quot;</span>;
    exit(1);
  }
}
</pre></div> </div>
<hr class="footer"/><address style="text-align: right;"><small>Generated by&nbsp;
<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>