aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/a03729.html
blob: c28e6f28b5bb59a8711062b2f4330c8c22b8adde (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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
<!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::CWordsDictionary 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&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="namespacemembers.html">Namespace&nbsp;Members</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a>  | <span class="search"><u>S</u>earch&nbsp;for&nbsp;<input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
<h1>NLMISC::CWordsDictionary Class Reference</h1><code>#include &lt;<a class="el" href="a06754.html">words_dictionary.h</a>&gt;</code>
<p>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Words dictionary: allows to search for keys and words in _words_&lt;language&gt;.txt Unicode files. All searches are case not-sensitive.<p>
<dl compact><dt><b>Author:</b></dt><dd>Olivier Cado <p>
Nevrax France </dd></dl>
<dl compact><dt><b>Date:</b></dt><dd>2003 </dd></dl>

<p>

<p>
Definition at line <a class="el" href="a06754.html#l00044">44</a> of file <a class="el" href="a06754.html">words_dictionary.h</a>.<table border=0 cellpadding=0 cellspacing=0>
<tr><td></td></tr>
<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya0">CWordsDictionary</a> ()</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Constructor.  <a href="#NLMISC_1_1CWordsDictionarya0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya1">exactLookupByKey</a> (const <a class="el" href="a03435.html">CSString</a> &amp;key, <a class="el" href="a03670.html">CVectorSString</a> &amp;resultVec)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set the result vector with the word(s) corresponding to the key.  <a href="#NLMISC_1_1CWordsDictionarya1"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a03670.html">CVectorSString</a> &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya2">getKeys</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>const <a class="el" href="a03670.html">CVectorSString</a> &amp;&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya3">getWords</a> ()</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03435.html">CSString</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya4">getWordsKey</a> (const <a class="el" href="a03435.html">CSString</a> &amp;resultStr)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Return the key contained in the provided string returned by <a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya6">lookup()</a> (without extension).  <a href="#NLMISC_1_1CWordsDictionarya4"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top>bool&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya5">init</a> (const std::string &amp;configFileName="words_dic.cfg")</td></tr>

<tr><td class="memItemLeft" nowrap align=right valign=top>void&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya6">lookup</a> (const <a class="el" href="a03435.html">CSString</a> &amp;inputStr, <a class="el" href="a03670.html">CVectorSString</a> &amp;resultVec)</td></tr>

<tr><td colspan=2><br><h2>Protected Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03435.html">CSString</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionaryb0">makeResult</a> (const <a class="el" href="a03435.html">CSString</a> key, const <a class="el" href="a03435.html">CSString</a> word)</td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Make a result string.  <a href="#NLMISC_1_1CWordsDictionaryb0"></a><br><br></td></tr>
<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03670.html">CVectorSString</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Keys (same indices as in _Words).  <a href="#NLMISC_1_1CWordsDictionaryr0"></a><br><br></td></tr>
<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03670.html">CVectorSString</a>&nbsp;</td><td class="memItemRight" valign=bottom><a class="el" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a></td></tr>

<tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Words (same indices as in _Keys).  <a href="#NLMISC_1_1CWordsDictionaryr1"></a><br><br></td></tr>
</table>
<hr><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" name="NLMISC_1_1CWordsDictionarya0" doxytag="NLMISC::CWordsDictionary::CWordsDictionary" ></a><p>
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td class="mdRow">
      <table cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td class="md" nowrap valign="top"> NLMISC::CWordsDictionary::CWordsDictionary </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Constructor. 
<p>

<p>
Definition at line <a class="el" href="a06753.html#l00041">41</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>.
<p>
<div class="fragment"><pre>00042 {
00043 }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="NLMISC_1_1CWordsDictionarya1" doxytag="NLMISC::CWordsDictionary::exactLookupByKey" ></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::CWordsDictionary::exactLookupByKey </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03435.html">CSString</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>key</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a03670.html">CVectorSString</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>resultVec</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Set the result vector with the word(s) corresponding to the key. 
<p>

<p>
Definition at line <a class="el" href="a06753.html#l00190">190</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>.
<p>
References <a class="el" href="a06754.html#l00091">_Words</a>.
<p>
<div class="fragment"><pre>00191 {
00192         <span class="comment">// Search</span>
00193         <span class="keywordflow">for</span> ( CVectorSString::const_iterator ivs=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.begin(); ivs!=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.end(); ++ivs )
00194         {
00195                 <span class="keywordflow">if</span> ( key == *ivs )
00196                         resultVec.push_back( _Words[ivs-<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.begin()] );
00197         }
00198 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CWordsDictionarya2" doxytag="NLMISC::CWordsDictionary::getKeys" ></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="a03670.html">CVectorSString</a>&amp; NLMISC::CWordsDictionary::getKeys </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06754.html#l00077">77</a> of file <a class="el" href="a06754.html">words_dictionary.h</a>.
<p>
<div class="fragment"><pre>00077 { <span class="keywordflow">return</span> <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>; }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CWordsDictionarya3" doxytag="NLMISC::CWordsDictionary::getWords" ></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="a03670.html">CVectorSString</a>&amp; NLMISC::CWordsDictionary::getWords </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="mdname1" valign="top" nowrap>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap><code> [inline]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>

<p>
Definition at line <a class="el" href="a06754.html#l00078">78</a> of file <a class="el" href="a06754.html">words_dictionary.h</a>.
<p>
References <a class="el" href="a06754.html#l00091">_Words</a>.
<p>
<div class="fragment"><pre>00078 { <span class="keywordflow">return</span> <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a>; }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CWordsDictionarya4" doxytag="NLMISC::CWordsDictionary::getWordsKey" ></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="a03435.html">CSString</a> NLMISC::CWordsDictionary::getWordsKey </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03435.html">CSString</a> &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>resultStr</em>          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Return the key contained in the provided string returned by <a class="el" href="a03729.html#NLMISC_1_1CWordsDictionarya6">lookup()</a> (without extension). 
<p>

<p>
Definition at line <a class="el" href="a06753.html#l00214">214</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>.
<p>
References <a class="el" href="a06431.html#l00133">NLMISC::CSString::splitTo()</a>.
<p>
<div class="fragment"><pre>00215 {
00216         <span class="keywordflow">return</span> resultStr.splitTo( <span class="charliteral">':'</span> );
00217 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CWordsDictionarya5" doxytag="NLMISC::CWordsDictionary::init" ></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::CWordsDictionary::init </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const std::string &amp;&nbsp;</td>
          <td class="mdname1" valign="top" nowrap> <em>configFileName</em> = "words_dic.cfg"          </td>
          <td class="md" valign="top">&nbsp;)&nbsp;</td>
          <td class="md" nowrap></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Load the config file and the related words files. Return false in case of failure. Config file variables:<ul>
<li>WordsPath: where to find *_words_.txt</li><li>LanguageCode: language code (ex: en for English)</li><li>Utf8: results are in UTF8, otherwise in ANSI string</li></ul>

<p>
Definition at line <a class="el" href="a06753.html#l00052">52</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>.
<p>
References <a class="el" href="a06754.html#l00091">_Words</a>, <a class="el" href="a05635.html#l00104">STRING_MANAGER::TWorksheet::begin()</a>, <a class="el" href="a05635.html#l00109">STRING_MANAGER::TWorksheet::end()</a>, <a class="el" href="a05635.html#l00209">STRING_MANAGER::TWorksheet::findCol()</a>, <a class="el" href="a05635.html#l00193">STRING_MANAGER::TWorksheet::findId()</a>, <a class="el" href="a05597.html#l00441">NLMISC::CConfigFile::getVarPtr()</a>, <a class="el" href="a05597.html#l00244">NLMISC::CConfigFile::load()</a>, <a class="el" href="a05634.html#l00558">STRING_MANAGER::loadExcelSheet()</a>, <a class="el" href="a05622.html#l00101">nldebug</a>, <a class="el" href="a05622.html#l00135">nlwarning</a>, <a class="el" href="a06229.html#l02652">NLMISC::toString()</a>, <a class="el" href="a05635.html#l00094">STRING_MANAGER::TWorksheet::TRow</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a05646.html#l00237">v</a>.
<p>
<div class="fragment"><pre>00053 {
00054         <span class="comment">// Read config file</span>
00055         <span class="keywordtype">bool</span> cfFound = <span class="keyword">false</span>;
00056         CConfigFile cf;
00057         <span class="keywordflow">try</span>
00058         {
00059                 cf.load( configFileName );
00060                 cfFound = <span class="keyword">true</span>;
00061         }
00062         <span class="keywordflow">catch</span> ( EConfigFile&amp; e )
00063         {
00064                 <a class="code" href="a04199.html#a2">nlwarning</a>( <span class="stringliteral">"WD: %s"</span>, e.what() );
00065         }
00066         string wordsPath, languageCode;
00067         <span class="keywordtype">bool</span> utf8 = <span class="keyword">false</span>;
00068         <span class="keywordflow">if</span> ( cfFound )
00069         {
00070                 <a class="code" href="a02402.html">CConfigFile::CVar</a> *<a class="code" href="a04223.html#a576">v</a> = cf.getVarPtr( <span class="stringliteral">"WordsPath"</span> );
00071                 <span class="keywordflow">if</span> ( <a class="code" href="a04223.html#a576">v</a> )
00072                 {
00073                         wordsPath = <a class="code" href="a04223.html#a576">v</a>-&gt;asString();
00074                         <span class="comment">/*if ( (!wordsPath.empty()) &amp;&amp; (wordsPath[wordsPath.size()-1]!='/') )</span>
00075 <span class="comment">                                wordsPath += '/';*/</span>
00076                 }
00077                 <a class="code" href="a04223.html#a576">v</a> = cf.getVarPtr( <span class="stringliteral">"LanguageCode"</span> );
00078                 <span class="keywordflow">if</span> ( <a class="code" href="a04223.html#a576">v</a> )
00079                         languageCode = <a class="code" href="a04223.html#a576">v</a>-&gt;asString();
00080                 <a class="code" href="a04223.html#a576">v</a> = cf.getVarPtr( <span class="stringliteral">"Utf8"</span> );
00081                 <span class="keywordflow">if</span> ( <a class="code" href="a04223.html#a576">v</a> )
00082                         utf8 = (<a class="code" href="a04223.html#a576">v</a>-&gt;asInt() == 1);
00083         }
00084         <span class="keywordflow">if</span> ( languageCode.empty() )
00085                 languageCode = <span class="stringliteral">"en"</span>;
00086 
00087         <span class="comment">// Load all found words files</span>
00088         <span class="keyword">const</span> string ext = <span class="stringliteral">".txt"</span>;
00089         vector&lt;string&gt; fileList;
00090         CPath::getPathContent( wordsPath, <span class="keyword">false</span>, <span class="keyword">false</span>, <span class="keyword">true</span>, fileList );
00091         <span class="keywordflow">for</span> ( vector&lt;string&gt;::const_iterator ifl=fileList.begin(); ifl!=fileList.end(); ++ifl )
00092         {
00093                 <span class="keyword">const</span> string&amp; <a class="code" href="a05377.html#a2">filename</a> = (*ifl);
00094                 string::size_type p;
00095                 <span class="keywordflow">if</span> ( (p = <a class="code" href="a05377.html#a2">filename</a>.find( string(<span class="stringliteral">"_words_"</span>) + languageCode + ext )) != string::npos )
00096                 {
00097                         <a class="code" href="a04199.html#a0">nldebug</a>( <span class="stringliteral">"WD: Loading %s"</span>, <a class="code" href="a05377.html#a2">filename</a>.c_str() );
00098                         string::size_type origSize = <a class="code" href="a05377.html#a2">filename</a>.size() - ext.size();
00099                         <span class="keyword">const</span> string truncFilename = CFile::getFilenameWithoutExtension( filename );
00100                         <span class="keyword">const</span> string wordType = truncFilename.substr( 0, p - (origSize - truncFilename.size()) );
00101 
00102                         <span class="comment">// Load Unicode Excel words file</span>
00103                         <a class="code" href="a03919.html">STRING_MANAGER::TWorksheet</a> worksheet;
00104                         <a class="code" href="a05383.html#a11">STRING_MANAGER::loadExcelSheet</a>( filename, worksheet );
00105                         <a class="code" href="a04558.html#a15">uint</a> ck, cw;
00106                         <span class="keywordflow">if</span> ( worksheet.<a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheeta8">findId</a>( ck ) &amp;&amp; worksheet.<a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheeta7">findCol</a>( <a class="code" href="a03924.html">ucstring</a>(<span class="stringliteral">"name"</span>), cw ) ) <span class="comment">// =&gt; </span>
00107                         {
00108                                 <span class="keywordflow">for</span> ( std::vector&lt;STRING_MANAGER::TWorksheet::TRow&gt;::iterator ip = worksheet.<a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheeta2">begin</a>(); ip!=worksheet.<a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheeta4">end</a>(); ++ip )
00109                                 {
00110                                         <span class="keywordflow">if</span> ( ip == worksheet.<a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheeta2">begin</a>() ) <span class="comment">// skip first row</span>
00111                                                 <span class="keywordflow">continue</span>;
00112                                         <a class="code" href="a03919.html#STRING__MANAGER_1_1TWorksheetw1">STRING_MANAGER::TWorksheet::TRow</a>&amp; row = *ip;
00113                                         <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.push_back( row[ck].<a class="code" href="a05378.html#a244">toString</a>() );
00114                                         string word = utf8 ? row[cw].toUtf8() : row[cw].<a class="code" href="a05378.html#a244">toString</a>();
00115                                         <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a>.push_back( word );
00116                                 }
00117                         }
00118                         <span class="keywordflow">else</span>
00119                                 <a class="code" href="a04199.html#a2">nlwarning</a>( <span class="stringliteral">"WD: %s ID or name not found in %s"</span>, wordType.c_str(), <a class="code" href="a05377.html#a2">filename</a>.c_str() );
00120                 }
00121         }
00122 
00123         <span class="keywordflow">if</span> ( <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.empty() )
00124         {
00125                 <span class="keywordflow">if</span> ( wordsPath.empty() )
00126                         <a class="code" href="a04199.html#a2">nlwarning</a>( <span class="stringliteral">"WD: WordsPath missing in config file %s"</span>, configFileName.c_str() );
00127                 <a class="code" href="a04199.html#a2">nlwarning</a>( <span class="stringliteral">"WD: *_words_%s.txt not found"</span>, languageCode.c_str() );
00128                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
00129         }
00130         <span class="keywordflow">else</span>
00131                 <span class="keywordflow">return</span> <span class="keyword">true</span>;
00132 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CWordsDictionarya6" doxytag="NLMISC::CWordsDictionary::lookup" ></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::CWordsDictionary::lookup </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03435.html">CSString</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>inputStr</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap><a class="el" href="a03670.html">CVectorSString</a> &amp;&nbsp;</td>
          <td class="mdname" nowrap> <em>resultVec</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Set the result vector with strings corresponding to the input string:<ul>
<li>If inputStr is partially or completely found in the keys, all the matching &lt;key,words&gt; are returned;</li><li>If inputStr is partially or completely in the words, all the matching &lt;key, words&gt; are returned. The following tags can modify the behaviour of the search algorithm:</li><li>^mystring returns mystring only if it is at the beginning of a key or word</li><li>mystring$ returns mystring only if it is at the end of a key or word All returned words are in UTF8 string or ANSI string, depending of the config file.</li></ul>

<p>
Definition at line <a class="el" href="a06753.html#l00144">144</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>.
<p>
References <a class="el" href="a06754.html#l00091">_Words</a>, <a class="el" href="a06431.html#l00506">NLMISC::CSString::find()</a>, <a class="el" href="a06753.html#l00204">makeResult()</a>, and <a class="el" href="a06431.html#l00111">NLMISC::CSString::rightCrop()</a>.
<p>
<div class="fragment"><pre>00145 {
00146         <span class="comment">// Prepare search string</span>
00147         <span class="keywordflow">if</span> ( inputStr.empty() )
00148                 <span class="keywordflow">return</span>;
00149 
00150         CSString searchStr = inputStr;
00151         <span class="keywordtype">bool</span> findAtBeginning = <span class="keyword">false</span>, findAtEnd = <span class="keyword">false</span>;
00152         <span class="keywordflow">if</span> ( searchStr[0] == <span class="charliteral">'^'</span> )
00153         {
00154                 searchStr = searchStr.substr( 1 );
00155                 findAtBeginning = <span class="keyword">true</span>;
00156         }
00157         <span class="keywordflow">if</span> ( searchStr[searchStr.size()-1] == <span class="charliteral">'$'</span> )
00158         {
00159                 searchStr = searchStr.rightCrop( 1 );
00160                 findAtEnd = <span class="keyword">true</span>;
00161         }
00162 
00163         <span class="comment">// Search</span>
00164         <span class="keywordflow">for</span> ( CVectorSString::const_iterator ivs=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.begin(); ivs!=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.end(); ++ivs )
00165         {
00166                 <span class="keyword">const</span> CSString&amp; key = *ivs;
00167                 string::size_type p;
00168                 <span class="keywordflow">if</span> ( (p = key.find( searchStr.c_str() )) != string::npos )
00169                 {
00170                         <span class="keywordflow">if</span> ( ((!findAtBeginning) || (p==0)) &amp;&amp; ((!findAtEnd) || (p==key.size()-searchStr.size())) )
00171                                 resultVec.push_back( <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryb0">makeResult</a>( key, _Words[ivs-<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">_Keys</a>.begin()] ) );
00172                 }
00173         }
00174         <span class="keywordflow">for</span> ( CVectorSString::const_iterator ivs=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a>.begin(); ivs!=<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a>.end(); ++ivs )
00175         {
00176                 <span class="keyword">const</span> CSString&amp; word = *ivs;
00177                 string::size_type p;
00178                 <span class="keywordflow">if</span> ( (p = word.find( searchStr.c_str() )) != string::npos )
00179                 {
00180                         <span class="keywordflow">if</span> ( ((!findAtBeginning) || (p==0)) &amp;&amp; ((!findAtEnd) || (p==word.size()-searchStr.size())) )
00181                                 resultVec.push_back( <a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryb0">makeResult</a>( _Keys[ivs-<a class="code" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">_Words</a>.begin()], word ) );
00182                 }
00183         }
00184 }
</pre></div>    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CWordsDictionaryb0" doxytag="NLMISC::CWordsDictionary::makeResult" ></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="a03435.html">CSString</a> NLMISC::CWordsDictionary::makeResult </td>
          <td class="md" valign="top">(&nbsp;</td>
          <td class="md" nowrap valign="top">const <a class="el" href="a03435.html">CSString</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>key</em>, </td>
        </tr>
        <tr>
          <td class="md" nowrap align="right"></td>
          <td></td>
          <td class="md" nowrap>const <a class="el" href="a03435.html">CSString</a>&nbsp;</td>
          <td class="mdname" nowrap> <em>word</em></td>
        </tr>
        <tr>
          <td></td>
          <td class="md">)&nbsp;</td>
          <td class="md" colspan="2"><code> [inline, protected]</code></td>
        </tr>

      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Make a result string. 
