diff options
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/a02647.html | 1807 |
1 files changed, 1807 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a02647.html b/docs/doxygen/nel/a02647.html new file mode 100644 index 00000000..909e1727 --- /dev/null +++ b/docs/doxygen/nel/a02647.html @@ -0,0 +1,1807 @@ +<!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::CI18N 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::CI18N Class Reference</h1><code>#include <<a class="el" href="a05799.html">i18n.h</a>></code> +<p> +<hr><a name="_details"></a><h2>Detailed Description</h2> +Class for the internationalisation. It's a singleton pattern.<p> +This class provide an easy way to localise all string. First you have to get all available language with <code><a class="el" href="a02647.html#NLMISC_1_1CI18Ne4">getLanguageNames()</a></code>. If you already know the number of the language (that is the index in the vector returns by <code>getLanguagesNames()</code>), you can load the language file with <code><a class="el" href="a02647.html#NLMISC_1_1CI18Ne5">load()</a></code>. Now, you can get a localised string with his association with <code><a class="el" href="a02647.html#NLMISC_1_1CI18Ne1">get()</a></code>.<p> +<pre class="fragment"><div> <span class="comment">// get all language names (you must call this before calling load())</span> + CI18N::getLanguageNames (); + <span class="comment">// load the language 1 (french)</span> + CI18N::load (1); + <span class="comment">// display "Salut" that is the "hi" string in the selected language (french).</span> + <a class="code" href="a04199.html#a1">nlinfo</a> (CI18N::get(<span class="stringliteral">"hi"</span>).c_str ()); + <span class="comment">// display "rms est un master", the french version of the string</span> + <a class="code" href="a04199.html#a1">nlinfo</a> (CI18N::get(<span class="stringliteral">"%s is a master"</span>).c_str (), <span class="stringliteral">"mrs"</span>); + * +</div></pre><p> +If the string doesn't exist, it will be automatically added in all language files with a mention. If the language file doesn't exist, it'll be automatically create.<p> +Update 26-02-2002 Boris Boucher<p> +Language are now preferably handled via official language code. We use the ISO 639-1 code for language. Optionnaly, we can append a country code (ISO 3066) to differentiate between language flavor (eg chinese is ISO 639-1 zh, but come in traditionnal or simplified form. So we append the country code : zh-CN (china) for simplified, zh for traditionnal).<p> +<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="a05799.html#l00076">76</a> of file <a class="el" href="a05799.html">i18n.h</a>.<table border=0 cellpadding=0 cellspacing=0> +<tr><td></td></tr> +<tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>std::string </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ne0">encodeUTF8</a> (const <a class="el" href="a03924.html">ucstring</a> &str)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a03924.html">ucstring</a> & </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ne1">get</a> (const std::string &label)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Find a string in the selected language and return his association. <a href="#NLMISC_1_1CI18Ne1"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03924.html">ucstring</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ne2">getCurrentLanguageName</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns the name of the language in english (french, english...). <a href="#NLMISC_1_1CI18Ne2"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>const std::vector< std::string > & </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ne3">getLanguageCodes</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>const std::vector< <a class="el" href="a03924.html">ucstring</a> > & </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ne4">getLanguageNames</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ne5">load</a> (const std::string &languageCode)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Load a language file depending of the language. <a href="#NLMISC_1_1CI18Ne5"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03924.html">ucstring</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ne6">makeMarkedString</a> (<a class="el" href="a05167.html#a18">ucchar</a> openMark, <a class="el" href="a05167.html#a18">ucchar</a> closeMark, const <a class="el" href="a03924.html">ucstring</a> &text)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ne7">readTextBuffer</a> (<a class="el" href="a04558.html#a7">uint8</a> *<a class="el" href="a04223.html#a589">buffer</a>, <a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a04223.html#a587">size</a>, <a class="el" href="a03924.html">ucstring</a> &result, bool forceUtf8=false)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ne8">readTextFile</a> (const std::string &<a class="el" href="a04560.html#a1">filename</a>, <a class="el" href="a03924.html">ucstring</a> &result, bool forceUtf8=false, bool fileLookup=true, bool preprocess=false)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Temporary, we don't have file system for now, so we do a tricky cheat. there s not check so be careful! <a href="#NLMISC_1_1CI18Ne8"></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="a02647.html#NLMISC_1_1CI18Ne9">remove_C_Comment</a> (<a class="el" href="a03924.html">ucstring</a> &commentedString)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ne10">setLoadProxy</a> (<a class="el" href="a02648.html">ILoadProxy</a> *loadProxy)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Set the load proxy class. Proxy can be NULL to unregister. <a href="#NLMISC_1_1CI18Ne10"></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="a02647.html#NLMISC_1_1CI18Ne11">writeTextFile</a> (const std::string <a class="el" href="a04560.html#a1">filename</a>, const <a class="el" href="a03924.html">ucstring</a> &content, bool utf8=true)</td></tr> + +<tr><td colspan="2"><div class="groupHeader"></div></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>std::string </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nz1955_0">hashToString</a> (<a class="el" href="a04558.html#a13">uint64</a> hash)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nz1955_1">hashToUCString</a> (<a class="el" href="a04558.html#a13">uint64</a> hash, <a class="el" href="a03924.html">ucstring</a> &dst)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a13">uint64</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nz1955_2">makeHash</a> (const <a class="el" href="a03924.html">ucstring</a> &str)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a13">uint64</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nz1955_3">stringToHash</a> (const std::string &str)</td></tr> + +<tr><td colspan="2"><div class="groupHeader">Category control</div></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nz1954_0">parseLabel</a> (ucstring::const_iterator &it, ucstring::const_iterator &last, std::string &label)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Parse a label. <a href="#NLMISC_1_1CI18Nz1954_0"></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="a02647.html#NLMISC_1_1CI18Nz1954_1">parseMarkedString</a> (<a class="el" href="a05167.html#a18">ucchar</a> openMark, <a class="el" href="a05167.html#a18">ucchar</a> closeMark, ucstring::const_iterator &it, ucstring::const_iterator &last, <a class="el" href="a03924.html">ucstring</a> &result)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Parse a marked string. NB : usualy, we use [ and ] as string delimiters in translation files. <a href="#NLMISC_1_1CI18Nz1954_1"></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="a02647.html#NLMISC_1_1CI18Nz1954_2">skipWhiteSpace</a> (ucstring::const_iterator &it, ucstring::const_iterator &last, <a class="el" href="a03924.html">ucstring</a> *storeComments=NULL)</td></tr> + +<tr><td colspan=2><br><h2>Private Types</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>typedef std::map< std::string,<br> + <a class="el" href="a03924.html">ucstring</a> > </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Ny0">StrMapContainer</a></td></tr> + +<tr><td colspan=2><br><h2>Static Private Attributes</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>const std::string </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nv0">_LanguageCodes</a> []</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nv1">_LanguagesNamesLoaded</a> = false</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02648.html">ILoadProxy</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nv2">_LoadProxy</a> = 0</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a04558.html#a15">uint</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nv3">_NbLanguages</a> = sizeof(<a class="el" href="a02647.html#NLMISC_1_1CI18Nv0">CI18N::_LanguageCodes</a>) / sizeof(std::string)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a03924.html">ucstring</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nv4">_NotTranslatedValue</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a10">sint32</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nv5">_SelectedLanguage</a> = -1</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a02647.html#NLMISC_1_1CI18Ny0">StrMapContainer</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nv6">_StrMap</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a02647.html#NLMISC_1_1CI18Nv7">_StrMapLoaded</a> = false</td></tr> + +</table> +<hr><h2>Member Typedef Documentation</h2> +<a class="anchor" name="NLMISC_1_1CI18Ny0" doxytag="NLMISC::CI18N::StrMapContainer" ></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"> typedef std::map<std::string, <a class="el" href="a03924.html">ucstring</a>> <a class="el" href="a02647.html#NLMISC_1_1CI18Ny0">NLMISC::CI18N::StrMapContainer</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="a05799.html#l00185">185</a> of file <a class="el" href="a05799.html">i18n.h</a>. </td> + </tr> +</table> +<hr><h2>Member Function Documentation</h2> +<a class="anchor" name="NLMISC_1_1CI18Ne0" doxytag="NLMISC::CI18N::encodeUTF8" ></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"> string NLMISC::CI18N::encodeUTF8 </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03924.html">ucstring</a> & </td> + <td class="mdname1" valign="top" nowrap> <em>str</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> +Encode a unicode string into a string using UTF-8 encoding. +<p> +Definition at line <a class="el" href="a05798.html#l00627">627</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a06640.html#l00151">ucstring::toUtf8()</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00557">writeTextFile()</a>. +<p> +<div class="fragment"><pre>00628 { +00629 <span class="keywordflow">return</span> str.<a class="code" href="a03924.html#ucstringa12">toUtf8</a>(); +00630 <span class="comment">/* </span> +00631 <span class="comment"> string res;</span> +00632 <span class="comment"> ucstring::const_iterator first(str.begin()), last(str.end());</span> +00633 <span class="comment"> for (; first != last; ++first)</span> +00634 <span class="comment"> {</span> +00635 <span class="comment"> //ucchar c = *first;</span> +00636 <span class="comment"> uint nbLoop = 0;</span> +00637 <span class="comment"> if (*first < 0x80)</span> +00638 <span class="comment"> res += char(*first);</span> +00639 <span class="comment"> else if (*first < 0x800)</span> +00640 <span class="comment"> {</span> +00641 <span class="comment"> ucchar c = *first;</span> +00642 <span class="comment"> c = c >> 6;</span> +00643 <span class="comment"> c = c & 0x1F;</span> +00644 <span class="comment"> res += c | 0xC0;</span> +00645 <span class="comment"> nbLoop = 1;</span> +00646 <span class="comment"> }</span> +00647 <span class="comment"> else if (*first < 0x10000)</span> +00648 <span class="comment"> {</span> +00649 <span class="comment"> ucchar c = *first;</span> +00650 <span class="comment"> c = c >> 12;</span> +00651 <span class="comment"> c = c & 0x0F;</span> +00652 <span class="comment"> res += c | 0xE0;</span> +00653 <span class="comment"> nbLoop = 2;</span> +00654 <span class="comment"> }</span> +00655 <span class="comment"></span> +00656 <span class="comment"> for (uint i=0; i<nbLoop; ++i)</span> +00657 <span class="comment"> {</span> +00658 <span class="comment"> ucchar c = *first;</span> +00659 <span class="comment"> c = c >> ((nbLoop - i - 1) * 6);</span> +00660 <span class="comment"> c = c & 0x3F;</span> +00661 <span class="comment"> res += char(c) | 0x80; </span> +00662 <span class="comment"> }</span> +00663 <span class="comment"> }</span> +00664 <span class="comment"> return res;</span> +00665 <span class="comment"> */</span> +00666 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne1" doxytag="NLMISC::CI18N::get" ></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"> const <a class="el" href="a03924.html">ucstring</a> & NLMISC::CI18N::get </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>label</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> +Find a string in the selected language and return his association. +<p> + +<p> +Definition at line <a class="el" href="a05798.html#l00140">140</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05798.html#l00044">_LanguageCodes</a>, <a class="el" href="a05798.html#l00057">_SelectedLanguage</a>, <a class="el" href="a05798.html#l00053">_StrMap</a>, and <a class="el" href="a05622.html#l00135">nlwarning</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00162">getCurrentLanguageName()</a>. +<p> +<div class="fragment"><pre>00141 { +00142 <span class="keywordflow">if</span> (label.empty()) +00143 { +00144 <span class="keyword">static</span> <a class="code" href="a03924.html">ucstring</a> emptyString; +00145 <span class="keywordflow">return</span> emptyString; +00146 } +00147 +00148 StrMapContainer::iterator it(<a class="code" href="a02647.html#NLMISC_1_1CI18Nv6">_StrMap</a>.find(label)); +00149 +00150 <span class="keywordflow">if</span> (it != <a class="code" href="a02647.html#NLMISC_1_1CI18Nv6">_StrMap</a>.end()) +00151 <span class="keywordflow">return</span> it->second; +00152 +00153 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: The string %s did not exist in language %s"</span>, label.c_str(), <a class="code" href="a02647.html#NLMISC_1_1CI18Nv0">_LanguageCodes</a>[<a class="code" href="a02647.html#NLMISC_1_1CI18Nv5">_SelectedLanguage</a>].c_str()); +00154 +00155 <span class="keyword">static</span> <a class="code" href="a03924.html">ucstring</a> badString; +00156 +00157 badString = <a class="code" href="a03924.html">ucstring</a>(std::string(<span class="stringliteral">"<NotExist:"</span>)+label+<span class="stringliteral">">"</span>); +00158 +00159 <span class="keywordflow">return</span> badString; +00160 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne2" doxytag="NLMISC::CI18N::getCurrentLanguageName" ></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="a03924.html">ucstring</a> NLMISC::CI18N::getCurrentLanguageName </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> +Returns the name of the language in english (french, english...). +<p> + +<p> +Definition at line <a class="el" href="a05798.html#l00162">162</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05798.html#l00140">get()</a>. +<p> +<div class="fragment"><pre>00163 { +00164 <span class="keywordflow">return</span> <a class="code" href="a02647.html#NLMISC_1_1CI18Ne1">get</a>(<span class="stringliteral">"LanguageName"</span>); +00165 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne3" doxytag="NLMISC::CI18N::getLanguageCodes" ></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"> const std::vector<std::string>& NLMISC::CI18N::getLanguageCodes </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> +Return a vector with all language code available. Code are ISO 639-2 compliant. As in <a class="el" href="a02647.html#NLMISC_1_1CI18Ne4">getLanguageNames()</a>, the index in the vector can be used to call <a class="el" href="a02647.html#NLMISC_1_1CI18Ne5">load()</a> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne4" doxytag="NLMISC::CI18N::getLanguageNames" ></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"> const std::vector<<a class="el" href="a03924.html">ucstring</a>>& NLMISC::CI18N::getLanguageNames </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> +Return a vector with all language available. The vector contains the name of the language. The index in the vector is used in <code><a class="el" href="a02647.html#NLMISC_1_1CI18Ne5">load()</a></code> function </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nz1955_0" doxytag="NLMISC::CI18N::hashToString" ></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"> string NLMISC::CI18N::hashToString </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a13">uint64</a> </td> + <td class="mdname1" valign="top" nowrap> <em>hash</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> + +<p> +Definition at line <a class="el" href="a05798.html#l00705">705</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00100">uint32</a>, and <a class="el" href="a05981.html#l00102">uint64</a>. +<p> +<div class="fragment"><pre>00706 { +00707 <a class="code" href="a04558.html#a11">uint32</a> *ph = (<a class="code" href="a04558.html#a11">uint32</a>*)&hash; +00708 +00709 <span class="keywordtype">char</span> temp[] = <span class="stringliteral">"0011223344556677"</span>; +00710 sprintf(temp, <span class="stringliteral">"%08X%08X"</span>, ph[0], ph[1]); +00711 +00712 <span class="keywordflow">return</span> string(temp); +00713 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nz1955_1" doxytag="NLMISC::CI18N::hashToUCString" ></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::CI18N::hashToUCString </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a13">uint64</a> </td> + <td class="mdname" nowrap> <em>hash</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03924.html">ucstring</a> & </td> + <td class="mdname" nowrap> <em>dst</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</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="a05798.html#l00716">716</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a06590.html#l00236">ucchar</a>, and <a class="el" href="a05981.html#l00102">uint64</a>. +<p> +<div class="fragment"><pre>00717 { +00718 <span class="keyword">static</span> <a class="code" href="a05167.html#a18">ucchar</a> cvtTable[]= {<span class="charliteral">'0'</span>,<span class="charliteral">'1'</span>,<span class="charliteral">'2'</span>,<span class="charliteral">'3'</span>,<span class="charliteral">'4'</span>,<span class="charliteral">'5'</span>,<span class="charliteral">'6'</span>,<span class="charliteral">'7'</span>,<span class="charliteral">'8'</span>,<span class="charliteral">'9'</span>,<span class="charliteral">'A'</span>,<span class="charliteral">'B'</span>,<span class="charliteral">'C'</span>,<span class="charliteral">'D'</span>,<span class="charliteral">'E'</span>,<span class="charliteral">'F'</span>}; +00719 +00720 dst.resize(16); +00721 <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a14">sint</a> i=15;i>=0;i--) +00722 { +00723 <span class="comment">// Must decal dest of 8, cause of hashToString code (Little Endian)</span> +00724 dst[(i+8)&15]= cvtTable[hash&15]; +00725 hash>>=4; +00726 } +00727 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne5" doxytag="NLMISC::CI18N::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::CI18N::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>languageCode</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> +Load a language file depending of the language. +<p> + +<p> +Definition at line <a class="el" href="a05798.html#l00067">67</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05798.html#l00044">_LanguageCodes</a>, <a class="el" href="a05798.html#l00058">_LoadProxy</a>, <a class="el" href="a05798.html#l00052">_NbLanguages</a>, <a class="el" href="a05798.html#l00057">_SelectedLanguage</a>, <a class="el" href="a05798.html#l00053">_StrMap</a>, <a class="el" href="a05798.html#l00054">_StrMapLoaded</a>, <a class="el" href="a02648.html#NLMISC_1_1CI18N_1_1ILoadProxya0">NLMISC::CI18N::ILoadProxy::loadStringFile()</a>, <a class="el" href="a05622.html#l00135">nlwarning</a>, <a class="el" href="a05798.html#l00264">parseLabel()</a>, <a class="el" href="a05798.html#l00297">parseMarkedString()</a>, <a class="el" href="a05798.html#l00377">readTextFile()</a>, <a class="el" href="a05798.html#l00168">remove_C_Comment()</a>, <a class="el" href="a05798.html#l00220">skipWhiteSpace()</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +<div class="fragment"><pre>00068 { +00069 <span class="comment">// nlassert (lid < _NbLanguages);</span> +00070 <span class="comment">// nlassert (_LanguagesNamesLoaded);</span> +00071 +00072 <a class="code" href="a04558.html#a15">uint</a> i; +00073 <span class="keywordflow">for</span> (i=0; i<<a class="code" href="a02647.html#NLMISC_1_1CI18Nv3">_NbLanguages</a>; ++i) +00074 { +00075 <span class="keywordflow">if</span> (<a class="code" href="a02647.html#NLMISC_1_1CI18Nv0">_LanguageCodes</a>[i] == languageCode) +00076 <span class="keywordflow">break</span>; +00077 } +00078 +00079 <span class="keywordflow">if</span> (i == _NbLanguages) +00080 { +00081 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: Unknow language code : %s, defaulting to %s"</span>, _LanguageCodes[0].c_str()); +00082 i = 0; +00083 } +00084 +00085 std::string fileName = <a class="code" href="a02647.html#NLMISC_1_1CI18Nv0">_LanguageCodes</a>[i] + <span class="stringliteral">".uxt"</span>; +00086 +00087 <a class="code" href="a02647.html#NLMISC_1_1CI18Nv5">_SelectedLanguage</a> = i; +00088 +00089 <span class="keywordflow">if</span> (<a class="code" href="a02647.html#NLMISC_1_1CI18Nv7">_StrMapLoaded</a>) <a class="code" href="a02647.html#NLMISC_1_1CI18Nv6">_StrMap</a>.clear (); +00090 <span class="keywordflow">else</span> <a class="code" href="a02647.html#NLMISC_1_1CI18Nv7">_StrMapLoaded</a> = <span class="keyword">true</span>; +00091 +00092 <a class="code" href="a03924.html">ucstring</a> text; +00093 <span class="comment">// read in the text</span> +00094 <span class="keywordflow">if</span> (<a class="code" href="a02647.html#NLMISC_1_1CI18Nv2">_LoadProxy</a>) +00095 <a class="code" href="a02647.html#NLMISC_1_1CI18Nv2">_LoadProxy</a>-><a class="code" href="a02648.html#NLMISC_1_1CI18N_1_1ILoadProxya0">loadStringFile</a>(fileName, text); +00096 <span class="keywordflow">else</span> +00097 <a class="code" href="a02647.html#NLMISC_1_1CI18Ne8">readTextFile</a>(fileName, text); +00098 <span class="comment">// remove any comment</span> +00099 <a class="code" href="a02647.html#NLMISC_1_1CI18Ne9">remove_C_Comment</a>(text); +00100 +00101 ucstring::const_iterator first(text.begin()), last(text.end()); +00102 std::string lastReadLabel(<span class="stringliteral">"nothing"</span>); +00103 +00104 <span class="keywordflow">while</span> (first != last) +00105 { +00106 <a class="code" href="a02647.html#NLMISC_1_1CI18Nz1954_2">skipWhiteSpace</a>(first, last); +00107 std::string label; +00108 <a class="code" href="a03924.html">ucstring</a> ucs; +00109 <span class="keywordflow">if</span> (!<a class="code" href="a02647.html#NLMISC_1_1CI18Nz1954_0">parseLabel</a>(first, last, label)) +00110 { +00111 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: Error reading label field in %s. Stop reading after %s."</span>, fileName.c_str(), lastReadLabel.c_str()); +00112 <span class="keywordflow">return</span>; +00113 } +00114 lastReadLabel = label; +00115 <a class="code" href="a02647.html#NLMISC_1_1CI18Nz1954_2">skipWhiteSpace</a>(first, last); +00116 <span class="keywordflow">if</span> (!<a class="code" href="a02647.html#NLMISC_1_1CI18Nz1954_1">parseMarkedString</a>(<span class="charliteral">'['</span>, <span class="charliteral">']'</span>, first, last, ucs)) +00117 { +00118 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: Error reading text for label %s in %s. Stop reading."</span>, label.c_str(), fileName.c_str()); +00119 <span class="keywordflow">return</span>; +00120 } +00121 +00122 <span class="comment">// ok, a line read.</span> +00123 std::pair<std::map<std::string, ucstring>::iterator, <span class="keywordtype">bool</span>> ret; +00124 ret = <a class="code" href="a02647.html#NLMISC_1_1CI18Nv6">_StrMap</a>.insert(std::make_pair(label, ucs)); +00125 <span class="keywordflow">if</span> (!ret.second) +00126 { +00127 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: Error in %s, the label %s exist twice !"</span>, fileName.c_str(), label.c_str()); +00128 } +00129 <a class="code" href="a02647.html#NLMISC_1_1CI18Nz1954_2">skipWhiteSpace</a>(first, last); +00130 } +00131 +00132 <span class="comment">// a little check to ensure that the lang name has been set.</span> +00133 StrMapContainer::iterator it(<a class="code" href="a02647.html#NLMISC_1_1CI18Nv6">_StrMap</a>.find(<span class="stringliteral">"LanguageName"</span>)); +00134 <span class="keywordflow">if</span> (it == <a class="code" href="a02647.html#NLMISC_1_1CI18Nv6">_StrMap</a>.end()) +00135 { +00136 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: In file %s, missing LanguageName translation (should be first in file)"</span>, fileName.c_str()); +00137 } +00138 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nz1955_2" doxytag="NLMISC::CI18N::makeHash" ></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#a13">uint64</a> NLMISC::CI18N::makeHash </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03924.html">ucstring</a> & </td> + <td class="mdname1" valign="top" nowrap> <em>str</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> + +<p> +Definition at line <a class="el" href="a05798.html#l00679">679</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00100">uint32</a>, <a class="el" href="a05981.html#l00102">uint64</a>, and <a class="el" href="a05981.html#l00096">uint8</a>. +<p> +<div class="fragment"><pre>00680 { +00681 <span class="comment">// on passe au moins 8 fois sur chaque octet de resultat</span> +00682 <span class="keywordflow">if</span> (str.empty()) +00683 <span class="keywordflow">return</span> 0; +00684 <span class="keyword">const</span> <a class="code" href="a04558.html#a11">uint32</a> MIN_TURN = 8*8; +00685 <a class="code" href="a04558.html#a13">uint64</a> hash = 0; +00686 <a class="code" href="a04558.html#a7">uint8</a> *ph = (<a class="code" href="a04558.html#a7">uint8</a>*)&hash; +00687 <a class="code" href="a04558.html#a7">uint8</a> *pc = (<a class="code" href="a04558.html#a7">uint8</a>*)str.data(); +00688 +00689 <a class="code" href="a04558.html#a15">uint</a> nbLoop = max(<a class="code" href="a05167.html#a13">uint32</a>(str.size()*2), MIN_TURN); +00690 <a class="code" href="a04558.html#a15">uint</a> roll = 0; +00691 +00692 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=0; i<nbLoop; ++i) +00693 { +00694 ph[(i/2) & 0x7] += pc[i%(str.size()*2)] << roll; +00695 ph[(i/2) & 0x7] += pc[i%(str.size()*2)] >> (8-roll); +00696 +00697 roll++; +00698 roll &= 0x7; +00699 } +00700 +00701 <span class="keywordflow">return</span> hash; +00702 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne6" doxytag="NLMISC::CI18N::makeMarkedString" ></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="a03924.html">ucstring</a> NLMISC::CI18N::makeMarkedString </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a05167.html#a18">ucchar</a> </td> + <td class="mdname" nowrap> <em>openMark</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a05167.html#a18">ucchar</a> </td> + <td class="mdname" nowrap> <em>closeMark</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a03924.html">ucstring</a> & </td> + <td class="mdname" nowrap> <em>text</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</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="a05798.html#l00590">590</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a06590.html#l00236">ucchar</a>. +<p> +<div class="fragment"><pre>00591 { +00592 <a class="code" href="a03924.html">ucstring</a> ret; +00593 +00594 ret.push_back(openMark); +00595 +00596 ucstring::const_iterator first(text.begin()), last(text.end()); +00597 <span class="keywordflow">for</span> (; first != last; ++first) +00598 { +00599 <span class="keywordflow">if</span> (*first == <span class="charliteral">'\n'</span>) +00600 { +00601 ret += <span class="charliteral">'\\'</span>; +00602 ret += <span class="charliteral">'n'</span>; +00603 } +00604 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (*first == <span class="charliteral">'\t'</span>) +00605 { +00606 ret += <span class="charliteral">'\\'</span>; +00607 ret += <span class="charliteral">'t'</span>; +00608 } +00609 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (*first == closeMark) +00610 { +00611 <span class="comment">// excape the embeded closing mark</span> +00612 ret += <span class="charliteral">'\\'</span>; +00613 ret += closeMark; +00614 } +00615 <span class="keywordflow">else</span> +00616 { +00617 ret += *first; +00618 } +00619 } +00620 +00621 ret += closeMark; +00622 +00623 <span class="keywordflow">return</span> ret; +00624 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nz1954_0" doxytag="NLMISC::CI18N::parseLabel" ></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::CI18N::parseLabel </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">ucstring::const_iterator & </td> + <td class="mdname" nowrap> <em>it</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>ucstring::const_iterator & </td> + <td class="mdname" nowrap> <em>last</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>std::string & </td> + <td class="mdname" nowrap> <em>label</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Parse a label. +<p> + +<p> +Definition at line <a class="el" href="a05798.html#l00264">264</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00067">load()</a>. +<p> +<div class="fragment"><pre>00265 { +00266 label.erase(); +00267 +00268 <span class="comment">// first char must be A-Za-z@_</span> +00269 <span class="keywordflow">if</span> (it != last && +00270 ( +00271 (*it >= <span class="charliteral">'0'</span> && *it <= <span class="charliteral">'9'</span>) +00272 || (*it >= <span class="charliteral">'A'</span> && *it <= <span class="charliteral">'Z'</span>) +00273 || (*it >= <span class="charliteral">'a'</span> && *it <= <span class="charliteral">'z'</span>) +00274 || (*it == <span class="charliteral">'_'</span>) +00275 || (*it == <span class="charliteral">'@'</span>) +00276 ) +00277 ) +00278 label.push_back(<span class="keywordtype">char</span>(*it++)); +00279 <span class="keywordflow">else</span> +00280 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00281 +00282 <span class="comment">// other char must be [0-9A-Za-z@_]*</span> +00283 <span class="keywordflow">while</span> (it != last && +00284 ( +00285 (*it >= <span class="charliteral">'0'</span> && *it <= <span class="charliteral">'9'</span>) +00286 || (*it >= <span class="charliteral">'A'</span> && *it <= <span class="charliteral">'Z'</span>) +00287 || (*it >= <span class="charliteral">'a'</span> && *it <= <span class="charliteral">'z'</span>) +00288 || (*it == <span class="charliteral">'_'</span>) +00289 || (*it == <span class="charliteral">'@'</span>) +00290 ) +00291 ) +00292 label.push_back(<span class="keywordtype">char</span>(*it++)); +00293 +00294 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00295 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nz1954_1" doxytag="NLMISC::CI18N::parseMarkedString" ></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::CI18N::parseMarkedString </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a05167.html#a18">ucchar</a> </td> + <td class="mdname" nowrap> <em>openMark</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a05167.html#a18">ucchar</a> </td> + <td class="mdname" nowrap> <em>closeMark</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>ucstring::const_iterator & </td> + <td class="mdname" nowrap> <em>it</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>ucstring::const_iterator & </td> + <td class="mdname" nowrap> <em>last</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03924.html">ucstring</a> & </td> + <td class="mdname" nowrap> <em>result</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Parse a marked string. NB : usualy, we use [ and ] as string delimiters in translation files. +<p> + +<p> +Definition at line <a class="el" href="a05798.html#l00297">297</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05622.html#l00135">nlwarning</a>, and <a class="el" href="a06590.html#l00236">ucchar</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00067">load()</a>, and <a class="el" href="a05798.html#l00377">readTextFile()</a>. +<p> +<div class="fragment"><pre>00298 { +00299 <span class="comment">// ucstring ret;</span> +00300 result.erase(); +00301 <span class="comment">// parse a string delimited by the specified opening and closing mark</span> +00302 +00303 <span class="keywordflow">if</span> (it != last && *it == openMark) +00304 { +00305 ++it; +00306 +00307 <span class="keywordflow">while</span> (it != last && *it != closeMark) +00308 { +00309 <span class="comment">// ignore tab, new lines and line feed</span> +00310 <span class="keywordflow">if</span> (*it == openMark) +00311 { +00312 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: Found a non escaped openmark %c in a delimited string (Delimiters : '%c' - '%c')"</span>, <span class="keywordtype">char</span>(openMark), <span class="keywordtype">char</span>(openMark), <span class="keywordtype">char</span>(closeMark)); +00313 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00314 } +00315 <span class="keywordflow">if</span> (*it == <span class="charliteral">'\t'</span> || *it == <span class="charliteral">'\n'</span> || *it == <span class="charliteral">'\r'</span>) +00316 ++it; +00317 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (*it == <span class="charliteral">'\\'</span> && it+1 != last && *(it+1) != <span class="charliteral">'\\'</span>) +00318 { +00319 ++it; +00320 <span class="comment">// this is an escape sequence !</span> +00321 <span class="keywordflow">switch</span>(*it) +00322 { +00323 <span class="keywordflow">case</span> <span class="charliteral">'t'</span>: +00324 result.push_back(<span class="charliteral">'\t'</span>); +00325 <span class="keywordflow">break</span>; +00326 <span class="keywordflow">case</span> <span class="charliteral">'n'</span>: +00327 result.push_back(<span class="charliteral">'\n'</span>); +00328 <span class="keywordflow">break</span>; +00329 <span class="keywordflow">case</span> <span class="charliteral">'d'</span>: +00330 <span class="comment">// insert a delete</span> +00331 result.push_back(8); +00332 <span class="keywordflow">break</span>; +00333 <span class="keywordflow">default</span>: +00334 <span class="comment">// escape the close mark ?</span> +00335 <span class="keywordflow">if</span>(*it == closeMark) +00336 result.push_back(closeMark); +00337 <span class="comment">// escape the open mark ?</span> +00338 <span class="keywordflow">else</span> <span class="keywordflow">if</span>(*it == openMark) +00339 result.push_back(openMark); +00340 <span class="keywordflow">else</span> +00341 { +00342 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: Ignoring unknown escape code \\%c (char value : %u)"</span>, <span class="keywordtype">char</span>(*it), *it); +00343 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00344 } +00345 } +00346 ++it; +00347 } +00348 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (*it == <span class="charliteral">'\\'</span> && it+1 != last && *(it+1) == <span class="charliteral">'\\'</span>) +00349 { +00350 <span class="comment">// escape the \ char</span> +00351 ++it; +00352 result.push_back(*it); +00353 ++it; +00354 } +00355 <span class="keywordflow">else</span> +00356 result.push_back(*it++); +00357 } +00358 +00359 <span class="keywordflow">if</span> (it == last || *it != closeMark) +00360 { +00361 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: Missing end of delimited string (Delimiters : '%c' - '%c')"</span>, <span class="keywordtype">char</span>(openMark), <span class="keywordtype">char</span>(closeMark)); +00362 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00363 } +00364 <span class="keywordflow">else</span> +00365 ++it; +00366 } +00367 <span class="keywordflow">else</span> +00368 { +00369 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: Malformed or non existent delimited string (Delimiters : '%c' - '%c')"</span>, <span class="keywordtype">char</span>(openMark), <span class="keywordtype">char</span>(closeMark)); +00370 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00371 } +00372 +00373 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00374 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne7" doxytag="NLMISC::CI18N::readTextBuffer" ></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::CI18N::readTextBuffer </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a7">uint8</a> * </td> + <td class="mdname" nowrap> <em>buffer</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>size</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03924.html">ucstring</a> & </td> + <td class="mdname" nowrap> <em>result</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>forceUtf8</em> = false</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Read the content of a buffer as a unicode text. This is to read preloaded unicode files. The method support 16 bits or 8bits utf-8 tagged buffer. 8 bits UTF-8 encofing can be reconized by a non official header : EF,BB, BF. 16 bits encoding can be reconized by the official header : FF, FE, witch can be reversed if the data are MSB first.<p> +Optionnaly, you can force the reader to consider the file as UTF-8 encoded. +<p> +Definition at line <a class="el" href="a05798.html#l00475">475</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05646.html#l00649">buffer</a>, <a class="el" href="a06640.html#l00191">ucstring::fromUtf8()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05646.html#l00645">size</a>, <a class="el" href="a05646.html#l01124">src</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a05981.html#l00098">uint16</a>, and <a class="el" href="a05981.html#l00096">uint8</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00377">readTextFile()</a>. +<p> +<div class="fragment"><pre>00476 { +00477 <span class="keyword">static</span> <a class="code" href="a04558.html#a7">uint8</a> utf16Header[] = {char(0xff), char(0xfe)}; +00478 <span class="keyword">static</span> <a class="code" href="a04558.html#a7">uint8</a> utf16RevHeader[] = {char(0xfe), char(0xff)}; +00479 <span class="keyword">static</span> <a class="code" href="a04558.html#a7">uint8</a> utf8Header[] = {char(0xef), char(0xbb), char(0xbf)}; +00480 +00481 <span class="keywordflow">if</span> (forceUtf8) +00482 { +00483 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a587">size</a>>=3 && +00484 <a class="code" href="a04223.html#a589">buffer</a>[0]==utf8Header[0] && +00485 <a class="code" href="a04223.html#a589">buffer</a>[1]==utf8Header[1] && +00486 <a class="code" href="a04223.html#a589">buffer</a>[2]==utf8Header[2] +00487 ) +00488 { +00489 <span class="comment">// remove utf8 header</span> +00490 <a class="code" href="a04223.html#a589">buffer</a>+= 3; +00491 <a class="code" href="a04223.html#a587">size</a>-=3; +00492 } +00493 std::string text((<span class="keywordtype">char</span>*)buffer, size); +00494 result.<a class="code" href="a03924.html#ucstringa1">fromUtf8</a>(text); +00495 } +00496 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a587">size</a>>=3 && +00497 <a class="code" href="a04223.html#a589">buffer</a>[0]==utf8Header[0] && +00498 <a class="code" href="a04223.html#a589">buffer</a>[1]==utf8Header[1] && +00499 <a class="code" href="a04223.html#a589">buffer</a>[2]==utf8Header[2] +00500 ) +00501 { +00502 <span class="comment">// remove utf8 header</span> +00503 <a class="code" href="a04223.html#a589">buffer</a>+= 3; +00504 <a class="code" href="a04223.html#a587">size</a>-=3; +00505 std::string text((<span class="keywordtype">char</span>*)buffer, size); +00506 result.<a class="code" href="a03924.html#ucstringa1">fromUtf8</a>(text); +00507 } +00508 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a587">size</a>>=2 && +00509 <a class="code" href="a04223.html#a589">buffer</a>[0]==utf16Header[0] && +00510 <a class="code" href="a04223.html#a589">buffer</a>[1]==utf16Header[1] +00511 ) +00512 { +00513 <span class="comment">// remove utf16 header</span> +00514 <a class="code" href="a04223.html#a589">buffer</a>+= 2; +00515 <a class="code" href="a04223.html#a587">size</a>-= 2; +00516 <span class="comment">// check pair number of bytes</span> +00517 <a class="code" href="a04199.html#a6">nlassert</a>((size & 1) == 0); +00518 <span class="comment">// and do manual conversion</span> +00519 <a class="code" href="a04558.html#a9">uint16</a> *<a class="code" href="a04223.html#a652">src</a> = (<a class="code" href="a04558.html#a9">uint16</a>*)(<a class="code" href="a04223.html#a589">buffer</a>); +00520 result.resize(size/2); +00521 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> j=0; j<result.size(); j++) +00522 result[j]= *<a class="code" href="a04223.html#a652">src</a>++; +00523 } +00524 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a587">size</a>>=2 && +00525 <a class="code" href="a04223.html#a589">buffer</a>[0]==utf16RevHeader[0] && +00526 <a class="code" href="a04223.html#a589">buffer</a>[1]==utf16RevHeader[1] +00527 ) +00528 { +00529 <span class="comment">// remove utf16 header</span> +00530 <a class="code" href="a04223.html#a589">buffer</a>+= 2; +00531 <a class="code" href="a04223.html#a587">size</a>-= 2; +00532 <span class="comment">// check pair number of bytes</span> +00533 <a class="code" href="a04199.html#a6">nlassert</a>((size & 1) == 0); +00534 <span class="comment">// and do manual conversion</span> +00535 <a class="code" href="a04558.html#a9">uint16</a> *<a class="code" href="a04223.html#a652">src</a> = (<a class="code" href="a04558.html#a9">uint16</a>*)(<a class="code" href="a04223.html#a589">buffer</a>); +00536 result.resize(size/2); +00537 <a class="code" href="a04558.html#a15">uint</a> j; +00538 <span class="keywordflow">for</span> (j=0; j<result.size(); j++) +00539 result[j]= *<a class="code" href="a04223.html#a652">src</a>++; +00540 <span class="comment">// Reverse byte order</span> +00541 <span class="keywordflow">for</span> (j=0; j<result.size(); j++) +00542 { +00543 <a class="code" href="a04558.html#a7">uint8</a> *pc = (<a class="code" href="a04558.html#a7">uint8</a>*) &result[j]; +00544 std::swap(pc[0], pc[1]); +00545 } +00546 } +00547 <span class="keywordflow">else</span> +00548 { +00549 <span class="comment">// hum.. ascii read ?</span> +00550 <span class="comment">// so, just to a direct conversion</span> +00551 std::string text((<span class="keywordtype">char</span>*)buffer, size); +00552 result = text; +00553 } +00554 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne8" doxytag="NLMISC::CI18N::readTextFile" ></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::CI18N::readTextFile </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>filename</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03924.html">ucstring</a> & </td> + <td class="mdname" nowrap> <em>result</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>forceUtf8</em> = false, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>fileLookup</em> = true, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>preprocess</em> = false</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Temporary, we don't have file system for now, so we do a tricky cheat. there s not check so be careful! +<p> +Read the content of a file as a unicode text. The method support 16 bits or 8bits utf-8 tagged files. 8 bits UTF-8 encofing can be reconized by a non official header : EF,BB, BF. 16 bits encoding can be reconized by the official header : FF, FE, witch can be reversed if the data are MSB first.<p> +Optionnaly, you can force the reader to consider the file as UTF-8 encoded. Optionnaly, you can ask the reader to interpret #include commands. +<p> +Definition at line <a class="el" href="a05798.html#l00377">377</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a06640.html#l00125">ucstring::c_str()</a>, <a class="el" href="a05538.html#l02654">file</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a05622.html#l00135">nlwarning</a>, <a class="el" href="a05708.html#l00135">NLMISC::CIFile::open()</a>, <a class="el" href="a05798.html#l00297">parseMarkedString()</a>, <a class="el" href="a05798.html#l00475">readTextBuffer()</a>, <a class="el" href="a05798.html#l00220">skipWhiteSpace()</a>, <a class="el" href="a06640.html#l00133">ucstring::toString()</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05981.html#l00096">uint8</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00067">load()</a>. +<p> +<div class="fragment"><pre>00378 { +00379 std::string fullName; +00380 <span class="keywordflow">if</span> (fileLookup) +00381 fullName = CPath::lookup(filename, <span class="keyword">false</span>); +00382 <span class="keywordflow">else</span> +00383 fullName = <a class="code" href="a05377.html#a2">filename</a>; +00384 +00385 <span class="keywordflow">if</span> (fullName.empty()) +00386 <span class="keywordflow">return</span>; +00387 +00388 <span class="comment">// If ::lookup is used, the file can be in a bnp and CFile::fileExists fails.</span> +00389 <span class="comment">// \todo Boris</span> +00390 <span class="keywordtype">bool</span> isInBnp = fullName.find(<span class="charliteral">'@'</span>) != string::npos; +00391 <span class="keywordflow">if</span> (!isInBnp && !CFile::fileExists(fullName)) +00392 { +00393 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"CI18N::readTextFile : file '%s' does not exist, returing empty string"</span>, fullName.c_str()); +00394 <span class="keywordflow">return</span>; +00395 } +00396 +00397 <a class="code" href="a02653.html">NLMISC::CIFile</a> <a class="code" href="a04115.html#a95">file</a>(fullName); +00398 +00399 +00400 <span class="comment">// Fast read all the text in binary mode.</span> +00401 std::string text; +00402 text.resize(<a class="code" href="a04115.html#a95">file</a>.getFileSize()); +00403 <a class="code" href="a04115.html#a95">file</a>.serialBuffer((<a class="code" href="a04558.html#a7">uint8</a>*)(&text[0]), text.size()); +00404 +00405 <span class="comment">// Transform the string in ucstring according to format header</span> +00406 <span class="keywordflow">if</span> (!text.empty()) +00407 <a class="code" href="a02647.html#NLMISC_1_1CI18Ne7">readTextBuffer</a>((<a class="code" href="a04558.html#a7">uint8</a>*)&text[0], text.size(), result, forceUtf8); +00408 +00409 <span class="keywordflow">if</span> (preprocess) +00410 { +00411 <a class="code" href="a03924.html">ucstring</a> <span class="keyword">final</span>; +00412 <span class="comment">// parse the file, looking for preprocessor command.</span> +00413 ucstring::size_type pos = 0; +00414 ucstring::size_type lastPos = 0; +00415 <a class="code" href="a03924.html">ucstring</a> includeCmd(<span class="stringliteral">"#include"</span>); +00416 +00417 <span class="keywordflow">while</span> ((pos = result.find(includeCmd, pos)) != ucstring::npos) +00418 { +00419 <span class="comment">// copy the previous text</span> +00420 <span class="keyword">final</span> += result.substr(lastPos, pos - lastPos); +00421 +00422 <span class="comment">// extract the inserted file name.</span> +00423 ucstring::const_iterator first, last; +00424 first = result.begin()+pos+includeCmd.size(); +00425 last = result.end(); +00426 +00427 <a class="code" href="a03924.html">ucstring</a> name; +00428 <a class="code" href="a02647.html#NLMISC_1_1CI18Nz1954_2">skipWhiteSpace</a>(first, last); +00429 <span class="keywordflow">if</span> (<a class="code" href="a02647.html#NLMISC_1_1CI18Nz1954_1">parseMarkedString</a>(<span class="charliteral">'\"'</span>, <span class="charliteral">'\"'</span>, first, last, name)) +00430 { +00431 string subFilename = name.<a class="code" href="a03924.html#ucstringa11">toString</a>(); +00432 <a class="code" href="a04199.html#a0">nldebug</a>(<span class="stringliteral">"I18N: Including '%s' into '%s'"</span>, +00433 subFilename.c_str(), +00434 <a class="code" href="a05377.html#a2">filename</a>.c_str()); +00435 <a class="code" href="a03924.html">ucstring</a> inserted; +00436 +00437 { +00438 <a class="code" href="a02653.html">CIFile</a> testFile; +00439 <span class="keywordflow">if</span> (!testFile.<a class="code" href="a02653.html#NLMISC_1_1CIFilea12">open</a>(subFilename)) +00440 { +00441 <span class="comment">// try to open the include file relative to current file</span> +00442 subFilename = CFile::getPath(filename)+subFilename; +00443 } +00444 } +00445 <a class="code" href="a02647.html#NLMISC_1_1CI18Ne8">readTextFile</a>(subFilename, inserted, forceUtf8, fileLookup, preprocess); +00446 +00447 <span class="keyword">final</span> += inserted; +00448 } +00449 <span class="keywordflow">else</span> +00450 { +00451 <a class="code" href="a04199.html#a2">nlwarning</a>(<span class="stringliteral">"I18N: Error parsing include file in line '%s' from file '%s'"</span>, +00452 result.substr(pos, result.find(<a class="code" href="a03924.html">ucstring</a>(<span class="stringliteral">"\n"</span>), pos) - pos).<a class="code" href="a03924.html#ucstringa0">c_str</a>(), +00453 <a class="code" href="a05377.html#a2">filename</a>.c_str()); +00454 } +00455 +00456 pos = lastPos = first - result.begin(); +00457 } +00458 +00459 <span class="comment">// copy the remaining chars</span> +00460 <a class="code" href="a03924.html">ucstring</a> temp = <span class="keyword">final</span>; +00461 +00462 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i=lastPos; i<result.size(); ++i) +00463 { +00464 temp += result[i]; +00465 } +00466 +00467 <span class="comment">// final = final + temp;</span> +00468 +00469 result.swap(temp); +00470 } +00471 +00472 +00473 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne9" doxytag="NLMISC::CI18N::remove_C_Comment" ></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::CI18N::remove_C_Comment </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a03924.html">ucstring</a> & </td> + <td class="mdname1" valign="top" nowrap> <em>commentedString</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> +Remove any C style comment from the passed string. +<p> +Definition at line <a class="el" href="a05798.html#l00168">168</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00067">load()</a>. +<p> +<div class="fragment"><pre>00169 { +00170 { +00171 <a class="code" href="a03924.html">ucstring</a> temp; +00172 temp.reserve(commentedString.size()); +00173 ucstring::const_iterator first(commentedString.begin()), last(commentedString.end()); +00174 <span class="keywordflow">for</span> (;first != last; ++first) +00175 { +00176 temp.push_back(*first); +00177 <span class="keywordflow">if</span> (*first == <span class="charliteral">'['</span>) +00178 { +00179 <span class="comment">// no comment inside string literal</span> +00180 <span class="keywordflow">while</span> (++first != last) +00181 { +00182 temp.push_back(*first); +00183 <span class="keywordflow">if</span> (*first == <span class="charliteral">']'</span>) +00184 <span class="keywordflow">break</span>; +00185 } +00186 } +00187 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (*first == <span class="charliteral">'/'</span>) +00188 { +00189 <span class="comment">// start of comment ?</span> +00190 ++first; +00191 <span class="keywordflow">if</span> (first != last && *first == <span class="charliteral">'/'</span>) +00192 { +00193 temp.pop_back(); +00194 <span class="comment">// one line comment, skip until end of line</span> +00195 <span class="keywordflow">while</span> (first != last && *first != <span class="charliteral">'\n'</span>) +00196 ++first; +00197 } +00198 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (first != last && *first == <span class="charliteral">'*'</span>) +00199 { +00200 temp.pop_back(); +00201 <span class="comment">// start of multiline comment, skip until we found '*/'</span> +00202 <span class="keywordflow">while</span> (first != last && !(*first == <span class="charliteral">'*'</span> && (first+1) != last && *(first+1) == <span class="charliteral">'/'</span>)) +00203 ++first; +00204 <span class="comment">// skip the closing '/'</span> +00205 <span class="keywordflow">if</span> (first != last) +00206 ++first; +00207 } +00208 <span class="keywordflow">else</span> +00209 { +00210 temp.push_back(*first); +00211 } +00212 } +00213 } +00214 +00215 commentedString.swap(temp); +00216 } +00217 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne10" doxytag="NLMISC::CI18N::setLoadProxy" ></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::CI18N::setLoadProxy </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a02648.html">ILoadProxy</a> * </td> + <td class="mdname1" valign="top" nowrap> <em>loadProxy</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 load proxy class. Proxy can be NULL to unregister. +<p> + +<p> +Definition at line <a class="el" href="a05798.html#l00061">61</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05798.html#l00058">_LoadProxy</a>. +<p> +<div class="fragment"><pre>00062 { +00063 <a class="code" href="a02647.html#NLMISC_1_1CI18Nv2">_LoadProxy</a> = loadProxy; +00064 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nz1954_2" doxytag="NLMISC::CI18N::skipWhiteSpace" ></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::CI18N::skipWhiteSpace </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">ucstring::const_iterator & </td> + <td class="mdname" nowrap> <em>it</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>ucstring::const_iterator & </td> + <td class="mdname" nowrap> <em>last</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a03924.html">ucstring</a> * </td> + <td class="mdname" nowrap> <em>storeComments</em> = NULL</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Skip the white space. You can optionnaly pass a ucstring pointer to receive any comments string that build the white space. This is usefull if you whant to keep the comments. NB : comments are appended to the comments string. +<p> +Definition at line <a class="el" href="a05798.html#l00220">220</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00067">load()</a>, and <a class="el" href="a05798.html#l00377">readTextFile()</a>. +<p> +<div class="fragment"><pre>00221 { +00222 <span class="keywordflow">while</span> (it != last && +00223 ( +00224 *it == 0xa +00225 || *it == 0xd +00226 || *it == <span class="charliteral">' '</span> +00227 || *it == <span class="charliteral">'\t'</span> +00228 || (storeComments && *it == <span class="charliteral">'/'</span> && it+1 != last && *(it+1) == <span class="charliteral">'/'</span>) +00229 || (storeComments && *it == <span class="charliteral">'/'</span> && it+1 != last && *(it+1) == <span class="charliteral">'*'</span>) +00230 )) +00231 { +00232 <span class="keywordflow">if</span> (storeComments && *it == <span class="charliteral">'/'</span> && it+1 != last && *(it+1) == <span class="charliteral">'/'</span>) +00233 { +00234 <span class="comment">// found a one line C comment. Store it until end of line.</span> +00235 <span class="keywordflow">while</span> (it != last && *it != <span class="charliteral">'\n'</span>) +00236 storeComments->push_back(*it++); +00237 <span class="comment">// store the final '\n'</span> +00238 <span class="keywordflow">if</span> (it != last) +00239 storeComments->push_back(*it++); +00240 } +00241 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (storeComments && *it == <span class="charliteral">'/'</span> && it+1 != last && *(it+1) == <span class="charliteral">'*'</span>) +00242 { +00243 <span class="comment">// found a multiline C++ comment. store until we found the closing '*/'</span> +00244 <span class="keywordflow">while</span> (it != last && !(*it == <span class="charliteral">'*'</span> && it+1 != last && *(it+1) == <span class="charliteral">'/'</span>)) +00245 storeComments->push_back(*it++); +00246 <span class="comment">// store the final '*'</span> +00247 <span class="keywordflow">if</span> (it != last) +00248 storeComments->push_back(*it++); +00249 <span class="comment">// store the final '/'</span> +00250 <span class="keywordflow">if</span> (it != last) +00251 storeComments->push_back(*it++); +00252 <span class="comment">// and a new line.</span> +00253 storeComments->push_back(<span class="charliteral">'\r'</span>); +00254 storeComments->push_back(<span class="charliteral">'\n'</span>); +00255 } +00256 <span class="keywordflow">else</span> +00257 { +00258 <span class="comment">// just skip white space or don't store comments</span> +00259 ++it; +00260 } +00261 } +00262 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nz1955_3" doxytag="NLMISC::CI18N::stringToHash" ></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#a13">uint64</a> NLMISC::CI18N::stringToHash </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>str</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> + +<p> +Definition at line <a class="el" href="a05798.html#l00730">730</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05981.html#l00100">uint32</a>, and <a class="el" href="a05981.html#l00102">uint64</a>. +<p> +Referenced by <a class="el" href="a05635.html#l00302">STRING_MANAGER::TGetWorksheetHashValue::operator()()</a>. +<p> +<div class="fragment"><pre>00731 { +00732 <a class="code" href="a04199.html#a6">nlassert</a>(str.size() == 16); +00733 <a class="code" href="a04558.html#a11">uint32</a> low, hight; +00734 +00735 string sl, sh; +00736 sh = str.substr(0, 8); +00737 sl = str.substr(8, 8); +00738 +00739 sscanf(sh.c_str(), <span class="stringliteral">"%08X"</span>, &hight); +00740 sscanf(sl.c_str(), <span class="stringliteral">"%08X"</span>, &low); +00741 +00742 <a class="code" href="a04558.html#a13">uint64</a> hash; +00743 <a class="code" href="a04558.html#a11">uint32</a> *ph = (<a class="code" href="a04558.html#a11">uint32</a>*)&hash; +00744 +00745 ph[0] = hight; +00746 ph[1] = low; +00747 +00748 <span class="keywordflow">return</span> hash; +00749 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Ne11" doxytag="NLMISC::CI18N::writeTextFile" ></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::CI18N::writeTextFile </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string </td> + <td class="mdname" nowrap> <em>filename</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a03924.html">ucstring</a> & </td> + <td class="mdname" nowrap> <em>content</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>utf8</em> = true</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Write a unicode text file using unicode 16 or UTF-8 encoding. +<p> +Definition at line <a class="el" href="a05798.html#l00557">557</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +References <a class="el" href="a05798.html#l00627">encodeUTF8()</a>, <a class="el" href="a05538.html#l02654">file</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05981.html#l00098">uint16</a>. +<p> +<div class="fragment"><pre>00558 { +00559 <a class="code" href="a03011.html">COFile</a> <a class="code" href="a04115.html#a95">file</a>(filename); +00560 +00561 <span class="keywordflow">if</span> (!utf8) +00562 { +00563 <span class="comment">// write the unicode 16 bits tag</span> +00564 <a class="code" href="a04558.html#a9">uint16</a> unicodeTag = 0xfeff; +00565 <a class="code" href="a04115.html#a95">file</a>.serial(unicodeTag); +00566 +00567 <a class="code" href="a04558.html#a15">uint</a> i; +00568 <span class="keywordflow">for</span> (i=0; i<content.size(); ++i) +00569 { +00570 <a class="code" href="a04558.html#a9">uint16</a> c = content[i]; +00571 <a class="code" href="a04115.html#a95">file</a>.serial(c); +00572 } +00573 } +00574 <span class="keywordflow">else</span> +00575 { +00576 <span class="keyword">static</span> <span class="keywordtype">char</span> utf8Header[] = {char(0xef), char(0xbb), char(0xbf), 0}; +00577 +00578 std::string str = <a class="code" href="a02647.html#NLMISC_1_1CI18Ne0">encodeUTF8</a>(content); +00579 <span class="comment">// add the UTF-8 'not official' header</span> +00580 str = utf8Header + str; +00581 +00582 <a class="code" href="a04558.html#a15">uint</a> i; +00583 <span class="keywordflow">for</span> (i=0; i<str.size(); ++i) +00584 { +00585 <a class="code" href="a04115.html#a95">file</a>.serial(str[i]); +00586 } +00587 } +00588 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Field Documentation</h2> +<a class="anchor" name="NLMISC_1_1CI18Nv0" doxytag="NLMISC::CI18N::_LanguageCodes" ></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"> const std::string <a class="el" href="a02647.html#NLMISC_1_1CI18Nv0">NLMISC::CI18N::_LanguageCodes</a><code> [static, private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +<b>Initial value:</b><div class="fragment"><pre> +{ + std::string(<span class="stringliteral">"en"</span>), + std::string(<span class="stringliteral">"fr"</span>), + std::string(<span class="stringliteral">"zh-TW"</span>), + std::string(<span class="stringliteral">"zh-CN"</span>) +} +</pre></div> +<p> +Definition at line <a class="el" href="a05798.html#l00044">44</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00140">get()</a>, and <a class="el" href="a05798.html#l00067">load()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nv1" doxytag="NLMISC::CI18N::_LanguagesNamesLoaded" ></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 <a class="el" href="a02647.html#NLMISC_1_1CI18Nv1">NLMISC::CI18N::_LanguagesNamesLoaded</a> = false<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="a05798.html#l00056">56</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nv2" doxytag="NLMISC::CI18N::_LoadProxy" ></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="a02648.html">CI18N::ILoadProxy</a> * <a class="el" href="a02647.html#NLMISC_1_1CI18Nv2">NLMISC::CI18N::_LoadProxy</a> = 0<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="a05798.html#l00058">58</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00067">load()</a>, and <a class="el" href="a05798.html#l00061">setLoadProxy()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nv3" doxytag="NLMISC::CI18N::_NbLanguages" ></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"> const <a class="el" href="a04558.html#a15">uint</a> <a class="el" href="a02647.html#NLMISC_1_1CI18Nv3">NLMISC::CI18N::_NbLanguages</a> = sizeof(<a class="el" href="a02647.html#NLMISC_1_1CI18Nv0">CI18N::_LanguageCodes</a>) / sizeof(std::string)<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="a05798.html#l00052">52</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00067">load()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nv4" doxytag="NLMISC::CI18N::_NotTranslatedValue" ></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"> const <a class="el" href="a03924.html">ucstring</a> <a class="el" href="a02647.html#NLMISC_1_1CI18Nv4">NLMISC::CI18N::_NotTranslatedValue</a><code> [static, private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nv5" doxytag="NLMISC::CI18N::_SelectedLanguage" ></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#a10">sint32</a> <a class="el" href="a02647.html#NLMISC_1_1CI18Nv5">NLMISC::CI18N::_SelectedLanguage</a> = -1<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="a05798.html#l00057">57</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00140">get()</a>, and <a class="el" href="a05798.html#l00067">load()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nv6" doxytag="NLMISC::CI18N::_StrMap" ></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="a02647.html#NLMISC_1_1CI18Ny0">CI18N::StrMapContainer</a> <a class="el" href="a02647.html#NLMISC_1_1CI18Nv6">NLMISC::CI18N::_StrMap</a><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="a05798.html#l00053">53</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00140">get()</a>, and <a class="el" href="a05798.html#l00067">load()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CI18Nv7" doxytag="NLMISC::CI18N::_StrMapLoaded" ></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 <a class="el" href="a02647.html#NLMISC_1_1CI18Nv7">NLMISC::CI18N::_StrMapLoaded</a> = false<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="a05798.html#l00054">54</a> of file <a class="el" href="a05798.html">i18n.cpp</a>. +<p> +Referenced by <a class="el" href="a05798.html#l00067">load()</a>. </td> + </tr> +</table> +<hr>The documentation for this class was generated from the following files:<ul> +<li><a class="el" href="a05799.html">i18n.h</a><li><a class="el" href="a05798.html">i18n.cpp</a></ul> +<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:18:40 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> |