This repository has been archived on 2020-05-16. You can view files and clone it, but cannot push or open issues or pull requests.
xdgcfg/docs/example_8cpp-example.html

78 lines
5.6 KiB
HTML
Raw Normal View History

2018-08-10 02:50:42 +02:00
<!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"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>xdgcfg: example.cpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
2019-08-02 13:33:50 +02:00
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
2018-08-10 02:50:42 +02:00
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">xdgcfg
2019-08-02 13:33:50 +02:00
&#160;<span id="projectnumber">0.4.1</span>
2018-08-10 02:50:42 +02:00
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
2019-08-02 13:33:50 +02:00
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
2018-08-10 02:50:42 +02:00
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
2019-08-02 13:33:50 +02:00
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
2018-08-10 02:50:42 +02:00
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
2019-08-02 13:33:50 +02:00
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
2018-08-10 02:50:42 +02:00
<div class="header">
<div class="headertitle">
<div class="title">example.cpp</div> </div>
</div><!--header-->
<div class="contents">
2019-08-02 13:33:50 +02:00
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;libconfig.h++&gt;</span></div><div class="line"><span class="preprocessor">#include &quot;xdgcfg.hpp&quot;</span></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line"> <a name="_a0"></a><a class="code" href="classxdgcfg.html">xdgcfg</a> config(<span class="stringliteral">&quot;test.cfg&quot;</span>, <span class="comment">// File name.</span></div><div class="line"> <span class="stringliteral">&quot;xdgcfg&quot;</span>); <span class="comment">// Sub directory (optional).</span></div><div class="line"> config.<a name="a1"></a><a class="code" href="classxdgcfg.html#a982f773bb644c465bed6144dca44c98f">set_verbose</a>(<span class="keyword">true</span>); <span class="comment">// Print error messages.</span></div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (config.<a name="a2"></a><a class="code" href="classxdgcfg.html#a60584df7badfddce574df3cc1b9fce85">read</a>() != 0)</div><div class="line"> {</div><div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;File not found.\n&quot;</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="comment">// Get a reference to the libconfig::Config object and use it as you would</span></div><div class="line"> <span class="comment">// normally do.</span></div><div class="line"> libconfig::Config &amp;cfg = config.<a name="a3"></a><a class="code" href="classxdgcfg.html#ac07980ed9c75aded9db7d9a56e9e7dbf">get_cfg</a>();</div><div class="line"> libconfig::Setting &amp;root = cfg.getRoot();</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (!root.exists(<span class="stringliteral">&quot;Hello&quot;</span>))</div><div class="line"> {</div><div class="line"> root.add(<span class="stringliteral">&quot;Hello&quot;</span>, libconfig::Setting::TypeString) = <span class="stringliteral">&quot;World&quot;</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (!config.<a name="a4"></a><a class="code" href="classxdgcfg.html#addb7dd29dc725fef54820aab38b42e30">write</a>())</div><div class="line"> {</div><div class="line"> std::cerr &lt;&lt; <span class="stringliteral">&quot;Writing failed.\n&quot;</span>;</div><div class="line"> }</div><div class="line"></div><div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Hello: &quot;</span> &lt;&lt; root[<span class="stringliteral">&quot;Hello&quot;</span>].c_str() &lt;&lt; std::endl;</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
2018-08-10 02:50:42 +02:00
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>