aboutsummaryrefslogblamecommitdiffstats
path: root/doc/api-documentation/html/versekey_8cpp-source.html
blob: 7a5266b92e2515508986be1d7f9ebe0ed6729761 (plain) (tree)
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
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
<!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>versekey.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> &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="functions.html">Compound Members</a> &nbsp; </center>
<hr><h1>versekey.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> *  VerseKey.cpp - code for class 'VerseKey'- a standard Biblical verse key</font>
00003 <font class="comment"> */</font>
00004 
00005 <font class="preprocessor">#include &lt;swmacs.h&gt;</font>
00006 <font class="preprocessor">#include &lt;utilfuns.h&gt;</font>
00007 <font class="preprocessor">#include &lt;string.h&gt;</font>
00008 <font class="preprocessor">#include &lt;stdio.h&gt;</font>
00009 <font class="preprocessor">#include &lt;fcntl.h&gt;</font>
00010 <font class="preprocessor">#include &lt;stdlib.h&gt;</font>
00011 
00012 <font class="preprocessor">#ifndef __GNUC__</font>
00013 <font class="preprocessor"></font><font class="preprocessor">#include &lt;io.h&gt;</font>
00014 <font class="preprocessor">#else</font>
00015 <font class="preprocessor"></font><font class="preprocessor">#include &lt;unistd.h&gt;</font>
00016 <font class="preprocessor">#endif</font>
00017 <font class="preprocessor"></font>
00018 <font class="preprocessor">#include &lt;utilstr.h&gt;</font>
00019 <font class="preprocessor">#include &lt;swkey.h&gt;</font>
00020 <font class="preprocessor">#include &lt;swlog.h&gt;</font>
00021 <font class="preprocessor">#include &lt;versekey.h&gt;</font>
00022 <font class="preprocessor">#include &lt;localemgr.h&gt;</font>
00023 <font class="keyword">extern</font> <font class="stringliteral">"C"</font> {
00024 <font class="preprocessor">#include &lt;roman.h&gt;</font>
00025 }
00026 
00027 
00028 <font class="keyword">static</font> <font class="keyword">const</font> <font class="keywordtype">char</font> *classes[] = {<font class="stringliteral">"VerseKey"</font>, <font class="stringliteral">"SWKey"</font>, <font class="stringliteral">"SWObject"</font>, 0};
00029 <a class="code" href="class_s_w_class.html">SWClass</a> VerseKey::classdef(classes);
00030 
00031 <font class="comment">/******************************************************************************</font>
00032 <font class="comment"> *  Initialize static members of VerseKey</font>
00033 <font class="comment"> */</font>
00034 
00035 <font class="preprocessor">#include &lt;canon.h&gt;</font>      <font class="comment">// Initialize static members of canonical books structure</font>
00036 
00037 <font class="keyword">struct </font>sbook *VerseKey::builtin_books[2]       = {0,0};
00038 <font class="keyword">const</font> <font class="keywordtype">char</font>    VerseKey::builtin_BMAX[2]        = {39, 27};
00039 <font class="keywordtype">long</font>         *VerseKey::offsets[2][2]  = {{VerseKey::otbks, VerseKey::otcps}, {VerseKey::ntbks, VerseKey::ntcps}};
<a name="l00040"></a><a class="code" href="class_verse_key.html#r3">00040</a> <font class="keywordtype">int</font>           <a class="code" href="class_verse_key.html#r3">VerseKey::instance</a>       = 0;
00041 VerseKey::LocaleCache   VerseKey::localeCache;
00042 
00043 
00044 <font class="comment">/******************************************************************************</font>
00045 <font class="comment"> * VerseKey::init - initializes instance of VerseKey</font>
00046 <font class="comment"> */</font>
00047 
<a name="l00048"></a><a class="code" href="class_verse_key.html#c3">00048</a> <font class="keywordtype">void</font> <a class="code" href="class_verse_key.html#c3">VerseKey::init</a>() {
00049         myclass = &amp;classdef;
00050         <font class="keywordflow">if</font> (!<a class="code" href="class_verse_key.html#r3">instance</a>)
00051                 <a class="code" href="class_verse_key.html#c2">initstatics</a>();
00052 
00053         <a class="code" href="class_verse_key.html#r3">instance</a>++;
00054         <a class="code" href="class_verse_key.html#o8">autonorm</a> = 1;           <font class="comment">// default auto normalization to true</font>
00055         <a class="code" href="class_verse_key.html#o9">headings</a> = 0;           <font class="comment">// default display headings option is false</font>
00056         upperBound = 0;
00057         lowerBound = 0;
00058         <a class="code" href="class_verse_key.html#o4">testament</a> = 0;
00059         book = 0;
00060         chapter = 0;
00061         verse = 0;
00062         locale = 0;
00063 
00064         setLocale(<a class="code" href="class_locale_mgr.html#p0">LocaleMgr::systemLocaleMgr</a>.getDefaultLocaleName());
00065 }
00066 
00067 <font class="comment">/******************************************************************************</font>
00068 <font class="comment"> * VerseKey Constructor - initializes instance of VerseKey</font>
00069 <font class="comment"> *</font>
00070 <font class="comment"> * ENT: ikey - base key (will take various forms of 'BOOK CH:VS'.  See</font>
00071 <font class="comment"> *              VerseKey::parse for more detailed information)</font>
00072 <font class="comment"> */</font>
00073 
<a name="l00074"></a><a class="code" href="class_verse_key.html#a1">00074</a> <a class="code" href="class_verse_key.html#a0">VerseKey::VerseKey</a>(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *ikey) : <a class="code" href="class_s_w_key.html">SWKey</a>(*ikey)
00075 {
00076         <a class="code" href="class_verse_key.html#c3">init</a>();
00077         <font class="keywordflow">if</font> (ikey)
00078                 <a class="code" href="class_verse_key.html#c5">parse</a>();
00079 }
00080 
00081 
00082 <font class="comment">/******************************************************************************</font>
00083 <font class="comment"> * VerseKey Constructor - initializes instance of VerseKey</font>
00084 <font class="comment"> *</font>
00085 <font class="comment"> * ENT: ikey - text key (will take various forms of 'BOOK CH:VS'.  See</font>
00086 <font class="comment"> *              VerseKey::parse for more detailed information)</font>
00087 <font class="comment"> */</font>
00088 
<a name="l00089"></a><a class="code" href="class_verse_key.html#a0">00089</a> <a class="code" href="class_verse_key.html#a0">VerseKey::VerseKey</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *ikey) : <a class="code" href="class_s_w_key.html">SWKey</a>(ikey)
00090 {
00091         <a class="code" href="class_verse_key.html#c3">init</a>();
00092         <font class="keywordflow">if</font> (ikey)
00093                 <a class="code" href="class_verse_key.html#c5">parse</a>();
00094 }
00095 
00096 
00097 <a class="code" href="class_verse_key.html#a0">VerseKey::VerseKey</a>(VerseKey <font class="keyword">const</font> &amp;k) : <a class="code" href="class_s_w_key.html">SWKey</a>(k)
00098 {
00099         <a class="code" href="class_verse_key.html#c3">init</a>();
00100         <a class="code" href="class_verse_key.html#o8">autonorm</a> = k.autonorm;
00101         <a class="code" href="class_verse_key.html#o9">headings</a> = k.headings;
00102         <a class="code" href="class_verse_key.html#o4">testament</a> = k.Testament();
00103         book = k.Book();
00104         chapter = k.Chapter();
00105         verse = k.Verse();
00106         <a class="code" href="class_verse_key.html#a7">LowerBound</a>(k.LowerBound());
00107         <a class="code" href="class_verse_key.html#a8">UpperBound</a>(k.UpperBound());
00108 }
00109 
00110 
<a name="l00111"></a><a class="code" href="class_verse_key.html#a2">00111</a> <a class="code" href="class_verse_key.html#a0">VerseKey::VerseKey</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *min, <font class="keyword">const</font> <font class="keywordtype">char</font> *max) : <a class="code" href="class_s_w_key.html">SWKey</a>()
00112 {
00113         <a class="code" href="class_verse_key.html#c3">init</a>();
00114         <a class="code" href="class_verse_key.html#a7">LowerBound</a>(min);
00115         <a class="code" href="class_verse_key.html#a8">UpperBound</a>(max);
00116         <a class="code" href="class_verse_key.html#a16">setPosition</a>(TOP);
00117 }
00118 
00119 
<a name="l00120"></a><a class="code" href="class_verse_key.html#a10">00120</a> <a class="code" href="class_s_w_key.html">SWKey</a> *<a class="code" href="class_verse_key.html#a10">VerseKey::clone</a>()<font class="keyword"> const</font>
00121 <font class="keyword"></font>{
00122         <font class="keywordflow">return</font> <font class="keyword">new</font> <a class="code" href="class_verse_key.html#a0">VerseKey</a>(*<font class="keyword">this</font>);
00123 }
00124 
00125 
00126 <font class="comment">/******************************************************************************</font>
00127 <font class="comment"> * VerseKey Destructor - cleans up instance of VerseKey</font>
00128 <font class="comment"> *</font>
00129 <font class="comment"> * ENT: ikey - text key</font>
00130 <font class="comment"> */</font>
00131 
<a name="l00132"></a><a class="code" href="class_verse_key.html#a4">00132</a> <a class="code" href="class_verse_key.html#a4">VerseKey::~VerseKey</a>() {
00133         <font class="keywordflow">if</font> (upperBound)
00134                 <font class="keyword">delete</font> upperBound;
00135         <font class="keywordflow">if</font> (lowerBound)
00136                 <font class="keyword">delete</font> lowerBound;
00137         <font class="keywordflow">if</font> (locale)
00138                 <font class="keyword">delete</font> [] locale;
00139 
00140         --<a class="code" href="class_verse_key.html#r3">instance</a>;
00141 }
00142 
00143 
00144 <font class="keywordtype">void</font> VerseKey::setLocale(<font class="keyword">const</font> <font class="keywordtype">char</font> *name) {
00145         <font class="keywordtype">char</font> *BMAX;
00146         <font class="keyword">struct </font>sbook **books;
00147         <font class="keywordtype">bool</font> useCache = <font class="keyword">false</font>;
00148 
00149         <font class="keywordflow">if</font> (localeCache.name)
00150                 useCache = (!strcmp(localeCache.name, name));
00151 
00152         <font class="keywordflow">if</font> (!useCache)  {       <font class="comment">// if we're setting params for a new locale</font>
00153                 stdstr(&amp;(localeCache.name), name);
00154                 localeCache.abbrevsCnt = 0;
00155         }
00156 
00157         <a class="code" href="class_s_w_locale.html">SWLocale</a> *locale = (useCache) ? localeCache.locale : <a class="code" href="class_locale_mgr.html#p0">LocaleMgr::systemLocaleMgr</a>.<a class="code" href="class_locale_mgr.html#a2">getLocale</a>(name);
00158         localeCache.locale = locale;
00159 
00160         <font class="keywordflow">if</font> (locale) {
00161                 locale-&gt;<a class="code" href="class_s_w_locale.html#a7">getBooks</a>(&amp;BMAX, &amp;books);
00162                 setBooks(BMAX, books);
00163                 setBookAbbrevs(locale-&gt;<a class="code" href="class_s_w_locale.html#a6">getBookAbbrevs</a>(), localeCache.abbrevsCnt);
00164                 localeCache.abbrevsCnt = abbrevsCnt;
00165         }
00166         <font class="keywordflow">else</font> {
00167                 setBooks(builtin_BMAX, builtin_books);
00168                 setBookAbbrevs(builtin_abbrevs, localeCache.abbrevsCnt);
00169                 localeCache.abbrevsCnt = abbrevsCnt;
00170         }
00171         stdstr(&amp;(this-&gt;locale), localeCache.name);
00172 }
00173 
00174 
00175 <font class="keywordtype">void</font> VerseKey::setBooks(<font class="keyword">const</font> <font class="keywordtype">char</font> *iBMAX, <font class="keyword">struct</font> sbook **ibooks) {
00176         BMAX = iBMAX;
00177         books = ibooks;
00178 }
00179 
00180 
00181 <font class="keywordtype">void</font> VerseKey::setBookAbbrevs(<font class="keyword">const</font> <font class="keyword">struct</font> abbrev *bookAbbrevs, <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> size) {
00182         abbrevs = bookAbbrevs;
00183         <font class="keywordflow">if</font> (!size) {
00184                 <font class="keywordflow">for</font> (abbrevsCnt = 1; *abbrevs[abbrevsCnt].ab; abbrevsCnt++) {
00185                         <font class="comment">/*</font>
00186 <font class="comment">                        if (strcmp(abbrevs[abbrevsCnt-1].ab, abbrevs[abbrevsCnt].ab) &gt; 0) {</font>
00187 <font class="comment">                                fprintf(stderr, "ERROR: book abbreviation (canon.h or locale) misordered at entry: %s\n", abbrevs[abbrevsCnt].ab);</font>
00188 <font class="comment">                                exit(-1);</font>
00189 <font class="comment">                        }</font>
00190 <font class="comment">                        */</font>
00191                 }
00192         <font class="keywordflow">for</font> (<font class="keywordtype">int</font> t = 0; t &lt; 2; t++) {
00193             <font class="keywordflow">for</font> (<font class="keywordtype">int</font> i = 0; i &lt; BMAX[t]; i++) {
00194                 <font class="keywordtype">int</font> bn = getBookAbbrev(books[t][i].name);
00195                 <font class="keywordflow">if</font> ((bn-1)%39 != i) {
00196                     SWLog::systemlog-&gt;LogError(<font class="stringliteral">"Book: %s does not have a matching toupper abbrevs entry! book number returned was: %d"</font>, books[t][i].name, bn);
00197                 }
00198             }
00199         }
00200     }
00201         <font class="keywordflow">else</font> abbrevsCnt = size;
00202 }
00203 
00204 
00205 <font class="comment">/******************************************************************************</font>
00206 <font class="comment"> * VerseKey::initstatics - initializes statics.  Performed only when first</font>
00207 <font class="comment"> *                                              instance on VerseKey (or descendent) is created.</font>
00208 <font class="comment"> */</font>
00209 
<a name="l00210"></a><a class="code" href="class_verse_key.html#c2">00210</a> <font class="keywordtype">void</font> <a class="code" href="class_verse_key.html#c2">VerseKey::initstatics</a>() {
00211         <font class="keywordtype">int</font> l1, l2, chaptmp = 0;
00212 
00213         builtin_books[0] = otbooks;
00214         builtin_books[1] = ntbooks;
00215 
00216         <font class="keywordflow">for</font> (l1 = 0; l1 &lt; 2; l1++) {
00217                 <font class="keywordflow">for</font> (l2 = 0; l2 &lt; builtin_BMAX[l1]; l2++) {
00218                         builtin_books[l1][l2].versemax = &amp;vm[chaptmp];
00219                         chaptmp += builtin_books[l1][l2].chapmax;
00220                 }
00221         }
00222 }
00223 
00224 
00225 <font class="comment">/******************************************************************************</font>
00226 <font class="comment"> * VerseKey::parse - parses keytext into testament|book|chapter|verse</font>
00227 <font class="comment"> *</font>
00228 <font class="comment"> * RET: error status</font>
00229 <font class="comment"> */</font>
00230 
<a name="l00231"></a><a class="code" href="class_verse_key.html#c5">00231</a> <font class="keywordtype">char</font> <a class="code" href="class_verse_key.html#c5">VerseKey::parse</a>()
00232 {
00233 
00234         
00235         <a class="code" href="class_verse_key.html#o4">testament</a> = 1;
00236         book      = 1;
00237         chapter   = 1;
00238         verse     = 1;
00239 
00240         error     = 0;
00241 
00242         <font class="keywordflow">if</font> (keytext) {
00243                 <a class="code" href="class_list_key.html">ListKey</a> tmpListKey = VerseKey::ParseVerseList(keytext);
00244                 <font class="keywordflow">if</font> (tmpListKey.<a class="code" href="class_list_key.html#a5">Count</a>()) {
00245                         <a class="code" href="class_s_w_key.html#a7">SWKey::setText</a>((<font class="keyword">const</font> <font class="keywordtype">char</font> *)tmpListKey);
00246                         <font class="keywordflow">for</font> (<a class="code" href="class_verse_key.html#o4">testament</a> = 1; <a class="code" href="class_verse_key.html#o4">testament</a> &lt; 3; <a class="code" href="class_verse_key.html#o4">testament</a>++) {
00247                                 <font class="keywordflow">for</font> (book = 1; book &lt;= BMAX[<a class="code" href="class_verse_key.html#o4">testament</a>-1]; book++) {
00248                                         <font class="keywordflow">if</font> (!strncmp(keytext, books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].name, strlen(books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].name)))
00249                                                 <font class="keywordflow">break</font>;
00250                                 }
00251                                 <font class="keywordflow">if</font> (book &lt;= BMAX[<a class="code" href="class_verse_key.html#o4">testament</a>-1])
00252                                         <font class="keywordflow">break</font>;
00253                         }
00254 
00255                         <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#o4">testament</a> &lt; 3) {
00256                                 sscanf(&amp;keytext[strlen(books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].name)], <font class="stringliteral">"%d:%d"</font>, &amp;chapter, &amp;verse);
00257                         }
00258                         <font class="keywordflow">else</font>    error = 1;
00259                 }
00260         }
00261         <a class="code" href="class_verse_key.html#a30">Normalize</a>(1);
00262         <a class="code" href="class_verse_key.html#c4">freshtext</a>();
00263 
00264         <font class="keywordflow">return</font> error;
00265 }
00266 
00267 
00268 <font class="comment">/******************************************************************************</font>
00269 <font class="comment"> * VerseKey::freshtext - refreshes keytext based on</font>
00270 <font class="comment"> *                              testament|book|chapter|verse</font>
00271 <font class="comment"> */</font>
00272 
<a name="l00273"></a><a class="code" href="class_verse_key.html#c4">00273</a> <font class="keywordtype">void</font> <a class="code" href="class_verse_key.html#c4">VerseKey::freshtext</a>()<font class="keyword"> const</font>
00274 <font class="keyword"></font>{
00275         <font class="keywordtype">char</font> buf[2024];
00276         <font class="keywordtype">int</font> realtest = <a class="code" href="class_verse_key.html#o4">testament</a>;
00277         <font class="keywordtype">int</font> realbook = book;
00278 
00279         <font class="keywordflow">if</font> (book &lt; 1) {
00280                 <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#o4">testament</a> &lt; 1)
00281                         sprintf(buf, <font class="stringliteral">"[ Module Heading ]"</font>);
00282                 <font class="keywordflow">else</font> sprintf(buf, <font class="stringliteral">"[ Testament %d Heading ]"</font>, (<font class="keywordtype">int</font>)<a class="code" href="class_verse_key.html#o4">testament</a>);
00283         }
00284         <font class="keywordflow">else</font> {
00285                 <font class="keywordflow">if</font> (realbook &gt; BMAX[realtest-1]) {
00286                         realbook -= BMAX[realtest-1];
00287                         <font class="keywordflow">if</font> (realtest &lt; 2)
00288                                 realtest++;
00289                         <font class="keywordflow">if</font> (realbook &gt; BMAX[realtest-1])
00290                                 realbook = BMAX[realtest-1];
00291                 }
00292                 sprintf(buf, <font class="stringliteral">"%s %d:%d"</font>, books[realtest-1][realbook-1].name, chapter, verse);
00293         }
00294 
00295         stdstr((<font class="keywordtype">char</font> **)&amp;keytext, buf);
00296 }
00297 
00298 
00299 
00300 <font class="comment">/******************************************************************************</font>
00301 <font class="comment"> * VerseKey::getBookAbbrev - Attempts to find a book abbreviation for a buffer</font>
00302 <font class="comment"> *</font>
00303 <font class="comment"> * ENT: abbr - key for which to search;</font>
00304 <font class="comment"> * RET: book number or &lt; 0 = not valid</font>
00305 <font class="comment"> */</font>
00306 
00307 <font class="keywordtype">int</font> VerseKey::getBookAbbrev(<font class="keyword">const</font> <font class="keywordtype">char</font> *iabbr)
00308 {
00309     <font class="keywordtype">int</font> loop, diff, abLen, min, max, target, retVal = -1;
00310 
00311     <font class="keywordtype">char</font> *abbr = 0;
00312 
00313         stdstr(&amp;abbr, iabbr);
00314         strstrip(abbr);
00315         abLen = strlen(abbr);
00316         <font class="keywordflow">for</font> (loop = 0; loop &lt; abLen; loop++)
00317                 abbr[loop] = SW_toupper(abbr[loop]);
00318 
00319         <font class="keywordflow">if</font> (abLen) {
00320                 min = 0;
00321 <font class="comment">//              max = abbrevsCnt - 1;</font>
00322                 max = abbrevsCnt;
00323                 <font class="keywordflow">while</font>(1) {
00324                         target = min + ((max - min) / 2);
00325                         diff = strncmp(abbr, abbrevs[target].ab, abLen);
00326                         <font class="keywordflow">if</font> ((!diff)||(target &gt;= max)||(target &lt;= min))
00327                                 <font class="keywordflow">break</font>;
00328                         <font class="keywordflow">if</font> (diff &gt; 0)
00329                                 min = target;
00330                         <font class="keywordflow">else</font>    max = target;
00331                 }
00332                 <font class="keywordflow">for</font> (; target &gt; 0; target--) {
00333                         <font class="keywordflow">if</font> (strncmp(abbr, abbrevs[target-1].ab, abLen))
00334                                 <font class="keywordflow">break</font>;
00335                 }
00336                         
00337                 retVal = (!diff) ? abbrevs[target].book : -1;
00338         }
00339         <font class="keyword">delete</font> [] abbr;
00340         <font class="keywordflow">return</font> retVal;
00341 }
00342 
00343 <font class="comment">/******************************************************************************</font>
00344 <font class="comment"> * VerseKey::ParseVerseList - Attempts to parse a buffer into separate</font>
00345 <font class="comment"> *                              verse entries returned in a ListKey</font>
00346 <font class="comment"> *</font>
00347 <font class="comment"> * ENT: buf             - buffer to parse;</font>
00348 <font class="comment"> *      defaultKey      - if verse, chap, book, or testament is left off,</font>
00349 <font class="comment"> *                              pull info from this key (ie. Gen 2:3; 4:5;</font>
00350 <font class="comment"> *                              Gen would be used when parsing the 4:5 section)</font>
00351 <font class="comment"> *      expandRange     - whether or not to expand eg. John 1:10-12 or just</font>
00352 <font class="comment"> *                              save John 1:10</font>
00353 <font class="comment"> *</font>
00354 <font class="comment"> * RET: ListKey reference filled with verse entries contained in buf</font>
00355 <font class="comment"> *</font>
00356 <font class="comment"> * COMMENT: This code works but wreaks.  Rewrite to make more maintainable.</font>
00357 <font class="comment"> */</font>
00358 
00359 <a class="code" href="class_list_key.html">ListKey</a> VerseKey::ParseVerseList(<font class="keyword">const</font> <font class="keywordtype">char</font> *buf, <font class="keyword">const</font> <font class="keywordtype">char</font> *defaultKey, <font class="keywordtype">bool</font> expandRange) {
00360         <a class="code" href="class_s_w_key.html">SWKey</a> textkey;
00361 
00362         <font class="keywordtype">char</font> book[255];
00363         <font class="keywordtype">char</font> number[255];
00364         <font class="keywordtype">int</font> tobook = 0;
00365         <font class="keywordtype">int</font> tonumber = 0;
00366         <font class="keywordtype">int</font> chap = -1, verse = -1;
00367         <font class="keywordtype">int</font> bookno = 0;
00368         VerseKey curkey, lBound;
00369         curkey.<a class="code" href="class_verse_key.html#a42">setLocale</a>(getLocale());
00370         lBound.<a class="code" href="class_verse_key.html#a42">setLocale</a>(getLocale());
00371         <font class="keywordtype">int</font> loop;
00372         <font class="keywordtype">char</font> comma = 0;
00373         <font class="keywordtype">char</font> dash = 0;
00374         <font class="keyword">const</font> <font class="keywordtype">char</font> *orig = buf;
00375         <a class="code" href="class_list_key.html">ListKey</a> tmpListKey;
00376         <a class="code" href="class_list_key.html">ListKey</a> internalListKey;
00377         <a class="code" href="class_s_w_key.html">SWKey</a> tmpDefaultKey = defaultKey;
00378         <font class="keywordtype">char</font> lastPartial = 0;
00379 
00380         curkey.<a class="code" href="class_verse_key.html#a31">AutoNormalize</a>(0);
00381         tmpListKey &lt;&lt; tmpDefaultKey;
00382         tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>()-&gt;<a class="code" href="class_s_w_key.html#m0">userData</a> = (<font class="keywordtype">void</font> *)buf;
00383         
00384         <font class="keywordflow">while</font> (*buf) {
00385                 <font class="keywordflow">switch</font> (*buf) {
00386                 <font class="keywordflow">case</font> <font class="charliteral">':'</font>:
00387                         number[tonumber] = 0;
00388                         tonumber = 0;
00389                         <font class="keywordflow">if</font> (*number)
00390                                 chap = atoi(number);
00391                         *number = 0;
00392                         <font class="keywordflow">break</font>;
00393 
00394                 <font class="keywordflow">case</font> <font class="charliteral">'-'</font>: 
00395                 <font class="keywordflow">case</font> <font class="charliteral">','</font>: <font class="comment">// on number new verse</font>
00396                 <font class="keywordflow">case</font> <font class="charliteral">';'</font>: <font class="comment">// on number new chapter</font>
00397                         number[tonumber] = 0;
00398                         tonumber = 0;
00399                         <font class="keywordflow">if</font> (*number) {
00400                                 <font class="keywordflow">if</font> (chap &gt;= 0)
00401                                         verse = atoi(number);
00402                                 <font class="keywordflow">else</font>    chap = atoi(number);
00403                         }
00404                         *number = 0;
00405                         book[tobook] = 0;
00406                         tobook = 0;
00407                         bookno = -1;
00408                         <font class="keywordflow">if</font> (*book) {
00409                                 <font class="keywordflow">for</font> (loop = strlen(book) - 1; loop+1; loop--) {
00410                                         <font class="keywordflow">if</font> ((isdigit(book[loop])) || (book[loop] == <font class="charliteral">' '</font>)) {
00411                                                 book[loop] = 0;
00412                                                 <font class="keywordflow">continue</font>;
00413                                         }
00414                                         <font class="keywordflow">else</font> {
00415                                                 <font class="keywordflow">if</font> ((SW_toupper(book[loop])==<font class="charliteral">'F'</font>)&amp;&amp;(loop)) {
00416                                                         <font class="keywordflow">if</font> ((isdigit(book[loop-1])) || (book[loop-1] == <font class="charliteral">' '</font>) || (SW_toupper(book[loop-1]) == <font class="charliteral">'F'</font>)) {
00417                                                                 book[loop] = 0;
00418                                                                 <font class="keywordflow">continue</font>;
00419                                                         }
00420                                                 }
00421                                         }
00422                                         <font class="keywordflow">break</font>;
00423                                 }
00424 
00425                     <font class="keywordflow">for</font> (loop = strlen(book) - 1; loop+1; loop--) {
00426                          <font class="keywordflow">if</font> (book[loop] == <font class="charliteral">' '</font>) {
00427                                                 <font class="keywordflow">if</font> (isroman(&amp;book[loop+1])) {
00428                                    <font class="keywordflow">if</font> (verse == -1) {
00429                                         verse = chap;
00430                                                                 chap = from_rom(&amp;book[loop+1]);
00431                                                                 book[loop] = 0;
00432                                                         }
00433                                                 }
00434                                                 <font class="keywordflow">break</font>;
00435                                         }
00436                                 }
00437 
00438                                 <font class="keywordflow">if</font> ((!stricmp(book, <font class="stringliteral">"V"</font>)) || (!stricmp(book, <font class="stringliteral">"VER"</font>))) { <font class="comment">// Verse abbrev</font>
00439                          <font class="keywordflow">if</font> (verse == -1) {
00440                               verse = chap;
00441                                                 chap = <a class="code" href="class_verse_key.html#a0">VerseKey</a>(tmpListKey).Chapter();
00442                               *book = 0;
00443                          }
00444                     }
00445                                 bookno = getBookAbbrev(book);
00446                         }
00447                         <font class="keywordflow">if</font> (((bookno &gt; -1) || (!*book)) &amp;&amp; ((*book) || (chap &gt;= 0) || (verse &gt;= 0))) {
00448                                 <font class="keywordtype">char</font> partial = 0;
00449                                 curkey.<a class="code" href="class_verse_key.html#a25">Verse</a>(1);
00450                                 curkey.<a class="code" href="class_verse_key.html#a24">Chapter</a>(1);
00451                                 curkey.<a class="code" href="class_verse_key.html#a23">Book</a>(1);
00452 
00453                                 <font class="keywordflow">if</font> (bookno &lt; 0) {
00454                                         curkey.<a class="code" href="class_verse_key.html#a22">Testament</a>(<a class="code" href="class_verse_key.html#a0">VerseKey</a>(tmpListKey).<a class="code" href="class_verse_key.html#a22">Testament</a>());
00455                                         curkey.<a class="code" href="class_verse_key.html#a23">Book</a>(<a class="code" href="class_verse_key.html#a0">VerseKey</a>(tmpListKey).<a class="code" href="class_verse_key.html#a23">Book</a>());
00456                                 }
00457                                 <font class="keywordflow">else</font> {
00458                                         curkey.<a class="code" href="class_verse_key.html#a22">Testament</a>(1);
00459                                         curkey.<a class="code" href="class_verse_key.html#a23">Book</a>(bookno);
00460                                 }
00461 
00462                                 <font class="keywordflow">if</font> (((comma)||((verse &lt; 0)&amp;&amp;(bookno &lt; 0)))&amp;&amp;(!lastPartial)) {
00463 <font class="comment">//                              if (comma) {</font>
00464                                         curkey.<a class="code" href="class_verse_key.html#a24">Chapter</a>(<a class="code" href="class_verse_key.html#a0">VerseKey</a>(tmpListKey).<a class="code" href="class_verse_key.html#a24">Chapter</a>());
00465                                         curkey.<a class="code" href="class_verse_key.html#a25">Verse</a>(chap);  <font class="comment">// chap because this is the first number captured</font>
00466                                 }
00467                                 <font class="keywordflow">else</font> {
00468                                         <font class="keywordflow">if</font> (chap &gt;= 0) {
00469                                                 curkey.<a class="code" href="class_verse_key.html#a24">Chapter</a>(chap);
00470                                         }
00471                                         <font class="keywordflow">else</font> {
00472                                                 partial++;
00473                                                 curkey.<a class="code" href="class_verse_key.html#a24">Chapter</a>(1);
00474                                         }
00475                                         <font class="keywordflow">if</font> (verse &gt;= 0) {
00476                                                 curkey.<a class="code" href="class_verse_key.html#a25">Verse</a>(verse);
00477                                         }
00478                                         <font class="keywordflow">else</font> {
00479                                                 partial++;
00480                                                 curkey.<a class="code" href="class_verse_key.html#a25">Verse</a>(1);
00481                                         }
00482                                 }
00483 
00484                                 <font class="keywordflow">if</font> ((*buf == <font class="charliteral">'-'</font>) &amp;&amp; (expandRange)) {   <font class="comment">// if this is a dash save lowerBound and wait for upper</font>
00485                                         VerseKey newElement;
00486                                         newElement.<a class="code" href="class_verse_key.html#a5">LowerBound</a>(curkey);
00487                                         newElement.<a class="code" href="class_verse_key.html#a16">setPosition</a>(TOP);
00488                                         tmpListKey &lt;&lt; newElement;
00489                                         tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>()-&gt;<a class="code" href="class_s_w_key.html#m0">userData</a> = (<font class="keywordtype">void</font> *)buf;
00490                                 }
00491                                 <font class="keywordflow">else</font> {
00492                                         <font class="keywordflow">if</font> (!dash) {    <font class="comment">// if last separator was not a dash just add</font>
00493                                                 <font class="keywordflow">if</font> (expandRange &amp;&amp; partial) {
00494                                                         VerseKey newElement;
00495                                                         newElement.<a class="code" href="class_verse_key.html#a5">LowerBound</a>(curkey);
00496                                                         <font class="keywordflow">if</font> (partial &gt; 1)
00497                                                                 curkey.<a class="code" href="class_verse_key.html#a16">setPosition</a>(MAXCHAPTER);
00498                                                         <font class="keywordflow">if</font> (partial &gt; 0)
00499                                                                 curkey = MAXVERSE;
00500                                                         newElement.<a class="code" href="class_verse_key.html#a6">UpperBound</a>(curkey);
00501                                                         newElement = TOP;
00502                                                         tmpListKey &lt;&lt; newElement;
00503                                                         tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>()-&gt;<a class="code" href="class_s_w_key.html#m0">userData</a> = (<font class="keywordtype">void</font> *)buf;
00504                                                 }
00505                                                 <font class="keywordflow">else</font> {
00506                                                         tmpListKey &lt;&lt; (<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> &amp;)(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a>)(<font class="keyword">const</font> <font class="keywordtype">char</font> *)curkey;
00507                                                         tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>()-&gt;<a class="code" href="class_s_w_key.html#m0">userData</a> = (<font class="keywordtype">void</font> *)buf;
00508                                                 }
00509                                         }
00510                                         <font class="keywordflow">else</font>    <font class="keywordflow">if</font> (expandRange) {
00511                                                 VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>());
00512                                                 <font class="keywordflow">if</font> (newElement) {
00513                                                         <font class="keywordflow">if</font> (partial &gt; 1)
00514                                                                 curkey = MAXCHAPTER;
00515                                                         <font class="keywordflow">if</font> (partial &gt; 0)
00516                                                                 curkey = MAXVERSE;
00517                                                         newElement-&gt;<a class="code" href="class_verse_key.html#a6">UpperBound</a>(curkey);
00518                                                         *newElement = TOP;
00519                                                         tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>()-&gt;<a class="code" href="class_s_w_key.html#m0">userData</a> = (<font class="keywordtype">void</font> *)buf;
00520                                                 }
00521                                         }
00522                                 }
00523                                 lastPartial = partial;
00524                         }
00525                         *book = 0;
00526                         chap = -1;
00527                         verse = -1;
00528                         <font class="keywordflow">if</font> (*buf == <font class="charliteral">','</font>)
00529                                 comma = 1;
00530                         <font class="keywordflow">else</font>    comma = 0;
00531                         <font class="keywordflow">if</font> (*buf == <font class="charliteral">'-'</font>)
00532                                 dash = 1;
00533                         <font class="keywordflow">else</font>    dash = 0;
00534                         <font class="keywordflow">break</font>;
00535                 <font class="keywordflow">case</font> 10:        <font class="comment">// ignore these</font>
00536                 <font class="keywordflow">case</font> 13: 
00537                         <font class="keywordflow">break</font>;
00538                 <font class="keywordflow">case</font> <font class="charliteral">'.'</font>:
00539                         <font class="keywordflow">if</font> (buf &gt; orig)                 <font class="comment">// ignore (break) if preceeding char is not a digit</font>
00540                                 <font class="keywordflow">if</font> (!isdigit(*(buf-1)))
00541                                         <font class="keywordflow">break</font>;
00542                         
00543                 <font class="keywordflow">default</font>:
00544                         <font class="keywordflow">if</font> (isdigit(*buf)) {
00545                                 number[tonumber++] = *buf;
00546                         }
00547                         <font class="keywordflow">else</font> {
00548                                 <font class="keywordflow">switch</font> (*buf) {
00549                                 <font class="keywordflow">case</font> <font class="charliteral">' '</font>:    <font class="comment">// ignore these and don't reset number</font>
00550                                 <font class="keywordflow">case</font> <font class="charliteral">'f'</font>:
00551                                 <font class="keywordflow">case</font> <font class="charliteral">'F'</font>:
00552                                         <font class="keywordflow">break</font>;
00553                                 <font class="keywordflow">default</font>:
00554                                         number[tonumber] = 0;
00555                                         tonumber = 0;
00556                                         <font class="keywordflow">break</font>;
00557                                 }
00558                         }
00559                         <font class="keywordflow">if</font> (chap == -1)
00560                                 book[tobook++] = SW_toupper(*buf);
00561                 }
00562                 buf++;
00563         }
00564         number[tonumber] = 0;
00565         tonumber = 0;
00566         <font class="keywordflow">if</font> (*number) {
00567                 <font class="keywordflow">if</font> (chap &gt;= 0)
00568                         verse = atoi(number);
00569                 <font class="keywordflow">else</font>    chap = atoi(number);
00570         }
00571         *number = 0;
00572         book[tobook] = 0;
00573         tobook = 0;
00574         <font class="keywordflow">if</font> (*book) {
00575                 <font class="keywordflow">for</font> (loop = strlen(book) - 1; loop+1; loop--) {
00576                         <font class="keywordflow">if</font> ((isdigit(book[loop])) || (book[loop] == <font class="charliteral">' '</font>)) {
00577                                 book[loop] = 0;
00578                                 <font class="keywordflow">continue</font>;
00579                         }
00580                         <font class="keywordflow">else</font> {
00581                                 <font class="keywordflow">if</font> ((SW_toupper(book[loop])==<font class="charliteral">'F'</font>)&amp;&amp;(loop)) {
00582                                         <font class="keywordflow">if</font> ((isdigit(book[loop-1])) || (book[loop-1] == <font class="charliteral">' '</font>) || (SW_toupper(book[loop-1]) == <font class="charliteral">'F'</font>)) {
00583                                                 book[loop] = 0;
00584                                                 <font class="keywordflow">continue</font>;
00585                                         }
00586                                 }
00587                         }
00588                         <font class="keywordflow">break</font>;
00589                 }
00590 
00591                 <font class="keywordflow">for</font> (loop = strlen(book) - 1; loop+1; loop--) {
00592                 <font class="keywordflow">if</font> (book[loop] == <font class="charliteral">' '</font>) {
00593                 <font class="keywordflow">if</font> (isroman(&amp;book[loop+1])) {
00594                         <font class="keywordflow">if</font> (verse == -1) {
00595                                 verse = chap;
00596                               chap = from_rom(&amp;book[loop+1]);
00597                               book[loop] = 0;
00598                          }
00599                     }
00600                 <font class="keywordflow">break</font>;
00601                         }
00602           }
00603                
00604                 <font class="keywordflow">if</font> ((!stricmp(book, <font class="stringliteral">"V"</font>)) || (!stricmp(book, <font class="stringliteral">"VER"</font>))) { <font class="comment">// Verse abbrev.</font>
00605                         <font class="keywordflow">if</font> (verse == -1) {
00606                                 verse = chap;
00607                                 chap = <a class="code" href="class_verse_key.html#a0">VerseKey</a>(tmpListKey).Chapter();
00608                                 *book = 0;
00609                         }
00610                 }
00611                         
00612                 bookno = getBookAbbrev(book);
00613         }
00614         <font class="keywordflow">if</font> (((bookno &gt; -1) || (!*book)) &amp;&amp; ((*book) || (chap &gt;= 0) || (verse &gt;= 0))) {
00615                 <font class="keywordtype">char</font> partial = 0;
00616                 curkey.<a class="code" href="class_verse_key.html#a25">Verse</a>(1);
00617                 curkey.<a class="code" href="class_verse_key.html#a24">Chapter</a>(1);
00618                 curkey.<a class="code" href="class_verse_key.html#a23">Book</a>(1);
00619 
00620                 <font class="keywordflow">if</font> (bookno &lt; 0) {
00621                         curkey.<a class="code" href="class_verse_key.html#a22">Testament</a>(<a class="code" href="class_verse_key.html#a0">VerseKey</a>(tmpListKey).<a class="code" href="class_verse_key.html#a22">Testament</a>());
00622                         curkey.<a class="code" href="class_verse_key.html#a23">Book</a>(<a class="code" href="class_verse_key.html#a0">VerseKey</a>(tmpListKey).<a class="code" href="class_verse_key.html#a23">Book</a>());
00623                 }
00624                 <font class="keywordflow">else</font> {
00625                         curkey.<a class="code" href="class_verse_key.html#a22">Testament</a>(1);
00626                         curkey.<a class="code" href="class_verse_key.html#a23">Book</a>(bookno);
00627                 }
00628 
00629                 <font class="keywordflow">if</font> (((comma)||((verse &lt; 0)&amp;&amp;(bookno &lt; 0)))&amp;&amp;(!lastPartial)) {
00630 <font class="comment">//              if (comma) {</font>
00631                         curkey.<a class="code" href="class_verse_key.html#a24">Chapter</a>(<a class="code" href="class_verse_key.html#a0">VerseKey</a>(tmpListKey).<a class="code" href="class_verse_key.html#a24">Chapter</a>());
00632                         curkey.<a class="code" href="class_verse_key.html#a25">Verse</a>(chap);  <font class="comment">// chap because this is the first number captured</font>
00633                 }
00634                 <font class="keywordflow">else</font> {
00635                         <font class="keywordflow">if</font> (chap &gt;= 0) {
00636                                 curkey.<a class="code" href="class_verse_key.html#a24">Chapter</a>(chap);
00637                         }
00638                         <font class="keywordflow">else</font> {
00639                                 partial++;
00640                                 curkey.<a class="code" href="class_verse_key.html#a24">Chapter</a>(1);
00641                         }
00642                         <font class="keywordflow">if</font> (verse &gt;= 0) {
00643                                 curkey.<a class="code" href="class_verse_key.html#a25">Verse</a>(verse);
00644                         }
00645                         <font class="keywordflow">else</font> {
00646                                 partial++;
00647                                 curkey.<a class="code" href="class_verse_key.html#a25">Verse</a>(1);
00648                         }
00649                 }
00650 
00651                 <font class="keywordflow">if</font> ((*buf == <font class="charliteral">'-'</font>) &amp;&amp; (expandRange)) {   <font class="comment">// if this is a dash save lowerBound and wait for upper</font>
00652                         VerseKey newElement;
00653                         newElement.<a class="code" href="class_verse_key.html#a5">LowerBound</a>(curkey);
00654                         newElement = TOP;
00655                         tmpListKey &lt;&lt; newElement;
00656                         tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>()-&gt;<a class="code" href="class_s_w_key.html#m0">userData</a> = (<font class="keywordtype">void</font> *)buf;
00657                 }
00658                 <font class="keywordflow">else</font> {
00659                         <font class="keywordflow">if</font> (!dash) {    <font class="comment">// if last separator was not a dash just add</font>
00660                                 <font class="keywordflow">if</font> (expandRange &amp;&amp; partial) {
00661                                         VerseKey newElement;
00662                                         newElement.<a class="code" href="class_verse_key.html#a5">LowerBound</a>(curkey);
00663                                         <font class="keywordflow">if</font> (partial &gt; 1)
00664                                                 curkey = MAXCHAPTER;
00665                                         <font class="keywordflow">if</font> (partial &gt; 0)
00666                                                 curkey = MAXVERSE;
00667                                         newElement.<a class="code" href="class_verse_key.html#a6">UpperBound</a>(curkey);
00668                                         newElement = TOP;
00669                                         tmpListKey &lt;&lt; newElement;
00670                                         tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>()-&gt;<a class="code" href="class_s_w_key.html#m0">userData</a> = (<font class="keywordtype">void</font> *)buf;
00671                                 }
00672                                 <font class="keywordflow">else</font> {
00673                                         tmpListKey &lt;&lt; (<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> &amp;)(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a>)(<font class="keyword">const</font> <font class="keywordtype">char</font> *)curkey;
00674                                         tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>()-&gt;<a class="code" href="class_s_w_key.html#m0">userData</a> = (<font class="keywordtype">void</font> *)buf;
00675                                 }
00676                         }
00677                         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (expandRange) {
00678                                 VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>());
00679                                 <font class="keywordflow">if</font> (newElement) {
00680                                         <font class="keywordflow">if</font> (partial &gt; 1)
00681                                                 curkey = MAXCHAPTER;
00682                                         <font class="keywordflow">if</font> (partial &gt; 0)
00683                                                 curkey = MAXVERSE;
00684                                         newElement-&gt;<a class="code" href="class_verse_key.html#a6">UpperBound</a>(curkey);
00685                                         *newElement = TOP;
00686                                         tmpListKey.<a class="code" href="class_list_key.html#a8">GetElement</a>()-&gt;<a class="code" href="class_s_w_key.html#m0">userData</a> = (<font class="keywordtype">void</font> *)buf;
00687                                 }
00688                         }
00689                 }
00690         }
00691         *book = 0;
00692         tmpListKey = TOP;
00693         tmpListKey.<a class="code" href="class_list_key.html#a6">Remove</a>();    <font class="comment">// remove defaultKey</font>
00694         internalListKey = tmpListKey;
00695         internalListKey = TOP;  <font class="comment">// Align internalListKey to first element before passing back;</font>
00696 
00697         <font class="keywordflow">return</font> internalListKey;
00698 }
00699 
00700 
00701 <font class="comment">/******************************************************************************</font>
00702 <font class="comment"> * VerseKey::LowerBound - sets / gets the lower boundary for this key</font>
00703 <font class="comment"> */</font>
00704 
<a name="l00705"></a><a class="code" href="class_verse_key.html#a5">00705</a> VerseKey &amp;<a class="code" href="class_verse_key.html#a7">VerseKey::LowerBound</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *lb)
00706 {
00707         <font class="keywordflow">if</font> (!lowerBound) 
00708                 initBounds();
00709 
00710         (*lowerBound) = lb;
00711         lowerBound-&gt;<a class="code" href="class_verse_key.html#a30">Normalize</a>();
00712 
00713         <font class="keywordflow">return</font> (*lowerBound);
00714 }
00715 
00716 
00717 <font class="comment">/******************************************************************************</font>
00718 <font class="comment"> * VerseKey::UpperBound - sets / gets the upper boundary for this key</font>
00719 <font class="comment"> */</font>
00720 
<a name="l00721"></a><a class="code" href="class_verse_key.html#a6">00721</a> VerseKey &amp;<a class="code" href="class_verse_key.html#a8">VerseKey::UpperBound</a>(<font class="keyword">const</font> <font class="keywordtype">char</font> *ub)
00722 {
00723         <font class="keywordflow">if</font> (!upperBound) 
00724                 initBounds();
00725 
00726 <font class="comment">// need to set upperbound parsing to resolve to max verse/chap if not specified</font>
00727            (*upperBound) = ub;
00728         <font class="keywordflow">if</font> (*upperBound &lt; *lowerBound)
00729                 *upperBound = *lowerBound;
00730         upperBound-&gt;<a class="code" href="class_verse_key.html#a30">Normalize</a>();
00731 
00732 <font class="comment">// until we have a proper method to resolve max verse/chap use this kludge</font>
00733         <font class="keywordtype">int</font> len = strlen(ub);
00734         <font class="keywordtype">bool</font> alpha = <font class="keyword">false</font>;
00735         <font class="keywordtype">bool</font> versespec = <font class="keyword">false</font>;
00736         <font class="keywordtype">bool</font> chapspec = <font class="keyword">false</font>;
00737         <font class="keywordflow">for</font> (<font class="keywordtype">int</font> i = 0; i &lt; len; i++) {
00738                 <font class="keywordflow">if</font> (isalpha(ub[i]))
00739                         alpha = <font class="keyword">true</font>;
00740                 <font class="keywordflow">if</font> (ub[i] == <font class="charliteral">':'</font>)       <font class="comment">// if we have a : we assume verse spec</font>
00741                         versespec = <font class="keyword">true</font>;
00742                 <font class="keywordflow">if</font> ((isdigit(ub[i])) &amp;&amp; (alpha))        <font class="comment">// if digit after alpha assume chap spec</font>
00743                         chapspec = <font class="keyword">true</font>;
00744         }
00745         <font class="keywordflow">if</font> (!chapspec)
00746                 *upperBound = MAXCHAPTER;
00747         <font class="keywordflow">if</font> (!versespec)
00748                 *upperBound = MAXVERSE;
00749         
00750 
00751 <font class="comment">// -- end kludge</font>
00752 
00753         <font class="keywordflow">return</font> (*upperBound);
00754 }
00755 
00756 
00757 <font class="comment">/******************************************************************************</font>
00758 <font class="comment"> * VerseKey::LowerBound - sets / gets the lower boundary for this key</font>
00759 <font class="comment"> */</font>
00760 
<a name="l00761"></a><a class="code" href="class_verse_key.html#a7">00761</a> VerseKey &amp;<a class="code" href="class_verse_key.html#a7">VerseKey::LowerBound</a>()<font class="keyword"> const</font>
00762 <font class="keyword"></font>{
00763         <font class="keywordflow">if</font> (!lowerBound) 
00764                 initBounds();
00765 
00766         <font class="keywordflow">return</font> (*lowerBound);
00767 }
00768 
00769 
00770 <font class="comment">/******************************************************************************</font>
00771 <font class="comment"> * VerseKey::UpperBound - sets / gets the upper boundary for this key</font>
00772 <font class="comment"> */</font>
00773 
<a name="l00774"></a><a class="code" href="class_verse_key.html#a8">00774</a> VerseKey &amp;<a class="code" href="class_verse_key.html#a8">VerseKey::UpperBound</a>()<font class="keyword"> const</font>
00775 <font class="keyword"></font>{
00776         <font class="keywordflow">if</font> (!upperBound) 
00777                 initBounds();
00778 
00779         <font class="keywordflow">return</font> (*upperBound);
00780 }
00781 
00782 
00783 <font class="comment">/******************************************************************************</font>
00784 <font class="comment"> * VerseKey::ClearBounds        - clears bounds for this VerseKey</font>
00785 <font class="comment"> */</font>
00786 
<a name="l00787"></a><a class="code" href="class_verse_key.html#a9">00787</a> <font class="keywordtype">void</font> <a class="code" href="class_verse_key.html#a9">VerseKey::ClearBounds</a>()
00788 {
00789         initBounds();
00790 }
00791 
00792 
00793 <font class="keywordtype">void</font> VerseKey::initBounds()<font class="keyword"> const</font>
00794 <font class="keyword"></font>{
00795         <font class="keywordflow">if</font> (!upperBound) {
00796                 upperBound = <font class="keyword">new</font> <a class="code" href="class_verse_key.html#a0">VerseKey</a>();
00797                 upperBound-&gt;<a class="code" href="class_verse_key.html#a31">AutoNormalize</a>(0);
00798                 upperBound-&gt;<a class="code" href="class_verse_key.html#a32">Headings</a>(1);
00799         }
00800         <font class="keywordflow">if</font> (!lowerBound) {
00801                 lowerBound = <font class="keyword">new</font> <a class="code" href="class_verse_key.html#a0">VerseKey</a>();
00802                 lowerBound-&gt;<a class="code" href="class_verse_key.html#a31">AutoNormalize</a>(0);
00803                 lowerBound-&gt;<a class="code" href="class_verse_key.html#a32">Headings</a>(1);
00804         }
00805 
00806         lowerBound-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(0);
00807         lowerBound-&gt;<a class="code" href="class_verse_key.html#a23">Book</a>(0);
00808         lowerBound-&gt;<a class="code" href="class_verse_key.html#a24">Chapter</a>(0);
00809         lowerBound-&gt;<a class="code" href="class_verse_key.html#a25">Verse</a>(0);
00810 
00811         upperBound-&gt;<a class="code" href="class_verse_key.html#a22">Testament</a>(2);
00812         upperBound-&gt;<a class="code" href="class_verse_key.html#a23">Book</a>(BMAX[1]);
00813         upperBound-&gt;<a class="code" href="class_verse_key.html#a24">Chapter</a>(books[1][BMAX[1]-1].chapmax);
00814         upperBound-&gt;<a class="code" href="class_verse_key.html#a25">Verse</a>(books[1][BMAX[1]-1].versemax[upperBound-&gt;<a class="code" href="class_verse_key.html#a24">Chapter</a>()-1]);
00815 }
00816 
00817 
00818 <font class="comment">/******************************************************************************</font>
00819 <font class="comment"> * VerseKey::copyFrom - Equates this VerseKey to another VerseKey</font>
00820 <font class="comment"> */</font>
00821 
<a name="l00822"></a><a class="code" href="class_verse_key.html#a15">00822</a> <font class="keywordtype">void</font> <a class="code" href="class_verse_key.html#a14">VerseKey::copyFrom</a>(<font class="keyword">const</font> VerseKey &amp;ikey) {
00823         <a class="code" href="class_s_w_key.html#a8">SWKey::copyFrom</a>(ikey);
00824 
00825         <a class="code" href="class_verse_key.html#c5">parse</a>();
00826 }
00827 
00828 
00829 <font class="comment">/******************************************************************************</font>
00830 <font class="comment"> * VerseKey::copyFrom - Equates this VerseKey to another SWKey</font>
00831 <font class="comment"> */</font>
00832 
<a name="l00833"></a><a class="code" href="class_verse_key.html#a14">00833</a> <font class="keywordtype">void</font> <a class="code" href="class_verse_key.html#a14">VerseKey::copyFrom</a>(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> &amp;ikey) {
00834         <a class="code" href="class_s_w_key.html#a8">SWKey::copyFrom</a>(ikey);
00835 
00836         <a class="code" href="class_verse_key.html#c5">parse</a>();
00837 }
00838 
00839 
00840 <font class="comment">/******************************************************************************</font>
00841 <font class="comment"> * VerseKey::getText - refreshes keytext before returning if cast to</font>
00842 <font class="comment"> *                              a (char *) is requested</font>
00843 <font class="comment"> */</font>
00844 
<a name="l00845"></a><a class="code" href="class_verse_key.html#a11">00845</a> <font class="keyword">const</font> <font class="keywordtype">char</font> *<a class="code" href="class_verse_key.html#a11">VerseKey::getText</a>()<font class="keyword"> const </font>{
00846         <a class="code" href="class_verse_key.html#c4">freshtext</a>();
00847         <font class="keywordflow">return</font> keytext;
00848 }
00849 
00850 
00851 <font class="keyword">const</font> <font class="keywordtype">char</font> *VerseKey::getShortText()<font class="keyword"> const </font>{
00852         <font class="keyword">static</font> <font class="keywordtype">char</font> *stext = 0;
00853         <font class="keywordtype">char</font> buf[2047];
00854         <a class="code" href="class_verse_key.html#c4">freshtext</a>();
00855         <font class="keywordflow">if</font> (book &lt; 1) {
00856                 <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#o4">testament</a> &lt; 1)
00857                         sprintf(buf, <font class="stringliteral">"[ Module Heading ]"</font>);
00858                 <font class="keywordflow">else</font> sprintf(buf, <font class="stringliteral">"[ Testament %d Heading ]"</font>, (<font class="keywordtype">int</font>)<a class="code" href="class_verse_key.html#o4">testament</a>);
00859         }
00860         <font class="keywordflow">else</font> {
00861                 sprintf(buf, <font class="stringliteral">"%s %d:%d"</font>, books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].prefAbbrev, chapter, verse);
00862         }
00863         stdstr(&amp;stext, buf);
00864         <font class="keywordflow">return</font> stext;
00865 }
00866 
00867 
00868 <font class="keyword">const</font> <font class="keywordtype">char</font> *VerseKey::getBookName()<font class="keyword"> const </font>{
00869         <font class="keywordflow">return</font> books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].name;
00870 }
00871 
00872 
00873 <font class="keyword">const</font> <font class="keywordtype">char</font> *VerseKey::getBookAbbrev()<font class="keyword"> const </font>{
00874         <font class="keywordflow">return</font> books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].prefAbbrev;
00875 }
00876 <font class="comment">/******************************************************************************</font>
00877 <font class="comment"> * VerseKey::setPosition(SW_POSITION)   - Positions this key</font>
00878 <font class="comment"> *</font>
00879 <font class="comment"> * ENT: p       - position</font>
00880 <font class="comment"> *</font>
00881 <font class="comment"> * RET: *this</font>
00882 <font class="comment"> */</font>
00883 
<a name="l00884"></a><a class="code" href="class_verse_key.html#a16">00884</a> <font class="keywordtype">void</font> <a class="code" href="class_verse_key.html#a16">VerseKey::setPosition</a>(SW_POSITION p) {
00885         <font class="keywordflow">switch</font> (p) {
00886         <font class="keywordflow">case</font> POS_TOP:
00887                 <a class="code" href="class_verse_key.html#o4">testament</a> = <a class="code" href="class_verse_key.html#a7">LowerBound</a>().<a class="code" href="class_verse_key.html#a22">Testament</a>();
00888                 book      = <a class="code" href="class_verse_key.html#a7">LowerBound</a>().<a class="code" href="class_verse_key.html#a23">Book</a>();
00889                 chapter   = <a class="code" href="class_verse_key.html#a7">LowerBound</a>().<a class="code" href="class_verse_key.html#a24">Chapter</a>();
00890                 verse     = <a class="code" href="class_verse_key.html#a7">LowerBound</a>().<a class="code" href="class_verse_key.html#a25">Verse</a>();
00891                 <font class="keywordflow">break</font>;
00892         <font class="keywordflow">case</font> POS_BOTTOM:
00893                 <a class="code" href="class_verse_key.html#o4">testament</a> = <a class="code" href="class_verse_key.html#a8">UpperBound</a>().<a class="code" href="class_verse_key.html#a22">Testament</a>();
00894                 book      = <a class="code" href="class_verse_key.html#a8">UpperBound</a>().<a class="code" href="class_verse_key.html#a23">Book</a>();
00895                 chapter   = <a class="code" href="class_verse_key.html#a8">UpperBound</a>().<a class="code" href="class_verse_key.html#a24">Chapter</a>();
00896                 verse     = <a class="code" href="class_verse_key.html#a8">UpperBound</a>().<a class="code" href="class_verse_key.html#a25">Verse</a>();
00897                 <font class="keywordflow">break</font>;
00898         <font class="keywordflow">case</font> POS_MAXVERSE:
00899                 <a class="code" href="class_verse_key.html#a30">Normalize</a>();
00900                 verse     = books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].versemax[chapter-1];
00901                 <font class="keywordflow">break</font>;
00902         <font class="keywordflow">case</font> POS_MAXCHAPTER:
00903                 verse     = 1;
00904                 <a class="code" href="class_verse_key.html#a30">Normalize</a>();
00905                 chapter   = books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].chapmax;
00906                 <font class="keywordflow">break</font>;
00907         } 
00908         <a class="code" href="class_verse_key.html#a30">Normalize</a>(1);
00909         <a class="code" href="class_s_w_key.html#a6">Error</a>();        <font class="comment">// clear error from normalize</font>
00910 }
00911 
00912 
00913 <font class="comment">/******************************************************************************</font>
00914 <font class="comment"> * VerseKey::increment  - Increments key a number of verses</font>
00915 <font class="comment"> *</font>
00916 <font class="comment"> * ENT: step    - Number of verses to jump forward</font>
00917 <font class="comment"> *</font>
00918 <font class="comment"> * RET: *this</font>
00919 <font class="comment"> */</font>
00920 
<a name="l00921"></a><a class="code" href="class_verse_key.html#a18">00921</a> <font class="keywordtype">void</font> <a class="code" href="class_verse_key.html#a18">VerseKey::increment</a>(<font class="keywordtype">int</font> step) {
00922         <font class="keywordtype">char</font> ierror = 0;
00923         <a class="code" href="class_verse_key.html#a34">Index</a>(<a class="code" href="class_verse_key.html#a34">Index</a>() + step);
00924         <font class="keywordflow">while</font> ((!verse) &amp;&amp; (!<a class="code" href="class_verse_key.html#o9">headings</a>) &amp;&amp; (!ierror)) {
00925                 <a class="code" href="class_verse_key.html#a34">Index</a>(<a class="code" href="class_verse_key.html#a34">Index</a>() + 1);
00926                 ierror = <a class="code" href="class_s_w_key.html#a6">Error</a>();
00927         }
00928 
00929         error = (ierror) ? ierror : error;
00930 }
00931 
00932 
00933 <font class="comment">/******************************************************************************</font>
00934 <font class="comment"> * VerseKey::decrement  - Decrements key a number of verses</font>
00935 <font class="comment"> *</font>
00936 <font class="comment"> * ENT: step    - Number of verses to jump backward</font>
00937 <font class="comment"> *</font>
00938 <font class="comment"> * RET: *this</font>
00939 <font class="comment"> */</font>
00940 
<a name="l00941"></a><a class="code" href="class_verse_key.html#a17">00941</a> <font class="keywordtype">void</font> <a class="code" href="class_verse_key.html#a17">VerseKey::decrement</a>(<font class="keywordtype">int</font> step) {
00942         <font class="keywordtype">char</font> ierror = 0;
00943 
00944         <a class="code" href="class_verse_key.html#a34">Index</a>(<a class="code" href="class_verse_key.html#a34">Index</a>() - step);
00945         <font class="keywordflow">while</font> ((!verse) &amp;&amp; (!<a class="code" href="class_verse_key.html#o9">headings</a>) &amp;&amp; (!ierror)) {
00946                 <a class="code" href="class_verse_key.html#a34">Index</a>(<a class="code" href="class_verse_key.html#a34">Index</a>() - 1);
00947                 ierror = <a class="code" href="class_s_w_key.html#a6">Error</a>();
00948         }
00949         <font class="keywordflow">if</font> ((ierror) &amp;&amp; (!<a class="code" href="class_verse_key.html#o9">headings</a>))
00950                 (*this)++;
00951 
00952         error = (ierror) ? ierror : error;
00953 }
00954 
00955 
00956 <font class="comment">/******************************************************************************</font>
00957 <font class="comment"> * VerseKey::Normalize  - checks limits and normalizes if necessary (e.g.</font>
00958 <font class="comment"> *                              Matthew 29:47 = Mark 2:2).  If last verse is</font>
00959 <font class="comment"> *                              exceeded, key is set to last Book CH:VS</font>
00960 <font class="comment"> * RET: *this</font>
00961 <font class="comment"> */</font>
00962 
<a name="l00963"></a><a class="code" href="class_verse_key.html#a30">00963</a> <font class="keywordtype">void</font> <a class="code" href="class_verse_key.html#a30">VerseKey::Normalize</a>(<font class="keywordtype">char</font> autocheck)
00964 {
00965         error = 0;
00966 
00967         <font class="keywordflow">if</font> ((autocheck) &amp;&amp; (!<a class="code" href="class_verse_key.html#o8">autonorm</a>)) <font class="comment">// only normalize if we were explicitely called or if autonorm is turned on</font>
00968                 <font class="keywordflow">return</font>;
00969 
00970         <font class="keywordflow">if</font> ((headings) &amp;&amp; (!verse))             <font class="comment">// this is cheeze and temporary until deciding what actions should be taken.</font>
00971                 <font class="keywordflow">return</font>;                                 <font class="comment">// so headings should only be turned on when positioning with Index() or incrementors</font>
00972 
00973         <font class="keywordflow">while</font> ((testament &lt; 3) &amp;&amp; (testament &gt; 0)) {
00974 
00975                 <font class="keywordflow">if</font> (book &gt; BMAX[<a class="code" href="class_verse_key.html#o4">testament</a>-1]) {
00976                         book -= BMAX[<a class="code" href="class_verse_key.html#o4">testament</a>-1];
00977                         <a class="code" href="class_verse_key.html#o4">testament</a>++;
00978                         <font class="keywordflow">continue</font>;
00979                 }
00980 
00981                 <font class="keywordflow">if</font> (book &lt; 1) {
00982                         <font class="keywordflow">if</font> (--<a class="code" href="class_verse_key.html#o4">testament</a> &gt; 0) {
00983                                 book += BMAX[<a class="code" href="class_verse_key.html#o4">testament</a>-1];
00984                         }
00985                         <font class="keywordflow">continue</font>;
00986                 }
00987 
00988                 <font class="keywordflow">if</font> (chapter &gt; books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].chapmax) {
00989                         chapter -= books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].chapmax;
00990                         book++;
00991                         <font class="keywordflow">continue</font>;
00992                 }
00993 
00994                 <font class="keywordflow">if</font> (chapter &lt; 1) {
00995                         <font class="keywordflow">if</font> (--book &gt; 0) {
00996                                 chapter += books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].chapmax;
00997                         }
00998                         <font class="keywordflow">else</font>    {
00999                                 <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#o4">testament</a> &gt; 1) {
01000                                         chapter += books[0][BMAX[0]-1].chapmax;
01001                                 }
01002                         }
01003                         <font class="keywordflow">continue</font>;
01004                 }
01005 
01006                 <font class="keywordflow">if</font> (verse &gt; books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].versemax[chapter-1]) { <font class="comment">// -1 because e.g chapter 1 of Matthew is books[1][0].versemax[0]</font>
01007                         verse -= books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].versemax[chapter++ - 1];
01008                         <font class="keywordflow">continue</font>;
01009                 }
01010 
01011                 <font class="keywordflow">if</font> (verse &lt; 1) {
01012                         <font class="keywordflow">if</font> (--chapter &gt; 0) {
01013                                 verse += books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].versemax[chapter-1];
01014                         }
01015                         <font class="keywordflow">else</font>    {
01016                                 <font class="keywordflow">if</font> (book &gt; 1) {
01017                                         verse += books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-2].versemax[books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-2].chapmax-1];
01018                                 }
01019                                 <font class="keywordflow">else</font>    {
01020                                         <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#o4">testament</a> &gt; 1) {
01021                                                 verse += books[0][BMAX[0]-1].versemax[books[0][BMAX[0]-1].chapmax-1];
01022                                         }
01023                                 }
01024                         }
01025                         <font class="keywordflow">continue</font>;
01026                 }
01027 
01028                 <font class="keywordflow">break</font>;  <font class="comment">// If we've made it this far (all failure checks continue) we're ok</font>
01029         }
01030 
01031         <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#o4">testament</a> &gt; 2) {
01032                 <a class="code" href="class_verse_key.html#o4">testament</a> = 2;
01033                 book      = BMAX[<a class="code" href="class_verse_key.html#o4">testament</a>-1];
01034                 chapter   = books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].chapmax;
01035                 verse     = books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].versemax[chapter-1];
01036                 error     = KEYERR_OUTOFBOUNDS;
01037         }
01038 
01039         <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#o4">testament</a> &lt; 1) {
01040                 error     = ((!<a class="code" href="class_verse_key.html#o9">headings</a>) || (<a class="code" href="class_verse_key.html#o4">testament</a> &lt; 0) || (book &lt; 0)) ? KEYERR_OUTOFBOUNDS : 0;
01041                 <a class="code" href="class_verse_key.html#o4">testament</a> = ((headings) ? 0 : 1);
01042                 book      = ((headings) ? 0 : 1);
01043                 chapter   = ((headings) ? 0 : 1);
01044                 verse     = ((headings) ? 0 : 1);
01045         }
01046         <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#a39">_compare</a>(<a class="code" href="class_verse_key.html#a8">UpperBound</a>()) &gt; 0) {
01047                 *<font class="keyword">this</font> = <a class="code" href="class_verse_key.html#a8">UpperBound</a>();
01048                 error = KEYERR_OUTOFBOUNDS;
01049         }
01050         <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#a39">_compare</a>(<a class="code" href="class_verse_key.html#a7">LowerBound</a>()) &lt; 0) {
01051                 *<font class="keyword">this</font> = <a class="code" href="class_verse_key.html#a7">LowerBound</a>();
01052                 error = KEYERR_OUTOFBOUNDS;
01053         }
01054 }
01055 
01056 
01057 <font class="comment">/******************************************************************************</font>
01058 <font class="comment"> * VerseKey::Testament - Gets testament</font>
01059 <font class="comment"> *</font>
01060 <font class="comment"> * RET: value of testament</font>
01061 <font class="comment"> */</font>
01062 
<a name="l01063"></a><a class="code" href="class_verse_key.html#a22">01063</a> <font class="keywordtype">char</font> <a class="code" href="class_verse_key.html#a22">VerseKey::Testament</a>()<font class="keyword"> const</font>
01064 <font class="keyword"></font>{
01065         <font class="keywordflow">return</font> <a class="code" href="class_verse_key.html#o4">testament</a>;
01066 }
01067 
01068 
01069 <font class="comment">/******************************************************************************</font>
01070 <font class="comment"> * VerseKey::Book - Gets book</font>
01071 <font class="comment"> *</font>
01072 <font class="comment"> * RET: value of book</font>
01073 <font class="comment"> */</font>
01074 
<a name="l01075"></a><a class="code" href="class_verse_key.html#a23">01075</a> <font class="keywordtype">char</font> <a class="code" href="class_verse_key.html#a23">VerseKey::Book</a>()<font class="keyword"> const</font>
01076 <font class="keyword"></font>{
01077         <font class="keywordflow">return</font> book;
01078 }
01079 
01080 
01081 <font class="comment">/******************************************************************************</font>
01082 <font class="comment"> * VerseKey::Chapter - Gets chapter</font>
01083 <font class="comment"> *</font>
01084 <font class="comment"> * RET: value of chapter</font>
01085 <font class="comment"> */</font>
01086 
<a name="l01087"></a><a class="code" href="class_verse_key.html#a24">01087</a> <font class="keywordtype">int</font> <a class="code" href="class_verse_key.html#a24">VerseKey::Chapter</a>()<font class="keyword"> const</font>
01088 <font class="keyword"></font>{
01089         <font class="keywordflow">return</font> chapter;
01090 }
01091 
01092 
01093 <font class="comment">/******************************************************************************</font>
01094 <font class="comment"> * VerseKey::Verse - Gets verse</font>
01095 <font class="comment"> *</font>
01096 <font class="comment"> * RET: value of verse</font>
01097 <font class="comment"> */</font>
01098 
<a name="l01099"></a><a class="code" href="class_verse_key.html#a25">01099</a> <font class="keywordtype">int</font> <a class="code" href="class_verse_key.html#a25">VerseKey::Verse</a>()<font class="keyword"> const</font>
01100 <font class="keyword"></font>{
01101         <font class="keywordflow">return</font> verse;
01102 }
01103 
01104 
01105 <font class="comment">/******************************************************************************</font>
01106 <font class="comment"> * VerseKey::Testament - Sets/gets testament</font>
01107 <font class="comment"> *</font>
01108 <font class="comment"> * ENT: itestament - value which to set testament</font>
01109 <font class="comment"> *              [MAXPOS(char)] - only get</font>
01110 <font class="comment"> *</font>
01111 <font class="comment"> * RET: if unchanged -&gt;          value of testament</font>
01112 <font class="comment"> *      if   changed -&gt; previous value of testament</font>
01113 <font class="comment"> */</font>
01114 
<a name="l01115"></a><a class="code" href="class_verse_key.html#a26">01115</a> <font class="keywordtype">char</font> <a class="code" href="class_verse_key.html#a22">VerseKey::Testament</a>(<font class="keywordtype">char</font> itestament)
01116 {
01117         <font class="keywordtype">char</font> retval = <a class="code" href="class_verse_key.html#o4">testament</a>;
01118 
01119         <font class="keywordflow">if</font> (itestament != MAXPOS(<font class="keywordtype">char</font>)) {
01120                 <a class="code" href="class_verse_key.html#o4">testament</a> = itestament;
01121                 <a class="code" href="class_verse_key.html#a30">Normalize</a>(1);
01122         }
01123         <font class="keywordflow">return</font> retval;
01124 }
01125 
01126 
01127 <font class="comment">/******************************************************************************</font>
01128 <font class="comment"> * VerseKey::Book - Sets/gets book</font>
01129 <font class="comment"> *</font>
01130 <font class="comment"> * ENT: ibook - value which to set book</font>
01131 <font class="comment"> *              [MAXPOS(char)] - only get</font>
01132 <font class="comment"> *</font>
01133 <font class="comment"> * RET: if unchanged -&gt;          value of book</font>
01134 <font class="comment"> *      if   changed -&gt; previous value of book</font>
01135 <font class="comment"> */</font>
01136 
<a name="l01137"></a><a class="code" href="class_verse_key.html#a27">01137</a> <font class="keywordtype">char</font> <a class="code" href="class_verse_key.html#a23">VerseKey::Book</a>(<font class="keywordtype">char</font> ibook)
01138 {
01139         <font class="keywordtype">char</font> retval = book;
01140 
01141         <a class="code" href="class_verse_key.html#a24">Chapter</a>(1);
01142         book = ibook;
01143         <a class="code" href="class_verse_key.html#a30">Normalize</a>(1);
01144 
01145         <font class="keywordflow">return</font> retval;
01146 }
01147 
01148 
01149 <font class="comment">/******************************************************************************</font>
01150 <font class="comment"> * VerseKey::Chapter - Sets/gets chapter</font>
01151 <font class="comment"> *</font>
01152 <font class="comment"> * ENT: ichapter - value which to set chapter</font>
01153 <font class="comment"> *              [MAXPOS(int)] - only get</font>
01154 <font class="comment"> *</font>
01155 <font class="comment"> * RET: if unchanged -&gt;          value of chapter</font>
01156 <font class="comment"> *      if   changed -&gt; previous value of chapter</font>
01157 <font class="comment"> */</font>
01158 
<a name="l01159"></a><a class="code" href="class_verse_key.html#a28">01159</a> <font class="keywordtype">int</font> <a class="code" href="class_verse_key.html#a24">VerseKey::Chapter</a>(<font class="keywordtype">int</font> ichapter)
01160 {
01161         <font class="keywordtype">int</font> retval = chapter;
01162 
01163         <a class="code" href="class_verse_key.html#a25">Verse</a>(1);
01164         chapter = ichapter;
01165         <a class="code" href="class_verse_key.html#a30">Normalize</a>(1);
01166 
01167         <font class="keywordflow">return</font> retval;
01168 }
01169 
01170 
01171 <font class="comment">/******************************************************************************</font>
01172 <font class="comment"> * VerseKey::Verse - Sets/gets verse</font>
01173 <font class="comment"> *</font>
01174 <font class="comment"> * ENT: iverse - value which to set verse</font>
01175 <font class="comment"> *              [MAXPOS(int)] - only get</font>
01176 <font class="comment"> *</font>
01177 <font class="comment"> * RET: if unchanged -&gt;          value of verse</font>
01178 <font class="comment"> *      if   changed -&gt; previous value of verse</font>
01179 <font class="comment"> */</font>
01180 
<a name="l01181"></a><a class="code" href="class_verse_key.html#a29">01181</a> <font class="keywordtype">int</font> <a class="code" href="class_verse_key.html#a25">VerseKey::Verse</a>(<font class="keywordtype">int</font> iverse)
01182 {
01183         <font class="keywordtype">int</font> retval = verse;
01184 
01185         verse = iverse;
01186         <a class="code" href="class_verse_key.html#a30">Normalize</a>(1);
01187 
01188         <font class="keywordflow">return</font> retval;
01189 }
01190 
01191 
01192 <font class="comment">/******************************************************************************</font>
01193 <font class="comment"> * VerseKey::AutoNormalize - Sets/gets flag that tells VerseKey to auto-</font>
01194 <font class="comment"> *                              matically normalize itself when modified</font>
01195 <font class="comment"> *</font>
01196 <font class="comment"> * ENT: iautonorm - value which to set autonorm</font>
01197 <font class="comment"> *              [MAXPOS(char)] - only get</font>
01198 <font class="comment"> *</font>
01199 <font class="comment"> * RET: if unchanged -&gt;          value of autonorm</font>
01200 <font class="comment"> *              if   changed -&gt; previous value of autonorm</font>
01201 <font class="comment"> */</font>
01202 
<a name="l01203"></a><a class="code" href="class_verse_key.html#a31">01203</a> <font class="keywordtype">char</font> <a class="code" href="class_verse_key.html#a31">VerseKey::AutoNormalize</a>(<font class="keywordtype">char</font> iautonorm)
01204 {
01205         <font class="keywordtype">char</font> retval = <a class="code" href="class_verse_key.html#o8">autonorm</a>;
01206 
01207         <font class="keywordflow">if</font> (iautonorm != MAXPOS(<font class="keywordtype">char</font>)) {
01208                 <a class="code" href="class_verse_key.html#o8">autonorm</a> = iautonorm;
01209                 <a class="code" href="class_verse_key.html#a30">Normalize</a>(1);
01210         }
01211         <font class="keywordflow">return</font> retval;
01212 }
01213 
01214 
01215 <font class="comment">/******************************************************************************</font>
01216 <font class="comment"> * VerseKey::Headings - Sets/gets flag that tells VerseKey to include</font>
01217 <font class="comment"> *                                      chap/book/testmnt/module headings</font>
01218 <font class="comment"> *</font>
01219 <font class="comment"> * ENT: iheadings - value which to set headings</font>
01220 <font class="comment"> *              [MAXPOS(char)] - only get</font>
01221 <font class="comment"> *</font>
01222 <font class="comment"> * RET: if unchanged -&gt;          value of headings</font>
01223 <font class="comment"> *              if   changed -&gt; previous value of headings</font>
01224 <font class="comment"> */</font>
01225 
<a name="l01226"></a><a class="code" href="class_verse_key.html#a32">01226</a> <font class="keywordtype">char</font> <a class="code" href="class_verse_key.html#a32">VerseKey::Headings</a>(<font class="keywordtype">char</font> iheadings)
01227 {
01228         <font class="keywordtype">char</font> retval = <a class="code" href="class_verse_key.html#o9">headings</a>;
01229 
01230         <font class="keywordflow">if</font> (iheadings != MAXPOS(<font class="keywordtype">char</font>)) {
01231                 <a class="code" href="class_verse_key.html#o9">headings</a> = iheadings;
01232                 <a class="code" href="class_verse_key.html#a30">Normalize</a>(1);
01233         }
01234         <font class="keywordflow">return</font> retval;
01235 }
01236 
01237 
01238 <font class="comment">/******************************************************************************</font>
01239 <font class="comment"> * VerseKey::findindex - binary search to find the index closest, but less</font>
01240 <font class="comment"> *                                              than the given value.</font>
01241 <font class="comment"> *</font>
01242 <font class="comment"> * ENT: array   - long * to array to search</font>
01243 <font class="comment"> *              size            - number of elements in the array</font>
01244 <font class="comment"> *              value   - value to find</font>
01245 <font class="comment"> *</font>
01246 <font class="comment"> * RET: the index into the array that is less than but closest to value</font>
01247 <font class="comment"> */</font>
01248 
<a name="l01249"></a><a class="code" href="class_verse_key.html#c6">01249</a> <font class="keywordtype">int</font> <a class="code" href="class_verse_key.html#c6">VerseKey::findindex</a>(<font class="keywordtype">long</font> *array, <font class="keywordtype">int</font> size, <font class="keywordtype">long</font> value)
01250 {
01251         <font class="keywordtype">int</font> lbound, ubound, tval;
01252 
01253         lbound = 0;
01254         ubound = size - 1;
01255         <font class="keywordflow">while</font> ((ubound - lbound) &gt; 1) {
01256                 tval = lbound + (ubound-lbound)/2;
01257                 <font class="keywordflow">if</font> (array[tval] &lt;= value)
01258                         lbound = tval;
01259                 <font class="keywordflow">else</font> ubound = tval;
01260         }
01261         <font class="keywordflow">return</font> (array[ubound] &lt;= value) ? ubound : lbound;
01262 }
01263 
01264 
01265 <font class="comment">/******************************************************************************</font>
01266 <font class="comment"> * VerseKey::Index - Gets index based upon current verse</font>
01267 <font class="comment"> *</font>
01268 <font class="comment"> * RET: offset</font>
01269 <font class="comment"> */</font>
01270 
<a name="l01271"></a><a class="code" href="class_verse_key.html#a34">01271</a> <font class="keywordtype">long</font> <a class="code" href="class_verse_key.html#a34">VerseKey::Index</a>()<font class="keyword"> const</font>
01272 <font class="keyword"></font>{
01273         <font class="keywordtype">long</font>  offset;
01274 
01275         <font class="keywordflow">if</font> (!<a class="code" href="class_verse_key.html#o4">testament</a>) { <font class="comment">// if we want module heading</font>
01276                 offset = 0;
01277                 verse  = 0;
01278         }
01279         <font class="keywordflow">else</font> {
01280                 <font class="keywordflow">if</font> (!book)
01281                         chapter = 0;
01282                 <font class="keywordflow">if</font> (!chapter)
01283                         verse   = 0;
01284 
01285                 offset = offsets[<a class="code" href="class_verse_key.html#o4">testament</a>-1][0][book];
01286                 offset = offsets[<a class="code" href="class_verse_key.html#o4">testament</a>-1][1][(int)offset + chapter];
01287                 <font class="keywordflow">if</font> (!(offset|verse)) <font class="comment">// if we have a testament but nothing else.</font>
01288                         offset = 1;
01289         }
01290         <font class="keywordflow">return</font> (offset + verse);
01291 }
01292 
01293 
01294 <font class="comment">/******************************************************************************</font>
01295 <font class="comment"> * VerseKey::Index - Gets index based upon current verse</font>
01296 <font class="comment"> *</font>
01297 <font class="comment"> * RET: offset</font>
01298 <font class="comment"> */</font>
01299 
01300 <font class="keywordtype">long</font> VerseKey::NewIndex()<font class="keyword"> const</font>
01301 <font class="keyword"></font>{
01302         <font class="keyword">static</font> <font class="keywordtype">long</font> otMaxIndex = 32300 - 8245;  <font class="comment">// total positions - new testament positions</font>
01303 <font class="comment">//      static long otMaxIndex = offsets[0][1][(int)offsets[0][0][BMAX[0]] + books[0][BMAX[0]].chapmax];</font>
01304         <font class="keywordflow">return</font> ((<a class="code" href="class_verse_key.html#o4">testament</a>-1) * otMaxIndex) + <a class="code" href="class_verse_key.html#a34">Index</a>();
01305 }
01306 
01307 
01308 <font class="comment">/******************************************************************************</font>
01309 <font class="comment"> * VerseKey::Index - Sets index based upon current verse</font>
01310 <font class="comment"> *</font>
01311 <font class="comment"> * ENT: iindex - value to set index to</font>
01312 <font class="comment"> *</font>
01313 <font class="comment"> * RET: offset</font>
01314 <font class="comment"> */</font>
01315 
<a name="l01316"></a><a class="code" href="class_verse_key.html#a35">01316</a> <font class="keywordtype">long</font> <a class="code" href="class_verse_key.html#a34">VerseKey::Index</a>(<font class="keywordtype">long</font> iindex)
01317 {
01318         <font class="keywordtype">long</font>  offset;
01319 
01320 <font class="comment">// This is the dirty stuff --------------------------------------------</font>
01321 
01322         <font class="keywordflow">if</font> (!<a class="code" href="class_verse_key.html#o4">testament</a>)
01323                 <a class="code" href="class_verse_key.html#o4">testament</a> = 1;
01324 
01325         <font class="keywordflow">if</font> (iindex &lt; 1) {                               <font class="comment">// if (-) or module heading</font>
01326                 <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#o4">testament</a> &lt; 2) {
01327                         <font class="keywordflow">if</font> (iindex &lt; 0) {
01328                                 <a class="code" href="class_verse_key.html#o4">testament</a> = 0;  <font class="comment">// previously we changed 0 -&gt; 1</font>
01329                                 error     = KEYERR_OUTOFBOUNDS;
01330                         }
01331                         <font class="keywordflow">else</font> <a class="code" href="class_verse_key.html#o4">testament</a> = 0;             <font class="comment">// we want module heading</font>
01332                 }
01333                 <font class="keywordflow">else</font> {
01334                         <a class="code" href="class_verse_key.html#o4">testament</a>--;
01335                         iindex = (offsets[<a class="code" href="class_verse_key.html#o4">testament</a>-1][1][offsize[<a class="code" href="class_verse_key.html#o4">testament</a>-1][1]-1] + books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][BMAX[<a class="code" href="class_verse_key.html#o4">testament</a>-1]-1].versemax[books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][BMAX[<a class="code" href="class_verse_key.html#o4">testament</a>-1]-1].chapmax-1]) + iindex; <font class="comment">// What a doozy! ((offset of last chapter + number of verses in the last chapter) + iindex)</font>
01336                 }
01337         }
01338 
01339 <font class="comment">// --------------------------------------------------------------------</font>
01340 
01341 
01342         <font class="keywordflow">if</font> (testament) {
01343                 <font class="keywordflow">if</font> ((!error) &amp;&amp; (iindex)) {
01344                         offset  = <a class="code" href="class_verse_key.html#c6">findindex</a>(offsets[<a class="code" href="class_verse_key.html#o4">testament</a>-1][1], offsize[<a class="code" href="class_verse_key.html#o4">testament</a>-1][1], iindex);
01345                         verse   = iindex - offsets[<a class="code" href="class_verse_key.html#o4">testament</a>-1][1][offset];
01346                         book    = <a class="code" href="class_verse_key.html#c6">findindex</a>(offsets[<a class="code" href="class_verse_key.html#o4">testament</a>-1][0], offsize[<a class="code" href="class_verse_key.html#o4">testament</a>-1][0], offset);
01347                         chapter = offset - offsets[<a class="code" href="class_verse_key.html#o4">testament</a>-1][0][VerseKey::book];
01348                         verse   = (chapter) ? verse : 0;  <font class="comment">// funny check. if we are index=1 (testmt header) all gets set to 0 exept verse.  Don't know why.  Fix if you figure out.  Think its in the offsets table.</font>
01349                         <font class="keywordflow">if</font> (verse) {            <font class="comment">// only check if -1 won't give negative</font>
01350                                 <font class="keywordflow">if</font> (verse &gt; books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].versemax[chapter-1]) {
01351                                         <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#o4">testament</a> &gt; 1) {
01352                                                 verse = books[<a class="code" href="class_verse_key.html#o4">testament</a>-1][book-1].versemax[chapter-1];
01353                                                 error = KEYERR_OUTOFBOUNDS;
01354                                         }
01355                                         <font class="keywordflow">else</font> {
01356                                                 <a class="code" href="class_verse_key.html#o4">testament</a>++;
01357                                                 <a class="code" href="class_verse_key.html#a34">Index</a>(verse - books[<a class="code" href="class_verse_key.html#o4">testament</a>-2][book-1].versemax[chapter-1]);
01358                                         }
01359                                 }
01360                         }
01361                 }
01362         }
01363         <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#a39">_compare</a>(<a class="code" href="class_verse_key.html#a8">UpperBound</a>()) &gt; 0) {
01364                 *<font class="keyword">this</font> = <a class="code" href="class_verse_key.html#a8">UpperBound</a>();
01365                 error = KEYERR_OUTOFBOUNDS;
01366         }
01367         <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#a39">_compare</a>(<a class="code" href="class_verse_key.html#a7">LowerBound</a>()) &lt; 0) {
01368                 *<font class="keyword">this</font> = <a class="code" href="class_verse_key.html#a7">LowerBound</a>();
01369                 error = KEYERR_OUTOFBOUNDS;
01370         }
01371         <font class="keywordflow">return</font> <a class="code" href="class_verse_key.html#a34">Index</a>();
01372 }
01373 
01374 
01375 <font class="comment">/******************************************************************************</font>
01376 <font class="comment"> * VerseKey::compare    - Compares another SWKey object</font>
01377 <font class="comment"> *</font>
01378 <font class="comment"> * ENT: ikey - key to compare with this one</font>
01379 <font class="comment"> *</font>
01380 <font class="comment"> * RET: &gt;0 if this versekey is greater than compare versekey</font>
01381 <font class="comment"> *      &lt;0 &lt;</font>
01382 <font class="comment"> *       0 =</font>
01383 <font class="comment"> */</font>
01384 
<a name="l01385"></a><a class="code" href="class_verse_key.html#a38">01385</a> <font class="keywordtype">int</font> <a class="code" href="class_verse_key.html#a38">VerseKey::compare</a>(<font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> &amp;ikey)
01386 {
01387         VerseKey ivkey = (<font class="keyword">const</font> <font class="keywordtype">char</font> *)ikey;
01388         <font class="keywordflow">return</font> <a class="code" href="class_verse_key.html#a39">_compare</a>(ivkey);
01389 }
01390 
01391 
01392 <font class="comment">/******************************************************************************</font>
01393 <font class="comment"> * VerseKey::_compare   - Compares another VerseKey object</font>
01394 <font class="comment"> *</font>
01395 <font class="comment"> * ENT: ikey - key to compare with this one</font>
01396 <font class="comment"> *</font>
01397 <font class="comment"> * RET: &gt;0 if this versekey is greater than compare versekey</font>
01398 <font class="comment"> *      &lt;0 &lt;</font>
01399 <font class="comment"> *       0 =</font>
01400 <font class="comment"> */</font>
01401 
<a name="l01402"></a><a class="code" href="class_verse_key.html#a39">01402</a> <font class="keywordtype">int</font> <a class="code" href="class_verse_key.html#a39">VerseKey::_compare</a>(<font class="keyword">const</font> VerseKey &amp;ivkey)
01403 {
01404         <font class="keywordtype">long</font> keyval1 = 0;
01405         <font class="keywordtype">long</font> keyval2 = 0;
01406 
01407         keyval1 += <a class="code" href="class_verse_key.html#a22">Testament</a>() * 1000000000;
01408         keyval2 += ivkey.<a class="code" href="class_verse_key.html#a22">Testament</a>() * 1000000000;
01409         keyval1 += <a class="code" href="class_verse_key.html#a23">Book</a>() * 1000000;
01410         keyval2 += ivkey.<a class="code" href="class_verse_key.html#a23">Book</a>() * 1000000;
01411         keyval1 += <a class="code" href="class_verse_key.html#a24">Chapter</a>() * 1000;
01412         keyval2 += ivkey.<a class="code" href="class_verse_key.html#a24">Chapter</a>() * 1000;
01413         keyval1 += <a class="code" href="class_verse_key.html#a25">Verse</a>();
01414         keyval2 += ivkey.<a class="code" href="class_verse_key.html#a25">Verse</a>();
01415         keyval1 -= keyval2;
01416         keyval1 = (keyval1) ? ((keyval1 &gt; 0) ? 1 : -1) <font class="comment">/*keyval1/labs(keyval1)*/</font>:0; <font class="comment">// -1 | 0 | 1</font>
01417         <font class="keywordflow">return</font> keyval1;
01418 }
01419 
01420 
01421 <font class="keyword">const</font> <font class="keywordtype">char</font> *VerseKey::getOSISRef()<font class="keyword"> const </font>{
01422         <font class="keyword">static</font> <font class="keywordtype">char</font> buf[5][254];
01423         <font class="keyword">static</font> <font class="keywordtype">char</font> loop = 0;
01424 
01425         <font class="keywordflow">if</font> (loop &gt; 4)
01426                 loop = 0;
01427 
01428         <font class="keyword">static</font> <font class="keywordtype">char</font> *osisotbooks[] = {
01429                         <font class="stringliteral">"Gen"</font>,<font class="stringliteral">"Exod"</font>,<font class="stringliteral">"Lev"</font>,<font class="stringliteral">"Num"</font>,<font class="stringliteral">"Deut"</font>,<font class="stringliteral">"Josh"</font>,<font class="stringliteral">"Judg"</font>,<font class="stringliteral">"Ruth"</font>,<font class="stringliteral">"_1Sam"</font>,<font class="stringliteral">"_2Sam"</font>,
01430                         <font class="stringliteral">"_1Kgs"</font>,<font class="stringliteral">"_2Kgs"</font>,<font class="stringliteral">"_1Chr"</font>,<font class="stringliteral">"_2Chr"</font>,<font class="stringliteral">"Ezra"</font>,<font class="stringliteral">"Neh"</font>,<font class="stringliteral">"Esth"</font>,<font class="stringliteral">"Job"</font>,<font class="stringliteral">"Ps"</font>,
01431                         <font class="stringliteral">"Prov"</font>,         <font class="comment">// added this.  Was not in OSIS spec</font>
01432                         <font class="stringliteral">"Eccl"</font>,
01433                         <font class="stringliteral">"Song"</font>,<font class="stringliteral">"Isa"</font>,<font class="stringliteral">"Jer"</font>,<font class="stringliteral">"Lam"</font>,<font class="stringliteral">"Ezek"</font>,<font class="stringliteral">"Dan"</font>,<font class="stringliteral">"Hos"</font>,<font class="stringliteral">"Joel"</font>,<font class="stringliteral">"Amos"</font>,<font class="stringliteral">"Obad"</font>,
01434                         <font class="stringliteral">"Jonah"</font>,<font class="stringliteral">"Mic"</font>,<font class="stringliteral">"Nah"</font>,<font class="stringliteral">"Hab"</font>,<font class="stringliteral">"Zeph"</font>,<font class="stringliteral">"Hag"</font>,<font class="stringliteral">"Zech"</font>,<font class="stringliteral">"Mal"</font>,<font class="stringliteral">"Bar"</font>,<font class="stringliteral">"PrAzar"</font>,
01435                         <font class="stringliteral">"Bel"</font>,<font class="stringliteral">"Sus"</font>,<font class="stringliteral">"_1Esd"</font>,<font class="stringliteral">"_2Esd"</font>,<font class="stringliteral">"AddEsth"</font>,<font class="stringliteral">"EpJer"</font>,<font class="stringliteral">"Jdt"</font>,<font class="stringliteral">"_1Macc"</font>,<font class="stringliteral">"_2Macc"</font>,<font class="stringliteral">"_3Macc"</font>,
01436                         <font class="stringliteral">"_4Macc"</font>,<font class="stringliteral">"PrMan"</font>,<font class="stringliteral">"Ps151"</font>,<font class="stringliteral">"Sir"</font>,<font class="stringliteral">"Tob"</font>,<font class="stringliteral">"Wis"</font>};
01437         <font class="keyword">static</font> <font class="keywordtype">char</font> *osisntbooks[] = {
01438                         <font class="stringliteral">"Matt"</font>,<font class="stringliteral">"Mark"</font>,<font class="stringliteral">"Luke"</font>,<font class="stringliteral">"John"</font>,<font class="stringliteral">"Acts"</font>,<font class="stringliteral">"Rom"</font>,<font class="stringliteral">"_1Cor"</font>,<font class="stringliteral">"_2Cor"</font>,<font class="stringliteral">"Gal"</font>,<font class="stringliteral">"Eph"</font>,
01439                         <font class="stringliteral">"Phil"</font>,<font class="stringliteral">"Col"</font>,<font class="stringliteral">"_1Thess"</font>,<font class="stringliteral">"_2Thess"</font>,<font class="stringliteral">"_1Tim"</font>,<font class="stringliteral">"_2Tim"</font>,<font class="stringliteral">"Titus"</font>,<font class="stringliteral">"Phlm"</font>,<font class="stringliteral">"Heb"</font>,<font class="stringliteral">"Jas"</font>,
01440                         <font class="stringliteral">"_1Pet"</font>,<font class="stringliteral">"_2Pet"</font>,<font class="stringliteral">"_1John"</font>,<font class="stringliteral">"_2John"</font>,<font class="stringliteral">"_3John"</font>,<font class="stringliteral">"Jude"</font>,<font class="stringliteral">"Rev"</font>};
01441         <font class="keyword">static</font> <font class="keywordtype">char</font> **osisbooks[] = { osisotbooks, osisntbooks };
01442         <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#a25">Verse</a>())
01443                 sprintf(buf[loop], <font class="stringliteral">"%s.%d.%d"</font>, osisbooks[<a class="code" href="class_verse_key.html#a22">Testament</a>()-1][<a class="code" href="class_verse_key.html#a23">Book</a>()-1], (<font class="keywordtype">int</font>)<a class="code" href="class_verse_key.html#a24">Chapter</a>(), (<font class="keywordtype">int</font>)<a class="code" href="class_verse_key.html#a25">Verse</a>());
01444         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#a24">Chapter</a>())
01445                 sprintf(buf[loop], <font class="stringliteral">"%s.%d"</font>, osisbooks[<a class="code" href="class_verse_key.html#a22">Testament</a>()-1][<a class="code" href="class_verse_key.html#a23">Book</a>()-1], (<font class="keywordtype">int</font>)<a class="code" href="class_verse_key.html#a24">Chapter</a>());
01446         <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="class_verse_key.html#a23">Book</a>())
01447                 sprintf(buf[loop], <font class="stringliteral">"%s"</font>, osisbooks[<a class="code" href="class_verse_key.html#a22">Testament</a>()-1][<a class="code" href="class_verse_key.html#a23">Book</a>()-1]);
01448         <font class="keywordflow">else</font>    sprintf(buf[loop], <font class="stringliteral">""</font>);
01449         <font class="keywordflow">return</font> buf[loop++];
01450 }
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:01 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>