aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/i18n_8cpp-source.html
blob: 9eb0dc40f1c7c8967f66b5d46e82fa849834020a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
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>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</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>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</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>
&nbsp;

<!-- 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>&nbsp;</td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <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> &nbsp; </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&lt;string, ucstring&gt;                    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&lt;ucstring&gt;                                 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 &amp;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 &amp; 0xFE) == 0xFC)
00058         {
00059                 code &amp;= 0x01;
00060                 iterations = 5;
00061         }
00062         <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((code &amp; 0xFC) == 0xF8)
00063         {
00064                 code &amp;= 0x03;
00065                 iterations = 4;
00066         }
00067         <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((code &amp; 0xF8) == 0xF0)
00068         {
00069                 code &amp;= 0x07;
00070                 iterations = 3;
00071         }
00072         <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((code &amp; 0xF0) == 0xE0)
00073         {
00074                 code &amp;= 0x0F;
00075                 iterations = 2;
00076         }
00077         <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((code &amp; 0xE0) == 0xC0)
00078         {
00079                 code &amp;= 0x1F;
00080                 iterations = 1;
00081         }
00082         <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((code &amp; 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 &lt; iterations; i++)
00092         {
00093                 uint8 ch;
00094                 is.serial (ch);
00095 
00096                 <font class="keywordflow">if</font> ((ch &amp; 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 &lt;&lt;= 6;
00102                 code |= (ucchar)(ch &amp; 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&gt;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 &amp;is, <font class="keywordtype">int</font> &amp;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 &amp;&amp; c == <font class="charliteral">'\n'</font>)
00130                 {
00131                         line++;
00132                         <font class="keywordflow">return</font>;
00133                 }
00134                 <font class="keywordflow">if</font> (longcomment &amp;&amp; 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 &amp;is, <font class="keywordtype">int</font> &amp;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 &gt;= 0 &amp;&amp; lid &lt; <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 &lt;&lt; <font class="stringliteral">"\""</font> &lt;&lt; <a class="code" href="classNLMISC_1_1CI18N.html#r4">_LanguageFiles</a>[lid] &lt;&lt; <font class="stringliteral">"\""</font> &lt;&lt; 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 &amp;lval, <font class="keyword">const</font> string &amp;rval)
00176 {
00177         sint i;
00178         <font class="keywordflow">for</font> (i = 0; i &lt; (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&gt;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 &lt; (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&gt;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 &lt; (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 &lt;&lt; <font class="stringliteral">"\""</font>;
00202                 <font class="keywordflow">for</font> (sint i = 0; i &lt; (sint) lval.size (); i++)
00203                 {
00204                         <font class="keywordflow">if</font> (lval[i] == <font class="charliteral">'"'</font>)
00205                                 ss2 &lt;&lt; <font class="charliteral">'\\'</font>;
00206                         ss2 &lt;&lt; lval[i];
00207                 }
00208                 ss2 &lt;&lt; <font class="stringliteral">"\" = \""</font>;
00209                 <font class="keywordflow">for</font> (sint i2 = 0; i2 &lt; (sint) rval.size(); i2++)
00210                 {
00211                         <font class="keywordflow">if</font> (rval[i2] == <font class="charliteral">'"'</font>)
00212                                 ss2 &lt;&lt; <font class="charliteral">'\\'</font>;
00213                         ss2 &lt;&lt; rval[i2];
00214                 }
00215                 ss2 &lt;&lt; <font class="stringliteral">"\""</font> &lt;&lt; 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 &gt;= 0 &amp;&amp; lid &lt; <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&lt;ItStrMap, bool&gt; 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 &amp;)
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> &amp;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 &lt;&lt; <font class="stringliteral">"&lt;Not Translated&gt;:"</font> &lt;&lt; str;
00373 
00374                 pair&lt;ItStrMap, bool&gt; 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-&gt;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">"&lt;NoLanguage&gt;"</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&lt;ucstring&gt; &amp;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 &lt; (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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </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>