<p>

<p>
Definition at line <a class="el" href="a06753.html#l00204">204</a> of file <a class="el" href="a06753.html">words_dictionary.cpp</a>.
<p>
References <a class="el" href="a05646.html#l01119">res</a>.
<p>
Referenced by <a class="el" href="a06753.html#l00144">lookup()</a>.
<p>
<div class="fragment"><pre>00205 {
00206         CSString <a class="code" href="a04223.html#a643">res</a> = key + CSString(<span class="stringliteral">": "</span>) + word;
00207         <span class="keywordflow">return</span> <a class="code" href="a04223.html#a643">res</a>;
00208 }
</pre></div>    </td>
  </tr>
</table>
<hr><h2>Field Documentation</h2>
<a class="anchor" name="NLMISC_1_1CWordsDictionaryr0" doxytag="NLMISC::CWordsDictionary::_Keys" ></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="a03670.html">CVectorSString</a> <a class="el" href="a03729.html#NLMISC_1_1CWordsDictionaryr0">NLMISC::CWordsDictionary::_Keys</a><code> [private]</code>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Keys (same indices as in _Words). 
<p>

<p>
Definition at line <a class="el" href="a06754.html#l00088">88</a> of file <a class="el" href="a06754.html">words_dictionary.h</a>.    </td>
  </tr>
</table>
<a class="anchor" name="NLMISC_1_1CWordsDictionaryr1" doxytag="NLMISC::CWordsDictionary::_Words" ></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="a03670.html">CVectorSString</a> <a class="el" href="a03729.html#NLMISC_1_1CWordsDictionaryr1">NLMISC::CWordsDictionary::_Words</a><code> [private]</code>
      </table>
    </td>
  </tr>
</table>
<table cellspacing=5 cellpadding=0 border=0>
  <tr>
    <td>
      &nbsp;
    </td>
    <td>

<p>
Words (same indices as in _Keys). 
<p>

<p>
Definition at line <a class="el" href="a06754.html#l00091">91</a> of file <a class="el" href="a06754.html">words_dictionary.h</a>.
<p>
Referenced by <a class="el" href="a06753.html#l00190">exactLookupByKey()</a>, <a class="el" href="a06754.html#l00078">getWords()</a>, <a class="el" href="a06753.html#l00052">init()</a>, and <a class="el" href="a06753.html#l00144">lookup()</a>.    </td>
  </tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a06754.html">words_dictionary.h</a><li><a class="el" href="a06753.html">words_dictionary.cpp</a></ul>
<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:43:30 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>