diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/i18n_8cpp-source.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to 'docs/doxygen/nel/i18n_8cpp-source.html')
-rw-r--r-- | docs/doxygen/nel/i18n_8cpp-source.html | 525 |
1 files changed, 525 insertions, 0 deletions
diff --git a/docs/doxygen/nel/i18n_8cpp-source.html b/docs/doxygen/nel/i18n_8cpp-source.html new file mode 100644 index 00000000..9eb0dc40 --- /dev/null +++ b/docs/doxygen/nel/i18n_8cpp-source.html @@ -0,0 +1,525 @@ +<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> +<HTML> +<HEAD> + <TITLE>nevrax.org : docs</TITLE> + <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css"> + <link href="doxygen.css" rel="stylesheet" type="text/css"> +</HEAD> +<BODY MARGINHEIGHT="0" MARGINWIDTH="0"> + +<!-- uplinks --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A> </TD> + <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A> </TD> + </TR> +</TABLE> + +<!-- banner Nevrax --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%> + <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR> +</TABLE> + +<!-- main table --> +<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%> + <TR> + <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD> + <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + + <!------ Begin Box ------> + <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black> + <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF> + <TABLE cellspacing=0 cellpadding=1 border=0> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr> + <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr> + </TABLE> + </TD></TR></TABLE></TD></TR></TABLE> + <!------ End Box ------> + + </TD> + <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD> + <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT=""> + +<!-- title --> +<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td> +<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A> +</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT=""> +</td></tr></table> + + +<!-- block --> +<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD> + <TD><B>Documentation</B></TD> + <TD ALIGN=RIGHT> </td> +</tr></table> +<!-- Generated by Doxygen 1.2.14 --> +<center> +<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> </center> +<hr><h1>i18n.cpp</h1><a href="i18n_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 +00009 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font> +00010 <font class="comment"> *</font> +00011 <font class="comment"> * This file is part of NEVRAX NEL.</font> +00012 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font> +00013 <font class="comment"> * it under the terms of the GNU General Public License as published by</font> +00014 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font> +00015 <font class="comment"> * any later version.</font> +00016 <font class="comment"></font> +00017 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font> +00018 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font> +00019 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font> +00020 <font class="comment"> * General Public License for more details.</font> +00021 <font class="comment"></font> +00022 <font class="comment"> * You should have received a copy of the GNU General Public License</font> +00023 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font> +00024 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font> +00025 <font class="comment"> * MA 02111-1307, USA.</font> +00026 <font class="comment"> */</font> +00027 +00028 +00029 <font class="preprocessor">#include "<a class="code" href="stdmisc_8h.html">stdmisc.h</a>"</font> +00030 +00031 <font class="preprocessor">#include "<a class="code" href="i18n_8h.html">nel/misc/i18n.h</a>"</font> +00032 +00033 <font class="keyword">using</font> <font class="keyword">namespace </font>std; +00034 +00035 <font class="keyword">namespace </font>NLMISC { +00036 +<a name="l00037"></a><a class="code" href="classNLMISC_1_1CI18N.html#r4">00037</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *CI18N::_LanguageFiles[] = { <font class="stringliteral">"english"</font>, <font class="stringliteral">"french"</font> }; +00038 +<a name="l00039"></a><a class="code" href="classNLMISC_1_1CI18N.html#r0">00039</a> map<string, ucstring> CI18N::_StrMap; +<a name="l00040"></a><a class="code" href="classNLMISC_1_1CI18N.html#r1">00040</a> <font class="keywordtype">bool</font> CI18N::_StrMapLoaded = <font class="keyword">false</font>; +<a name="l00041"></a><a class="code" href="classNLMISC_1_1CI18N.html#r2">00041</a> string CI18N::_Path = <font class="stringliteral">""</font>; +<a name="l00042"></a><a class="code" href="classNLMISC_1_1CI18N.html#r3">00042</a> string CI18N::_FileName = <font class="stringliteral">""</font>; +00043 +<a name="l00044"></a><a class="code" href="classNLMISC_1_1CI18N.html#r5">00044</a> vector<ucstring> CI18N::_LanguageNames; +<a name="l00045"></a><a class="code" href="classNLMISC_1_1CI18N.html#r6">00045</a> <font class="keywordtype">bool</font> CI18N::_LanguagesNamesLoaded = <font class="keyword">false</font>; +<a name="l00046"></a><a class="code" href="classNLMISC_1_1CI18N.html#r7">00046</a> sint32 CI18N::_SelectedLanguage = -1; +00047 +<a name="l00048"></a><a class="code" href="classNLMISC_1_1CI18N.html#f0">00048</a> <a class="code" href="types__nl_8h.html#a15">ucchar</a> CI18N::eatChar (IStream &is) +00049 { +00050 uint8 c; +00051 <a class="code" href="types__nl_8h.html#a15">ucchar</a> code; +00052 sint iterations = 0; +00053 +00054 is.serial (c); +00055 code = c; +00056 +00057 <font class="keywordflow">if</font> ((code & 0xFE) == 0xFC) +00058 { +00059 code &= 0x01; +00060 iterations = 5; +00061 } +00062 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((code & 0xFC) == 0xF8) +00063 { +00064 code &= 0x03; +00065 iterations = 4; +00066 } +00067 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((code & 0xF8) == 0xF0) +00068 { +00069 code &= 0x07; +00070 iterations = 3; +00071 } +00072 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((code & 0xF0) == 0xE0) +00073 { +00074 code &= 0x0F; +00075 iterations = 2; +00076 } +00077 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((code & 0xE0) == 0xC0) +00078 { +00079 code &= 0x1F; +00080 iterations = 1; +00081 } +00082 <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((code & 0x80) == 0x80) +00083 { +00084 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"CI18N::eatChar(): Invalid UTF-8 character"</font>); +00085 } +00086 <font class="keywordflow">else</font> +00087 { +00088 <font class="keywordflow">return</font> code; +00089 } +00090 +00091 <font class="keywordflow">for</font> (sint i = 0; i < iterations; i++) +00092 { +00093 uint8 ch; +00094 is.serial (ch); +00095 +00096 <font class="keywordflow">if</font> ((ch & 0xC0) != 0x80) +00097 { +00098 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"CI18N::eatChar(): Invalid UTF-8 character"</font>); +00099 } +00100 +00101 code <<= 6; +00102 code |= (ucchar)(ch & 0x3F); +00103 } +00104 <font class="keywordflow">return</font> code; +00105 } +00106 +<a name="l00107"></a><a class="code" href="classNLMISC_1_1CI18N.html#f1">00107</a> <font class="keywordtype">void</font> CI18N::checkASCII7B (<a class="code" href="types__nl_8h.html#a15">ucchar</a> c) +00108 { +00109 <font class="keywordflow">if</font> (c>0x7F) +00110 { +00111 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"CI18N::checkASCII7B: '%c' isn't ASCII 7bits"</font>, c); +00112 } +00113 } +00114 +00115 +<a name="l00116"></a><a class="code" href="classNLMISC_1_1CI18N.html#f4">00116</a> <font class="keywordtype">void</font> CI18N::skipComment(IStream &is, <font class="keywordtype">int</font> &line) +00117 { +00118 <font class="comment">// the first '/' is already eated</font> +00119 <a class="code" href="types__nl_8h.html#a15">ucchar</a> c; +00120 <font class="keywordtype">bool</font> longcomment = <font class="keyword">false</font>; +00121 +00122 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (is); +00123 <font class="keywordflow">if</font> (c == <font class="charliteral">'/'</font>) longcomment = <font class="keyword">false</font>; +00124 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (c == <font class="charliteral">'*'</font>) longcomment = <font class="keyword">true</font>; +00125 +00126 <font class="keywordflow">do</font> +00127 { +00128 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (is); +00129 <font class="keywordflow">if</font> (!longcomment && c == <font class="charliteral">'\n'</font>) +00130 { +00131 line++; +00132 <font class="keywordflow">return</font>; +00133 } +00134 <font class="keywordflow">if</font> (longcomment && c == <font class="charliteral">'*'</font>) +00135 { +00136 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (is); +00137 <font class="keywordflow">if</font> (c == <font class="charliteral">'/'</font>) <font class="keywordflow">return</font>; +00138 } +00139 } +00140 <font class="keywordflow">while</font> (true); +00141 } +00142 +<a name="l00143"></a><a class="code" href="classNLMISC_1_1CI18N.html#f5">00143</a> <a class="code" href="types__nl_8h.html#a15">ucchar</a> CI18N::skipWS(IStream &is, <font class="keywordtype">int</font> &line) +00144 { +00145 <a class="code" href="types__nl_8h.html#a15">ucchar</a> c; +00146 <font class="keywordflow">do</font> +00147 { +00148 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (is); +00149 <font class="keywordflow">if</font> (c == <font class="charliteral">'\n'</font>) line++; +00150 <font class="keywordflow">if</font> (c == <font class="charliteral">'/'</font>) +00151 { +00152 <a class="code" href="classNLMISC_1_1CI18N.html#f4">skipComment</a> (is, line); +00153 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (is); +00154 } +00155 } +00156 <font class="keywordflow">while</font> (isspace (c)); +00157 <font class="keywordflow">return</font> c; +00158 } +00159 +00160 +<a name="l00161"></a><a class="code" href="classNLMISC_1_1CI18N.html#f2">00161</a> <font class="keywordtype">void</font> CI18N::createLanguageFile (uint32 lid) +00162 { +00163 <a class="code" href="debug_8h.html#a6">nlassert</a> (lid >= 0 && lid < <font class="keyword">sizeof</font> (<a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>)/<font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[0])); +00164 +00165 <font class="comment">// write the new string in the file</font> +00166 COFile cof; +00167 <a class="code" href="debug_8h.html#a9">nlverify</a> (cof.open (<a class="code" href="classNLMISC_1_1CI18N.html#r2">_Path</a> + <a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[lid] + <font class="stringliteral">".uxt"</font>, <font class="keyword">true</font>, <font class="keyword">true</font>)); +00168 +00169 stringstream ss2; +00170 ss2 << <font class="stringliteral">"\""</font> << <a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[lid] << <font class="stringliteral">"\""</font> << endl; +00171 cof.serialBuffer((uint8 *)(ss2.str().c_str()), ss2.str().size()); +00172 cof.close (); +00173 } +00174 +<a name="l00175"></a><a class="code" href="classNLMISC_1_1CI18N.html#f3">00175</a> <font class="keywordtype">void</font> CI18N::createLanguageEntry (<font class="keyword">const</font> string &lval, <font class="keyword">const</font> string &rval) +00176 { +00177 sint i; +00178 <font class="keywordflow">for</font> (i = 0; i < (sint)lval.size () ; i++) +00179 { +00180 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> c = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>) lval[i]; +00181 <font class="keywordflow">if</font> (c>0x7F) +00182 { +00183 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"CI18N::createLanguageEntry(\"%s\"): your string must be ASCII 7bits ('%c' isn't ASCII 7bits)"</font>, lval.c_str(), c); +00184 } +00185 } +00186 <font class="keywordflow">for</font> (i = 0; i < (sint)rval.size () ; i++) +00187 { +00188 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> c = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>) rval[i]; +00189 <font class="keywordflow">if</font> (c>0x7F) +00190 { +00191 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"CI18N::createLanguageEntry(\"%s\"): your string must be ASCII 7bits ('%c' isn't ASCII 7bits)"</font>, rval.c_str(), c); +00192 } +00193 } +00194 +00195 <font class="keywordflow">for</font> (i = 0; i < (sint)(<font class="keyword">sizeof</font>(_LanguageFiles)/<font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[0])); i++) +00196 { +00197 COFile cof; +00198 <a class="code" href="debug_8h.html#a9">nlverify</a> (cof.open (<a class="code" href="classNLMISC_1_1CI18N.html#r2">_Path</a> + <a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[i] + <font class="stringliteral">".uxt"</font>, <font class="keyword">true</font>, <font class="keyword">true</font>)); +00199 +00200 stringstream ss2; +00201 ss2 << <font class="stringliteral">"\""</font>; +00202 <font class="keywordflow">for</font> (sint i = 0; i < (sint) lval.size (); i++) +00203 { +00204 <font class="keywordflow">if</font> (lval[i] == <font class="charliteral">'"'</font>) +00205 ss2 << <font class="charliteral">'\\'</font>; +00206 ss2 << lval[i]; +00207 } +00208 ss2 << <font class="stringliteral">"\" = \""</font>; +00209 <font class="keywordflow">for</font> (sint i2 = 0; i2 < (sint) rval.size(); i2++) +00210 { +00211 <font class="keywordflow">if</font> (rval[i2] == <font class="charliteral">'"'</font>) +00212 ss2 << <font class="charliteral">'\\'</font>; +00213 ss2 << rval[i2]; +00214 } +00215 ss2 << <font class="stringliteral">"\""</font> << endl; +00216 cof.serialBuffer((uint8 *)(ss2.str().c_str()), ss2.str().size()); +00217 cof.close (); +00218 } +00219 } +00220 +<a name="l00221"></a><a class="code" href="classNLMISC_1_1CI18N.html#d4">00221</a> <font class="keywordtype">void</font> CI18N::setPath (<font class="keyword">const</font> <font class="keywordtype">char</font>* str) +00222 { +00223 <a class="code" href="classNLMISC_1_1CI18N.html#r2">_Path</a> = str; +00224 } +00225 +<a name="l00226"></a><a class="code" href="classNLMISC_1_1CI18N.html#d1">00226</a> <font class="keywordtype">void</font> CI18N::load (uint32 lid) +00227 { +00228 <a class="code" href="debug_8h.html#a6">nlassert</a> (lid >= 0 && lid < <font class="keyword">sizeof</font> (<a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>)/<font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[0])); +00229 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLMISC_1_1CI18N.html#r6">_LanguagesNamesLoaded</a>); +00230 +00231 <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a> = <a class="code" href="classNLMISC_1_1CI18N.html#r2">_Path</a> + <a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[lid] + <font class="stringliteral">".uxt"</font>; +00232 +00233 <a class="code" href="classNLMISC_1_1CI18N.html#r7">_SelectedLanguage</a> = lid; +00234 +00235 <font class="keywordflow">if</font> (_StrMapLoaded) <a class="code" href="classNLMISC_1_1CI18N.html#r0">_StrMap</a>.clear (); +00236 <font class="keywordflow">else</font> <a class="code" href="classNLMISC_1_1CI18N.html#r1">_StrMapLoaded</a> = <font class="keyword">true</font>; +00237 +00238 CIFile cf; +00239 <font class="comment">// if the file does not exist, it'll be create automatically</font> +00240 <font class="keywordflow">if</font> (!cf.open (<a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>, <font class="keyword">true</font>)) +00241 { +00242 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Could not open file \"%s\" (this file should contain the %s language (lid:%d))"</font>, <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str (), <a class="code" href="classNLMISC_1_1CI18N.html#r5">_LanguageNames</a>[lid].toString().c_str(), lid); +00243 <a class="code" href="classNLMISC_1_1CI18N.html#f2">createLanguageFile</a> (lid); +00244 <font class="keywordflow">return</font>; +00245 } +00246 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"Loading file \"%s\" (this file should contain the %s language (lid:%d))"</font>, <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str (), <a class="code" href="classNLMISC_1_1CI18N.html#r5">_LanguageNames</a>[lid].toString ().c_str(), lid); +00247 +00248 <font class="keywordtype">bool</font> startstr = <font class="keyword">false</font>, equal = <font class="keyword">false</font>, second = <font class="keyword">false</font>; +00249 <font class="keywordtype">int</font> line = 1; +00250 <font class="keywordflow">try</font> +00251 { +00252 <a class="code" href="types__nl_8h.html#a15">ucchar</a> c; +00253 <font class="comment">// get the language name</font> +00254 c = <a class="code" href="classNLMISC_1_1CI18N.html#f5">skipWS</a> (cf, line); +00255 <font class="keywordflow">if</font> (c != <font class="charliteral">'"'</font>) +00256 { +00257 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"open '\"' missing in \"%s\" line %d"</font>, <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str(), line); +00258 } +00259 <font class="keywordflow">do</font> +00260 { +00261 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (cf); +00262 <font class="keywordflow">if</font> (c == <font class="charliteral">'\\'</font>) +00263 { +00264 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (cf); +00265 } +00266 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (c == <font class="charliteral">'"'</font>) <font class="keywordflow">break</font>; +00267 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (c == <font class="charliteral">'\n'</font>) line++; +00268 } +00269 <font class="keywordflow">while</font> (true); +00270 +00271 <font class="keywordflow">while</font> (true) +00272 { +00273 string codstr; +00274 <a class="code" href="classucstring.html">ucstring</a> trsstr; +00275 <a class="code" href="types__nl_8h.html#a15">ucchar</a> c; +00276 +00277 codstr = <font class="stringliteral">""</font>; +00278 trsstr = <font class="stringliteral">""</font>; +00279 +00280 <font class="comment">// get the coder string</font> +00281 c = <a class="code" href="classNLMISC_1_1CI18N.html#f5">skipWS</a> (cf, line); +00282 <font class="keywordflow">if</font> (c != <font class="charliteral">'"'</font>) +00283 { +00284 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"open '\"' missing in \"%s\" line %d"</font>, <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str(), line); +00285 } +00286 startstr = <font class="keyword">true</font>; +00287 <font class="keywordflow">do</font> +00288 { +00289 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (cf); +00290 <font class="keywordflow">if</font> (c == <font class="charliteral">'\\'</font>) +00291 { +00292 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (cf); +00293 } +00294 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (c == <font class="charliteral">'"'</font>) <font class="keywordflow">break</font>; +00295 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (c == <font class="charliteral">'\n'</font>) line++; +00296 <a class="code" href="classNLMISC_1_1CI18N.html#f1">checkASCII7B</a> (c); +00297 codstr += (char) c; +00298 } +00299 <font class="keywordflow">while</font> (true); +00300 startstr = <font class="keyword">false</font>; +00301 +00302 equal = <font class="keyword">true</font>; +00303 <font class="comment">// get the '='</font> +00304 c = <a class="code" href="classNLMISC_1_1CI18N.html#f5">skipWS</a> (cf, line); +00305 <font class="keywordflow">if</font> (c != <font class="charliteral">'='</font>) +00306 { +00307 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"'=' missing in \"%s\" line %d"</font>, <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str(), line); +00308 } +00309 equal = <font class="keyword">false</font>; +00310 +00311 second = <font class="keyword">true</font>; +00312 <font class="comment">// get the translated string</font> +00313 c = <a class="code" href="classNLMISC_1_1CI18N.html#f5">skipWS</a> (cf, line); +00314 <font class="keywordflow">if</font> (c != <font class="charliteral">'"'</font>) +00315 { +00316 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"open '\"' missing in \"%s\" line %d"</font>, <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str(), line); +00317 } +00318 startstr = <font class="keyword">true</font>; +00319 <font class="keywordflow">do</font> +00320 { +00321 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (cf); +00322 <font class="keywordflow">if</font> (c == <font class="charliteral">'\\'</font>) +00323 { +00324 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (cf); +00325 } +00326 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (c == <font class="charliteral">'"'</font>) <font class="keywordflow">break</font>; +00327 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (c == <font class="charliteral">'\n'</font>) line++; +00328 trsstr += c; +00329 } +00330 <font class="keywordflow">while</font> (true); +00331 startstr = <font class="keyword">false</font>; +00332 second = <font class="keyword">false</font>; +00333 +00334 <font class="comment">// Insert the node.</font> +00335 pair<ItStrMap, bool> pr; +00336 pr = <a class="code" href="classNLMISC_1_1CI18N.html#r0">_StrMap</a>.insert (<a class="code" href="classNLMISC_1_1CI18N.html#u1">ValueStrMap</a> (codstr, trsstr)); +00337 <font class="keywordflow">if</font> (!pr.second) +00338 { +00339 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"the string '%s' is duplicate in the langage file '%s' line %d, ignored the last one"</font>, codstr.c_str(), <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str(), line); +00340 } +00341 } +00342 } +00343 <font class="keywordflow">catch</font> (EReadError &) +00344 { +00345 <font class="comment">// always comes here when it's the end of file</font> +00346 <font class="keywordflow">if</font> (startstr) +00347 { +00348 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"a string didn't have the close '\"' in \"%s\" line %d"</font>, <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str(), line); +00349 } +00350 <font class="keywordflow">if</font> (equal) +00351 { +00352 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"'=' missing in \"%s\" line %d"</font>, <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str(), line); +00353 } +00354 <font class="keywordflow">if</font> (second) +00355 { +00356 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"open '\"' missing in \"%s\" line %d"</font>, <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str(), line); +00357 } +00358 cf.close (); +00359 } +00360 } +00361 +<a name="l00362"></a><a class="code" href="classNLMISC_1_1CI18N.html#d3">00362</a> <font class="keyword">const</font> <a class="code" href="classucstring.html">ucstring</a> &CI18N::get (<font class="keyword">const</font> <font class="keywordtype">char</font> *str) +00363 { +00364 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="classNLMISC_1_1CI18N.html#r1">_StrMapLoaded</a>); +00365 +00366 <a class="code" href="classNLMISC_1_1CI18N.html#u0">ItStrMap</a> it = <a class="code" href="classNLMISC_1_1CI18N.html#r0">_StrMap</a>.find (str); +00367 +00368 <font class="keywordflow">if</font> (it == <a class="code" href="classNLMISC_1_1CI18N.html#r0">_StrMap</a>.end ()) +00369 { +00370 <font class="comment">// str not found, add it in the map and in the file</font> +00371 stringstream ss; +00372 ss << <font class="stringliteral">"<Not Translated>:"</font> << str; +00373 +00374 pair<ItStrMap, bool> pr; +00375 +00376 pr = <a class="code" href="classNLMISC_1_1CI18N.html#r0">_StrMap</a>.insert (<a class="code" href="classNLMISC_1_1CI18N.html#u1">ValueStrMap</a> (str, ss.str())); +00377 <a class="code" href="debug_8h.html#a6">nlassert</a> (pr.second); +00378 it = pr.first; +00379 +00380 <font class="comment">// write the new string in all files</font> +00381 <a class="code" href="classNLMISC_1_1CI18N.html#f3">createLanguageEntry</a> (str, ss.str()); +00382 +00383 <font class="comment">// warn the user</font> +00384 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"\"%s\" is not in the \"%s\" language file, I add in all languages files."</font>, str, <a class="code" href="classNLMISC_1_1CI18N.html#r3">_FileName</a>.c_str()); +00385 } +00386 +00387 <font class="keywordflow">return</font> it->second; +00388 } +00389 +00390 +<a name="l00391"></a><a class="code" href="classNLMISC_1_1CI18N.html#d2">00391</a> string CI18N::getCurrentLanguage () +00392 { +00393 <font class="keywordflow">if</font> (<a class="code" href="classNLMISC_1_1CI18N.html#r7">_SelectedLanguage</a> == -1) +00394 <font class="keywordflow">return</font> <font class="stringliteral">"<NoLanguage>"</font>; +00395 <font class="keywordflow">else</font> +00396 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[<a class="code" href="classNLMISC_1_1CI18N.html#r7">_SelectedLanguage</a>]; +00397 } +00398 +<a name="l00399"></a><a class="code" href="classNLMISC_1_1CI18N.html#d0">00399</a> <font class="keyword">const</font> vector<ucstring> &CI18N::getLanguageNames() +00400 { +00401 CIFile cf; +00402 +00403 <font class="keywordflow">if</font> (!<a class="code" href="classNLMISC_1_1CI18N.html#r6">_LanguagesNamesLoaded</a>) +00404 { +00405 <font class="keywordflow">for</font> (<font class="keywordtype">int</font> i = 0; i < (int)(<font class="keyword">sizeof</font>(_LanguageFiles)/<font class="keyword">sizeof</font>(<a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[0])); i++) +00406 { +00407 string fn = <a class="code" href="classNLMISC_1_1CI18N.html#r2">_Path</a> + <a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[i] + <font class="stringliteral">".uxt"</font>; +00408 +00409 <a class="code" href="classucstring.html">ucstring</a> lg; +00410 +00411 <font class="keywordflow">if</font> (!cf.open (fn, <font class="keyword">true</font>)) +00412 { +00413 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"Could not open file \"%s\" (lid:%d)"</font>, fn.c_str(), i); +00414 <a class="code" href="classNLMISC_1_1CI18N.html#f2">createLanguageFile</a> (i); +00415 lg = <a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[i]; +00416 } +00417 <font class="keywordflow">else</font> +00418 { +00419 <font class="keywordtype">int</font> line = 1; +00420 <font class="keywordflow">try</font> +00421 { +00422 <a class="code" href="types__nl_8h.html#a15">ucchar</a> c; +00423 <font class="comment">// get the language name</font> +00424 c = <a class="code" href="classNLMISC_1_1CI18N.html#f5">skipWS</a> (cf, line); +00425 <font class="keywordflow">if</font> (c != <font class="charliteral">'"'</font>) +00426 { +00427 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"open '\"' missing in \"%s\" line %d"</font>, fn.c_str(), line); +00428 } +00429 <font class="keywordflow">do</font> +00430 { +00431 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (cf); +00432 <font class="keywordflow">if</font> (c == <font class="charliteral">'\\'</font>) +00433 { +00434 c = <a class="code" href="classNLMISC_1_1CI18N.html#f0">eatChar</a> (cf); +00435 } +00436 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (c == <font class="charliteral">'"'</font>) <font class="keywordflow">break</font>; +00437 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (c == <font class="charliteral">'\n'</font>) line++; +00438 lg += c; +00439 } +00440 <font class="keywordflow">while</font> (true); +00441 } +00442 <font class="keywordflow">catch</font> (EReadError) +00443 { +00444 <a class="code" href="debug_8h.html#a3">nlerror</a> (<font class="stringliteral">"Missing the language name in the beginning of the file %s"</font>, fn.c_str()); +00445 } +00446 cf.close (); +00447 } +00448 <font class="comment">// add the language name</font> +00449 <a class="code" href="classNLMISC_1_1CI18N.html#r5">_LanguageNames</a>.push_back (lg); +00450 <a class="code" href="debug_8h.html#a0">nldebug</a> (<font class="stringliteral">"add %d '%s' '%s'"</font>, i, fn.c_str (), <a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[i]); +00451 } +00452 <a class="code" href="classNLMISC_1_1CI18N.html#r6">_LanguagesNamesLoaded</a> = <font class="keyword">true</font>; +00453 } +00454 <font class="keywordflow">return</font> <a class="code" href="classNLMISC_1_1CI18N.html#r5">_LanguageNames</a>; +00455 } +00456 +00457 +00458 } <font class="comment">// NLMISC</font> +</pre></div> + +<!-- footer --> +<BR><FONT Size=+5> </FONT> +</TD> +<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD> +</TR> +</TABLE> +</BODY> +</HTML> |