1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>ConfigReader class Reference</title>
4 <link href="inspircd.css" rel="stylesheet" type="text/css">
6 <!-- Generated by Doxygen 1.3-rc3 -->
8 <a class="qindex" href="main.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center>
9 <hr><h1>ConfigReader Class Reference</h1>Allows reading of values from configuration files This class allows a module to read from either the main configuration file (inspircd.conf) or from a module-specified configuration file.
10 <a href="#_details">More...</a>
12 <code>#include <<a class="el" href="modules_8h-source.html">modules.h</a>></code>
14 Inheritance diagram for ConfigReader:<p><center><img src="classConfigReader__inherit__graph.gif" border="0" usemap="#ConfigReader__inherit__map" alt="Inheritance graph"></center>
15 <map name="ConfigReader__inherit__map">
16 <area href="classclassbase.html" shape="rect" coords="19,16,85,37" alt="">
18 <center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center>Collaboration diagram for ConfigReader:<p><center><img src="classConfigReader__coll__graph.gif" border="0" usemap="#ConfigReader__coll__map" alt="Collaboration graph"></center>
19 <map name="ConfigReader__coll__map">
20 <area href="classclassbase.html" shape="rect" coords="7,107,73,128" alt="">
22 <center><font size="2">[<a target="top" href="graph_legend.html">legend</a>]</font></center><a href="classConfigReader-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0>
24 <tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
25 <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classConfigReader.html#a0">ConfigReader</a> ()</td></tr>
26 <tr><td> </td><td><font size=-1><em>Default constructor.</em> <a href="#a0"></a><em></em></font><br><br></td></tr>
27 <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classConfigReader.html#a1">ConfigReader</a> (std::string filename)</td></tr>
28 <tr><td> </td><td><font size=-1><em>Overloaded constructor.</em> <a href="#a1"></a><em></em></font><br><br></td></tr>
29 <tr><td nowrap align=right valign=top> </td><td valign=bottom><a class="el" href="classConfigReader.html#a2">~ConfigReader</a> ()</td></tr>
30 <tr><td> </td><td><font size=-1><em>Default destructor.</em> <a href="#a2"></a><em></em></font><br><br></td></tr>
31 <tr><td nowrap align=right valign=top>std::string </td><td valign=bottom><a class="el" href="classConfigReader.html#a3">ReadValue</a> (std::string tag, std::string name, int index)</td></tr>
32 <tr><td> </td><td><font size=-1><em>Retrieves a value from the config file.</em> <a href="#a3"></a><em></em></font><br><br></td></tr>
33 <tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classConfigReader.html#a4">Enumerate</a> (std::string tag)</td></tr>
34 <tr><td> </td><td><font size=-1><em>Counts the number of times a given tag appears in the config file.</em> <a href="#a4"></a><em></em></font><br><br></td></tr>
35 <tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classConfigReader.html#a5">Verify</a> ()</td></tr>
36 <tr><td> </td><td><font size=-1><em>Returns true if a config file is valid.</em> <a href="#a5"></a><em></em></font><br><br></td></tr>
37 <tr><td nowrap align=right valign=top>int </td><td valign=bottom><a class="el" href="classConfigReader.html#a6">EnumerateValues</a> (std::string tag, int index)</td></tr>
38 <tr><td> </td><td><font size=-1><em>Returns the number of items within a tag.</em> <a href="#a6"></a><em></em></font><br><br></td></tr>
39 <tr><td colspan=2><br><h2>Protected Attributes</h2></td></tr>
40 <tr><td nowrap align=right valign=top>std::stringstream * </td><td valign=bottom><a class="el" href="classConfigReader.html#n0">cache</a></td></tr>
41 <tr><td> </td><td><font size=-1><em>The contents of the configuration file This protected member should never be accessed by a module (and cannot be accessed unless the core is changed).</em> <a href="#n0"></a><em></em></font><br><br></td></tr>
42 <tr><td nowrap align=right valign=top>bool </td><td valign=bottom><a class="el" href="classConfigReader.html#n1">error</a></td></tr>
43 <tr><td> </td><td><font size=-1><em>Used to store errors.</em> <a href="#n1"></a><em></em></font><br><br></td></tr>
45 <hr><a name="_details"></a><h2>Detailed Description</h2>
46 Allows reading of values from configuration files This class allows a module to read from either the main configuration file (inspircd.conf) or from a module-specified configuration file.
48 It may either be instantiated with one parameter or none. Constructing the class using one parameter allows you to specify a path to your own configuration file, otherwise, inspircd.conf is read.
52 Definition at line <a class="el" href="modules_8h-source.html#l00518">518</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor & Destructor Documentation</h2>
53 <a name="a0" doxytag="ConfigReader::ConfigReader"></a><p>
54 <table width="100%" cellpadding="2" cellspacing="0" border="0">
57 <table cellpadding="0" cellspacing="0" border="0">
59 <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
60 <td class="md" valign="top">( </td>
61 <td class="mdname1" valign="top" nowrap> </td>
62 <td class="md" valign="top">) </td>
63 <td class="md" nowrap></td>
70 <table cellspacing=5 cellpadding=0 border=0>
80 This constructor initialises the ConfigReader class to read the inspircd.conf file as specified when running ./configure.
82 Definition at line <a class="el" href="modules_8cpp-source.html#l00343">343</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
84 References <a class="el" href="modules_8h-source.html#l00526">cache</a>, and <a class="el" href="modules_8h-source.html#l00529">error</a>.
86 <div class="fragment"><pre>00344 {
87 00345 this-><a class="code" href="classConfigReader.html#n0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
88 00346 this-><a class="code" href="classConfigReader.html#n1">error</a> = LoadConf(CONFIG_FILE,this->cache);
93 <a name="a1" doxytag="ConfigReader::ConfigReader"></a><p>
94 <table width="100%" cellpadding="2" cellspacing="0" border="0">
97 <table cellpadding="0" cellspacing="0" border="0">
99 <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
100 <td class="md" valign="top">( </td>
101 <td class="md" nowrap valign="top">std::string </td>
102 <td class="mdname1" valign="top" nowrap> <em>filename</em> </td>
103 <td class="md" valign="top">) </td>
104 <td class="md" nowrap></td>
111 <table cellspacing=5 cellpadding=0 border=0>
119 Overloaded constructor.
121 This constructor initialises the ConfigReader class to read a user-specified config file
123 Definition at line <a class="el" href="modules_8cpp-source.html#l00357">357</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
125 References <a class="el" href="modules_8h-source.html#l00526">cache</a>, and <a class="el" href="modules_8h-source.html#l00529">error</a>.
127 <div class="fragment"><pre>00358 {
128 00359 this-><a class="code" href="classConfigReader.html#n0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
129 00360 this-><a class="code" href="classConfigReader.html#n1">error</a> = LoadConf(filename.c_str(),this-><a class="code" href="classConfigReader.html#n0">cache</a>);
134 <a name="a2" doxytag="ConfigReader::~ConfigReader"></a><p>
135 <table width="100%" cellpadding="2" cellspacing="0" border="0">
138 <table cellpadding="0" cellspacing="0" border="0">
140 <td class="md" nowrap valign="top"> ConfigReader::~ConfigReader </td>
141 <td class="md" valign="top">( </td>
142 <td class="mdname1" valign="top" nowrap> </td>
143 <td class="md" valign="top">) </td>
144 <td class="md" nowrap></td>
151 <table cellspacing=5 cellpadding=0 border=0>
161 This method destroys the ConfigReader class.
163 Definition at line <a class="el" href="modules_8cpp-source.html#l00350">350</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
165 References <a class="el" href="modules_8h-source.html#l00526">cache</a>.
167 <div class="fragment"><pre>00351 {
168 00352 <span class="keywordflow">if</span> (this-><a class="code" href="classConfigReader.html#n0">cache</a>)
169 00353 <span class="keyword">delete</span> this-><a class="code" href="classConfigReader.html#n0">cache</a>;
174 <hr><h2>Member Function Documentation</h2>
175 <a name="a4" doxytag="ConfigReader::Enumerate"></a><p>
176 <table width="100%" cellpadding="2" cellspacing="0" border="0">
179 <table cellpadding="0" cellspacing="0" border="0">
181 <td class="md" nowrap valign="top"> int ConfigReader::Enumerate </td>
182 <td class="md" valign="top">( </td>
183 <td class="md" nowrap valign="top">std::string </td>
184 <td class="mdname1" valign="top" nowrap> <em>tag</em> </td>
185 <td class="md" valign="top">) </td>
186 <td class="md" nowrap></td>
193 <table cellspacing=5 cellpadding=0 border=0>
201 Counts the number of times a given tag appears in the config file.
203 This method counts the number of times a tag appears in a config file, for use where there are several tags of the same kind, e.g. with opers and connect types. It can be used with the index value of <a class="el" href="classConfigReader.html#a3">ConfigReader::ReadValue</a> to loop through all copies of a multiple instance tag.
205 Definition at line <a class="el" href="modules_8cpp-source.html#l00375">375</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
207 <div class="fragment"><pre>00376 {
208 00377 <span class="keywordflow">return</span> EnumConf(cache,tag.c_str());
213 <a name="a6" doxytag="ConfigReader::EnumerateValues"></a><p>
214 <table width="100%" cellpadding="2" cellspacing="0" border="0">
217 <table cellpadding="0" cellspacing="0" border="0">
219 <td class="md" nowrap valign="top"> int ConfigReader::EnumerateValues </td>
220 <td class="md" valign="top">( </td>
221 <td class="md" nowrap valign="top">std::string </td>
222 <td class="mdname" nowrap> <em>tag</em>, </td>
227 <td class="md" nowrap>int </td>
228 <td class="mdname" nowrap> <em>index</em></td>
232 <td class="md">) </td>
233 <td class="md" colspan="2"></td>
240 <table cellspacing=5 cellpadding=0 border=0>
248 Returns the number of items within a tag.
250 For example if the tag was <test tag="blah" data="foo"> then this function would return 2. Spaces and newlines both qualify as valid seperators between values.
252 Definition at line <a class="el" href="modules_8cpp-source.html#l00380">380</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
254 <div class="fragment"><pre>00381 {
255 00382 <span class="keywordflow">return</span> EnumValues(cache, tag.c_str(), index);
260 <a name="a3" doxytag="ConfigReader::ReadValue"></a><p>
261 <table width="100%" cellpadding="2" cellspacing="0" border="0">
264 <table cellpadding="0" cellspacing="0" border="0">
266 <td class="md" nowrap valign="top"> std::string ConfigReader::ReadValue </td>
267 <td class="md" valign="top">( </td>
268 <td class="md" nowrap valign="top">std::string </td>
269 <td class="mdname" nowrap> <em>tag</em>, </td>
274 <td class="md" nowrap>std::string </td>
275 <td class="mdname" nowrap> <em>name</em>, </td>
280 <td class="md" nowrap>int </td>
281 <td class="mdname" nowrap> <em>index</em></td>
285 <td class="md">) </td>
286 <td class="md" colspan="2"></td>
293 <table cellspacing=5 cellpadding=0 border=0>
301 Retrieves a value from the config file.
303 This method retrieves a value from the config file. Where multiple copies of the tag exist in the config file, index indicates which of the values to retrieve.
305 Definition at line <a class="el" href="modules_8cpp-source.html#l00363">363</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
307 <div class="fragment"><pre>00364 {
308 00365 <span class="keywordtype">char</span> val[MAXBUF];
309 00366 <span class="keywordtype">char</span> t[MAXBUF];
310 00367 <span class="keywordtype">char</span> n[MAXBUF];
311 00368 strncpy(t,tag.c_str(),MAXBUF);
312 00369 strncpy(n,name.c_str(),MAXBUF);
313 00370 ReadConf(cache,t,n,index,val);
314 00371 <span class="keywordflow">return</span> std::string(val);
319 <a name="a5" doxytag="ConfigReader::Verify"></a><p>
320 <table width="100%" cellpadding="2" cellspacing="0" border="0">
323 <table cellpadding="0" cellspacing="0" border="0">
325 <td class="md" nowrap valign="top"> bool ConfigReader::Verify </td>
326 <td class="md" valign="top">( </td>
327 <td class="mdname1" valign="top" nowrap> </td>
328 <td class="md" valign="top">) </td>
329 <td class="md" nowrap></td>
336 <table cellspacing=5 cellpadding=0 border=0>
344 Returns true if a config file is valid.
346 This method is partially implemented and will only return false if the config file does not exist or could not be opened.
348 Definition at line <a class="el" href="modules_8cpp-source.html#l00385">385</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
350 References <a class="el" href="modules_8h-source.html#l00529">error</a>.
352 <div class="fragment"><pre>00386 {
353 00387 <span class="keywordflow">return</span> this-><a class="code" href="classConfigReader.html#n1">error</a>;
358 <hr><h2>Member Data Documentation</h2>
359 <a name="n0" doxytag="ConfigReader::cache"></a><p>
360 <table width="100%" cellpadding="2" cellspacing="0" border="0">
363 <table cellpadding="0" cellspacing="0" border="0">
365 <td class="md" nowrap valign="top"> std::stringstream* ConfigReader::cache<code> [protected]</code>
370 <table cellspacing=5 cellpadding=0 border=0>
378 The contents of the configuration file This protected member should never be accessed by a module (and cannot be accessed unless the core is changed).
380 It will contain a pointer to the configuration file data with unneeded data (such as comments) stripped from it.
382 Definition at line <a class="el" href="modules_8h-source.html#l00526">526</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
384 Referenced by <a class="el" href="modules_8cpp-source.html#l00343">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00350">~ConfigReader()</a>. </td>
387 <a name="n1" doxytag="ConfigReader::error"></a><p>
388 <table width="100%" cellpadding="2" cellspacing="0" border="0">
391 <table cellpadding="0" cellspacing="0" border="0">
393 <td class="md" nowrap valign="top"> bool ConfigReader::error<code> [protected]</code>
398 <table cellspacing=5 cellpadding=0 border=0>
406 Used to store errors.
410 Definition at line <a class="el" href="modules_8h-source.html#l00529">529</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
412 Referenced by <a class="el" href="modules_8cpp-source.html#l00343">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00385">Verify()</a>. </td>
415 <hr>The documentation for this class was generated from the following files:<ul>
416 <li><a class="el" href="modules_8h-source.html">modules.h</a><li><a class="el" href="modules_8cpp-source.html">modules.cpp</a></ul>
417 <hr><address style="align: right;"><small>Generated on Fri Apr 30 13:23:28 2004 for InspIRCd by
418 <a href="http://www.doxygen.org/index.html">
419 <img src="doxygen.png" alt="doxygen" align="middle" border=0
420 width=110 height=53></a>1.3-rc3 </small></address>