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
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>swmodule.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<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="functions.html">Compound Members</a> </center>
<hr><h1>swmodule.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> * swmodule.cpp -code for base class 'module'. Module is the basis for all</font>
00003 <font class="comment"> * types of modules (e.g. texts, commentaries, maps, lexicons,</font>
00004 <font class="comment"> * etc.)</font>
00005 <font class="comment"> */</font>
00006
00007 <font class="preprocessor">#include <string.h></font>
00008 <font class="preprocessor">#include <swmodule.h></font>
00009 <font class="preprocessor">#include <utilfuns.h></font>
00010 <font class="preprocessor">#include <regex.h></font> <font class="comment">// GNU</font>
00011 <font class="preprocessor">#include <swfilter.h></font>
00012 <font class="preprocessor">#include <versekey.h></font> <font class="comment">// KLUDGE for Search</font>
00013 <font class="preprocessor">#ifndef _MSC_VER</font>
00014 <font class="preprocessor"></font><font class="preprocessor">#include <iostream.h></font>
00015 <font class="preprocessor">#endif</font>
00016 <font class="preprocessor"></font>
00017 <a class="code" href="class_s_w_display.html">SWDisplay</a> SWModule::rawdisp;
<a name="l00018"></a><a class="code" href="class_s_w_module.html#d0">00018</a> <font class="keywordtype">void</font> <a class="code" href="class_s_w_module.html#d0">SWModule::nullPercent</a>(<font class="keywordtype">char</font> percent, <font class="keywordtype">void</font> *percentUserData) {}
00019
00020 <font class="comment">/******************************************************************************</font>
00021 <font class="comment"> * SWModule Constructor - Initializes data for instance of SWModule</font>
00022 <font class="comment"> *</font>
00023 <font class="comment"> * ENT: imodname - Internal name for module</font>
00024 <font class="comment"> * imoddesc - Name to display to user for module</font>
00025 <font class="comment"> * idisp - Display object to use for displaying</font>
00026 <font class="comment"> * imodtype - Type of Module (All modules will be displayed with</font>
00027 <font class="comment"> * others of same type under their modtype heading</font>
00028 <font class="comment"> * unicode - if this module is unicode</font>
00029 <font class="comment"> */</font>
00030
<a name="l00031"></a><a class="code" href="class_s_w_module.html#a0">00031</a> <a class="code" href="class_s_w_module.html#a0">SWModule::SWModule</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *imodname, <font class="keyword">const</font> <font class="keywordtype">char</font> *imoddesc, <a class="code" href="class_s_w_display.html">SWDisplay</a> *idisp, <font class="keywordtype">char</font> *imodtype, SWTextEncoding encoding, SWTextDirection direction, SWTextMarkup markup, <font class="keyword">const</font> <font class="keywordtype">char</font>* imodlang)
00032 {
00033 <a class="code" href="class_s_w_module.html#n6">key</a> = <a class="code" href="class_s_w_module.html#a26">CreateKey</a>();
00034 entrybuf = <font class="keyword">new</font> <font class="keywordtype">char</font> [1];
00035 *entrybuf = 0;
00036 config = &ownConfig;
00037 entrybufallocsize = 0;
00038 modname = 0;
00039 error = 0;
00040 moddesc = 0;
00041 modtype = 0;
00042 modlang = 0;
00043 this->encoding = encoding;
00044 this->direction = direction;
00045 this->markup = markup;
00046 entrySize= -1;
00047 <a class="code" href="class_s_w_module.html#n15">disp</a> = (idisp) ? idisp : &rawdisp;
00048 stdstr(&modname, imodname);
00049 stdstr(&moddesc, imoddesc);
00050 stdstr(&modtype, imodtype);
00051 stdstr(&modlang, imodlang);
00052 <a class="code" href="class_s_w_module.html#n18">stripFilters</a> = <font class="keyword">new</font> FilterList();
00053 <a class="code" href="class_s_w_module.html#n19">rawFilters</a> = <font class="keyword">new</font> FilterList();
00054 <a class="code" href="class_s_w_module.html#n20">renderFilters</a> = <font class="keyword">new</font> FilterList();
00055 <a class="code" href="class_s_w_module.html#n21">optionFilters</a> = <font class="keyword">new</font> FilterList();
00056 <a class="code" href="class_s_w_module.html#n22">encodingFilters</a> = <font class="keyword">new</font> FilterList();
00057 skipConsecutiveLinks = <font class="keyword">true</font>;
00058 procEntAttr = <font class="keyword">true</font>;
00059 }
00060
00061
00062 <font class="comment">/******************************************************************************</font>
00063 <font class="comment"> * SWModule Destructor - Cleans up instance of SWModule</font>
00064 <font class="comment"> */</font>
00065
<a name="l00066"></a><a class="code" href="class_s_w_module.html#a1">00066</a> <a class="code" href="class_s_w_module.html#a1">SWModule::~SWModule</a>()
00067 {
00068 <font class="keywordflow">if</font> (entrybuf)
00069 <font class="keyword">delete</font> [] entrybuf;
00070 <font class="keywordflow">if</font> (modname)
00071 <font class="keyword">delete</font> [] modname;
00072 <font class="keywordflow">if</font> (moddesc)
00073 <font class="keyword">delete</font> [] moddesc;
00074 <font class="keywordflow">if</font> (modtype)
00075 <font class="keyword">delete</font> [] modtype;
00076 <font class="keywordflow">if</font> (modlang)
00077 <font class="keyword">delete</font> [] modlang;
00078
00079 <font class="keywordflow">if</font> (key) {
00080 <font class="keywordflow">if</font> (!<a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a4">Persist</a>())
00081 <font class="keyword">delete</font> <a class="code" href="class_s_w_module.html#n6">key</a>;
00082 }
00083
00084 <a class="code" href="class_s_w_module.html#n18">stripFilters</a>->clear();
00085 <a class="code" href="class_s_w_module.html#n19">rawFilters</a>->clear();
00086 <a class="code" href="class_s_w_module.html#n20">renderFilters</a>->clear();
00087 <a class="code" href="class_s_w_module.html#n21">optionFilters</a>->clear();
00088 <a class="code" href="class_s_w_module.html#n22">encodingFilters</a>->clear();
00089 entryAttributes.clear();
00090
00091 <font class="keyword">delete</font> <a class="code" href="class_s_w_module.html#n18">stripFilters</a>;
00092 <font class="keyword">delete</font> <a class="code" href="class_s_w_module.html#n19">rawFilters</a>;
00093 <font class="keyword">delete</font> <a class="code" href="class_s_w_module.html#n20">renderFilters</a>;
00094 <font class="keyword">delete</font> <a class="code" href="class_s_w_module.html#n21">optionFilters</a>;
00095 <font class="keyword">delete</font> <a class="code" href="class_s_w_module.html#n22">encodingFilters</a>;
00096 }
00097
00098
00099 <font class="comment">/******************************************************************************</font>
00100 <font class="comment"> * SWModule::CreateKey - Allocates a key of specific type for module</font>
00101 <font class="comment"> *</font>
00102 <font class="comment"> * RET: pointer to allocated key</font>
00103 <font class="comment"> */</font>
00104
<a name="l00105"></a><a class="code" href="class_s_w_module.html#a26">00105</a> <a class="code" href="class_s_w_key.html">SWKey</a> *<a class="code" href="class_s_w_module.html#a26">SWModule::CreateKey</a>()
00106 {
00107 <font class="keywordflow">return</font> <font class="keyword">new</font> <a class="code" href="class_s_w_key.html">SWKey</a>();
00108 }
00109
00110
00111 <font class="comment">/******************************************************************************</font>
00112 <font class="comment"> * SWModule::Error - Gets and clears error status</font>
00113 <font class="comment"> *</font>
00114 <font class="comment"> * RET: error status</font>
00115 <font class="comment"> */</font>
00116
<a name="l00117"></a><a class="code" href="class_s_w_module.html#a2">00117</a> <font class="keywordtype">char</font> <a class="code" href="class_s_w_module.html#a2">SWModule::Error</a>()
00118 {
00119 <font class="keywordtype">char</font> retval = error;
00120
00121 error = 0;
00122 <font class="keywordflow">return</font> retval;
00123 }
00124
00125
00126 <font class="comment">/******************************************************************************</font>
00127 <font class="comment"> * SWModule::Name - Sets/gets module name</font>
00128 <font class="comment"> *</font>
00129 <font class="comment"> * ENT: imodname - value which to set modname</font>
00130 <font class="comment"> * [0] - only get</font>
00131 <font class="comment"> *</font>
00132 <font class="comment"> * RET: pointer to modname</font>
00133 <font class="comment"> */</font>
00134
<a name="l00135"></a><a class="code" href="class_s_w_module.html#a15">00135</a> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_module.html#a15">SWModule::Name</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *imodname)
00136 {
00137 <font class="keywordflow">return</font> stdstr(&modname, imodname);
00138 }
00139
00140
00141 <font class="comment">/******************************************************************************</font>
00142 <font class="comment"> * SWModule::Description - Sets/gets module description</font>
00143 <font class="comment"> *</font>
00144 <font class="comment"> * ENT: imoddesc - value which to set moddesc</font>
00145 <font class="comment"> * [0] - only get</font>
00146 <font class="comment"> *</font>
00147 <font class="comment"> * RET: pointer to moddesc</font>
00148 <font class="comment"> */</font>
00149
<a name="l00150"></a><a class="code" href="class_s_w_module.html#a16">00150</a> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_module.html#a16">SWModule::Description</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *imoddesc)
00151 {
00152 <font class="keywordflow">return</font> stdstr(&moddesc, imoddesc);
00153 }
00154
00155
00156 <font class="comment">/******************************************************************************</font>
00157 <font class="comment"> * SWModule::Type - Sets/gets module type</font>
00158 <font class="comment"> *</font>
00159 <font class="comment"> * ENT: imodtype - value which to set modtype</font>
00160 <font class="comment"> * [0] - only get</font>
00161 <font class="comment"> *</font>
00162 <font class="comment"> * RET: pointer to modtype</font>
00163 <font class="comment"> */</font>
00164
<a name="l00165"></a><a class="code" href="class_s_w_module.html#a17">00165</a> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_module.html#a17">SWModule::Type</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *imodtype)
00166 {
00167 <font class="keywordflow">return</font> stdstr(&modtype, imodtype);
00168 }
00169
00170 <font class="comment">/******************************************************************************</font>
00171 <font class="comment"> * SWModule::Direction - Sets/gets module direction</font>
00172 <font class="comment"> *</font>
00173 <font class="comment"> * ENT: newdir - value which to set direction</font>
00174 <font class="comment"> * [-1] - only get</font>
00175 <font class="comment"> *</font>
00176 <font class="comment"> * RET: char direction</font>
00177 <font class="comment"> */</font>
<a name="l00178"></a><a class="code" href="class_s_w_module.html#a18">00178</a> <font class="keywordtype">char</font> <a class="code" href="class_s_w_module.html#a18">SWModule::Direction</a>(<font class="keywordtype">signed</font> <font class="keywordtype">char</font> newdir) {
00179 <font class="keywordflow">if</font> (newdir != -1)
00180 direction = newdir;
00181 <font class="keywordflow">return</font> direction;
00182 }
00183
00184 <font class="comment">/******************************************************************************</font>
00185 <font class="comment"> * SWModule::Encoding - Sets/gets module encoding</font>
00186 <font class="comment"> *</font>
00187 <font class="comment"> * ENT: newdir - value which to set direction</font>
00188 <font class="comment"> * [-1] - only get</font>
00189 <font class="comment"> *</font>
00190 <font class="comment"> * RET: char encoding</font>
00191 <font class="comment"> */</font>
<a name="l00192"></a><a class="code" href="class_s_w_module.html#a19">00192</a> <font class="keywordtype">char</font> <a class="code" href="class_s_w_module.html#a19">SWModule::Encoding</a>(<font class="keywordtype">signed</font> <font class="keywordtype">char</font> newenc) {
00193 <font class="keywordflow">if</font> (newenc != -1)
00194 encoding = newenc;
00195 <font class="keywordflow">return</font> encoding;
00196 }
00197
00198 <font class="comment">/******************************************************************************</font>
00199 <font class="comment"> * SWModule::Markup - Sets/gets module markup</font>
00200 <font class="comment"> *</font>
00201 <font class="comment"> * ENT: newdir - value which to set direction</font>
00202 <font class="comment"> * [-1] - only get</font>
00203 <font class="comment"> *</font>
00204 <font class="comment"> * RET: char markup</font>
00205 <font class="comment"> */</font>
<a name="l00206"></a><a class="code" href="class_s_w_module.html#a20">00206</a> <font class="keywordtype">char</font> <a class="code" href="class_s_w_module.html#a20">SWModule::Markup</a>(<font class="keywordtype">signed</font> <font class="keywordtype">char</font> newmark) {
00207 <font class="keywordflow">if</font> (newmark != -1)
00208 markup = newmark;
00209 <font class="keywordflow">return</font> markup;
00210 }
00211
00212
00213 <font class="comment">/******************************************************************************</font>
00214 <font class="comment"> * SWModule::Lang - Sets/gets module language</font>
00215 <font class="comment"> *</font>
00216 <font class="comment"> * ENT: imodlang - value which to set modlang</font>
00217 <font class="comment"> * [0] - only get</font>
00218 <font class="comment"> *</font>
00219 <font class="comment"> * RET: pointer to modname</font>
00220 <font class="comment"> */</font>
00221
<a name="l00222"></a><a class="code" href="class_s_w_module.html#a21">00222</a> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_module.html#a21">SWModule::Lang</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *imodlang)
00223 {
00224 <font class="keywordflow">return</font> stdstr(&modlang, imodlang);
00225 }
00226
00227
00228 <font class="comment">/******************************************************************************</font>
00229 <font class="comment"> * SWModule::Disp - Sets/gets display driver</font>
00230 <font class="comment"> *</font>
00231 <font class="comment"> * ENT: idisp - value which to set disp</font>
00232 <font class="comment"> * [0] - only get</font>
00233 <font class="comment"> *</font>
00234 <font class="comment"> * RET: pointer to disp</font>
00235 <font class="comment"> */</font>
00236
<a name="l00237"></a><a class="code" href="class_s_w_module.html#a14">00237</a> <a class="code" href="class_s_w_display.html">SWDisplay</a> *<a class="code" href="class_s_w_module.html#a14">SWModule::Disp</a>(<a class="code" href="class_s_w_display.html">SWDisplay</a> *idisp)
00238 {
00239 <font class="keywordflow">if</font> (idisp)
00240 <a class="code" href="class_s_w_module.html#n15">disp</a> = idisp;
00241
00242 <font class="keywordflow">return</font> <a class="code" href="class_s_w_module.html#n15">disp</a>;
00243 }
00244
00245
00246 <font class="comment">/******************************************************************************</font>
00247 <font class="comment"> * SWModule::Display - Calls this modules display object and passes itself</font>
00248 <font class="comment"> *</font>
00249 <font class="comment"> * RET: error status</font>
00250 <font class="comment"> */</font>
00251
<a name="l00252"></a><a class="code" href="class_s_w_module.html#a13">00252</a> <font class="keywordtype">char</font> <a class="code" href="class_s_w_module.html#a13">SWModule::Display</a>()
00253 {
00254 <a class="code" href="class_s_w_module.html#n15">disp</a>-><a class="code" href="class_s_w_display.html#a1">Display</a>(*<font class="keyword">this</font>);
00255 <font class="keywordflow">return</font> 0;
00256 }
00257
00258
00259 <font class="comment">/******************************************************************************</font>
00260 <font class="comment"> * SWModule::SetKey - Sets a key to this module for position to a particular</font>
00261 <font class="comment"> * record or set of records</font>
00262 <font class="comment"> *</font>
00263 <font class="comment"> * ENT: ikey - key with which to set this module</font>
00264 <font class="comment"> *</font>
00265 <font class="comment"> * RET: error status</font>
00266 <font class="comment"> */</font>
00267
<a name="l00268"></a><a class="code" href="class_s_w_module.html#a9">00268</a> <font class="keywordtype">char</font> <a class="code" href="class_s_w_module.html#a8">SWModule::SetKey</a>(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> &ikey) {
00269 <font class="keywordflow">return</font> <a class="code" href="class_s_w_module.html#a8">SetKey</a>(&ikey);
00270 }
00271
<a name="l00272"></a><a class="code" href="class_s_w_module.html#a8">00272</a> <font class="keywordtype">char</font> <a class="code" href="class_s_w_module.html#a8">SWModule::SetKey</a>(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *ikey)
00273 {
00274 <a class="code" href="class_s_w_key.html">SWKey</a> *oldKey = 0;
00275
00276 <font class="keywordflow">if</font> (key) {
00277 <font class="keywordflow">if</font> (!<a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a4">Persist</a>()) <font class="comment">// if we have our own copy</font>
00278 oldKey = <a class="code" href="class_s_w_module.html#n6">key</a>;
00279 }
00280
00281 <font class="keywordflow">if</font> (!ikey-><a class="code" href="class_s_w_key.html#a4">Persist</a>()) { <font class="comment">// if we are to keep our own copy</font>
00282 <a class="code" href="class_s_w_module.html#n6">key</a> = <a class="code" href="class_s_w_module.html#a26">CreateKey</a>();
00283 *<a class="code" href="class_s_w_module.html#n6">key</a> = *ikey;
00284 }
00285 <font class="keywordflow">else</font> <a class="code" href="class_s_w_module.html#n6">key</a> = (<a class="code" href="class_s_w_key.html">SWKey</a> *)ikey; <font class="comment">// if we are to just point to an external key</font>
00286
00287 <font class="keywordflow">if</font> (oldKey)
00288 <font class="keyword">delete</font> oldKey;
00289
00290 <font class="keywordflow">return</font> 0;
00291 }
00292
00293
00294 <font class="comment">/******************************************************************************</font>
00295 <font class="comment"> * SWModule::KeyText - Sets/gets module KeyText</font>
00296 <font class="comment"> *</font>
00297 <font class="comment"> * ENT: ikeytext - value which to set keytext</font>
00298 <font class="comment"> * [0] - only get</font>
00299 <font class="comment"> *</font>
00300 <font class="comment"> * RET: pointer to keytext</font>
00301 <font class="comment"> */</font>
00302
<a name="l00303"></a><a class="code" href="class_s_w_module.html#a12">00303</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_module.html#a12">SWModule::KeyText</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *ikeytext)
00304 {
00305 <font class="keywordflow">if</font> (ikeytext)
00306 <a class="code" href="class_s_w_module.html#a8">SetKey</a>(ikeytext);
00307
00308 <font class="keywordflow">return</font> *<a class="code" href="class_s_w_module.html#n6">key</a>;
00309 }
00310
00311
00312 <font class="comment">/******************************************************************************</font>
00313 <font class="comment"> * SWModule::operator =(SW_POSITION) - Positions this modules to an entry</font>
00314 <font class="comment"> *</font>
00315 <font class="comment"> * ENT: p - position (e.g. TOP, BOTTOM)</font>
00316 <font class="comment"> *</font>
00317 <font class="comment"> * RET: *this</font>
00318 <font class="comment"> */</font>
00319
<a name="l00320"></a><a class="code" href="class_s_w_module.html#a40">00320</a> <a class="code" href="class_s_w_module.html">SWModule</a> &<a class="code" href="class_s_w_module.html#a40">SWModule::operator =</a>(SW_POSITION p)
00321 {
00322 *<a class="code" href="class_s_w_module.html#n6">key</a> = p;
00323 <font class="keywordtype">char</font> saveError = <a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a6">Error</a>();
00324
00325 <font class="keywordflow">switch</font> (p) {
00326 <font class="keywordflow">case</font> POS_TOP:
00327 (*this)++;
00328 (*this)--;
00329 <font class="keywordflow">break</font>;
00330
00331 <font class="keywordflow">case</font> POS_BOTTOM:
00332 (*this)--;
00333 (*this)++;
00334 <font class="keywordflow">break</font>;
00335 }
00336
00337 error = saveError;
00338 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
00339 }
00340
00341
00342 <font class="comment">/******************************************************************************</font>
00343 <font class="comment"> * SWModule::operator += - Increments module key a number of entries</font>
00344 <font class="comment"> *</font>
00345 <font class="comment"> * ENT: increment - Number of entries to jump forward</font>
00346 <font class="comment"> *</font>
00347 <font class="comment"> * RET: *this</font>
00348 <font class="comment"> */</font>
00349
<a name="l00350"></a><a class="code" href="class_s_w_module.html#a37">00350</a> <a class="code" href="class_s_w_module.html">SWModule</a> &<a class="code" href="class_s_w_module.html#a37">SWModule::operator +=</a>(<font class="keywordtype">int</font> increment)
00351 {
00352 (*key) += increment;
00353 error = <a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a6">Error</a>();
00354
00355 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
00356 }
00357
00358
00359 <font class="comment">/******************************************************************************</font>
00360 <font class="comment"> * SWModule::operator -= - Decrements module key a number of entries</font>
00361 <font class="comment"> *</font>
00362 <font class="comment"> * ENT: decrement - Number of entries to jump backward</font>
00363 <font class="comment"> *</font>
00364 <font class="comment"> * RET: *this</font>
00365 <font class="comment"> */</font>
00366
<a name="l00367"></a><a class="code" href="class_s_w_module.html#a36">00367</a> <a class="code" href="class_s_w_module.html">SWModule</a> &<a class="code" href="class_s_w_module.html#a36">SWModule::operator -=</a>(<font class="keywordtype">int</font> increment)
00368 {
00369 (*key) -= increment;
00370 error = <a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a6">Error</a>();
00371
00372 <font class="keywordflow">return</font> *<font class="keyword">this</font>;
00373 }
00374
00375
00376 <font class="comment">/******************************************************************************</font>
00377 <font class="comment"> * SWModule::Search - Searches a module for a string</font>
00378 <font class="comment"> *</font>
00379 <font class="comment"> * ENT: istr - string for which to search</font>
00380 <font class="comment"> * searchType - type of search to perform</font>
00381 <font class="comment"> * >=0 - regex</font>
00382 <font class="comment"> * -1 - phrase</font>
00383 <font class="comment"> * -2 - multiword</font>
00384 <font class="comment"> * flags - options flags for search</font>
00385 <font class="comment"> * justCheckIfSupported - if set, don't search, only tell if this</font>
00386 <font class="comment"> * function supports requested search.</font>
00387 <font class="comment"> *</font>
00388 <font class="comment"> * RET: listkey set to verses that contain istr</font>
00389 <font class="comment"> */</font>
00390
<a name="l00391"></a><a class="code" href="class_s_w_module.html#a22">00391</a> <a class="code" href="class_list_key.html">ListKey</a> &<a class="code" href="class_s_w_module.html#a22">SWModule::Search</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *istr, <font class="keywordtype">int</font> searchType, <font class="keywordtype">int</font> flags, <a class="code" href="class_s_w_key.html">SWKey</a> *scope, <font class="keywordtype">bool</font> *justCheckIfSupported, <font class="keywordtype">void</font> (*percent)(<font class="keywordtype">char</font>, <font class="keywordtype">void</font> *), <font class="keywordtype">void</font> *percentUserData)
00392 {
00393 <a class="code" href="class_s_w_key.html">SWKey</a> *savekey = 0;
00394 <a class="code" href="class_s_w_key.html">SWKey</a> *searchkey = 0;
00395 regex_t preg;
00396 <a class="code" href="class_s_w_key.html">SWKey</a> textkey;
00397 <font class="keywordtype">char</font> **words = 0;
00398 <font class="keywordtype">char</font> *wordBuf = 0;
00399 <font class="keywordtype">int</font> wordCount = 0;
00400 <font class="keyword">const</font> <font class="keywordtype">char</font> *sres;
00401 <a class="code" href="class_s_w_module.html#m0">terminateSearch</a> = <font class="keyword">false</font>;
00402 <font class="keywordtype">char</font> perc = 1;
00403 <font class="keywordtype">bool</font> savePEA = isProcessEntryAttributes();
00404
00405 processEntryAttributes(<font class="keyword">false</font>);
00406 listkey.<a class="code" href="class_list_key.html#a4">ClearList</a>();
00407
00408 <font class="keywordflow">if</font> (!<a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a4">Persist</a>()) {
00409 savekey = <a class="code" href="class_s_w_module.html#a26">CreateKey</a>();
00410 *savekey = *<a class="code" href="class_s_w_module.html#n6">key</a>;
00411 }
00412 <font class="keywordflow">else</font> savekey = <a class="code" href="class_s_w_module.html#n6">key</a>;
00413
00414 searchkey = (scope)?scope-><a class="code" href="class_s_w_key.html#a3">clone</a>():(<a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a4">Persist</a>())?<a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a3">clone</a>():0;
00415 <font class="keywordflow">if</font> (searchkey) {
00416 searchkey-><a class="code" href="class_s_w_key.html#a4">Persist</a>(1);
00417 <a class="code" href="class_s_w_module.html#a8">SetKey</a>(*searchkey);
00418 }
00419
00420 (*percent)(perc, percentUserData);
00421 <font class="comment">// MAJOR KLUDGE: VerseKey::Index still return index within testament.</font>
00422 <font class="comment">// VerseKey::NewIndex should be moved to Index and Index should be some</font>
00423 <font class="comment">// VerseKey specific name</font>
00424 <a class="code" href="class_verse_key.html">VerseKey</a> *vkcheck = 0;
00425 <font class="preprocessor">#ifndef _WIN32_WCE</font>
00426 <font class="preprocessor"></font> <font class="keywordflow">try</font> {
00427 <font class="preprocessor">#endif</font>
00428 <font class="preprocessor"></font> vkcheck = SWDYNAMIC_CAST(<a class="code" href="class_verse_key.html">VerseKey</a>, <a class="code" href="class_s_w_module.html#n6">key</a>);
00429 <font class="preprocessor">#ifndef _WIN32_WCE</font>
00430 <font class="preprocessor"></font> }
00431 <font class="keywordflow">catch</font> (...) {}
00432 <font class="preprocessor">#endif</font>
00433 <font class="preprocessor"></font> <font class="comment">// end MAJOR KLUDGE</font>
00434
00435 *<font class="keyword">this</font> = BOTTOM;
00436 <font class="comment">// fix below when we find out the bug</font>
00437 <font class="keywordtype">long</font> highIndex = (vkcheck)?32300<font class="comment">/*vkcheck->NewIndex()*/</font>:<a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a17">Index</a>();
00438 <font class="keywordflow">if</font> (!highIndex)
00439 highIndex = 1; <font class="comment">// avoid division by zero errors.</font>
00440 *<font class="keyword">this</font> = TOP;
00441 <font class="keywordflow">if</font> (searchType >= 0) {
00442 flags |=searchType|REG_NOSUB|REG_EXTENDED;
00443 regcomp(&preg, istr, flags);
00444 }
00445
00446 (*percent)(++perc, percentUserData);
00447 <font class="keywordflow">if</font> (searchType == -2) {
00448 wordBuf = (<font class="keywordtype">char</font> *)calloc(<font class="keyword">sizeof</font>(<font class="keywordtype">char</font>), strlen(istr) + 1);
00449 strcpy(wordBuf, istr);
00450 words = (<font class="keywordtype">char</font> **)calloc(<font class="keyword">sizeof</font>(<font class="keywordtype">char</font> *), 10);
00451 <font class="keywordtype">int</font> allocWords = 10;
00452 words[wordCount] = strtok(wordBuf, <font class="stringliteral">" "</font>);
00453 <font class="keywordflow">while</font> (words[wordCount]) {
00454 wordCount++;
00455 <font class="keywordflow">if</font> (wordCount == allocWords) {
00456 allocWords+=10;
00457 words = (<font class="keywordtype">char</font> **)realloc(words, <font class="keyword">sizeof</font>(<font class="keywordtype">char</font> *)*allocWords);
00458 }
00459 words[wordCount] = strtok(NULL, <font class="stringliteral">" "</font>);
00460 }
00461 }
00462
00463 perc = 5;
00464 (*percent)(perc, percentUserData);
00465
00466 <font class="keywordflow">while</font> (!<a class="code" href="class_s_w_module.html#a2">Error</a>() && !<a class="code" href="class_s_w_module.html#m0">terminateSearch</a>) {
00467
00468
00469 <font class="keywordtype">long</font> mindex = 0;
00470 <font class="keywordflow">if</font> (vkcheck)
00471 mindex = vkcheck-><a class="code" href="class_verse_key.html#a33">NewIndex</a>();
00472 <font class="keywordflow">else</font> mindex = <a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a17">Index</a>();
00473 <font class="keywordtype">float</font> per = (float)mindex / highIndex;
00474 per *= 93;
00475 per += 5;
00476 <font class="keywordtype">char</font> newperc = (char)per;
00477 <font class="comment">// char newperc = (char)(5+(93*(((float)((vkcheck)?vkcheck->NewIndex():key->Index()))/highIndex)));</font>
00478 <font class="keywordflow">if</font> (newperc > perc) {
00479 perc = newperc;
00480 (*percent)(perc, percentUserData);
00481 }
00482 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (newperc < perc) {
00483 <font class="preprocessor">#ifndef _MSC_VER</font>
00484 <font class="preprocessor"></font> cerr << <font class="stringliteral">"Serious error: new percentage complete is less than previous value\n"</font>;
00485 cerr << <font class="stringliteral">"using vk? "</font> << ((vkcheck)?<font class="stringliteral">"yes"</font>:<font class="stringliteral">"no"</font>) << <font class="stringliteral">"\n"</font>;
00486 cerr << <font class="stringliteral">"index: "</font> << ((vkcheck)?vkcheck-><a class="code" href="class_verse_key.html#a33">NewIndex</a>():<a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a17">Index</a>()) << <font class="stringliteral">"\n"</font>;
00487 cerr << <font class="stringliteral">"highIndex: "</font> << highIndex << <font class="stringliteral">"\n"</font>;
00488 cerr << <font class="stringliteral">"newperc =="</font> << (int)newperc << <font class="stringliteral">"%"</font> << <font class="stringliteral">"is smaller than\n"</font>;
00489 cerr << <font class="stringliteral">"perc == "</font> << (int )perc << <font class="stringliteral">"% \n"</font>;
00490 <font class="preprocessor">#endif</font>
00491 <font class="preprocessor"></font> }
00492 <font class="keywordflow">if</font> (searchType >= 0) {
00493 <font class="keywordflow">if</font> (!regexec(&preg, <a class="code" href="class_s_w_module.html#a56">StripText</a>(), 0, 0, 0)) {
00494 textkey = <a class="code" href="class_s_w_module.html#a12">KeyText</a>();
00495 listkey << textkey;
00496 }
00497 }
00498 <font class="keywordflow">else</font> {
00499 <font class="keywordflow">if</font> (searchType == -1) {
00500 sres = ((flags & REG_ICASE) == REG_ICASE) ? stristr(<a class="code" href="class_s_w_module.html#a56">StripText</a>(), istr) : strstr(<a class="code" href="class_s_w_module.html#a56">StripText</a>(), istr);
00501 <font class="keywordflow">if</font> (sres) {
00502 textkey = <a class="code" href="class_s_w_module.html#a12">KeyText</a>();
00503 listkey << textkey;
00504 }
00505 }
00506 <font class="keywordflow">if</font> (searchType == -2) {
00507 <font class="keywordtype">int</font> i;
00508 <font class="keyword">const</font> <font class="keywordtype">char</font> *stripBuf = <a class="code" href="class_s_w_module.html#a56">StripText</a>();
00509 <font class="keywordflow">for</font> (i = 0; i < wordCount; i++) {
00510 sres = ((flags & REG_ICASE) == REG_ICASE) ? stristr(stripBuf, words[i]) : strstr(stripBuf, words[i]);
00511 <font class="keywordflow">if</font> (!sres)
00512 <font class="keywordflow">break</font>;
00513 }
00514 <font class="keywordflow">if</font> (i == wordCount) {
00515 textkey = <a class="code" href="class_s_w_module.html#a12">KeyText</a>();
00516 listkey << textkey;
00517 }
00518
00519 }
00520 }
00521 (*this)++;
00522 }
00523 <font class="keywordflow">if</font> (searchType >= 0)
00524 regfree(&preg);
00525
00526 <font class="keywordflow">if</font> (searchType == -2) {
00527 free(words);
00528 free(wordBuf);
00529 }
00530
00531 <a class="code" href="class_s_w_module.html#a8">SetKey</a>(*savekey);
00532
00533 <font class="keywordflow">if</font> (!savekey-><a class="code" href="class_s_w_key.html#a4">Persist</a>())
00534 <font class="keyword">delete</font> savekey;
00535
00536 <font class="keywordflow">if</font> (searchkey)
00537 <font class="keyword">delete</font> searchkey;
00538
00539 listkey = TOP;
00540 processEntryAttributes(savePEA);
00541 (*percent)(100, percentUserData);
00542
00543 <font class="keywordflow">return</font> listkey;
00544 }
00545
00546
00547 <font class="comment">/******************************************************************************</font>
00548 <font class="comment"> * SWModule::StripText() - calls all stripfilters on current text</font>
00549 <font class="comment"> *</font>
00550 <font class="comment"> * ENT: buf - buf to massage instead of this modules current text</font>
00551 <font class="comment"> * len - max len of buf</font>
00552 <font class="comment"> *</font>
00553 <font class="comment"> * RET: this module's text at specified key location massaged by Strip filters</font>
00554 <font class="comment"> */</font>
00555
<a name="l00556"></a><a class="code" href="class_s_w_module.html#a56">00556</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_module.html#a56">SWModule::StripText</a>(<font class="keywordtype">char</font> *buf, <font class="keywordtype">int</font> len)
00557 {
00558 <font class="keywordflow">return</font> <a class="code" href="class_s_w_module.html#a57">RenderText</a>(buf, len, <font class="keyword">false</font>);
00559 }
00560
00561
00562 <font class="comment">/******************************************************************************</font>
00563 <font class="comment"> * SWModule::RenderText - calls all renderfilters on current text</font>
00564 <font class="comment"> *</font>
00565 <font class="comment"> * ENT: buf - buffer to Render instead of current module position</font>
00566 <font class="comment"> *</font>
00567 <font class="comment"> * RET: listkey set to verses that contain istr</font>
00568 <font class="comment"> */</font>
00569
<a name="l00570"></a><a class="code" href="class_s_w_module.html#a57">00570</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_module.html#a57">SWModule::RenderText</a>(<font class="keywordtype">char</font> *buf, <font class="keywordtype">int</font> len, <font class="keywordtype">bool</font> render) {
00571 entryAttributes.clear();
00572 <font class="keywordtype">char</font> *tmpbuf = (buf) ? buf : <a class="code" href="class_s_w_module.html#a28">getRawEntry</a>();
00573 <a class="code" href="class_s_w_key.html">SWKey</a> *<a class="code" href="class_s_w_module.html#n6">key</a> = 0;
00574 <font class="keyword">static</font> <font class="keywordtype">char</font> *null = <font class="stringliteral">""</font>;
00575
00576 <font class="keywordflow">if</font> (tmpbuf) {
00577 <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> size = (len < 0) ? ((<a class="code" href="class_s_w_module.html#a7">getEntrySize</a>()<0) ? strlen(tmpbuf) : <a class="code" href="class_s_w_module.html#a7">getEntrySize</a>()) * FILTERPAD : len;
00578 <font class="keywordflow">if</font> (size > 0) {
00579 key = (<a class="code" href="class_s_w_key.html">SWKey</a> *)*<font class="keyword">this</font>;
00580
00581 <a class="code" href="class_s_w_module.html#a55">optionFilter</a>(tmpbuf, size, key);
00582
00583 <font class="keywordflow">if</font> (render) {
00584 <a class="code" href="class_s_w_module.html#a44">renderFilter</a>(tmpbuf, size, key);
00585 <a class="code" href="class_s_w_module.html#a48">encodingFilter</a>(tmpbuf, size, key);
00586 }
00587 <font class="keywordflow">else</font> <a class="code" href="class_s_w_module.html#a50">stripFilter</a>(tmpbuf, size, key);
00588 }
00589 }
00590 <font class="keywordflow">else</font> {
00591 tmpbuf = null;
00592 }
00593
00594 <font class="keywordflow">return</font> tmpbuf;
00595 }
00596
00597
00598 <font class="comment">/******************************************************************************</font>
00599 <font class="comment"> * SWModule::RenderText - calls all renderfilters on current text</font>
00600 <font class="comment"> *</font>
00601 <font class="comment"> * ENT: tmpKey - key to use to grab text</font>
00602 <font class="comment"> *</font>
00603 <font class="comment"> * RET: this module's text at specified key location massaged by RenderFilers</font>
00604 <font class="comment"> */</font>
00605
<a name="l00606"></a><a class="code" href="class_s_w_module.html#a59">00606</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_module.html#a57">SWModule::RenderText</a>(<a class="code" href="class_s_w_key.html">SWKey</a> *tmpKey)
00607 {
00608 <a class="code" href="class_s_w_key.html">SWKey</a> *savekey;
00609 <font class="keyword">const</font> <font class="keywordtype">char</font> *retVal;
00610
00611 <font class="keywordflow">if</font> (!<a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a4">Persist</a>()) {
00612 savekey = <a class="code" href="class_s_w_module.html#a26">CreateKey</a>();
00613 *savekey = *<a class="code" href="class_s_w_module.html#n6">key</a>;
00614 }
00615 <font class="keywordflow">else</font> savekey = <a class="code" href="class_s_w_module.html#n6">key</a>;
00616
00617 <a class="code" href="class_s_w_module.html#a8">SetKey</a>(*tmpKey);
00618
00619 retVal = <a class="code" href="class_s_w_module.html#a57">RenderText</a>();
00620
00621 <a class="code" href="class_s_w_module.html#a8">SetKey</a>(*savekey);
00622
00623 <font class="keywordflow">if</font> (!savekey-><a class="code" href="class_s_w_key.html#a4">Persist</a>())
00624 <font class="keyword">delete</font> savekey;
00625
00626 <font class="keywordflow">return</font> retVal;
00627 }
00628
00629
00630 <font class="comment">/******************************************************************************</font>
00631 <font class="comment"> * SWModule::StripText - calls all StripTextFilters on current text</font>
00632 <font class="comment"> *</font>
00633 <font class="comment"> * ENT: tmpKey - key to use to grab text</font>
00634 <font class="comment"> *</font>
00635 <font class="comment"> * RET: this module's text at specified key location massaged by Strip filters</font>
00636 <font class="comment"> */</font>
00637
<a name="l00638"></a><a class="code" href="class_s_w_module.html#a58">00638</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="class_s_w_module.html#a56">SWModule::StripText</a>(<a class="code" href="class_s_w_key.html">SWKey</a> *tmpKey)
00639 {
00640 <a class="code" href="class_s_w_key.html">SWKey</a> *savekey;
00641 <font class="keyword">const</font> <font class="keywordtype">char</font> *retVal;
00642
00643 <font class="keywordflow">if</font> (!<a class="code" href="class_s_w_module.html#n6">key</a>-><a class="code" href="class_s_w_key.html#a4">Persist</a>()) {
00644 savekey = <a class="code" href="class_s_w_module.html#a26">CreateKey</a>();
00645 *savekey = *<a class="code" href="class_s_w_module.html#n6">key</a>;
00646 }
00647 <font class="keywordflow">else</font> savekey = <a class="code" href="class_s_w_module.html#n6">key</a>;
00648
00649 <a class="code" href="class_s_w_module.html#a8">SetKey</a>(*tmpKey);
00650
00651 retVal = <a class="code" href="class_s_w_module.html#a56">StripText</a>();
00652
00653 <a class="code" href="class_s_w_module.html#a8">SetKey</a>(*savekey);
00654
00655 <font class="keywordflow">if</font> (!savekey-><a class="code" href="class_s_w_key.html#a4">Persist</a>())
00656 <font class="keyword">delete</font> savekey;
00657
00658 <font class="keywordflow">return</font> retVal;
00659 }
00660
00661
<a name="l00662"></a><a class="code" href="class_s_w_module.html#a27">00662</a> <a class="code" href="class_s_w_module.html#a27">SWModule::operator const char*</a>() {
00663 <font class="keywordflow">return</font> <a class="code" href="class_s_w_module.html#a57">RenderText</a>();
00664 }
00665
00666
00667 <font class="keyword">const</font> <font class="keywordtype">char</font> *SWModule::getConfigEntry(<font class="keyword">const</font> <font class="keywordtype">char</font> *key)<font class="keyword"> const </font>{
00668 ConfigEntMap::iterator it = config->find(<a class="code" href="class_s_w_module.html#n6">key</a>);
00669 <font class="keywordflow">return</font> (it != config->end()) ? it->second.c_str() : 0;
00670 }
00671
00672
00673 <font class="keywordtype">void</font> SWModule::setConfig(ConfigEntMap *config) {
00674 this->config = config;
00675 }
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:00 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>
|