]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - docs/module-doc/classConfigReader.html
1e56ef39b56cc8105676b8b2b4fb23821999c9ab
[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 colspan=2><br><h2>Protected Attributes</h2></td></tr>
38 <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>
39 <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>
40 <tr><td nowrap align=right valign=top>bool&nbsp;</td><td valign=bottom><a class="el" href="classConfigReader.html#n1">error</a></td></tr>
41 <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>
42 </table>
43 <hr><a name="_details"></a><h2>Detailed Description</h2>
44 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.
45 <p>
46 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. 
47 <p>
48
49 <p>
50 Definition at line <a class="el" href="modules_8h-source.html#l00469">469</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.<hr><h2>Constructor &amp; Destructor Documentation</h2>
51 <a name="a0" doxytag="ConfigReader::ConfigReader"></a><p>
52 <table width="100%" cellpadding="2" cellspacing="0" border="0">
53   <tr>
54     <td class="md">
55       <table cellpadding="0" cellspacing="0" border="0">
56         <tr>
57           <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
58           <td class="md" valign="top">(&nbsp;</td>
59           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
60           <td class="md" valign="top">)&nbsp;</td>
61           <td class="md" nowrap></td>
62         </tr>
63
64       </table>
65     </td>
66   </tr>
67 </table>
68 <table cellspacing=5 cellpadding=0 border=0>
69   <tr>
70     <td>
71       &nbsp;
72     </td>
73     <td>
74
75 <p>
76 Default constructor.
77 <p>
78 This constructor initialises the ConfigReader class to read the inspircd.conf file as specified when running ./configure.
79 <p>
80 Definition at line <a class="el" href="modules_8cpp-source.html#l00319">319</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
81 <p>
82 References <a class="el" href="modules_8h-source.html#l00477">cache</a>, and <a class="el" href="modules_8h-source.html#l00480">error</a>.
83 <p>
84 <div class="fragment"><pre>00320 {
85 00321         this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a> = <span class="keyword">new</span> std::stringstream(stringstream::in | stringstream::out);
86 00322         this-&gt;<a class="code" href="classConfigReader.html#n1">error</a> = LoadConf(CONFIG_FILE,this-&gt;cache);
87 00323 }
88 </pre></div>    </td>
89   </tr>
90 </table>
91 <a name="a1" doxytag="ConfigReader::ConfigReader"></a><p>
92 <table width="100%" cellpadding="2" cellspacing="0" border="0">
93   <tr>
94     <td class="md">
95       <table cellpadding="0" cellspacing="0" border="0">
96         <tr>
97           <td class="md" nowrap valign="top"> ConfigReader::ConfigReader </td>
98           <td class="md" valign="top">(&nbsp;</td>
99           <td class="md" nowrap valign="top">std::string&nbsp;</td>
100           <td class="mdname1" valign="top" nowrap>&nbsp; <em>filename</em>          </td>
101           <td class="md" valign="top">)&nbsp;</td>
102           <td class="md" nowrap></td>
103         </tr>
104
105       </table>
106     </td>
107   </tr>
108 </table>
109 <table cellspacing=5 cellpadding=0 border=0>
110   <tr>
111     <td>
112       &nbsp;
113     </td>
114     <td>
115
116 <p>
117 Overloaded constructor.
118 <p>
119 This constructor initialises the ConfigReader class to read a user-specified config file
120 <p>
121 Definition at line <a class="el" href="modules_8cpp-source.html#l00333">333</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
122 <p>
123 References <a class="el" href="modules_8h-source.html#l00477">cache</a>, and <a class="el" href="modules_8h-source.html#l00480">error</a>.
124 <p>
125 <div class="fragment"><pre>00334 {
126 00335         this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a> = <span class="keyword">new</span> std::stringstream(stringstream::in | stringstream::out);
127 00336         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>);
128 00337 };
129 </pre></div>    </td>
130   </tr>
131 </table>
132 <a name="a2" doxytag="ConfigReader::~ConfigReader"></a><p>
133 <table width="100%" cellpadding="2" cellspacing="0" border="0">
134   <tr>
135     <td class="md">
136       <table cellpadding="0" cellspacing="0" border="0">
137         <tr>
138           <td class="md" nowrap valign="top"> ConfigReader::~ConfigReader </td>
139           <td class="md" valign="top">(&nbsp;</td>
140           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
141           <td class="md" valign="top">)&nbsp;</td>
142           <td class="md" nowrap></td>
143         </tr>
144
145       </table>
146     </td>
147   </tr>
148 </table>
149 <table cellspacing=5 cellpadding=0 border=0>
150   <tr>
151     <td>
152       &nbsp;
153     </td>
154     <td>
155
156 <p>
157 Default destructor.
158 <p>
159 This method destroys the ConfigReader class.
160 <p>
161 Definition at line <a class="el" href="modules_8cpp-source.html#l00326">326</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
162 <p>
163 References <a class="el" href="modules_8h-source.html#l00477">cache</a>.
164 <p>
165 <div class="fragment"><pre>00327 {
166 00328         <span class="keywordflow">if</span> (this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a>)
167 00329                 <span class="keyword">delete</span> this-&gt;<a class="code" href="classConfigReader.html#n0">cache</a>;
168 00330 }
169 </pre></div>    </td>
170   </tr>
171 </table>
172 <hr><h2>Member Function Documentation</h2>
173 <a name="a4" doxytag="ConfigReader::Enumerate"></a><p>
174 <table width="100%" cellpadding="2" cellspacing="0" border="0">
175   <tr>
176     <td class="md">
177       <table cellpadding="0" cellspacing="0" border="0">
178         <tr>
179           <td class="md" nowrap valign="top"> int ConfigReader::Enumerate </td>
180           <td class="md" valign="top">(&nbsp;</td>
181           <td class="md" nowrap valign="top">std::string&nbsp;</td>
182           <td class="mdname1" valign="top" nowrap>&nbsp; <em>tag</em>          </td>
183           <td class="md" valign="top">)&nbsp;</td>
184           <td class="md" nowrap></td>
185         </tr>
186
187       </table>
188     </td>
189   </tr>
190 </table>
191 <table cellspacing=5 cellpadding=0 border=0>
192   <tr>
193     <td>
194       &nbsp;
195     </td>
196     <td>
197
198 <p>
199 Counts the number of times a given tag appears in the config file.
200 <p>
201 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.
202 <p>
203 Definition at line <a class="el" href="modules_8cpp-source.html#l00347">347</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
204 <p>
205 <div class="fragment"><pre>00348 {
206 00349         <span class="keywordflow">return</span> EnumConf(cache,tag.c_str());
207 00350 }
208 </pre></div>    </td>
209   </tr>
210 </table>
211 <a name="a3" doxytag="ConfigReader::ReadValue"></a><p>
212 <table width="100%" cellpadding="2" cellspacing="0" border="0">
213   <tr>
214     <td class="md">
215       <table cellpadding="0" cellspacing="0" border="0">
216         <tr>
217           <td class="md" nowrap valign="top"> std::string ConfigReader::ReadValue </td>
218           <td class="md" valign="top">(&nbsp;</td>
219           <td class="md" nowrap valign="top">std::string&nbsp;</td>
220           <td class="mdname" nowrap>&nbsp; <em>tag</em>, </td>
221         </tr>
222         <tr>
223           <td></td>
224           <td></td>
225           <td class="md" nowrap>std::string&nbsp;</td>
226           <td class="mdname" nowrap>&nbsp; <em>name</em>, </td>
227         </tr>
228         <tr>
229           <td></td>
230           <td></td>
231           <td class="md" nowrap>int&nbsp;</td>
232           <td class="mdname" nowrap>&nbsp; <em>index</em></td>
233         </tr>
234         <tr>
235           <td></td>
236           <td class="md">)&nbsp;</td>
237           <td class="md" colspan="2"></td>
238         </tr>
239
240       </table>
241     </td>
242   </tr>
243 </table>
244 <table cellspacing=5 cellpadding=0 border=0>
245   <tr>
246     <td>
247       &nbsp;
248     </td>
249     <td>
250
251 <p>
252 Retrieves a value from the config file.
253 <p>
254 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.
255 <p>
256 Definition at line <a class="el" href="modules_8cpp-source.html#l00339">339</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
257 <p>
258 <div class="fragment"><pre>00340 {
259 00341         <span class="keywordtype">char</span> val[MAXBUF];
260 00342         ReadConf(cache,tag.c_str(),name.c_str(),index,val);
261 00343         <span class="keywordflow">return</span> val;
262 00344 }
263 </pre></div>    </td>
264   </tr>
265 </table>
266 <a name="a5" doxytag="ConfigReader::Verify"></a><p>
267 <table width="100%" cellpadding="2" cellspacing="0" border="0">
268   <tr>
269     <td class="md">
270       <table cellpadding="0" cellspacing="0" border="0">
271         <tr>
272           <td class="md" nowrap valign="top"> bool ConfigReader::Verify </td>
273           <td class="md" valign="top">(&nbsp;</td>
274           <td class="mdname1" valign="top" nowrap>&nbsp;          </td>
275           <td class="md" valign="top">)&nbsp;</td>
276           <td class="md" nowrap></td>
277         </tr>
278
279       </table>
280     </td>
281   </tr>
282 </table>
283 <table cellspacing=5 cellpadding=0 border=0>
284   <tr>
285     <td>
286       &nbsp;
287     </td>
288     <td>
289
290 <p>
291 Returns true if a config file is valid.
292 <p>
293 This method is partially implemented and will only return false if the config file does not exist or could not be opened.
294 <p>
295 Definition at line <a class="el" href="modules_8cpp-source.html#l00353">353</a> of file <a class="el" href="modules_8cpp-source.html">modules.cpp</a>.
296 <p>
297 References <a class="el" href="modules_8h-source.html#l00480">error</a>.
298 <p>
299 <div class="fragment"><pre>00354 {
300 00355         <span class="keywordflow">return</span> this-&gt;<a class="code" href="classConfigReader.html#n1">error</a>;
301 00356 }
302 </pre></div>    </td>
303   </tr>
304 </table>
305 <hr><h2>Member Data Documentation</h2>
306 <a name="n0" doxytag="ConfigReader::cache"></a><p>
307 <table width="100%" cellpadding="2" cellspacing="0" border="0">
308   <tr>
309     <td class="md">
310       <table cellpadding="0" cellspacing="0" border="0">
311         <tr>
312           <td class="md" nowrap valign="top"> std::stringstream* ConfigReader::cache<code> [protected]</code>
313       </table>
314     </td>
315   </tr>
316 </table>
317 <table cellspacing=5 cellpadding=0 border=0>
318   <tr>
319     <td>
320       &nbsp;
321     </td>
322     <td>
323
324 <p>
325 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).
326 <p>
327 It will contain a pointer to the configuration file data with unneeded data (such as comments) stripped from it.
328 <p>
329 Definition at line <a class="el" href="modules_8h-source.html#l00477">477</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
330 <p>
331 Referenced by <a class="el" href="modules_8cpp-source.html#l00319">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00326">~ConfigReader()</a>.    </td>
332   </tr>
333 </table>
334 <a name="n1" doxytag="ConfigReader::error"></a><p>
335 <table width="100%" cellpadding="2" cellspacing="0" border="0">
336   <tr>
337     <td class="md">
338       <table cellpadding="0" cellspacing="0" border="0">
339         <tr>
340           <td class="md" nowrap valign="top"> bool ConfigReader::error<code> [protected]</code>
341       </table>
342     </td>
343   </tr>
344 </table>
345 <table cellspacing=5 cellpadding=0 border=0>
346   <tr>
347     <td>
348       &nbsp;
349     </td>
350     <td>
351
352 <p>
353 Used to store errors.
354 <p>
355
356 <p>
357 Definition at line <a class="el" href="modules_8h-source.html#l00480">480</a> of file <a class="el" href="modules_8h-source.html">modules.h</a>.
358 <p>
359 Referenced by <a class="el" href="modules_8cpp-source.html#l00319">ConfigReader()</a>, and <a class="el" href="modules_8cpp-source.html#l00353">Verify()</a>.    </td>
360   </tr>
361 </table>
362 <hr>The documentation for this class was generated from the following files:<ul>
363 <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>
364 <hr><address style="align: right;"><small>Generated on Wed Apr 7 19:20:37 2004 for InspIRCd by
365 <a href="http://www.doxygen.org/index.html">
366 <img src="doxygen.png" alt="doxygen" align="middle" border=0 
367 width=110 height=53></a>1.3-rc3 </small></address>
368 </body>
369 </html>