]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classConfigReader.html
More documentation updates
[user/henk/code/inspircd.git] / docs / module-doc / classConfigReader.html
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">
5 </head><body>
6 <!-- Generated by Doxygen 1.3-rc3 -->
7 <center>
8 <a class="qindex" href="main.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; </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>
11 <p>
12 <code>#include &lt;<a class="el" href="modules_8h-source.html">modules.h</a>&gt;</code>
13 <p>
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="">
17 </map>
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="">
21 </map>
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>
23 <tr><td></td></tr>
24 <tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
25 <tr><td nowrap align=right valign=top>&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a0">ConfigReader</a> ()</td></tr>
26 <tr><td>&nbsp;</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>&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a1">ConfigReader</a> (std::string filename)</td></tr>
28 <tr><td>&nbsp;</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>&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a2">~ConfigReader</a> ()</td></tr>
30 <tr><td>&nbsp;</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&nbsp;</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>&nbsp;</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&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a4">Enumerate</a> (std::string tag)</td></tr>
34 <tr><td>&nbsp;</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&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a5">Verify</a> ()</td></tr>
36 <tr><td>&nbsp;</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&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#a6">EnumerateValues</a> (std::string tag, int index)</td></tr>
38 <tr><td>&nbsp;</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 *&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#n0">cache</a></td></tr>
41 <tr><td>&nbsp;</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&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#n1">error</a></td></tr>
43 <tr><td>&nbsp;</td><td><font size=-1><em>Used to store errors.</em> <a href="#n1"></a><em></em></font><br><br></td></tr>
44 </table>
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.
47 <p>
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. 
49 <p>
50
51 <p>
52 Definition at line <a class="el" href="modules_8h-source.html#l00497">497</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2>
53 <a name="a0" doxytag="ConfigReader::ConfigReader"></a><p>
54 <table width="100%" cellpadding="2" cellspacing="0" border="0">
55   <tr>
56     <td class="md">
57       <table cellpadding="0" cellspacing="0" border="0">
58         <tr>
59           <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
60           <td class="md" valign="top">(&nbsp;</td>
61           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
62           <td class="md" valign="top">)&nbsp;</td>
63           <td class="md" nowrap></td>
64         </tr>
65
66       </table>
67     </td>
68   </tr>
69 </table>
70 <table cellspacing=5 cellpadding=0 border=0>
71   <tr>
72     <td>
73       &nbsp;
74     </td>
75     <td>
76
77 <p>
78 Default constructor.
79 <p>
80 This constructor initialises the ConfigReader class to read the inspircd.conf file as specified when running ./configure.
81 <p>
82 Definition at line <a class="el" href="modules_8cpp-source.html#l00334">334</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
83 <p>
84 References <a class="el" href="modules_8h-source.html#l00505">cache</a>, and <a class="el" href="modules_8h-source.html#l00508">error</a>.
85 <p>
86 <div class="fragment"><pre>00335 {
87 00336         this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
88 00337         this-&gt;<a class="code" href="classConfigReader.html#n1">error</a> = LoadConf(CONFIG_FILE,this-&gt;cache);
89 00338 }
90 </pre></div>    </td>
91   </tr>
92 </table>
93 <a name="a1" doxytag="ConfigReader::ConfigReader"></a><p>
94 <table width="100%" cellpadding="2" cellspacing="0" border="0">
95   <tr>
96     <td class="md">
97       <table cellpadding="0" cellspacing="0" border="0">
98         <tr>
99           <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
100           <td class="md" valign="top">(&nbsp;</td>
101           <td class="md" nowrap valign="top">std::string&nbsp;</td>
102           <td class="mdname1" valign="top" nowrap>&nbsp; <em>filename</em>          </td>
103           <td class="md" valign="top">)&nbsp;</td>
104           <td class="md" nowrap></td>
105         </tr>
106
107       </table>
108     </td>
109   </tr>
110 </table>
111 <table cellspacing=5 cellpadding=0 border=0>
112   <tr>
113     <td>
114       &nbsp;
115     </td>
116     <td>
117
118 <p>
119 Overloaded constructor.
120 <p>
121 This constructor initialises the ConfigReader class to read a user-specified config file
122 <p>
123 Definition at line <a class="el" href="modules_8cpp-source.html#l00348">348</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
124 <p>
125 References <a class="el" href="modules_8h-source.html#l00505">cache</a>, and <a class="el" href="modules_8h-source.html#l00508">error</a>.
126 <p>
127 <div class="fragment"><pre>00349 {
128 00350         this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a> = <span class="keyword">new</span> std::stringstream(std::stringstream::in | std::stringstream::out);
129 00351         this-&gt;<a class="code" href="classConfigReader.html#n1">error</a> = LoadConf(filename.c_str(),this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a>);
130 00352 };
131 </pre></div>    </td>
132   </tr>
133 </table>
134 <a name="a2" doxytag="ConfigReader::~ConfigReader"></a><p>
135 <table width="100%" cellpadding="2" cellspacing="0" border="0">
136   <tr>
137     <td class="md">
138       <table cellpadding="0" cellspacing="0" border="0">
139         <tr>
140           <td class="md" nowrap valign="top"> ConfigReader::~ConfigReader </td>
141           <td class="md" valign="top">(&nbsp;</td>
142           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
143           <td class="md" valign="top">)&nbsp;</td>
144           <td class="md" nowrap></td>
145         </tr>
146
147       </table>
148     </td>
149   </tr>
150 </table>
151 <table cellspacing=5 cellpadding=0 border=0>
152   <tr>
153     <td>
154       &nbsp;
155     </td>
156     <td>
157
158 <p>
159 Default destructor.
160 <p>
161 This method destroys the ConfigReader class.
162 <p>
163 Definition at line <a class="el" href="modules_8cpp-source.html#l00341">341</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
164 <p>
165 References <a class="el" href="modules_8h-source.html#l00505">cache</a>.
166 <p>
167 <div class="fragment"><pre>00342 {
168 00343         <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a>)
169 00344                 <span class="keyword">delete</span> this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a>;
170 00345 }
171 </pre></div>    </td>
172   </tr>
173 </table>
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">
177   <tr>
178     <td class="md">
179       <table cellpadding="0" cellspacing="0" border="0">
180         <tr>
181           <td class="md" nowrap valign="top"> int ConfigReader::Enumerate </td>
182           <td class="md" valign="top">(&nbsp;</td>
183           <td class="md" nowrap valign="top">std::string&nbsp;</td>
184           <td class="mdname1" valign="top" nowrap>&nbsp; <em>tag</em>          </td>
185           <td class="md" valign="top">)&nbsp;</td>
186           <td class="md" nowrap></td>
187         </tr>
188
189       </table>
190     </td>
191   </tr>
192 </table>
193 <table cellspacing=5 cellpadding=0 border=0>
194   <tr>
195     <td>
196       &nbsp;
197     </td>
198     <td>
199
200 <p>
201 Counts the number of times a given tag appears in the config file.
202 <p>
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.
204 <p>
205 Definition at line <a class="el" href="modules_8cpp-source.html#l00362">362</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
206 <p>
207 <div class="fragment"><pre>00363 {
208 00364         <span class="keywordflow">return</span> EnumConf(cache,tag.c_str());
209 00365 }
210 </pre></div>    </td>
211   </tr>
212 </table>
213 <a name="a6" doxytag="ConfigReader::EnumerateValues"></a><p>
214 <table width="100%" cellpadding="2" cellspacing="0" border="0">
215   <tr>
216     <td class="md">
217       <table cellpadding="0" cellspacing="0" border="0">
218         <tr>
219           <td class="md" nowrap valign="top"> int ConfigReader::EnumerateValues </td>
220           <td class="md" valign="top">(&nbsp;</td>
221           <td class="md" nowrap valign="top">std::string&nbsp;</td>
222           <td class="mdname" nowrap>&nbsp; <em>tag</em>, </td>
223         </tr>
224         <tr>
225           <td></td>
226           <td></td>
227           <td class="md" nowrap>int&nbsp;</td>
228           <td class="mdname" nowrap>&nbsp; <em>index</em></td>
229         </tr>
230         <tr>
231           <td></td>
232           <td class="md">)&nbsp;</td>
233           <td class="md" colspan="2"></td>
234         </tr>
235
236       </table>
237     </td>
238   </tr>
239 </table>
240 <table cellspacing=5 cellpadding=0 border=0>
241   <tr>
242     <td>
243       &nbsp;
244     </td>
245     <td>
246
247 <p>
248 Returns the number of items within a tag.
249 <p>
250 For example if the tag was &lt;test tag="blah" data="foo"&gt; then this function would return 2. Spaces and newlines both qualify as valid seperators between values.
251 <p>
252 Definition at line <a class="el" href="modules_8cpp-source.html#l00367">367</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
253 <p>
254 <div class="fragment"><pre>00368 {
255 00369         <span class="keywordflow">return</span> EnumValues(cache, tag.c_str(), index);
256 00370 }
257 </pre></div>    </td>
258   </tr>
259 </table>
260 <a name="a3" doxytag="ConfigReader::ReadValue"></a><p>
261 <table width="100%" cellpadding="2" cellspacing="0" border="0">
262   <tr>
263     <td class="md">
264       <table cellpadding="0" cellspacing="0" border="0">
265         <tr>
266           <td class="md" nowrap valign="top"> std::string ConfigReader::ReadValue </td>
267           <td class="md" valign="top">(&nbsp;</td>
268           <td class="md" nowrap valign="top">std::string&nbsp;</td>
269           <td class="mdname" nowrap>&nbsp; <em>tag</em>, </td>
270         </tr>
271         <tr>
272           <td></td>
273           <td></td>
274           <td class="md" nowrap>std::string&nbsp;</td>
275           <td class="mdname" nowrap>&nbsp; <em>name</em>, </td>
276         </tr>
277         <tr>
278           <td></td>
279           <td></td>
280           <td class="md" nowrap>int&nbsp;</td>
281           <td class="mdname" nowrap>&nbsp; <em>index</em></td>
282         </tr>
283         <tr>
284           <td></td>
285           <td class="md">)&nbsp;</td>
286           <td class="md" colspan="2"></td>
287         </tr>
288
289       </table>
290     </td>
291   </tr>
292 </table>
293 <table cellspacing=5 cellpadding=0 border=0>
294   <tr>
295     <td>
296       &nbsp;
297     </td>
298     <td>
299
300 <p>
301 Retrieves a value from the config file.
302 <p>
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.
304 <p>
305 Definition at line <a class="el" href="modules_8cpp-source.html#l00354">354</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
306 <p>
307 <div class="fragment"><pre>00355 {
308 00356         <span class="keywordtype">char</span> val[MAXBUF];
309 00357         ReadConf(cache,tag.c_str(),name.c_str(),index,val);
310 00358         <span class="keywordflow">return</span> val;
311 00359 }
312 </pre></div>    </td>
313   </tr>
314 </table>
315 <a name="a5" doxytag="ConfigReader::Verify"></a><p>
316 <table width="100%" cellpadding="2" cellspacing="0" border="0">
317   <tr>
318     <td class="md">
319       <table cellpadding="0" cellspacing="0" border="0">
320         <tr>
321           <td class="md" nowrap valign="top"> bool ConfigReader::Verify </td>
322           <td class="md" valign="top">(&nbsp;</td>
323           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
324           <td class="md" valign="top">)&nbsp;</td>
325           <td class="md" nowrap></td>
326         </tr>
327
328       </table>
329     </td>
330   </tr>
331 </table>
332 <table cellspacing=5 cellpadding=0 border=0>
333   <tr>
334     <td>
335       &nbsp;
336     </td>
337     <td>
338
339 <p>
340 Returns true if a config file is valid.
341 <p>
342 This method is partially implemented and will only return false if the config file does not exist or could not be opened.
343 <p>
344 Definition at line <a class="el" href="modules_8cpp-source.html#l00372">372</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
345 <p>
346 References <a class="el" href="modules_8h-source.html#l00508">error</a>.
347 <p>
348 <div class="fragment"><pre>00373 {
349 00374         <span class="keywordflow">return</span> this-&gt;<a class="code" href="classConfigReader.html#n1">error</a>;
350 00375 }
351 </pre></div>    </td>
352   </tr>
353 </table>
354 <hr><h2>Member Data Documentation</h2>
355 <a name="n0" doxytag="ConfigReader::cache"></a><p>
356 <table width="100%" cellpadding="2" cellspacing="0" border="0">
357   <tr>
358     <td class="md">
359       <table cellpadding="0" cellspacing="0" border="0">
360         <tr>
361           <td class="md" nowrap valign="top"> std::stringstream* ConfigReader::cache<code> [protected]</code>
362       </table>
363     </td>
364   </tr>
365 </table>
366 <table cellspacing=5 cellpadding=0 border=0>
367   <tr>
368     <td>
369       &nbsp;
370     </td>
371     <td>
372
373 <p>
374 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).
375 <p>
376 It will contain a pointer to the configuration file data with unneeded data (such as comments) stripped from it.
377 <p>
378 Definition at line <a class="el" href="modules_8h-source.html#l00505">505</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
379 <p>
380 Referenced by <a class="el" href="modules_8cpp-source.html#l00334">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00341">~ConfigReader()</a>.    </td>
381   </tr>
382 </table>
383 <a name="n1" doxytag="ConfigReader::error"></a><p>
384 <table width="100%" cellpadding="2" cellspacing="0" border="0">
385   <tr>
386     <td class="md">
387       <table cellpadding="0" cellspacing="0" border="0">
388         <tr>
389           <td class="md" nowrap valign="top"> bool ConfigReader::error<code> [protected]</code>
390       </table>
391     </td>
392   </tr>
393 </table>
394 <table cellspacing=5 cellpadding=0 border=0>
395   <tr>
396     <td>
397       &nbsp;
398     </td>
399     <td>
400
401 <p>
402 Used to store errors.
403 <p>
404
405 <p>
406 Definition at line <a class="el" href="modules_8h-source.html#l00508">508</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
407 <p>
408 Referenced by <a class="el" href="modules_8cpp-source.html#l00334">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00372">Verify()</a>.    </td>
409   </tr>
410 </table>
411 <hr>The documentation for this class was generated from the following files:<ul>
412 <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>
413 <hr><address style="align: right;"><small>Generated on Sat Apr 17 13:33:53 2004 for InspIRCd by
414 <a href="http://www.doxygen.org/index.html">
415 <img src="doxygen.png" alt="doxygen" align="middle" border=0 
416 width=110 height=53></a>1.3-rc3 </small></address>
417 </body>
418 </html>