diff options
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/a02401.html | 1630 |
1 files changed, 1630 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a02401.html b/docs/doxygen/nel/a02401.html new file mode 100644 index 00000000..2e5c1ba6 --- /dev/null +++ b/docs/doxygen/nel/a02401.html @@ -0,0 +1,1630 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>NeL: NLMISC::CConfigFile class Reference</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +</head><body> +<!-- Generated by Doxygen 1.3.6 --> +<div class="qindex"> <form class="search" action="search.php" method="get"> +<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">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div> +<h1>NLMISC::CConfigFile Class Reference</h1><code>#include <<a class="el" href="a05598.html">config_file.h</a>></code> +<p> +<hr><a name="_details"></a><h2>Detailed Description</h2> +<a class="el" href="a02401.html">CConfigFile</a> class. Useful when you want to have a configuration file with variables. It manages integers, real (double), and string basic types. A variable can be an array of basic type. In this case, all elements of the array must have the same type.<p> +If you setup the global callback before loading, it'll be call after the <a class="el" href="a02401.html#NLMISC_1_1CConfigFilea12">load()</a> function.<p> +Example: <pre class="fragment"><div> <span class="keywordflow">try</span> + { + <a class="code" href="a02401.html">CConfigFile</a> cf; + + <span class="comment">// Load and parse "test.txt" file</span> + cf.<a class="code" href="a02401.html#NLMISC_1_1CConfigFilea12">load</a> (<span class="stringliteral">"test.txt"</span>); + + <span class="comment">// Attach a callback to the var1 variable. When the var1 will changed, this cvar1cb function will be called</span> + cf.<a class="code" href="a02401.html#NLMISC_1_1CConfigFilea17">setCallback</a> (<span class="stringliteral">"var1"</span>, var1cb); + + <span class="comment">// Get the foo variable (suppose it's a string variable)</span> + <a class="code" href="a02402.html">CConfigFile::CVar</a> &foo = cf.<a class="code" href="a02401.html#NLMISC_1_1CConfigFilea9">getVar</a> (<span class="stringliteral">"foo"</span>); + + <span class="comment">// Display the content of the variable</span> + printf (<span class="stringliteral">"foo = %s\n"</span>, foo.<a class="code" href="a02402.html#NLMISC_1_1CConfigFile_1_1CVarz1933_3">asString</a> ().c_str ()); + + <span class="comment">// Get the bar variable (suppose it's an array of int)</span> + <a class="code" href="a02402.html">CConfigFile::CVar</a> &bar = cf.<a class="code" href="a02401.html#NLMISC_1_1CConfigFilea9">getVar</a> (<span class="stringliteral">"bar"</span>); + + <span class="comment">// Display the content of the all elements of the bar variable</span> + printf (<span class="stringliteral">"bar have %d elements : \n"</span>, bar.<a class="code" href="a02402.html#NLMISC_1_1CConfigFile_1_1CVara4">size</a> ()); + <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < bar.<a class="code" href="a02402.html#NLMISC_1_1CConfigFile_1_1CVara4">size</a> (); i++) + printf (<span class="stringliteral">"%d "</span>, bar.<a class="code" href="a02402.html#NLMISC_1_1CConfigFile_1_1CVarz1933_2">asInt</a> (i)); + printf(<span class="stringliteral">"\n"</span>); + } + <span class="keywordflow">catch</span> (EConfigFile &e) + { + <span class="comment">// Something goes wrong... catch that</span> + printf (<span class="stringliteral">"%s\n"</span>, e.what ()); + } + * +</div></pre><p> +Example of config file: <pre class="fragment"><div> <span class="comment">// one line comment</span> + / * big <a class="code" href="a04115.html#a118">comment</a> + on more than one <a class="code" href="a05377.html#a3">line</a> * / + + var1 = 123; <span class="comment">// var1 type:int, value:123</span> + var2 = <span class="stringliteral">"456.25"</span>; <span class="comment">// var2 type:string, value:"456.25"</span> + var3 = 123.123; <span class="comment">// var3 type:real, value:123.123</span> + + <span class="comment">// the resulting type is type of the first left value</span> + var4 = 123.123 + 2; <span class="comment">// var4 type:real, value:125.123</span> + var5 = 123 + 2.1; <span class="comment">// var5 type:int, value:125</span> + + var6 = (-112+1) * 3 - 14; <span class="comment">// var6 type:int, value:-347</span> + + var7 = var1 + 1; <span class="comment">// var7 type:int, value:124</span> + + var8 = var2 + 10; <span class="comment">// var8 type:string, value:456.2510 (convert 10 into a string and concat it)</span> + var9 = 10.15 + var2; <span class="comment">// var9 type:real, value:466.4 (convert var2 into a real and add it)</span> + + var10 = { 10.0, 51.1 }; <span class="comment">// var10 type:realarray, value:{10.0,51.1}</span> + var11 = { <span class="stringliteral">"str1"</span>, <span class="stringliteral">"str2"</span>, <span class="stringliteral">"str3"</span> }; <span class="comment">// var11 type:stringarray, value:{"str1", "str2", "str3"}</span> + + var12 = { 10+var1, var1-var7 }; <span class="comment">// var12 type:intarray, value:{133,-1}</span> + * +</div></pre><p> +Operators are '+', '-', '*', '/'. You can't use operators on a array variable, for example, you can't do =var12+1. If you have 2 variables with the same name, the first value will be remplaced by the second one.<p> +<dl compact><dt><b><a class="el" href="bug.html#_bug000001">Bug:</a></b></dt><dd>if you terminate the config file with a comment without carriage returns it'll generate an exception, add a carriage returns </dd></dl> +<dl compact><dt><b>Author:</b></dt><dd>Vianney Lecroart <p> +Nevrax France </dd></dl> +<dl compact><dt><b>Date:</b></dt><dd>2000 </dd></dl> + +<p> + +<p> +Definition at line <a class="el" href="a05598.html#l00119">119</a> of file <a class="el" href="a05598.html">config_file.h</a>.<table border=0 cellpadding=0 cellspacing=0> +<tr><td></td></tr> +<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea0">CConfigFile</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea1">clear</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Clear all the variable array (including information on variable callback etc). <a href="#NLMISC_1_1CConfigFilea1"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea2">clearVars</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">set to 0 or "" all variable in the array (but not destroy them) <a href="#NLMISC_1_1CConfigFilea2"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea3">display</a> (<a class="el" href="a02813.html">CLog</a> *log) const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">display all variables with nlinfo (debug use) <a href="#NLMISC_1_1CConfigFilea3"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea4">display</a> () const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">display all variables with nlinfo (debug use) <a href="#NLMISC_1_1CConfigFilea4"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea5">exists</a> (const std::string &varName)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Return true if the variable exists, false otherwise. <a href="#NLMISC_1_1CConfigFilea5"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>std::string </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea6">getFilename</a> () const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">returns the config file name <a href="#NLMISC_1_1CConfigFilea6"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a15">uint</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea7">getNumVar</a> () const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Get the variable count. <a href="#NLMISC_1_1CConfigFilea7"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02402.html">CVar</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea8">getVar</a> (<a class="el" href="a04558.html#a15">uint</a> varId)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Get a variable. <a href="#NLMISC_1_1CConfigFilea8"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02402.html">CVar</a> & </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea9">getVar</a> (const std::string &varName)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Get a variable with the variable name. <a href="#NLMISC_1_1CConfigFilea9"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02402.html">CVar</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea10">getVarPtr</a> (const std::string &varName)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Get a variable pointer with the variable name, without throwing exception. Return NULL if not found. <a href="#NLMISC_1_1CConfigFilea10"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02402.html">CVar</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea11">insertVar</a> (const std::string &varName, const <a class="el" href="a02402.html">CVar</a> &varToCopy)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Add a variable. If the variable already exit, return it. <a href="#NLMISC_1_1CConfigFilea11"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea12">load</a> (const std::string &fileName)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">load and parse the file <a href="#NLMISC_1_1CConfigFilea12"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea13">loaded</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns true if the file has been loaded. <a href="#NLMISC_1_1CConfigFilea13"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea14">reparse</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">reload and reparse the file <a href="#NLMISC_1_1CConfigFilea14"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea15">save</a> () const </td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">save the config file <a href="#NLMISC_1_1CConfigFilea15"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea16">setCallback</a> (const std::string &VarName, void(*cb)(<a class="el" href="a02402.html">CConfigFile::CVar</a> &var))</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">set a callback function to a variable, it will be called when this variable is modified <a href="#NLMISC_1_1CConfigFilea16"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea17">setCallback</a> (void(*cb)())</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">set a callback function that is called when the config file is modified <a href="#NLMISC_1_1CConfigFilea17"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>virtual </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilea18">~CConfigFile</a> ()</td></tr> + +<tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilee0">checkConfigFiles</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Internal use only. <a href="#NLMISC_1_1CConfigFilee0"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilee1">setTimeout</a> (<a class="el" href="a04558.html#a11">uint32</a> timeout)</td></tr> + +<tr><td colspan=2><br><h2>Data Fields</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< std::string > </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFileo0">UnknownVariables</a></td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">contains the variable names that <a class="el" href="a02401.html#NLMISC_1_1CConfigFilea9">getVar()</a> and <a class="el" href="a02401.html#NLMISC_1_1CConfigFilea10">getVarPtr()</a> tried to access but not present in the cfg <a href="#NLMISC_1_1CConfigFileo0"></a><br><br></td></tr> +<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void(* </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFiler0">_Callback</a> )()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Internal use only. <a href="#NLMISC_1_1CConfigFiler0"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< <a class="el" href="a02402.html">CVar</a> > </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a></td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Internal use only. <a href="#NLMISC_1_1CConfigFiler1"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< std::string > </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFiler2">FileNames</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< <a class="el" href="a04558.html#a11">uint32</a> > </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFiler3">LastModified</a></td></tr> + +<tr><td colspan=2><br><h2>Static Private Attributes</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< <a class="el" href="a02401.html">CConfigFile</a> * > * </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilev0">_ConfigFiles</a> = NULL</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a11">uint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02401.html#NLMISC_1_1CConfigFilev1">_Timeout</a> = 1000</td></tr> + +</table> +<hr><h2>Constructor & Destructor Documentation</h2> +<a class="anchor" name="NLMISC_1_1CConfigFilea0" doxytag="NLMISC::CConfigFile::CConfigFile" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLMISC::CConfigFile::CConfigFile </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05598.html#l00202">202</a> of file <a class="el" href="a05598.html">config_file.h</a>. +<p> +References <a class="el" href="a02401.html#NLMISC_1_1CConfigFiler0">_Callback</a>. +<p> +<div class="fragment"><pre>00202 : <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler0">_Callback</a>(NULL) {} +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea18" doxytag="NLMISC::CConfigFile::~CConfigFile" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLMISC::CConfigFile::~<a class="el" href="a02401.html">CConfigFile</a> </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [virtual]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00227">227</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05597.html#l00677">_ConfigFiles</a>. +<p> +<div class="fragment"><pre>00228 { +00229 <span class="keywordflow">if</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFilev0">_ConfigFiles</a> == NULL || (*_ConfigFiles).empty ()) <span class="keywordflow">return</span>; +00230 +00231 vector<CConfigFile *>::iterator it = find ((*_ConfigFiles).begin (), (*_ConfigFiles).end (), <span class="keyword">this</span>); +00232 <span class="keywordflow">if</span> (it != (*_ConfigFiles).end ()) +00233 { +00234 (*_ConfigFiles).erase (it); +00235 } +00236 +00237 <span class="keywordflow">if</span> ((*_ConfigFiles).empty()) +00238 { +00239 <span class="keyword">delete</span> <a class="code" href="a02401.html#NLMISC_1_1CConfigFilev0">_ConfigFiles</a>; +00240 <a class="code" href="a02401.html#NLMISC_1_1CConfigFilev0">_ConfigFiles</a> = NULL; +00241 } +00242 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Member Function Documentation</h2> +<a class="anchor" name="NLMISC_1_1CConfigFilee0" doxytag="NLMISC::CConfigFile::checkConfigFiles" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::checkConfigFiles </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Internal use only. +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00681">681</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05597.html#l00677">_ConfigFiles</a>, <a class="el" href="a05597.html#l00679">_Timeout</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05622.html#l00135">nlwarning</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +<div class="fragment"><pre>00682 { +00683 <span class="keywordflow">if</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFilev0">_ConfigFiles</a> == NULL) <span class="keywordflow">return</span>; +00684 +00685 <span class="keyword">static</span> time_t LastCheckTime = time (NULL); +00686 <span class="keywordflow">if</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFilev1">_Timeout</a> > 0 && (<span class="keywordtype">float</span>)(time (NULL) - LastCheckTime)*1000.0f < (<span class="keywordtype">float</span>)<a class="code" href="a02401.html#NLMISC_1_1CConfigFilev1">_Timeout</a>) <span class="keywordflow">return</span>; +00687 +00688 LastCheckTime = time (NULL); +00689 +00690 <span class="keywordtype">bool</span> needReparse; +00691 <span class="keywordflow">for</span> (vector<CConfigFile *>::iterator it = (*_ConfigFiles).begin (); it != (*_ConfigFiles).end (); it++) +00692 { +00693 needReparse = <span class="keyword">false</span>; +00694 <a class="code" href="a04199.html#a6">nlassert</a> ((*it)->FileNames.size() == (*it)->LastModified.size()); +00695 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < (*it)->FileNames.size(); i++) +00696 { +00697 <span class="keywordflow">if</span> ((*it)->LastModified[i] != CFile::getFileModificationDate((*it)->FileNames[i])) +00698 { +00699 needReparse = <span class="keyword">true</span>; +00700 (*it)->LastModified[i] = CFile::getFileModificationDate((*it)->FileNames[i]); +00701 } +00702 } +00703 <span class="keywordflow">if</span> (needReparse) +00704 { +00705 <span class="keywordflow">try</span> +00706 { +00707 (*it)->reparse (); +00708 } +00709 <span class="keywordflow">catch</span> (EConfigFile &e) +00710 { +00711 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"CF: Exception will re-read modified config file '%s': %s"</span>, (*it)->getFilename().c_str(), e.what ()); +00712 } +00713 } +00714 } +00715 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea1" doxytag="NLMISC::CConfigFile::clear" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::clear </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Clear all the variable array (including information on variable callback etc). +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00722">722</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +<div class="fragment"><pre>00723 { +00724 <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.clear (); +00725 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea2" doxytag="NLMISC::CConfigFile::clearVars" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::clearVars </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +set to 0 or "" all variable in the array (but not destroy them) +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00727">727</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +<div class="fragment"><pre>00728 { +00729 <span class="keywordflow">for</span> (vector<CVar>::iterator it = <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.begin (); it != <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.end (); it++) +00730 { +00731 (*it).Type = CVar::T_UNKNOWN; +00732 } +00733 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea3" doxytag="NLMISC::CConfigFile::display" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::display </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a02813.html">CLog</a> * </td> + <td class="mdname1" valign="top" nowrap> <em>log</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const</td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +display all variables with nlinfo (debug use) +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00559">559</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05621.html#l00900">NLMISC::createDebug()</a>, <a class="el" href="a05943.html#l00467">NLMISC::CLog::displayRaw()</a>, <a class="el" href="a05943.html#l00442">NLMISC::CLog::displayRawNL()</a>, and <a class="el" href="a05598.html#l00258">getFilename()</a>. +<p> +<div class="fragment"><pre>00560 { +00561 <a class="code" href="a05378.html#a298">createDebug</a> (); +00562 +00563 log->displayRawNL (<span class="stringliteral">"Config file %s have %d variables and %d root config file:"</span>, <a class="code" href="a02401.html#NLMISC_1_1CConfigFilea6">getFilename</a>().c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.size(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler2">FileNames</a>.size()-1); +00564 log->displayRaw (<span class="stringliteral">"Root config files: "</span>); +00565 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 1; i < (<span class="keywordtype">int</span>)<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler2">FileNames</a>.size(); i++) +00566 { +00567 log->displayRaw (FileNames[i].c_str()); +00568 } +00569 log->displayRawNL (<span class="stringliteral">""</span>); +00570 log->displayRawNL (<span class="stringliteral">"------------------------------------------------------"</span>); +00571 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i < (<span class="keywordtype">int</span>)<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.size(); i++) +00572 { +00573 log->displayRaw ((_Vars[i].Callback==NULL)?<span class="stringliteral">" "</span>:<span class="stringliteral">"CB "</span>); +00574 log->displayRaw ((_Vars[i].Root)?<span class="stringliteral">"Root "</span>:<span class="stringliteral">" "</span>); +00575 <span class="keywordflow">if</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Comp) +00576 { +00577 <span class="keywordflow">switch</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Type) +00578 { +00579 <span class="keywordflow">case</span> CConfigFile::CVar::T_INT: +00580 { +00581 log->displayRaw (<span class="stringliteral">"%-20s { "</span>, _Vars[i].Name.c_str()); +00582 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> it=0; it < (<span class="keywordtype">int</span>)<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].IntValues.size(); it++) +00583 { +00584 log->displayRaw (<span class="stringliteral">"'%d' "</span>, _Vars[i].IntValues[it]); +00585 } +00586 log->displayRawNL (<span class="stringliteral">"}"</span>); +00587 <span class="keywordflow">break</span>; +00588 } +00589 <span class="keywordflow">case</span> CConfigFile::CVar::T_STRING: +00590 { +00591 log->displayRaw (<span class="stringliteral">"%-20s { "</span>, _Vars[i].Name.c_str()); +00592 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> st=0; st < (<span class="keywordtype">int</span>)<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].StrValues.size(); st++) +00593 { +00594 log->displayRaw (<span class="stringliteral">"\"%s\" "</span>, _Vars[i].StrValues[st].c_str()); +00595 } +00596 log->displayRawNL (<span class="stringliteral">"}"</span>); +00597 <span class="keywordflow">break</span>; +00598 } +00599 <span class="keywordflow">case</span> CConfigFile::CVar::T_REAL: +00600 { +00601 log->displayRaw (<span class="stringliteral">"%-20s { "</span> , _Vars[i].Name.c_str()); +00602 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> rt=0; rt < (<span class="keywordtype">int</span>)<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].RealValues.size(); rt++) +00603 { +00604 log->displayRaw (<span class="stringliteral">"`%f` "</span>, _Vars[i].RealValues[rt]); +00605 } +00606 log->displayRawNL (<span class="stringliteral">"}"</span>); +00607 <span class="keywordflow">break</span>; +00608 } +00609 <span class="keywordflow">case</span> CConfigFile::CVar::T_UNKNOWN: +00610 { +00611 log->displayRawNL (<span class="stringliteral">"%-20s { }"</span> , _Vars[i].Name.c_str()); +00612 <span class="keywordflow">break</span>; +00613 } +00614 <span class="keywordflow">default</span>: +00615 { +00616 log->displayRawNL (<span class="stringliteral">"%-20s <default case comp> (%d)"</span> , _Vars[i].Name.c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Type); +00617 <span class="keywordflow">break</span>; +00618 } +00619 } +00620 } +00621 <span class="keywordflow">else</span> +00622 { +00623 <span class="keywordflow">switch</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Type) +00624 { +00625 <span class="keywordflow">case</span> CConfigFile::CVar::T_INT: +00626 log->displayRawNL (<span class="stringliteral">"%-20s '%d'"</span>, _Vars[i].Name.c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].IntValues[0]); +00627 <span class="keywordflow">break</span>; +00628 <span class="keywordflow">case</span> CConfigFile::CVar::T_STRING: +00629 log->displayRawNL (<span class="stringliteral">"%-20s \"%s\""</span>, _Vars[i].Name.c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].StrValues[0].c_str()); +00630 <span class="keywordflow">break</span>; +00631 <span class="keywordflow">case</span> CConfigFile::CVar::T_REAL: +00632 log->displayRawNL (<span class="stringliteral">"%-20s `%f`"</span>, _Vars[i].Name.c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].RealValues[0]); +00633 <span class="keywordflow">break</span>; +00634 <span class="keywordflow">case</span> CConfigFile::CVar::T_UNKNOWN: +00635 log->displayRawNL (<span class="stringliteral">"%-20s <Unknown>"</span>, _Vars[i].Name.c_str()); +00636 <span class="keywordflow">break</span>; +00637 <span class="keywordflow">default</span>: +00638 { +00639 log->displayRawNL (<span class="stringliteral">"%-20s <default case> (%d)"</span> , _Vars[i].Name.c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Type); +00640 <span class="keywordflow">break</span>; +00641 } +00642 } +00643 } +00644 } +00645 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea4" doxytag="NLMISC::CConfigFile::display" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::display </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const</td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +display all variables with nlinfo (debug use) +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00554">554</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05621.html#l00091">NLMISC::InfoLog</a>. +<p> +<div class="fragment"><pre>00555 { +00556 <a class="code" href="a02401.html#NLMISC_1_1CConfigFilea4">display</a> (InfoLog); +00557 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea5" doxytag="NLMISC::CConfigFile::exists" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CConfigFile::exists </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>varName</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return true if the variable exists, false otherwise. +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00461">461</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a06364.html#l00419">NLNET::IService::main()</a>. +<p> +<div class="fragment"><pre>00462 { +00463 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.size(); i++) +00464 { +00465 <span class="comment">// the type could be T_UNKNOWN if we add a callback on this name but this var is not in the config file</span> +00466 <span class="keywordflow">if</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Name == varName && (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Type != CVar::T_UNKNOWN || _Vars[i].Comp)) +00467 { +00468 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00469 } +00470 } +00471 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00472 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea6" doxytag="NLMISC::CConfigFile::getFilename" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::string NLMISC::CConfigFile::getFilename </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +returns the config file name +<p> + +<p> +Definition at line <a class="el" href="a05598.html#l00258">258</a> of file <a class="el" href="a05598.html">config_file.h</a>. +<p> +Referenced by <a class="el" href="a05597.html#l00559">display()</a>, <a class="el" href="a05597.html#l00431">getVar()</a>, <a class="el" href="a06665.html#l00050">NLMISC::IVariable::init()</a>, <a class="el" href="a05597.html#l00474">save()</a>, and <a class="el" href="a05597.html#l00647">setCallback()</a>. +<p> +<div class="fragment"><pre>00258 { <span class="keywordflow">return</span> <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler2">FileNames</a>[0]; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea7" doxytag="NLMISC::CConfigFile::getNumVar" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a15">uint</a> NLMISC::CConfigFile::getNumVar </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const</td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Get the variable count. +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00735">735</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00105">uint</a>. +<p> +<div class="fragment"><pre>00736 { +00737 <span class="keywordflow">return</span> <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.size (); +00738 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea8" doxytag="NLMISC::CConfigFile::getVar" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a02402.html">CConfigFile::CVar</a> * NLMISC::CConfigFile::getVar </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname1" valign="top" nowrap> <em>varId</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Get a variable. +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00740">740</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00105">uint</a>. +<p> +<div class="fragment"><pre>00741 { +00742 <span class="keywordflow">return</span> &(<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[varId]); +00743 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea9" doxytag="NLMISC::CConfigFile::getVar" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a02402.html">CConfigFile::CVar</a> & NLMISC::CConfigFile::getVar </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>varName</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Get a variable with the variable name. +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00431">431</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05598.html#l00258">getFilename()</a>, and <a class="el" href="a05597.html#l00441">getVarPtr()</a>. +<p> +Referenced by <a class="el" href="a06364.html#l00419">NLNET::IService::main()</a>, <a class="el" href="a05903.html#l00042">NLLIGO::CLigoConfig::read()</a>, and <a class="el" href="a06641.html#l00202">NLNET::CUdpSimSock::setSimValues()</a>. +<p> +<div class="fragment"><pre>00432 { +00433 CVar *var = <a class="code" href="a02401.html#NLMISC_1_1CConfigFilea10">getVarPtr</a> (varName); +00434 <span class="keywordflow">if</span> (var == 0) +00435 <span class="keywordflow">throw</span> <a class="code" href="a03827.html">EUnknownVar</a> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFilea6">getFilename</a>(), varName); +00436 <span class="keywordflow">else</span> +00437 <span class="keywordflow">return</span> *var; +00438 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea10" doxytag="NLMISC::CConfigFile::getVarPtr" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a02402.html">CConfigFile::CVar</a> * NLMISC::CConfigFile::getVarPtr </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>varName</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Get a variable pointer with the variable name, without throwing exception. Return NULL if not found. +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00441">441</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05598.html#l00255">UnknownVariables</a>. +<p> +Referenced by <a class="el" href="a05597.html#l00431">getVar()</a>, <a class="el" href="a06753.html#l00052">NLMISC::CWordsDictionary::init()</a>, <a class="el" href="a06665.html#l00050">NLMISC::IVariable::init()</a>, <a class="el" href="a05597.html#l00745">insertVar()</a>, <a class="el" href="a06364.html#l00419">NLNET::IService::main()</a>, and <a class="el" href="a05597.html#l00297">reparse()</a>. +<p> +<div class="fragment"><pre>00442 { +00443 <a class="code" href="a04558.html#a15">uint</a> i; +00444 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.size(); i++) +00445 { +00446 <span class="comment">// the type could be T_UNKNOWN if we add a callback on this name but this var is not in the config file</span> +00447 <span class="keywordflow">if</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Name == varName && (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Type != CVar::T_UNKNOWN || _Vars[i].Comp)) +00448 <span class="keywordflow">return</span> &(_Vars[i]); +00449 } +00450 +00451 <span class="comment">// if not found, add it in the array if necessary</span> +00452 <span class="keywordflow">for</span> (i = 0; i < <a class="code" href="a02401.html#NLMISC_1_1CConfigFileo0">UnknownVariables</a>.size(); i++) +00453 <span class="keywordflow">if</span>(<a class="code" href="a02401.html#NLMISC_1_1CConfigFileo0">UnknownVariables</a>[i] == varName) +00454 <span class="keywordflow">break</span>; +00455 <span class="keywordflow">if</span> (i == <a class="code" href="a02401.html#NLMISC_1_1CConfigFileo0">UnknownVariables</a>.size()) +00456 <a class="code" href="a02401.html#NLMISC_1_1CConfigFileo0">UnknownVariables</a>.push_back(varName); +00457 +00458 <span class="keywordflow">return</span> NULL; +00459 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea11" doxytag="NLMISC::CConfigFile::insertVar" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a02402.html">CConfigFile::CVar</a> * NLMISC::CConfigFile::insertVar </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>varName</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a02402.html">CVar</a> & </td> + <td class="mdname" nowrap> <em>varToCopy</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Add a variable. If the variable already exit, return it. +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00745">745</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05597.html#l00441">getVarPtr()</a>, <a class="el" href="a05598.html#l00188">NLMISC::CConfigFile::CVar::Name</a>, and <a class="el" href="a05598.html#l00190">NLMISC::CConfigFile::CVar::Root</a>. +<p> +<div class="fragment"><pre>00746 { +00747 <span class="comment">// Get the var</span> +00748 CVar *var = <a class="code" href="a02401.html#NLMISC_1_1CConfigFilea10">getVarPtr</a> (varName); +00749 <span class="keywordflow">if</span> (!var) +00750 { +00751 <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.push_back (varToCopy); +00752 var = &(<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.back ()); +00753 var->Root = <span class="keyword">false</span>; +00754 var->Name = varName; +00755 } +00756 <span class="keywordflow">return</span> var; +00757 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea12" doxytag="NLMISC::CConfigFile::load" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::load </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>fileName</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +load and parse the file +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00244">244</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05597.html#l00677">_ConfigFiles</a>, <a class="el" href="a05622.html#l00135">nlwarning</a>, and <a class="el" href="a05597.html#l00297">reparse()</a>. +<p> +Referenced by <a class="el" href="a06753.html#l00052">NLMISC::CWordsDictionary::init()</a>, <a class="el" href="a06364.html#l00419">NLNET::IService::main()</a>, and <a class="el" href="a05903.html#l00042">NLLIGO::CLigoConfig::read()</a>. +<p> +<div class="fragment"><pre>00245 { +00246 <span class="keywordflow">if</span>(fileName.empty()) +00247 { +00248 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"CF: Can't load a empty file name configfile"</span>); +00249 <span class="keywordflow">return</span>; +00250 } +00251 +00252 <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler2">FileNames</a>.clear (); +00253 <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler2">FileNames</a>.push_back (fileName); +00254 +00255 <span class="keywordflow">if</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFilev0">_ConfigFiles</a> == NULL) +00256 { +00257 <a class="code" href="a02401.html#NLMISC_1_1CConfigFilev0">_ConfigFiles</a> = <span class="keyword">new</span> std::vector<CConfigFile *>; +00258 } +00259 (*CConfigFile::_ConfigFiles).push_back (<span class="keyword">this</span>); +00260 <a class="code" href="a02401.html#NLMISC_1_1CConfigFilea14">reparse</a> (); +00261 +00262 <span class="comment">/* _FileName.clear ();</span> +00263 <span class="comment"> _FileName.push_back (fileName);</span> +00264 <span class="comment"></span> +00265 <span class="comment"> if (_ConfigFiles == NULL)</span> +00266 <span class="comment"> {</span> +00267 <span class="comment"> _ConfigFiles = new std::vector<CConfigFile *>;</span> +00268 <span class="comment"> }</span> +00269 <span class="comment"> (*CConfigFile::_ConfigFiles).push_back (this);</span> +00270 <span class="comment"> reparse ();</span> +00271 <span class="comment"></span> +00272 <span class="comment"> // If we find a linked config file, load it but don't overload already existant variable</span> +00273 <span class="comment"> CVar *var = getVarPtr ("RootConfigFilename");</span> +00274 <span class="comment"> if (var)</span> +00275 <span class="comment"> {</span> +00276 <span class="comment"> string RootConfigFilename = var->asString();</span> +00277 <span class="comment"> nlinfo ("RootConfigFilename variable found in the '%s' config file, parse it (%s)", fileName.c_str(), RootConfigFilename.c_str());</span> +00278 <span class="comment"></span> +00279 <span class="comment"> string path = CFile::getPath(fileName);</span> +00280 <span class="comment"></span> +00281 <span class="comment"> if (!path.empty())</span> +00282 <span class="comment"> path += "/";</span> +00283 <span class="comment"></span> +00284 <span class="comment"> path += RootConfigFilename;</span> +00285 <span class="comment"></span> +00286 <span class="comment"> reparse (path.c_str());</span> +00287 <span class="comment"> }</span> +00288 <span class="comment">*/</span> +00289 <span class="comment">// print ();</span> +00290 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea13" doxytag="NLMISC::CConfigFile::loaded" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CConfigFile::loaded </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Returns true if the file has been loaded. +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00292">292</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +<div class="fragment"><pre>00293 { +00294 <span class="keywordflow">return</span> !CConfigFile::FileNames.empty(); +00295 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea14" doxytag="NLMISC::CConfigFile::reparse" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::reparse </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +reload and reparse the file +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00297">297</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a02401.html#NLMISC_1_1CConfigFiler0">_Callback</a>, <a class="el" href="a05597.html#l00097">NLMISC::CConfigFile::CVar::asString()</a>, <a class="el" href="a05536.html#l00094">cf_CurrentLine</a>, <a class="el" href="a05538.html#l01682">cf_ifile</a>, <a class="el" href="a05536.html#l00096">cf_OverwriteExistingVariable</a>, <a class="el" href="a04174.html#a6">cfparse()</a>, <a class="el" href="a04115.html#a101">cfrestart()</a>, <a class="el" href="a05708.html#l00255">NLMISC::CIFile::close()</a>, <a class="el" href="a06167.html#l01402">NLMISC::CFile::fileExists()</a>, <a class="el" href="a06167.html#l00525">NLMISC::CPath::getFullPath()</a>, <a class="el" href="a05597.html#l00441">getVarPtr()</a>, <a class="el" href="a05536.html#l00086">LoadRoot</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a05622.html#l00111">nlinfo</a>, <a class="el" href="a05622.html#l00135">nlwarning</a>, <a class="el" href="a05708.html#l00135">NLMISC::CIFile::open()</a>, and <a class="el" href="a06167.html#l00452">NLMISC::CPath::standardizePath()</a>. +<p> +Referenced by <a class="el" href="a05597.html#l00244">load()</a>. +<p> +<div class="fragment"><pre>00298 { +00299 <span class="keywordflow">if</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler2">FileNames</a>.empty()) +00300 { +00301 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"CF: Can't reparse config file because file name is empty"</span>); +00302 <span class="keywordflow">return</span>; +00303 } +00304 +00305 string fn = <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler2">FileNames</a>[0]; +00306 +00307 FileNames.clear (); +00308 <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler3">LastModified</a>.clear (); +00309 +00310 <span class="comment">// clearVars ();</span> +00311 +00312 <span class="keywordflow">while</span> (!fn.empty()) +00313 { +00314 fn = <a class="code" href="a03072.html#NLMISC_1_1CPathe11">NLMISC::CPath::getFullPath</a>(fn, <span class="keyword">false</span>); +00315 <a class="code" href="a04199.html#a0">nldebug</a> (<span class="stringliteral">"CF: Adding config file '%s' in the config file"</span>, fn.c_str()); +00316 FileNames.push_back (fn); +00317 <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler3">LastModified</a>.push_back (CFile::getFileModificationDate(fn)); +00318 +00319 <span class="keywordflow">if</span> (<a class="code" href="a04115.html#a91">cf_ifile</a>.<a class="code" href="a02653.html#NLMISC_1_1CIFilea12">open</a> (fn)) +00320 { +00321 <a class="code" href="a04115.html#a101">cfrestart</a> (NULL); +00322 <a class="code" href="a04113.html#a57">cf_OverwriteExistingVariable</a> = (FileNames.size()==1); +00323 <a class="code" href="a04113.html#a53">LoadRoot</a> = (FileNames.size()>1); +00324 <span class="keywordtype">bool</span> parsingOK = (<a class="code" href="a04174.html#a6">cfparse</a> (&(_Vars)) == 0); +00325 <a class="code" href="a04115.html#a91">cf_ifile</a>.<a class="code" href="a02653.html#NLMISC_1_1CIFilea3">close</a>(); +00326 <span class="keywordflow">if</span> (!parsingOK) +00327 { +00328 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"CF: Parsing error in file %s line %d"</span>, fn.c_str(), <a class="code" href="a04113.html#a56">cf_CurrentLine</a>); +00329 <span class="keywordflow">throw</span> <a class="code" href="a03799.html">EParseError</a> (fn, cf_CurrentLine); +00330 } +00331 } +00332 <span class="keywordflow">else</span> +00333 { +00334 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"CF: Config file '%s' not found in the path '%s'"</span>, fn.c_str(), CPath::getCurrentPath().c_str()); +00335 <span class="keywordflow">throw</span> <a class="code" href="a03791.html">EFileNotFound</a> (fn); +00336 } +00337 <a class="code" href="a04115.html#a91">cf_ifile</a>.<a class="code" href="a02653.html#NLMISC_1_1CIFilea3">close</a> (); +00338 +00339 <span class="comment">// If we find a linked config file, load it but don't overload already existant variable</span> +00340 CVar *var = <a class="code" href="a02401.html#NLMISC_1_1CConfigFilea10">getVarPtr</a> (<span class="stringliteral">"RootConfigFilename"</span>); +00341 <span class="keywordflow">if</span> (var) +00342 { +00343 string RootConfigFilename = var->asString(); +00344 +00345 <span class="keywordflow">if</span> (!<a class="code" href="a02524.html#NLMISC_1_1CFilee5">NLMISC::CFile::fileExists</a>(RootConfigFilename)) +00346 { +00347 <span class="comment">// file is not found, try with the path of the master cfg</span> +00348 string path = <a class="code" href="a03072.html#NLMISC_1_1CPathe24">NLMISC::CPath::standardizePath</a> (NLMISC::CFile::getPath(FileNames[0])); +00349 RootConfigFilename = path + RootConfigFilename; +00350 } +00351 +00352 RootConfigFilename = <a class="code" href="a03072.html#NLMISC_1_1CPathe11">NLMISC::CPath::getFullPath</a>(RootConfigFilename, <span class="keyword">false</span>); +00353 +00354 <span class="keywordflow">if</span> (RootConfigFilename != fn) +00355 { +00356 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"CF: RootConfigFilename variable found in the '%s' config file, parse the root config file '%s'"</span>, fn.c_str(), RootConfigFilename.c_str()); +00357 fn = RootConfigFilename; +00358 } +00359 <span class="keywordflow">else</span> +00360 fn.clear (); +00361 } +00362 <span class="keywordflow">else</span> +00363 fn.clear (); +00364 } +00365 +00366 <span class="keywordflow">if</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler0">_Callback</a> != NULL) +00367 <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler0">_Callback</a>(); +00368 +00369 <span class="comment">/* if (filename == NULL)</span> +00370 <span class="comment"> {</span> +00371 <span class="comment"> _LastModified = getLastModified ();</span> +00372 <span class="comment"></span> +00373 <span class="comment"> nlassert (!_FileName.empty());</span> +00374 <span class="comment"></span> +00375 <span class="comment"> if (cf_ifile.open (_FileName[0]))</span> +00376 <span class="comment"> {</span> +00377 <span class="comment"> // if we clear all the array, we'll lost the callback on variable and all information</span> +00378 <span class="comment"> // _Vars.clear();</span> +00379 <span class="comment"> cfrestart (NULL);</span> +00380 <span class="comment"> cf_OverwriteExistingVariable = true;</span> +00381 <span class="comment"> LoadRoot = false;</span> +00382 <span class="comment"> bool parsingOK = (cfparse (&(_Vars)) == 0);</span> +00383 <span class="comment"> cf_ifile.close();</span> +00384 <span class="comment"> if (!parsingOK)</span> +00385 <span class="comment"> {</span> +00386 <span class="comment"> nlwarning ("Parsing error in file %s line %d", _FileName.c_str(), cf_CurrentLine);</span> +00387 <span class="comment"> throw EParseError (_FileName, cf_CurrentLine);</span> +00388 <span class="comment"> }</span> +00389 <span class="comment"> }</span> +00390 <span class="comment"> else</span> +00391 <span class="comment"> {</span> +00392 <span class="comment"> nlwarning ("ConfigFile '%s' not found in the path '%s'", _FileName.c_str(), CPath::getCurrentPath().c_str());</span> +00393 <span class="comment"> throw EFileNotFound (_FileName);</span> +00394 <span class="comment"> }</span> +00395 <span class="comment"> }</span> +00396 <span class="comment"> else</span> +00397 <span class="comment"> {</span> +00398 <span class="comment"> nlassert (strlen(filename)>0);</span> +00399 <span class="comment"></span> +00400 <span class="comment"> // load external config filename, don't overwrite existant variable</span> +00401 <span class="comment"> if (cf_ifile.open (filename))</span> +00402 <span class="comment"> {</span> +00403 <span class="comment"> cfrestart (NULL);</span> +00404 <span class="comment"> cf_OverwriteExistingVariable = false;</span> +00405 <span class="comment"> LoadRoot = true;</span> +00406 <span class="comment"> bool parsingOK = (cfparse (&(_Vars)) == 0);</span> +00407 <span class="comment"> cf_ifile.close ();</span> +00408 <span class="comment"> if (!parsingOK)</span> +00409 <span class="comment"> {</span> +00410 <span class="comment"> nlwarning ("Parsing error in file %s line %d", filename, cf_CurrentLine);</span> +00411 <span class="comment"> throw EParseError (filename, cf_CurrentLine);</span> +00412 <span class="comment"> }</span> +00413 <span class="comment"> }</span> +00414 <span class="comment"> else</span> +00415 <span class="comment"> {</span> +00416 <span class="comment"> nlwarning ("RootConfigFilename '%s' not found", _FileName.c_str());</span> +00417 <span class="comment"> }</span> +00418 <span class="comment"> }</span> +00419 <span class="comment"></span> +00420 <span class="comment"> if (callingCallback)</span> +00421 <span class="comment"> {</span> +00422 <span class="comment"> if (_Callback != NULL) </span> +00423 <span class="comment"> _Callback();</span> +00424 <span class="comment"> }</span> +00425 <span class="comment">*/</span> +00426 +00427 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea15" doxytag="NLMISC::CConfigFile::save" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::save </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const</td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +save the config file +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00474">474</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05598.html#l00258">getFilename()</a>, and <a class="el" href="a05622.html#l00135">nlwarning</a>. +<p> +<div class="fragment"><pre>00475 { +00476 FILE *fp = fopen (<a class="code" href="a02401.html#NLMISC_1_1CConfigFilea6">getFilename</a>().c_str (), <span class="stringliteral">"w"</span>); +00477 <span class="keywordflow">if</span> (fp == NULL) +00478 { +00479 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"CF: Couldn't create %s file"</span>, <a class="code" href="a02401.html#NLMISC_1_1CConfigFilea6">getFilename</a>().c_str ()); +00480 <span class="keywordflow">return</span>; +00481 } +00482 +00483 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i = 0; i < (<span class="keywordtype">int</span>)<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.size(); i++) +00484 { +00485 <span class="comment">// Not a root value </span> +00486 <span class="keywordflow">if</span> (!<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Root) +00487 { +00488 <span class="keywordflow">if</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Comp) +00489 { +00490 fprintf(fp, <span class="stringliteral">"%-20s = {"</span>, _Vars[i].Name.c_str()); +00491 <span class="keywordflow">switch</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Type) +00492 { +00493 <span class="keywordflow">case</span> CConfigFile::CVar::T_INT: +00494 { +00495 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> it=0; it < (<span class="keywordtype">int</span>)<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].IntValues.size(); it++) +00496 { +00497 <span class="keywordflow">if</span> (it%<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].SaveWrap == 0) +00498 { +00499 fprintf(fp, <span class="stringliteral">"\n\t"</span>); +00500 } +00501 fprintf(fp, <span class="stringliteral">"%d%s"</span>, _Vars[i].IntValues[it], it<(<span class="keywordtype">int</span>)_Vars[i].IntValues.size()-1?<span class="stringliteral">", "</span>:<span class="stringliteral">" "</span>); +00502 } +00503 <span class="keywordflow">break</span>; +00504 } +00505 <span class="keywordflow">case</span> CConfigFile::CVar::T_STRING: +00506 { +00507 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> st=0; st < (<span class="keywordtype">int</span>)<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].StrValues.size(); st++) +00508 { +00509 <span class="keywordflow">if</span> (st%<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].SaveWrap == 0) +00510 { +00511 fprintf(fp, <span class="stringliteral">"\n\t"</span>); +00512 } +00513 fprintf(fp, <span class="stringliteral">"\"%s\"%s"</span>, _Vars[i].StrValues[st].c_str(), st<(<span class="keywordtype">int</span>)_Vars[i].StrValues.size()-1?<span class="stringliteral">", "</span>:<span class="stringliteral">" "</span>); +00514 } +00515 <span class="keywordflow">break</span>; +00516 } +00517 <span class="keywordflow">case</span> CConfigFile::CVar::T_REAL: +00518 { +00519 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> rt=0; rt < (<span class="keywordtype">int</span>)<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].RealValues.size(); rt++) +00520 { +00521 <span class="keywordflow">if</span> (rt%<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].SaveWrap == 0) +00522 { +00523 fprintf(fp, <span class="stringliteral">"\n\t"</span>); +00524 } +00525 fprintf(fp, <span class="stringliteral">"%.10f%s"</span>, _Vars[i].RealValues[rt], rt<(<span class="keywordtype">int</span>)_Vars[i].RealValues.size()-1?<span class="stringliteral">", "</span>:<span class="stringliteral">" "</span>); +00526 } +00527 <span class="keywordflow">break</span>; +00528 } +00529 <span class="keywordflow">default</span>: <span class="keywordflow">break</span>; +00530 } +00531 fprintf(fp, <span class="stringliteral">"\n};\n"</span>); +00532 } +00533 <span class="keywordflow">else</span> +00534 { +00535 <span class="keywordflow">switch</span> (<a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].Type) +00536 { +00537 <span class="keywordflow">case</span> CConfigFile::CVar::T_INT: +00538 fprintf(fp, <span class="stringliteral">"%-20s = %d;\n"</span>, _Vars[i].Name.c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].IntValues[0]); +00539 <span class="keywordflow">break</span>; +00540 <span class="keywordflow">case</span> CConfigFile::CVar::T_STRING: +00541 fprintf(fp, <span class="stringliteral">"%-20s = \"%s\";\n"</span>, _Vars[i].Name.c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].StrValues[0].c_str()); +00542 <span class="keywordflow">break</span>; +00543 <span class="keywordflow">case</span> CConfigFile::CVar::T_REAL: +00544 fprintf(fp, <span class="stringliteral">"%-20s = %.10f;\n"</span>, _Vars[i].Name.c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>[i].RealValues[0]); +00545 <span class="keywordflow">break</span>; +00546 <span class="keywordflow">default</span>: <span class="keywordflow">break</span>; +00547 } +00548 } +00549 } +00550 } +00551 fclose (fp); +00552 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea16" doxytag="NLMISC::CConfigFile::setCallback" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::setCallback </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>VarName</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>void(* </td> + <td class="mdname" nowrap> <em>cb</em>)(<a class="el" href="a02402.html">CConfigFile::CVar</a> &var)</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +set a callback function to a variable, it will be called when this variable is modified +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00653">653</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a02402.html#NLMISC_1_1CConfigFile_1_1CVarz1937_1">NLMISC::CConfigFile::CVar::Callback</a>, <a class="el" href="a05598.html#l00191">NLMISC::CConfigFile::CVar::Comp</a>, <a class="el" href="a05598.html#l00258">getFilename()</a>, <a class="el" href="a05598.html#l00188">NLMISC::CConfigFile::CVar::Name</a>, <a class="el" href="a05622.html#l00111">nlinfo</a>, and <a class="el" href="a05598.html#l00189">NLMISC::CConfigFile::CVar::Type</a>. +<p> +<div class="fragment"><pre>00654 { +00655 <span class="keywordflow">for</span> (vector<CVar>::iterator it = <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.begin (); it != <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.end (); it++) +00656 { +00657 <span class="keywordflow">if</span> (VarName == (*it).Name) +00658 { +00659 (*it).Callback = cb; +00660 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"CF: Setting callback when the variable '%s' on the file '%s' is modified externaly"</span>, VarName.c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFilea6">getFilename</a>().c_str()); +00661 <span class="keywordflow">return</span>; +00662 } +00663 } +00664 <span class="comment">// VarName doesn't exist, add it now for the future</span> +00665 CVar Var; +00666 Var.Name = VarName; +00667 Var.Callback = cb; +00668 Var.Type = CVar::T_UNKNOWN; +00669 Var.Comp = <span class="keyword">false</span>; +00670 <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler1">_Vars</a>.push_back (Var); +00671 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"CF: Setting callback when the variable '%s' on the file '%s' is modified externaly (actually unknown)"</span>, VarName.c_str(), <a class="code" href="a02401.html#NLMISC_1_1CConfigFilea6">getFilename</a>().c_str()); +00672 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilea17" doxytag="NLMISC::CConfigFile::setCallback" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::setCallback </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">void(* </td> + <td class="mdname1" valign="top" nowrap> <em>cb</em>)() </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +set a callback function that is called when the config file is modified +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00647">647</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a02401.html#NLMISC_1_1CConfigFiler0">_Callback</a>, <a class="el" href="a05598.html#l00258">getFilename()</a>, and <a class="el" href="a05622.html#l00111">nlinfo</a>. +<p> +Referenced by <a class="el" href="a06665.html#l00050">NLMISC::IVariable::init()</a>, <a class="el" href="a06364.html#l00419">NLNET::IService::main()</a>, and <a class="el" href="a06641.html#l00202">NLNET::CUdpSimSock::setSimValues()</a>. +<p> +<div class="fragment"><pre>00648 { +00649 <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler0">_Callback</a> = cb; +00650 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"CF: Setting callback when the file '%s' is modified externaly"</span>, <a class="code" href="a02401.html#NLMISC_1_1CConfigFiler2">FileNames</a>.empty()?<span class="stringliteral">""</span>:<a class="code" href="a02401.html#NLMISC_1_1CConfigFilea6">getFilename</a>().c_str()); +00651 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilee1" doxytag="NLMISC::CConfigFile::setTimeout" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CConfigFile::setTimeout </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a11">uint32</a> </td> + <td class="mdname1" valign="top" nowrap> <em>timeout</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +set the time between 2 file checking (default value is 1 second) <dl compact><dt><b>Parameters:</b></dt><dd> + <table border="0" cellspacing="2" cellpadding="0"> + <tr><td valign=top><em>timeout</em> </td><td>time in millisecond, if timeout=0, the check will be made each "frame" </td></tr> + </table> +</dl> + +<p> +Definition at line <a class="el" href="a05597.html#l00717">717</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +References <a class="el" href="a05597.html#l00679">_Timeout</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00718 { +00719 <a class="code" href="a02401.html#NLMISC_1_1CConfigFilev1">_Timeout</a> = timeout; +00720 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Field Documentation</h2> +<a class="anchor" name="NLMISC_1_1CConfigFiler0" doxytag="NLMISC::CConfigFile::_Callback" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void(* <a class="el" href="a02401.html#NLMISC_1_1CConfigFiler0">NLMISC::CConfigFile::_Callback</a>)()<code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Internal use only. +<p> + +<p> +Referenced by <a class="el" href="a05598.html#l00202">CConfigFile()</a>, <a class="el" href="a05597.html#l00297">reparse()</a>, and <a class="el" href="a05597.html#l00647">setCallback()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilev0" doxytag="NLMISC::CConfigFile::_ConfigFiles" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> vector< <a class="el" href="a02401.html">CConfigFile</a> * > * <a class="el" href="a02401.html#NLMISC_1_1CConfigFilev0">NLMISC::CConfigFile::_ConfigFiles</a> = NULL<code> [static, private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00677">677</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +Referenced by <a class="el" href="a05597.html#l00681">checkConfigFiles()</a>, <a class="el" href="a05597.html#l00244">load()</a>, and <a class="el" href="a05597.html#l00227">~CConfigFile()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFilev1" doxytag="NLMISC::CConfigFile::_Timeout" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a11">uint32</a> <a class="el" href="a02401.html#NLMISC_1_1CConfigFilev1">NLMISC::CConfigFile::_Timeout</a> = 1000<code> [static, private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05597.html#l00679">679</a> of file <a class="el" href="a05597.html">config_file.cpp</a>. +<p> +Referenced by <a class="el" href="a05597.html#l00681">checkConfigFiles()</a>, and <a class="el" href="a05597.html#l00717">setTimeout()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFiler1" doxytag="NLMISC::CConfigFile::_Vars" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<<a class="el" href="a02402.html">CVar</a>> <a class="el" href="a02401.html#NLMISC_1_1CConfigFiler1">NLMISC::CConfigFile::_Vars</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Internal use only. +<p> + +<p> +Definition at line <a class="el" href="a05598.html#l00273">273</a> of file <a class="el" href="a05598.html">config_file.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFiler2" doxytag="NLMISC::CConfigFile::FileNames" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<std::string> <a class="el" href="a02401.html#NLMISC_1_1CConfigFiler2">NLMISC::CConfigFile::FileNames</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05598.html#l00280">280</a> of file <a class="el" href="a05598.html">config_file.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFiler3" doxytag="NLMISC::CConfigFile::LastModified" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<<a class="el" href="a04558.html#a11">uint32</a>> <a class="el" href="a02401.html#NLMISC_1_1CConfigFiler3">NLMISC::CConfigFile::LastModified</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a05598.html#l00281">281</a> of file <a class="el" href="a05598.html">config_file.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CConfigFileo0" doxytag="NLMISC::CConfigFile::UnknownVariables" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<std::string> <a class="el" href="a02401.html#NLMISC_1_1CConfigFileo0">NLMISC::CConfigFile::UnknownVariables</a> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +contains the variable names that <a class="el" href="a02401.html#NLMISC_1_1CConfigFilea9">getVar()</a> and <a class="el" href="a02401.html#NLMISC_1_1CConfigFilea10">getVarPtr()</a> tried to access but not present in the cfg +<p> + +<p> +Definition at line <a class="el" href="a05598.html#l00255">255</a> of file <a class="el" href="a05598.html">config_file.h</a>. +<p> +Referenced by <a class="el" href="a05597.html#l00441">getVarPtr()</a>. </td> + </tr> +</table> +<hr>The documentation for this class was generated from the following files:<ul> +<li><a class="el" href="a05598.html">config_file.h</a><li><a class="el" href="a05597.html">config_file.cpp</a></ul> +<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:06:34 2004 for NeL by +<a href="http://www.doxygen.org/index.html"> +<img src="doxygen.png" alt="doxygen" align="middle" border=0 > +</a>1.3.6 </small></address> +</body> +</html> |