OOFILE  1.9
oof4.cpp
Go to the documentation of this file.
1 // COPYRIGHT 1994-1997 A.D. Software, All rights reserved
2 
3 // OOFILE database field-related classes
4 // numeric fields - see also oof3.cpp & oof5.cpp
5 
6 #include "oofpch_c.h" // for precompilation of core files
7 
8 #include <ctype.h>
9 
10 #ifdef OOF_MEM_DEBUG_LAST_INCLUDE
11  #include OOF_MEM_DEBUG_LAST_INCLUDE
12 #endif
13 
14 #ifndef OOF_NO_STDLIB
15  #ifndef std
16  using namespace std;
17  #endif
18 #endif
19 
20 
21 // -------------------------------------------------------
22 // d b N u m e r i c F i e l d
23 // -------------------------------------------------------
25  dbField(indexOptions)
26 {}
27 
28 
29 dbNumericField::dbNumericField(const char* fieldName) :
30  dbField(fieldName)
31 {}
32 
33 
34 dbNumericField::dbNumericField(const char* fieldName, const OOF_IndexOptions indexOptions) :
35  dbField(fieldName, indexOptions)
36 {}
37 
38 
39 
40 void
42 {
43  setNumber(0);
44 }
45 
46 
48 dbNumericField::between(long fromNum, long toNum) const
49 {
51  makeQueryLiteral(fromNum), makeQueryLiteral(toNum));
52 }
53 
54 
56 dbNumericField::outside(long fromNum, long toNum) const
57 {
59  makeQueryLiteral(fromNum), makeQueryLiteral(toNum));
60 }
61 
62 
65 {
67 }
68 
69 
72 {
74 }
75 
76 
79 {
81 }
82 
83 
86 {
88 }
89 
90 
93 {
95 }
96 
97 
100 {
102 }
103 
104 
105 #if defined(_MSC_VER) || defined(__MWERKS__)
107 dbNumericField::operator==(short n) const
108 {
110 }
111 
112 
114 dbNumericField::operator!=(short n) const
115 {
117 }
118 
119 
121 dbNumericField::operator<(short n) const
122 {
124 }
125 
126 
128 dbNumericField::operator<=(short n) const
129 {
131 }
132 
133 
135 dbNumericField::operator>(short n) const
136 {
138 }
139 
140 
142 dbNumericField::operator>=(short n) const
143 {
145 }
146 
147 
149 dbNumericField::operator==(int n) const
150 {
152 }
153 
154 
156 dbNumericField::operator!=(int n) const
157 {
159 }
160 
161 
163 dbNumericField::operator<(int n) const
164 {
166 }
167 
168 
170 dbNumericField::operator<=(int n) const
171 {
173 }
174 
175 
177 dbNumericField::operator>(int n) const
178 {
180 }
181 
182 
184 dbNumericField::operator>=(int n) const
185 {
187 }
188 
189 
191 dbNumericField::operator==(unsigned long n) const
192 {
194 }
195 
196 
198 dbNumericField::operator!=(unsigned long n) const
199 {
201 }
202 
203 
205 dbNumericField::operator<(unsigned long n) const
206 {
208 }
209 
210 
212 dbNumericField::operator<=(unsigned long n) const
213 {
215 }
216 
217 
219 dbNumericField::operator>(unsigned long n) const
220 {
222 }
223 
224 
226 dbNumericField::operator>=(unsigned long n) const
227 {
229 }
230 
231 
233 dbNumericField::operator==(unsigned short n) const
234 {
236 }
237 
238 
240 dbNumericField::operator!=(unsigned short n) const
241 {
243 }
244 
245 
247 dbNumericField::operator<(unsigned short n) const
248 {
250 }
251 
252 
254 dbNumericField::operator<=(unsigned short n) const
255 {
257 }
258 
259 
261 dbNumericField::operator>(unsigned short n) const
262 {
264 }
265 
266 
268 dbNumericField::operator>=(unsigned short n) const
269 {
271 }
272 
273 
275 dbNumericField::operator==(unsigned int n) const
276 {
278 }
279 
280 
282 dbNumericField::operator!=(unsigned int n) const
283 {
285 }
286 
287 
289 dbNumericField::operator<(unsigned int n) const
290 {
292 }
293 
294 
296 dbNumericField::operator<=(unsigned int n) const
297 {
299 }
300 
301 
303 dbNumericField::operator>(unsigned int n) const
304 {
306 }
307 
308 
310 dbNumericField::operator>=(unsigned int n) const
311 {
313 }
314 
315 
316 #endif // #if defined(_MSC_VER) || defined(__MWERKS__)
317 
318 
321 {
323 }
324 
325 
328 {
330 }
331 
332 
335 {
337 }
338 
339 
342 {
344 }
345 
346 
349 {
351 }
352 
353 
356 {
358 }
359 
360 
361 void
363 
364 {
365 // NOT YET IMPLEMENTED
366 }
367 
368 
369 
370 void
372 
373 {
374 // NOT YET IMPLEMENTED
375 }
376 
377 
378 
379 void
381 
382 {
383 // NOT YET IMPLEMENTED
384 }
385 
386 
387 
388 void
390 
391 {
392 // NOT YET IMPLEMENTED
393 ;
394 }
395 
396 
397 void
399 
400 {
401 // NOT YET IMPLEMENTED
402 }
403 
404 
405 
406 void
408 
409 {
410 // NOT YET IMPLEMENTED
411 }
412 
413 
414 
415 void
417 
418 {
419 // NOT YET IMPLEMENTED
420 }
421 
422 
423 
424 void
426 
427 {
428 // NOT YET IMPLEMENTED
429 ;
430 }
431 
432 
433 
434 void
435 dbNumericField::CheckRange(double d, long minL, long maxL, const char* file, int line)
436 {
437  if (d<minL) {
438  oofE_RangeError excp(stringstream() << flush << file << "line: " << line
439  << "Range conversion error: double " << d
440  << " below min of " << minL << endl);
441  RAISE_EXCEPTION(excp);
442  }
443  else
444  if (d>maxL) {
445  oofE_RangeError excp(stringstream() << flush << file << "line: " << line
446  << "Range conversion error: double " << d
447  << " above max of " << maxL << endl);
448  RAISE_EXCEPTION(excp);
449  }
450 }
451 
452 
453 
454 void
455 dbNumericField::CheckRange(long l, long minL, long maxL, const char* file, int line)
456 {
457  if (l<minL) {
458  oofE_RangeError excp(stringstream() << flush << file << "line: " << line
459  << "Range conversion error: long " << l
460  << " below min of " << minL << endl);
461  RAISE_EXCEPTION(excp);
462  }
463  else
464  if (l>maxL) {
465  oofE_RangeError excp(stringstream() << flush << file << "line: " << line
466  << "Range conversion error: long " << l
467  << " above max of " << maxL << endl);
468  RAISE_EXCEPTION(excp);
469  }
470 }
471 
472 
473 void
474 dbNumericField::CheckRange(unsigned long l, unsigned long maxL, const char* file, int line)
475 {
476  if (l>maxL) {
477  oofE_RangeError excp(stringstream() << flush << file << "line: " << line
478  << "Range conversion error: ulong " << l
479  << " above max of " << maxL << endl);
480  RAISE_EXCEPTION(excp);
481  }
482 }
483 
484 
487 {
488  return new dbQueryLiteralLong(n);
489 }
490 
491 
492 unsigned long
494 {
495  unsigned long ret = mFormatMask.length();
496  if (ret==0)
497  ret = fieldStorageLen()*2+2; // just an arbitrary number that will make most dates & longs etc. fit
498 
499  return ret;
500 }
501 // -------------------------------------------------------
502 // d b S h o r t
503 // -------------------------------------------------------
504 dbShort::dbShort(const OOF_IndexOptions indexOptions) :
505  dbNumericField(indexOptions)
506 {}
507 
508 
509 dbShort::dbShort(const char* fieldName) :
510  dbNumericField(fieldName)
511 {}
512 
513 
514 dbShort::dbShort(const char* fieldName, const OOF_IndexOptions indexOptions) :
515  dbNumericField(fieldName, indexOptions)
516 {}
517 
518 
520  dbNumericField(k)
521 {}
522 
523 
525 {
526 }
527 
528 
529 dbField*
531 {
532  return new dbShort(*this);
533 }
534 
535 
536 dbShort&
537 dbShort::calculateWith(dbShortCalculator* adoptedCalculator, bool useOnlyForDefaults)
538 {
539  CalculateWith(adoptedCalculator, useOnlyForDefaults);
540  return *this;
541 }
542 
543 
544 void
546 {
547  assert(mCalculator);
548  *this = calculator()->calc(this);
549 }
550 
551 dbShort&
553 {
554  if (this == &rhs)
555  return *this;
556 
557  *this = (short)rhs;
558  return *this;
559 }
560 
561 
562 void
564 {
565  *this = n;
566 }
567 
568 
569 void
570 dbShort::setString(const char* str)
571 {
572  short n;
573  istringstream is((char*)str); // cast away const for Borland
574  is >> n;
575  *this = n;
576 }
577 
578 
579 dbShort::operator short() const
580 {
581  short ret;
582  if (usingCalculator())
583  ret = calculator()->calc(this);
584  else {
585  if (fieldIsStandalone()) {
586  ret = (long) mBackend;
587  }
588  else {
589  assert(mBackend);
590  ret = mBackend->readShort(this);
591  }
592  }
593  return ret;
594 }
595 
596 
597 dbShort::dbShort(const dbShort& rhs) :
598  dbNumericField(rhs)
599 {
600 }
601 
602 
603 dbShort&
605 {
606  if (fieldIsStandalone())
607  mBackend = (OOF_tableBackend*) n;
608  else {
609  assert(mBackend);
610  mBackend->writeShort(n, this);
611  }
612  return *this;
613 }
614 
615 
616 void
618 {
619  if (srcField->fieldType()==shortField)
620  *this = *(dbShort*)srcField; // safe downcast
621 #ifdef OOF_DEBUG
622  else
623  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbShort::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
624 #endif
625 }
626 
627 
628 void
630 {
631  if (srcField->fieldType()==shortField) {
632  const long rhs = *(dbShort*)srcField; // safe downcast
633  if (value() != rhs)
634  *this = rhs;
635  }
636 #ifdef OOF_DEBUG
637  else
638  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbShort::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
639 #endif
640 }
641 
642 
645 {
646  return shortField;
647 }
648 
649 
650 unsigned long
652 {
653  return sizeof(short);
654 }
655 
656 
657 void
658 dbShort::extract(ostream& os) const
659 {
660  os << (short) *this;
661 }
662 
663 
664 bool
665 dbShort::insert(istream& is, char fieldSep, char recSep)
666 {
667  // is the stream good?
668  if (!is.good())
669  return false;
670  // read in the short
671  short n=0;
672  if (skipTillNumber(is, fieldSep, recSep))
673  is >> n;
674  // read in a potential field/record separator
675  const char c = is.peek();
676  bool hitEndOfField = false;
677  if ((c==fieldSep) || (c==recSep))
678  hitEndOfField = true;
679  if (hitEndOfField)
680  *this = n;
681  return hitEndOfField;
682 }
683 
684 
685 void
686 dbShort::generateTestData(bool generateRandom, unsigned long seedOrCount)
687 {
688  if (generateRandom)
689  *this = (short)(rand()-rand()/2);
690  else
691  *this = (short)seedOrCount;
692 }
693 
694 
697 {
698  return new dbQueryLiteralShort((short)n);
699 }
700 
701 
704 {
706  return ret;
707 }
708 
709 
710 // -------------------------------------------------------
711 // d b U s h o r t
712 // -------------------------------------------------------
713 
715  dbNumericField(indexOptions)
716 {}
717 
718 
719 dbUshort::dbUshort(const char* fieldName) :
720  dbNumericField(fieldName)
721 {}
722 
723 
724 dbUshort::dbUshort(const char* fieldName, const OOF_IndexOptions indexOptions) :
725  dbNumericField(fieldName, indexOptions)
726 {}
727 
728 
729 
731  dbNumericField(k)
732 {}
733 
734 
736 {
737 }
738 
739 
740 dbField*
742 {
743  return new dbUshort(*this);
744 }
745 
746 
747 dbUshort&
748 dbUshort::calculateWith(dbUshortCalculator* adoptedCalculator, bool useOnlyForDefaults)
749 {
750  CalculateWith(adoptedCalculator, useOnlyForDefaults);
751  return *this;
752 }
753 
754 
755 void
757 {
758  assert(mCalculator);
759  *this = calculator()->calc(this);
760 }
761 
762 
763 dbUshort&
765 {
766  if (this == &rhs)
767  return *this;
768 
769  *this = (unsigned short)rhs;
770  return *this;
771 }
772 
773 
774 void
776 {
777  *this = n;
778 }
779 
780 
781 void
782 dbUshort::setString(const char* str)
783 {
784  unsigned short n;
785  istringstream is((char*)str); // cast away const for Borland
786  is >> n;
787  *this = n;
788 }
789 
790 
791 dbUshort::operator unsigned short() const
792 {
793  unsigned short ret;
794  if (usingCalculator())
795  ret = calculator()->calc(this);
796  else {
797  if (fieldIsStandalone()) {
798  ret = (unsigned long) mBackend;
799  }
800  else {
801  assert(mBackend);
802  ret = mBackend->readShort(this);
803  }
804  }
805  return ret;
806 }
807 
808 
810  dbNumericField(rhs)
811 {
812 }
813 
814 
815 dbUshort&
816 dbUshort::operator=(unsigned short n)
817 {
818  if (fieldIsStandalone())
819  mBackend = (OOF_tableBackend*) n;
820  else {
821  assert(mBackend);
822  mBackend->writeShort(n, this);
823  }
824  return *this;
825 }
826 
827 
828 void
830 {
831  if (srcField->fieldType()==uShortField)
832  *this = *(dbUshort*)srcField; // safe downcast
833 #ifdef OOF_DEBUG
834  else
835  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbUshort::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
836 #endif
837 }
838 
839 
840 void
842 {
843  if (srcField->fieldType()==uShortField) {
844  const long rhs = *(dbUshort*)srcField; // safe downcast
845  if (value() != rhs)
846  *this = rhs;
847  }
848 #ifdef OOF_DEBUG
849  else
850  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbUshort::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
851 #endif
852 }
853 
854 
857 {
858  return uShortField;
859 }
860 
861 
862 unsigned long
864 {
865  return sizeof(unsigned short);
866 }
867 
868 
869 void
870 dbUshort::extract(ostream& os) const
871 {
872  os << (unsigned short)*this;
873 }
874 
875 
876 bool
877 dbUshort::insert(istream& is, char fieldSep, char recSep)
878 {
879  // is the stream good?
880  if (!is.good())
881  return false;
882  // read in the unsigned short
883  unsigned short n=0;
884  if (skipTillDigit(is, fieldSep, recSep))
885  is >> n;
886  // read in a potential field/record separator
887  const char c = is.peek();
888  bool hitEndOfField = false;
889  if ((c==fieldSep) || (c==recSep))
890  hitEndOfField = true;
891  if (hitEndOfField)
892  *this = n;
893  return hitEndOfField;
894 }
895 
896 
897 
898 void
899 dbUshort::generateTestData(bool generateRandom, unsigned long seedOrCount)
900 {
901  if (generateRandom)
902  *this = (unsigned short)(rand());
903  else
904  *this = (const unsigned short)seedOrCount;
905 }
906 
907 
910 {
911  return new dbQueryLiteralUshort((unsigned short)n);
912 }
913 
914 
916 dbUshort::operator==(unsigned short n) const
917 {
919 }
920 
921 
924 {
926  return ret;
927 }
928 
929 
930 // -------------------------------------------------------
931 // d b B o o l
932 // -------------------------------------------------------
933 
934 dbBool::dbBool(const OOF_IndexOptions indexOptions) :
935  dbNumericField(indexOptions)
936 {}
937 
938 
939 dbBool::dbBool(const char* fieldName) :
940  dbNumericField(fieldName)
941 {}
942 
943 
944 dbBool::dbBool(const char* fieldName, const OOF_IndexOptions indexOptions) :
945  dbNumericField(fieldName, indexOptions)
946 {}
947 
948 
949 
951  dbNumericField(k)
952 {}
953 
954 
956 {
957 }
958 
959 
960 dbField*
962 {
963  return new dbBool(*this);
964 }
965 
966 
967 dbBool&
968 dbBool::calculateWith(dbBoolCalculator* adoptedCalculator, bool useOnlyForDefaults)
969 {
970  CalculateWith(adoptedCalculator, useOnlyForDefaults);
971  return *this;
972 }
973 
974 
975 void
977 {
978  assert(mCalculator);
979  *this = calculator()->calc(this);
980 }
981 
982 
983 dbBool&
985 {
986  if (this == &rhs)
987  return *this;
988 
989  *this = (bool)rhs;
990  return *this;
991 }
992 
993 
994 void
996 {
997  bool b = (n!=0);
998  *this = b;
999 }
1000 
1001 
1002 void
1003 dbBool::setString(const char* str)
1004 {
1005  bool b = str2bool(str);
1006  *this = b;
1007 }
1008 
1009 
1010 dbBool::operator bool() const
1011 {
1012  bool ret;
1013  if (usingCalculator())
1014  ret = calculator()->calc(this);
1015  else {
1016  if (fieldIsStandalone()) {
1017  ret = ((unsigned long) mBackend!=0);
1018  }
1019  else {
1020  assert(mBackend);
1021  ret = mBackend->readBool(this);
1022  }
1023  }
1024  return ret;
1025 }
1026 
1027 
1028 dbBool::dbBool(const dbBool& rhs) :
1029  dbNumericField(rhs)
1030 {
1031 }
1032 
1033 
1034 dbBool&
1036 {
1037  if (fieldIsStandalone()) {
1038  long forConversion = n;
1039  mBackend = (OOF_tableBackend*) forConversion;
1040  }
1041  else {
1042  assert(mBackend);
1043  mBackend->writeBool(n, this);
1044  }
1045  return *this;
1046 }
1047 
1048 
1049 void
1051 {
1052  if (srcField->fieldType()==boolField)
1053  *this = *(dbBool*)srcField; // safe downcast
1054 #ifdef OOF_DEBUG
1055  else
1056  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbBool::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
1057 #endif
1058 }
1059 
1060 
1061 void
1063 {
1064  if (srcField->fieldType()==boolField) {
1065  bool rhs = *(dbBool*)srcField; // safe downcast
1066  if (value() != rhs)
1067  *this = rhs;
1068  }
1069 #ifdef OOF_DEBUG
1070  else
1071  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbBool::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
1072 #endif
1073 }
1074 
1075 
1078 {
1079  return boolField;
1080 }
1081 
1082 
1085 {
1086  return uShortField;
1087 }
1088 
1089 
1090 unsigned long
1092 {
1093  return sizeof(unsigned short);
1094 }
1095 
1096 
1097 void
1098 dbBool::extract(ostream& os) const
1099 {
1100  os << bool2char((bool)*this);
1101 }
1102 
1103 
1104 bool
1105 dbBool::insert(istream& is, char fieldSep, char recSep)
1106 {
1107  // is the stream good?
1108  if (!is.good())
1109  return false;
1110  // read in the char
1111  char c;
1112  c = is.peek();
1113  if ((c==fieldSep) || (c==recSep))
1114  return true; // early exit, blank field defaults to false
1115 
1116  is >> c;
1117  *this = c;
1118 
1119  bool hitEndOfField = skipRestOfField(is, fieldSep, recSep);
1120  return hitEndOfField;
1121 }
1122 
1123 
1124 
1125 void
1126 dbBool::generateTestData(bool generateRandom, unsigned long seedOrCount)
1127 {
1128  bool b;
1129  if (generateRandom)
1130  b = ((rand()%1)!=0);
1131  else
1132  if ((seedOrCount/2)*2==seedOrCount) // even
1133  b = true;
1134  else
1135  b = false;
1136  *this = b;
1137 }
1138 
1139 
1142 {
1143  unsigned short n = 0;
1144  if (b!=0)
1145  n = 1;
1146  return new dbQueryLiteralUshort(n);
1147 }
1148 
1149 
1152 {
1153  if (n!=0)
1154  n = 1;
1155  return new dbQueryLiteralUshort(n);
1156 }
1157 
1158 
1159 
1160 
1161 dbBool::operator dbQueryBinary() const
1162 {
1163  const bool b = true;
1164  return dbQueryBinary(new dbQueryField(this), dbQueryClause::equals, makeQueryLiteral(b));
1165 }
1166 
1167 
1168 dbQueryClause*
1170 {
1172  return ret;
1173 }
1174 
1175 
1177 dbBool::operator==(bool b) const
1178 {
1180 }
1181 
1182 #ifdef OOF_HAS_BOOL
1183 #else
1184 // causes ambiguity in CodeWarrior 10
1186 dbBool::operator==(char c) const
1187 {
1188  const bool b = char2bool(c);
1190 }
1191 
1192 
1193 dbBool&
1194 dbBool::operator=(char c)
1195 {
1196  const bool b = char2bool(c);
1197  *this = b;
1198  return *this;
1199 }
1200 #endif // OOF_HAS_BOOL
1201 
1203 dbBool::operator==(const char* str) const
1204 {
1205  const bool b = str2bool(str);
1207 }
1208 
1209 
1210 char
1212 {
1213  if (b)
1214  return 'T';
1215  else
1216  return 'F';
1217 }
1218 
1219 
1220 bool
1222 {
1223  const char uc = toupper(c);
1224  if ((uc=='T') || (uc=='Y') || (uc=='1')) // check 1 in case get char const instead of number
1225  return true;
1226  else
1227  return false;
1228 }
1229 
1230 
1231 bool
1232 dbBool::str2bool(const char* str)
1233 {
1234 // crude implementation for now!
1235  if (strlen(str))
1236  return char2bool(str[0]);
1237  else
1238  return false;
1239 }
1240 
1241 
1242 // -------------------------------------------------------
1243 // d b L o n g
1244 // -------------------------------------------------------
1245 
1246 dbLong::dbLong(const OOF_IndexOptions indexOptions) :
1247  dbNumericField(indexOptions)
1248 {}
1249 
1250 
1251 dbLong::dbLong(const char* fieldName) :
1252  dbNumericField(fieldName)
1253 {}
1254 
1255 
1256 dbLong::dbLong(const char* fieldName, const OOF_IndexOptions indexOptions) :
1257  dbNumericField(fieldName, indexOptions)
1258 {}
1259 
1260 
1262  dbNumericField(k)
1263 {}
1264 
1265 
1267 {
1268 }
1269 
1270 
1271 dbField*
1273 {
1274  return new dbLong(*this);
1275 }
1276 
1277 
1278 dbLong&
1279 dbLong::calculateWith(dbLongCalculator* adoptedCalculator, bool useOnlyForDefaults)
1280 {
1281  CalculateWith(adoptedCalculator, useOnlyForDefaults);
1282  return *this;
1283 }
1284 
1285 
1286 void
1288 {
1289  assert(mCalculator);
1290  *this = calculator()->calc(this);
1291 }
1292 
1293 
1294 dbLong&
1296 {
1297  if (this == &rhs)
1298  return *this;
1299 
1300  *this = (long)rhs;
1301  return *this;
1302 }
1303 
1304 
1305 dbLong::dbLong(const dbLong& rhs) :
1306  dbNumericField(rhs)
1307 {
1308 }
1309 
1310 
1311 dbLong&
1313 {
1314  if (fieldIsStandalone())
1315  mBackend = (OOF_tableBackend*) n;
1316  else {
1317  assert(mBackend);
1318  mBackend->writeLong(n, this);
1319  }
1320  return *this;
1321 }
1322 
1323 
1324 void
1326 {
1327  *this = n;
1328 }
1329 
1330 
1331 
1332 void
1333 dbLong::setString(const char* str)
1334 {
1335  long n;
1336  istringstream is((char*)str); // cast away const for Borland
1337  is >> n;
1338  *this = n;
1339 }
1340 
1341 
1342 dbLong::operator long() const
1343 {
1344  long ret;
1345  if (usingCalculator())
1346  ret = calculator()->calc(this);
1347  else {
1348  if (fieldIsStandalone())
1349  ret = (long) mBackend;
1350  else {
1351  assert(mBackend);
1352  ret = mBackend->readLong(this);
1353  }
1354  }
1355  return ret;
1356 }
1357 
1358 
1359 void
1361 {
1362  if (srcField->fieldType()==longField)
1363  *this = *(dbLong*)srcField; // safe downcast
1364 #ifdef OOF_DEBUG
1365  else
1366  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbLong::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
1367 #endif
1368 }
1369 
1370 
1371 void
1373 {
1374  if (srcField->fieldType()==longField) {
1375  long rhs = *(dbLong*)srcField; // safe downcast
1376  if (value() != rhs)
1377  *this = rhs;
1378  }
1379 #ifdef OOF_DEBUG
1380  else
1381  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbLong::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
1382 #endif
1383 }
1384 
1385 
1388 {
1389  return longField;
1390 }
1391 
1392 
1393 unsigned long
1395 {
1396  return sizeof(long);
1397 }
1398 
1399 
1400 void
1401 dbLong::extract(ostream& os) const
1402 {
1403  os << (long) *this;
1404 }
1405 
1406 
1407 bool
1408 dbLong::insert(istream& is, char fieldSep, char recSep)
1409 {
1410  // is the stream good?
1411  if (!is.good())
1412  return false;
1413  // read in the long
1414  long n=0;
1415  if (skipTillNumber(is, fieldSep, recSep))
1416  is >> n;
1417  // read in a potential field/record separator
1418  const char c = is.peek();
1419  bool hitEndOfField = false;
1420  if ((c==fieldSep) || (c==recSep))
1421  hitEndOfField = true;
1422  if (hitEndOfField)
1423  *this = n;
1424  return hitEndOfField;
1425 }
1426 
1427 dbQueryClause*
1429 {
1431  return ret;
1432 }
1433 
1434 
1435 void
1436 dbLong::generateTestData(bool generateRandom, unsigned long seedOrCount)
1437 {
1438  if (generateRandom)
1439  *this = (long)(rand()-rand());
1440  else
1441  *this = (long)seedOrCount;
1442 }
1443 
1444 
1445 // -------------------------------------------------------
1446 // d b U l o n g
1447 // -------------------------------------------------------
1448 
1449 dbUlong::dbUlong(const OOF_IndexOptions indexOptions) :
1450  dbNumericField(indexOptions)
1451 {}
1452 
1453 
1454 dbUlong::dbUlong(const char* fieldName) :
1455  dbNumericField(fieldName)
1456 {}
1457 
1458 
1459 dbUlong::dbUlong(const char* fieldName, const OOF_IndexOptions indexOptions) :
1460  dbNumericField(fieldName, indexOptions)
1461 {}
1462 
1463 
1465  dbNumericField(k)
1466 {}
1467 
1468 
1470 {
1471 }
1472 
1473 
1474 dbField*
1476 {
1477  return new dbUlong(*this);
1478 }
1479 
1480 
1482  dbNumericField(rhs)
1483 {
1484 }
1485 
1486 
1487 dbUlong&
1488 dbUlong::calculateWith(dbUlongCalculator* adoptedCalculator, bool useOnlyForDefaults)
1489 {
1490  CalculateWith(adoptedCalculator, useOnlyForDefaults);
1491  return *this;
1492 }
1493 
1494 
1495 void
1497 {
1498  assert(mCalculator);
1499  *this = calculator()->calc(this);
1500 }
1501 
1502 
1503 dbUlong&
1505 {
1506  if (this == &rhs)
1507  return *this;
1508 
1509  *this = (unsigned long)rhs;
1510  return *this;
1511 }
1512 
1513 
1514 dbUlong&
1515 dbUlong::operator=(unsigned long n)
1516 {
1517  if (fieldIsStandalone())
1518  mBackend = (OOF_tableBackend*) n;
1519  else {
1520  assert(mBackend);
1521  mBackend->writeLong(n, this);
1522  }
1523  return *this;
1524 }
1525 
1526 
1527 void
1529 {
1530  *this = (unsigned long) n;
1531 }
1532 
1533 
1534 void
1535 dbUlong::setString(const char* str)
1536 {
1537  unsigned long n;
1538  istringstream is((char*)str); // cast away const for Borland
1539  is >> n;
1540  *this = n;
1541 }
1542 
1543 
1544 dbUlong::operator unsigned long() const
1545 {
1546  unsigned long ret;
1547  if (usingCalculator())
1548  ret = calculator()->calc(this);
1549  else {
1550  if (fieldIsStandalone())
1551  return (unsigned long) mBackend;
1552  else {
1553  assert(mBackend);
1554  ret = mBackend->readLong(this);
1555  }
1556  }
1557  return ret;
1558 }
1559 
1560 
1561 void
1563 {
1564  if (srcField->fieldType()==uLongField)
1565  *this = *(dbUlong*)srcField; // safe downcast
1566 #ifdef OOF_DEBUG
1567  else
1568  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbUlong::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
1569 #endif
1570 }
1571 
1572 
1573 void
1575 {
1576  if (srcField->fieldType()==uLongField) {
1577  const unsigned long rhs = *(dbUlong*)srcField; // safe downcast
1578  if (value() != rhs)
1579  *this = rhs;
1580  }
1581 #ifdef OOF_DEBUG
1582  else
1583  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbUlong::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
1584 #endif
1585 }
1586 
1587 
1590 {
1591  return uLongField;
1592 }
1593 
1594 
1595 unsigned long
1597 {
1598  return sizeof(unsigned long);
1599 }
1600 
1601 
1602 void
1603 dbUlong::extract(ostream& os) const
1604 {
1605  os << (unsigned long)*this;
1606 }
1607 
1608 
1609 bool
1610 dbUlong::insert(istream& is, char fieldSep, char recSep)
1611 {
1612  // is the stream good?
1613  if (!is.good())
1614  return false;
1615  // read in the unsigned long
1616  unsigned long n=0;
1617  if (skipTillDigit(is, fieldSep, recSep))
1618  is >> n;
1619  // read in a potential field/record separator
1620  const char c = is.peek();
1621  bool hitEndOfField = false;
1622  if ((c==fieldSep) || (c==recSep))
1623  hitEndOfField = true;
1624  if (hitEndOfField)
1625  *this = n;
1626  return hitEndOfField;
1627 }
1628 
1629 
1630 void
1631 dbUlong::generateTestData(bool generateRandom, unsigned long seedOrCount)
1632 {
1633  if (generateRandom)
1634  *this = (unsigned long)(rand());
1635  else
1636  *this = seedOrCount;
1637 }
1638 
1639 
1641 dbUlong::makeQueryLiteral(unsigned long n) const
1642 {
1643  return new dbQueryLiteralUlong(n);
1644 }
1645 
1646 
1649 {
1650  return new dbQueryLiteralUlong((unsigned long) n);
1651 }
1652 
1653 
1654 dbQueryClause*
1656 {
1658  return ret;
1659 }
1660 
1661 
1663 dbUlong::operator==(unsigned long n) const
1664 {
1666 }
1667 
1668 
1669 
1670 // -------------------------------------------------------
1671 // d b R e a l
1672 // -------------------------------------------------------
1673 
1675  dbNumericField(k)
1676 {
1677  CompleteInit();
1678 }
1679 
1680 
1681 dbReal::dbReal(const OOF_IndexOptions indexOptions) :
1682  dbNumericField(indexOptions)
1683 {
1684  CompleteInit();
1685 }
1686 
1687 
1688 dbReal::dbReal(const char* fieldName) :
1689  dbNumericField(fieldName)
1690 {
1691  CompleteInit();
1692 }
1693 
1694 
1695 dbReal::dbReal(const char* fieldName, const OOF_IndexOptions indexOptions) :
1696  dbNumericField(fieldName, indexOptions)
1697 {
1698  CompleteInit();
1699 }
1700 
1701 
1702 dbReal::dbReal(const dbReal& rhs) :
1703  dbNumericField(rhs)
1704 {
1705  CompleteInit();
1706  if (fieldIsStandalone())
1707  *((double*) mBackend) = *((double*) rhs.mBackend) ;
1708 }
1709 
1710 
1711 void
1713 {
1714  if (fieldIsStandalone())
1715  mBackend = (OOF_tableBackend*) (new double);
1716 }
1717 
1718 
1720 {
1721  if (fieldIsStandalone())
1722  delete (double*) mBackend;
1723 }
1724 
1725 
1726 dbField*
1728 {
1729  return new dbReal(*this);
1730 }
1731 
1732 
1733 dbReal&
1734 dbReal::calculateWith(dbRealCalculator* adoptedCalculator, bool useOnlyForDefaults)
1735 {
1736  CalculateWith(adoptedCalculator, useOnlyForDefaults);
1737  return *this;
1738 }
1739 
1740 
1741 void
1743 {
1744  assert(mCalculator);
1745  *this = calculator()->calc(this);
1746 }
1747 
1748 
1749 dbReal&
1751 {
1752  if (this == &rhs)
1753  return *this;
1754 
1755  *this = (double)rhs;
1756  return *this;
1757 }
1758 
1759 
1760 dbReal&
1762 {
1763  if (fieldIsStandalone())
1764  *((double*) mBackend) = n;
1765  else {
1766  assert(mBackend);
1767  mBackend->writeDouble(n, this);
1768  }
1769  return *this;
1770 }
1771 
1772 
1773 void
1775 {
1776  *this = n;
1777 }
1778 
1779 
1780 void
1781 dbReal::setString(const char* str)
1782 {
1783  double n;
1784  istringstream is((char*)str); // cast away const for Borland
1785  is >> n;
1786  *this = n;
1787 }
1788 
1789 
1790 dbReal::operator double() const
1791 {
1792  double ret;
1793  if (usingCalculator())
1794  ret = calculator()->calc(this);
1795  else {
1796  if (fieldIsStandalone())
1797  ret = *((double*) mBackend);
1798  else {
1799  assert(mBackend);
1800  ret = mBackend->readDouble(this);
1801  }
1802  }
1803  return ret;
1804 }
1805 
1806 
1807 void
1809 {
1810  if (srcField->fieldType()==realField)
1811  *this = *(dbReal*)srcField; // safe downcast
1812 #ifdef OOF_DEBUG
1813  else
1814  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbReal::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
1815 #endif
1816 }
1817 
1818 
1819 void
1821 {
1822  if (srcField->fieldType()==realField) {
1823  long rhs = *(dbReal*)srcField; // safe downcast
1824  if (value() != rhs)
1825  *this = rhs;
1826  }
1827 #ifdef OOF_DEBUG
1828  else
1829  dbConnect::raise(stringstream() << flush << "wrong field type passed in to dbReal::copyValueFrom, copying to " << fieldName() << " from " << srcField->fieldName());
1830 #endif
1831 }
1832 
1833 
1836 {
1837  return realField;
1838 }
1839 
1840 
1841 unsigned long
1843 {
1844  return sizeof(double);
1845 }
1846 
1847 
1848 void
1849 dbReal::extract(ostream& os) const
1850 {
1851  os << (double)*this;
1852 }
1853 
1854 
1855 bool
1856 dbReal::insert(istream& is, char fieldSep, char recSep)
1857 {
1858  // is the stream good?
1859  if (!is.good())
1860  return false;
1861  // read in the real
1862  double n=0;
1863  if (skipTillNumber(is, fieldSep, recSep, true))
1864  is >> n;
1865  // read in a potential field/record separator
1866  const char c = is.peek();
1867  bool hitEndOfField = false;
1868  if ((c==fieldSep) || (c==recSep))
1869  hitEndOfField = true;
1870  if (hitEndOfField)
1871  *this = n;
1872  return hitEndOfField;
1873 }
1874 
1875 
1876 void
1877 dbReal::generateTestData(bool generateRandom, unsigned long seedOrCount)
1878 {
1879  if (generateRandom)
1880  *this = (1.7*rand()-rand()*1.5);
1881  else
1882  *this = (double)seedOrCount;
1883 }
1884 
1885 
1887 dbReal::between(double fromNum, double toNum) const
1888 {
1890  new dbQueryLiteralDouble(fromNum), new dbQueryLiteralDouble(toNum));
1891 }
1892 
1893 
1895 dbReal::outside(double fromNum, double toNum) const
1896 {
1898  new dbQueryLiteralDouble(fromNum), new dbQueryLiteralDouble(toNum));
1899 }
1900 
1901 
1902 dbQueryClause*
1904 {
1906  return ret;
1907 }
1908 
1909 
1911 dbReal::operator==(double d) const
1912 {
1914 }
1915 
1916 
1917  dbQueryBinary
1918  dbReal::operator!=(double d) const
1919 {
1921 }
1922 
1923 
1924  dbQueryBinary
1925  dbReal::operator<(double d) const
1926 {
1928 }
1929 
1930 
1931  dbQueryBinary
1932  dbReal::operator<=(double d) const
1933 {
1935 }
1936 
1937 
1939 dbReal::operator>(double d) const
1940 {
1942 }
1943 
1944 
1946 dbReal::operator>=(double d) const
1947 {
1949 }
1950 
1951 
1954 {
1955  return new dbQueryLiteralDouble(n);
1956 }
1957 
1958 
1961 {
1962  return new dbQueryLiteralDouble(n);
1963 }
1964 
1965 
1966 // -------------------------------------------------------
1967 // o o f C h a r
1968 // -------------------------------------------------------
1969 oofChar::oofChar(unsigned long fieldWidth) :
1970  dbChar(dbField::eFieldIsStandalone, fieldWidth)
1971 {
1972 }
1973 
1974 
1975 oofChar::oofChar(const char* initialString, unsigned long fieldWidth) :
1976  dbChar(dbField::eFieldIsStandalone, fieldWidth ? fieldWidth : strlen(initialString))
1977 {
1978  assert((fieldWidth==0) || strlen(initialString) <= fieldWidth);
1979  dbChar::operator=(initialString);
1980 }
1981 
1982 
1983 oofChar::oofChar(const dbChar& rhs) :
1984  dbChar(dbField::eFieldIsStandalone, rhs.fieldStorageLen())
1985 {
1986  dbChar::operator=(rhs);
1987 }
1988 
1989 
1991  dbChar(dbField::eFieldIsStandalone, rhs.fieldStorageLen())
1992 {
1993  dbChar::operator=(rhs);
1994 }
1995 
1996 
1997 dbField*
1999 {
2000  return new oofChar(*this);
2001 }
2002 
2003 
2004 oofChar&
2006 {
2007  dbChar::operator=(rhs);
2008  return *this;
2009 }
2010 
2011 
2012 oofChar&
2014 {
2015  dbChar::operator=(rhs);
2016  return *this;
2017 }
2018 
2019 
2020 oofChar&
2021 oofChar::operator=(const char* rhs)
2022 {
2023  dbChar::operator=(rhs);
2024  return *this;
2025 }
2026 
2027 
2028 oofChar&
2030 {
2031  dbChar::operator=(rhs);
2032  return *this;
2033 }
2034 
2035 
2036 // -------------------------------------------------------
2037 // o o f T e x t
2038 // -------------------------------------------------------
2040  dbText(dbField::eFieldIsStandalone)
2041 {
2042  dbText::operator=("");
2043 }
2044 
2045 
2046 oofText::oofText(const char* initialString) :
2047  dbText(dbField::eFieldIsStandalone)
2048 {
2049  dbText::operator=(initialString);
2050 }
2051 
2052 
2053 oofText::oofText(const dbText& rhs) :
2054  dbText(dbField::eFieldIsStandalone)
2055 {
2056  dbText::operator=(rhs);
2057 }
2058 
2059 
2061  dbText(dbField::eFieldIsStandalone)
2062 {
2063  dbText::operator=(rhs);
2064 }
2065 
2066 
2067 dbField*
2069 {
2070  return new oofText(*this);
2071 }
2072 
2073 
2074 oofText&
2075 oofText::operator=(const char* rhs)
2076 {
2077  dbText::operator=(rhs);
2078  return *this;
2079 }
2080 
2081 
2082 oofText&
2084 {
2085  dbText::operator=(rhs);
2086  return *this;
2087 }
2088 
2089 
2090 oofText&
2092 {
2093  dbText::operator=(rhs);
2094  return *this;
2095 }
2096 
2097 
2098 oofText&
2100 {
2101  dbText::operator=(rhs);
2102  return *this;
2103 }
2104 
2105 
2106 // -------------------------------------------------------
2107 // o o f B L O B
2108 // -------------------------------------------------------
2110  dbBLOB(dbField::eFieldIsStandalone)
2111 {
2112 }
2113 
2114 
2115 oofBLOB::oofBLOB(const dbBLOB& rhs) :
2116  dbBLOB(dbField::eFieldIsStandalone)
2117 {
2118  dbBLOB::operator=(rhs);
2119 }
2120 
2121 
2123  dbBLOB(dbField::eFieldIsStandalone)
2124 {
2125  dbBLOB::operator=(rhs);
2126 }
2127 
2128 
2129 oofBLOB&
2131 {
2132  dbBLOB::operator=(rhs);
2133  return *this;
2134 }
2135 
2136 
2137 oofBLOB&
2139 {
2140  dbBLOB::operator=(rhs);
2141  return *this;
2142 }
2143 
2144 
2145 dbField*
2147 {
2148  return new oofBLOB(*this);
2149 }
2150 
2151 
2152 // -------------------------------------------------------
2153 // o o f L o n g
2154 // -------------------------------------------------------
2156  dbLong(dbField::eFieldIsStandalone)
2157 {
2158 }
2159 
2160 
2161 oofLong::oofLong(long initialValue) :
2162  dbLong(dbField::eFieldIsStandalone)
2163 {
2164  dbLong::operator=(initialValue);
2165 }
2166 
2167 
2168 oofLong::oofLong(const dbLong& rhs) :
2169  dbLong(dbField::eFieldIsStandalone)
2170 {
2171  dbLong::operator=(rhs);
2172 }
2173 
2174 
2176  dbLong(dbField::eFieldIsStandalone)
2177 {
2178  dbLong::operator=(rhs);
2179 }
2180 
2181 
2182 dbField*
2184 {
2185  return new oofLong(*this);
2186 }
2187 
2188 
2189 oofLong&
2191 {
2192  dbLong::operator=(rhs);
2193  return *this;
2194 }
2195 
2196 
2197 oofLong&
2199 {
2200  dbLong::operator=(rhs);
2201  return *this;
2202 }
2203 
2204 
2205 oofLong&
2207 {
2208  dbLong::operator=(rhs);
2209  return *this;
2210 }
2211 
2212 
2213 // -------------------------------------------------------
2214 // o o f U l o n g
2215 // -------------------------------------------------------
2217  dbUlong(dbField::eFieldIsStandalone)
2218 {
2219 }
2220 
2221 
2222 oofUlong::oofUlong(unsigned long initialValue) :
2223  dbUlong(dbField::eFieldIsStandalone)
2224 {
2225  dbUlong::operator=(initialValue);
2226 }
2227 
2228 
2230  dbUlong(dbField::eFieldIsStandalone)
2231 {
2232  dbUlong::operator=(rhs);
2233 }
2234 
2235 
2237  dbUlong(dbField::eFieldIsStandalone)
2238 {
2239  dbUlong::operator=(rhs);
2240 }
2241 
2242 
2243 dbField*
2245 {
2246  return new oofUlong(*this);
2247 }
2248 
2249 
2250 oofUlong&
2251 oofUlong::operator=(unsigned long rhs)
2252 {
2253  dbUlong::operator=(rhs);
2254  return *this;
2255 }
2256 
2257 
2258 oofUlong&
2260 {
2261  dbUlong::operator=(rhs);
2262  return *this;
2263 }
2264 
2265 
2266 oofUlong&
2268 {
2269  dbUlong::operator=(rhs);
2270  return *this;
2271 }
2272 
2273 
2274 // -------------------------------------------------------
2275 // o o f S h o r t
2276 // -------------------------------------------------------
2278  dbShort(dbField::eFieldIsStandalone)
2279 {
2280 }
2281 
2282 
2283 oofShort::oofShort(short initialValue) :
2284  dbShort(dbField::eFieldIsStandalone)
2285 {
2286  dbShort::operator=(initialValue);
2287 }
2288 
2289 
2291  dbShort(dbField::eFieldIsStandalone)
2292 {
2293  dbShort::operator=(rhs);
2294 }
2295 
2296 
2298  dbShort(dbField::eFieldIsStandalone)
2299 {
2300  dbShort::operator=(rhs);
2301 }
2302 
2303 
2304 dbField*
2306 {
2307  return new oofShort(*this);
2308 }
2309 
2310 
2311 oofShort&
2313 {
2314  dbShort::operator=(rhs);
2315  return *this;
2316 }
2317 
2318 
2319 oofShort&
2321 {
2322  dbShort::operator=(rhs);
2323  return *this;
2324 }
2325 
2326 
2327 oofShort&
2329 {
2330  dbShort::operator=(rhs);
2331  return *this;
2332 }
2333 
2334 
2335 // -------------------------------------------------------
2336 // o o f U s h o r t
2337 // -------------------------------------------------------
2339  dbUshort(dbField::eFieldIsStandalone)
2340 {
2341 }
2342 
2343 
2344 oofUshort::oofUshort(unsigned short initialValue) :
2345  dbUshort(dbField::eFieldIsStandalone)
2346 {
2347  dbUshort::operator=(initialValue);
2348 }
2349 
2350 
2352  dbUshort(dbField::eFieldIsStandalone)
2353 {
2354  dbUshort::operator=(rhs);
2355 }
2356 
2357 
2359  dbUshort(dbField::eFieldIsStandalone)
2360 {
2361  dbUshort::operator=(rhs);
2362 }
2363 
2364 
2365 dbField*
2367 {
2368  return new oofUshort(*this);
2369 }
2370 
2371 
2372 oofUshort&
2373 oofUshort::operator=(unsigned short rhs)
2374 {
2375  dbUshort::operator=(rhs);
2376  return *this;
2377 }
2378 
2379 
2380 oofUshort&
2382 {
2383  dbUshort::operator=(rhs);
2384  return *this;
2385 }
2386 
2387 
2388 oofUshort&
2390 {
2391  dbUshort::operator=(rhs);
2392  return *this;
2393 }
2394 
2395 
2396 // -------------------------------------------------------
2397 // o o f R e a l
2398 // -------------------------------------------------------
2400  dbReal(dbField::eFieldIsStandalone)
2401 {
2402 }
2403 
2404 
2405 oofReal::oofReal(double initialValue) :
2406  dbReal(dbField::eFieldIsStandalone)
2407 {
2408  dbReal::operator=(initialValue);
2409 }
2410 
2411 
2412 oofReal::oofReal(const dbReal& rhs) :
2413  dbReal(dbField::eFieldIsStandalone)
2414 {
2415  dbReal::operator=(rhs);
2416 }
2417 
2418 
2420  dbReal(dbField::eFieldIsStandalone)
2421 {
2422  dbReal::operator=(rhs);
2423 }
2424 
2425 
2426 dbField*
2428 {
2429  return new oofReal(*this);
2430 }
2431 
2432 
2433 oofReal&
2435 {
2436  dbReal::operator=(rhs);
2437  return *this;
2438 }
2439 
2440 
2441 oofReal&
2443 {
2444  dbReal::operator=(rhs);
2445  return *this;
2446 }
2447 
2448 
2449 oofReal&
2451 {
2452  dbReal::operator=(rhs);
2453  return *this;
2454 }
2455 
2456 
2457 // -------------------------------------------------------
2458 // o o f B o o l
2459 // -------------------------------------------------------
2461  dbBool(dbField::eFieldIsStandalone)
2462 {
2463 }
2464 
2465 
2466 oofBool::oofBool(bool initialValue) :
2467  dbBool(dbField::eFieldIsStandalone)
2468 {
2469  dbBool::operator=(initialValue);
2470 }
2471 
2472 
2473 oofBool::oofBool(char initialValue) :
2474  dbBool(dbField::eFieldIsStandalone)
2475 {
2476  dbBool::operator=(initialValue);
2477 }
2478 
2479 
2480 oofBool::oofBool(const char* initialValue) :
2481  dbBool(dbField::eFieldIsStandalone)
2482 {
2483  setString(initialValue);
2484 }
2485 
2486 
2487 oofBool::oofBool(const dbBool& rhs) :
2488  dbBool(dbField::eFieldIsStandalone)
2489 {
2490  dbBool::operator=(rhs);
2491 }
2492 
2493 
2495  dbBool(dbField::eFieldIsStandalone)
2496 {
2497  dbBool::operator=(rhs);
2498 }
2499 
2500 
2501 dbField*
2503 {
2504  return new oofBool(*this);
2505 }
2506 
2507 
2508 oofBool&
2510 {
2511  dbBool::operator=(rhs);
2512  return *this;
2513 }
2514 
2515 
2516 
2517 oofBool&
2519 {
2520  dbBool::operator=(rhs);
2521  return *this;
2522 }
2523 
2524 
2525 oofBool&
2527 {
2528  dbBool::operator=(rhs);
2529  return *this;
2530 }
2531 
2532 
2533 #ifdef OOF_HAS_BOOL
2534 oofBool&
2536 {
2537  const bool b = n;
2538  *this = b;
2539  return *this;
2540 }
2541 #else
2542 oofBool&
2543 oofBool::operator=(char rhs)
2544 {
2545  dbBool::operator=(rhs);
2546  return *this;
2547 }
2548 
2549 #endif
bool value() const
Definition: oof4.h:1529
virtual dbField * clone() const
Definition: oof4.cpp:2366
virtual OOF_fieldTypes fieldType() const
Definition: oof4.cpp:1835
oofReal & operator=(double)
Definition: oof4.cpp:2434
virtual void setString(const char *)
Definition: oof4.cpp:1333
Persistent field used to store a double.
Definition: oof4.h:521
dbReal & operator=(double)
Definition: oof4.cpp:1761
virtual OOF_fieldTypes fieldType() const
Definition: oof4.cpp:1387
RHS unsigned long argument to queries on fields like dbUlong.
Definition: oofquery.h:503
virtual void extract(std::ostream &os) const
Definition: oof4.cpp:1401
dbQueryTrinary outside(long, long) const
Definition: oof4.cpp:56
dbQueryBinary operator==(long) const
Definition: oof4.cpp:64
virtual long calc(const dbLong *)=0
virtual void setNumber(long)
Definition: oof3.h:133
static void raise(std::ostream &, bool terminateAfterMsg=true)
dbQueryTrinary between(long, long) const
Definition: oof4.cpp:48
virtual OOF_fieldTypes fieldType() const
Definition: oof4.cpp:1589
virtual dbQueryLiteral * makeQueryLiteral(long) const
Definition: oof4.cpp:1953
dbQueryBinary operator==(unsigned short) const
Definition: oof4.cpp:916
oofBool & operator=(bool)
Definition: oof4.cpp:2509
virtual const oofString & fieldName() const
Definition: oof3.h:769
precompilation header.
static void CheckRange(double d, long minL, long maxL, const char *file, int line)
Definition: oof4.cpp:435
dbLong & calculateWith(dbLongCalculator *adoptedCalculator, bool useOnlyForDefaults=false)
Definition: oof4.cpp:1279
Definition: oof3.h:26
virtual dbQueryLiteral * makeQueryLiteral(long) const
Definition: oof4.cpp:486
Calculator attached to a dbUshort field.
Definition: oof4.h:77
static bool char2bool(char)
Definition: oof4.cpp:1221
dbReal(const char *fieldName=0)
Definition: oof4.cpp:1688
virtual void setString(const char *)
Definition: oof4.cpp:1781
virtual dbField * clone() const
Definition: oof4.cpp:2427
Highest level used to assemble queries.
Definition: oofquery.h:46
oofBool()
Definition: oof4.cpp:2460
virtual dbField * clone() const
Definition: oof4.cpp:2502
virtual void CopyCalculatedValueToBuffer()
Definition: oof4.cpp:545
dbShortCalculator * calculator() const
Definition: oof4.h:1446
virtual OOF_fieldTypes nativeType() const
Definition: oof4.cpp:1084
bool skipRestOfField(std::istream &, char fieldSep=dbTable::kFieldSep, char recSep=dbTable::kRecSep)
virtual ~dbUlong()
Definition: oof4.cpp:1469
dbQueryBinary operator==(double) const
Definition: oof4.cpp:1911
virtual void copyValueFrom(const dbField *)
Definition: oof4.cpp:1562
bool fieldIsStandalone() const
Definition: oof3.h:733
oofReal()
Definition: oof4.cpp:2399
oofText & operator=(const char *)
Definition: oof4.cpp:2075
virtual void setNumber(long)
Definition: oof4.cpp:775
oofChar & operator=(const char *)
Definition: oof4.cpp:2021
Exception for database field operation violating field data numeric range.
Definition: oofexcep.h:238
RHS double argument to queries on fields like dbReal.
Definition: oofquery.h:431
virtual unsigned long fieldStorageLen() const
Definition: oof4.cpp:1394
Calculator attached to a dbLong field.
Definition: oof4.h:99
void operator-=(long)
Definition: oof4.cpp:371
OOF_tableBackend * mBackend
Definition: oof3.h:155
double value() const
Definition: oof4.h:1887
virtual void copyValueIfDifferent(const dbField *)
Definition: oof4.cpp:1372
virtual unsigned long fieldMinWrapWidth() const
Definition: oof4.cpp:493
Persistent base for fields which can be represented as numbers.
Definition: oof4.h:166
virtual unsigned long fieldStorageLen() const =0
oofShort & operator=(short)
Definition: oof4.cpp:2312
virtual bool calc(const dbBool *)=0
Definition: oof3.h:26
dbBool & calculateWith(dbBoolCalculator *adoptedCalculator, bool useOnlyForDefaults=false)
Definition: oof4.cpp:968
oofBLOB()
Definition: oof4.cpp:2109
virtual dbField * clone() const
Definition: oof4.cpp:1475
Common trinary query for field, eg: People.Salary.between(50000, 90000); Very similar to dbQueryBinar...
Definition: oofquery.h:263
RHS long argument to queries on fields like dbLong.
Definition: oofquery.h:480
virtual void setString(const char *)
Definition: oof4.cpp:1003
static bool str2bool(const char *)
Definition: oof4.cpp:1232
OOF_String mFormatMask
Definition: oof4.h:253
Use to have local non-persistent variable of type dbBool.
Definition: oof4.h:1309
dbLong & operator=(long)
Definition: oof4.cpp:1312
virtual void setString(const char *)
Definition: oof4.cpp:1535
dbQueryBinary operator<=(double) const
Definition: oof4.cpp:1932
oofBLOB & operator=(const oofBLOB &)
Definition: oof4.cpp:2130
dbUshort & calculateWith(dbUshortCalculator *adoptedCalculator, bool useOnlyForDefaults=false)
Definition: oof4.cpp:748
virtual void setString(const char *)
Definition: oof4.cpp:570
virtual dbField * clone() const
Definition: oof4.cpp:2244
virtual OOF_fieldTypes fieldType() const
Definition: oof4.cpp:1077
dbReal & calculateWith(dbRealCalculator *adoptedCalculator, bool useOnlyForDefaults=false)
Definition: oof4.cpp:1734
dbQueryBinary operator!=(double) const
Definition: oof4.cpp:1918
virtual void copyValueFrom(const dbField *)
Definition: oof4.cpp:1808
virtual void generateTestData(bool generateRandom, unsigned long seedOrCount)
Definition: oof4.cpp:1126
dbQueryBinary equal(long) const
Definition: oof4.cpp:320
oofLong & operator=(long)
Definition: oof4.cpp:2190
bool skipTillNumber(std::istream &is, char fieldSep, char recSep, bool canStartWithDecimal=false)
virtual void copyValueIfDifferent(const dbField *)
Definition: oof4.cpp:629
Persistent field used to store an unsigned short.
Definition: oof4.h:317
dbQueryBinary operator<=(long) const
Definition: oof4.cpp:85
virtual void writeBool(bool, const dbField *)=0
virtual void clear()
Definition: oof4.cpp:41
virtual void copyValueIfDifferent(const dbField *)
Definition: oof4.cpp:1820
dbLong(const char *fieldName=0)
Definition: oof4.cpp:1251
dbUlong & calculateWith(dbUlongCalculator *adoptedCalculator, bool useOnlyForDefaults=false)
Definition: oof4.cpp:1488
oofUshort & operator=(unsigned short)
Definition: oof4.cpp:2373
dbLongCalculator * calculator() const
Definition: oof4.h:1600
virtual void copyValueFrom(const dbField *)
Definition: oof4.cpp:829
virtual void CopyCalculatedValueToBuffer()
Definition: oof4.cpp:1496
virtual void copyValueFrom(const dbField *)
Definition: oof4.cpp:1360
Common binary query for field, eg: People.Salary > 90000.
Definition: oofquery.h:165
virtual ~dbBool()
Definition: oof4.cpp:955
virtual dbField * clone() const
Definition: oof4.cpp:2146
dbUshortCalculator * calculator() const
Definition: oof4.h:1504
dbQueryBinary operator>=(long) const
Definition: oof4.cpp:99
virtual dbQueryLiteral * makeQueryLiteral(long n) const
Definition: oof4.cpp:1648
dbRealCalculator * calculator() const
Definition: oof4.h:1895
dbQueryTrinary outside(double, double) const
Definition: oof4.cpp:1895
virtual double calc(const dbReal *)=0
virtual dbField * clone() const
Definition: oof4.cpp:1272
virtual dbQueryLiteral * makeQueryLiteral(long) const
Definition: oof4.cpp:696
dbBoolCalculator * calculator() const
Definition: oof4.h:1522
virtual unsigned long fieldStorageLen() const
Definition: oof4.cpp:1842
dbUlong(const char *fieldName=0)
Definition: oof4.cpp:1454
virtual void writeShort(short, const dbField *)=0
dbCalculator * mCalculator
Definition: oof3.h:158
Calculator attached to a dbBool field.
Definition: oof4.h:88
oofUshort()
Definition: oof4.cpp:2338
dbQueryBinary operator!=(long) const
Definition: oof4.cpp:71
Use to have local non-persistent variable of type dbText.
Definition: oof4.h:1146
Definition: oof3.h:26
dbNumericField(const OOF_IndexOptions)
Definition: oof4.cpp:24
virtual ~dbUshort()
Definition: oof4.cpp:735
LHS argument to queries on fields.
Definition: oofquery.h:572
virtual void setNumber(long)
Definition: oof4.cpp:995
virtual ~dbReal()
Definition: oof4.cpp:1719
dbQueryTrinary between(double, double) const
Definition: oof4.cpp:1887
virtual bool insert(std::istream &, char fieldSep, char recSep)
Definition: oof4.cpp:1105
dbUlongCalculator * calculator() const
Definition: oof4.h:1648
virtual void extract(std::ostream &os) const
Definition: oof4.cpp:1849
dbQueryBinary greaterThanOrEqual(long) const
Definition: oof4.cpp:355
virtual void copyValueFrom(const dbField *)
Definition: oof4.cpp:1050
virtual void generateTestData(bool generateRandom, unsigned long seedOrCount)
Definition: oof4.cpp:899
virtual dbField * clone() const
Definition: oof4.cpp:741
virtual void setNumber(long)
Definition: oof4.cpp:1528
unsigned long length() const
Primary test: oofStringTest::emptyStringByNullInitIsLenZero()
Definition: oofstr.h:447
dbQueryBinary lessThan(long) const
Definition: oof4.cpp:334
Abstract interface to database backend.
Definition: oof1.h:1047
Use to have local non-persistent variable of type dbUshort.
Definition: oof4.h:1269
Calculator attached to a dbUlong field.
Definition: oof4.h:110
virtual bool insert(std::istream &, char fieldSep, char recSep)
Definition: oof4.cpp:877
unsigned long value() const
Definition: oof4.h:1641
virtual void extract(std::ostream &os) const
Definition: oof4.cpp:1098
virtual bool insert(std::istream &, char fieldSep, char recSep)
Definition: oof4.cpp:1610
virtual dbField * clone() const
Definition: oof4.cpp:2305
virtual void setNumber(long)
Definition: oof4.cpp:1325
virtual void CopyCalculatedValueToBuffer()
Definition: oof4.cpp:976
dbBLOB & operator=(const dbBLOB &)
Definition: oof3.cpp:2254
Persistent field used to store a fixed-length string.
Definition: oof3.h:255
virtual void writeDouble(double, const dbField *)=0
Calculator attached to a dbReal field.
Definition: oof4.h:132
oofText()
Definition: oof4.cpp:2039
virtual dbField * clone() const
Definition: oof4.cpp:1727
virtual OOF_fieldTypes fieldType() const
Definition: oof4.cpp:644
OOF_fieldTypes
Definition: oof3.h:26
virtual dbQueryClause * valueAsQueryLiteral() const
Definition: oof4.cpp:1428
virtual void writeLong(long, const dbField *)=0
dbShort(const char *fieldName=0)
Definition: oof4.cpp:509
unsigned short value() const
Definition: oof4.h:1497
virtual void extract(std::ostream &os) const
Definition: oof4.cpp:658
dbText & operator=(char)
Definition: oof3.cpp:1644
virtual void CopyCalculatedValueToBuffer()
Definition: oof4.cpp:1742
#define RAISE_EXCEPTION(E)
Macro to allow us to either throw an exception or call dbConnect::raise.
Definition: oofexcep.h:31
virtual void generateTestData(bool generateRandom, unsigned long seedOrCount)
Definition: oof4.cpp:1877
Persistent field used to store a boolean.
Definition: oof4.h:367
dbQueryBinary operator>(double) const
Definition: oof4.cpp:1939
dbQueryBinary operator==(bool) const
Definition: oof4.cpp:1177
virtual void copyValueIfDifferent(const dbField *)
Definition: oof4.cpp:1574
virtual dbQueryClause * valueAsQueryLiteral() const
Definition: oof4.cpp:923
virtual void copyValueIfDifferent(const dbField *)
Definition: oof4.cpp:1062
oofUlong & operator=(unsigned long)
Definition: oof4.cpp:2251
virtual dbQueryLiteral * makeQueryLiteral(long) const
Definition: oof4.cpp:909
virtual dbQueryLiteral * makeQueryLiteral(bool) const
Definition: oof4.cpp:1141
long value() const
Definition: oof4.h:1593
short value() const
Definition: oof4.h:1439
virtual void CopyCalculatedValueToBuffer()
Definition: oof4.cpp:756
dbQueryBinary operator>(long) const
Definition: oof4.cpp:92
virtual void setString(const char *)
Definition: oof4.cpp:782
virtual void CopyCalculatedValueToBuffer()
Definition: oof4.cpp:1287
Persistent field used to store a short.
Definition: oof4.h:272
virtual dbQueryClause * valueAsQueryLiteral() const
Definition: oof4.cpp:1903
RHS short argument to queries on fields like dbShort.
Definition: oofquery.h:526
virtual dbField * clone() const
Definition: oof4.cpp:2183
virtual dbField * clone() const
Definition: oof4.cpp:1998
dbQueryBinary operator<(double) const
Definition: oof4.cpp:1925
virtual void extract(std::ostream &os) const
Definition: oof4.cpp:870
void operator/=(long)
Definition: oof4.cpp:362
virtual void setNumber(long)
Definition: oof4.cpp:1774
virtual unsigned long fieldStorageLen() const
Definition: oof4.cpp:1596
virtual unsigned short calc(const dbUshort *)=0
virtual void extract(std::ostream &os) const
Definition: oof4.cpp:1603
dbQueryBinary notEqual(long) const
Definition: oof4.cpp:327
RHS unsigned short argument to queries on fields like dbUshort.
Definition: oofquery.h:549
virtual short calc(const dbShort *)=0
dbUlong & operator=(unsigned long)
Definition: oof4.cpp:1515
virtual void generateTestData(bool generateRandom, unsigned long seedOrCount)
Definition: oof4.cpp:1631
void CalculateWith(dbCalculator *adoptedCalculator, bool useOnlyForDefaults)
Definition: oof3.cpp:444
Persistent field used to store a variable length string.
Definition: oof3.h:459
OOF_IndexOptions
type used to specify index options for dbField's.
Definition: oof1.h:236
dbBool(const char *fieldName=0)
Definition: oof4.cpp:939
Use to have local non-persistent variable of type dbShort.
Definition: oof4.h:1249
dbChar & operator=(const char *)
Definition: oof3.cpp:1026
virtual dbQueryClause * valueAsQueryLiteral() const
Definition: oof4.cpp:1169
virtual ~dbShort()
Definition: oof4.cpp:524
Use to have local non-persistent variable of type dbLong.
Definition: oof4.h:1209
dbQueryBinary operator==(unsigned long) const
Definition: oof4.cpp:1663
dbQueryBinary lessThanOrEqual(long) const
Definition: oof4.cpp:341
FieldIsStandaloneT
Definition: oof3.h:65
dbUshort & operator=(unsigned short)
Definition: oof4.cpp:816
virtual unsigned long fieldStorageLen() const
Definition: oof4.cpp:1091
virtual OOF_fieldTypes fieldType() const =0
Use to have local non-persistent variable of type dbReal.
Definition: oof4.h:1289
virtual dbField * clone() const
Definition: oof4.cpp:530
virtual void setNumber(long)
Definition: oof4.cpp:563
Calculator attached to a dbShort field.
Definition: oof4.h:66
dbShort & operator=(short)
Definition: oof4.cpp:604
virtual unsigned long fieldStorageLen() const
Definition: oof4.cpp:651
virtual unsigned long calc(const dbUlong *)=0
Persistent field used to store an arbitrary binary object.
Definition: oof3.h:387
dbQueryBinary operator>=(double) const
Definition: oof4.cpp:1946
virtual bool insert(std::istream &, char fieldSep, char recSep)
Definition: oof4.cpp:665
virtual void generateTestData(bool generateRandom, unsigned long seedOrCount)
Definition: oof4.cpp:686
oofChar(unsigned long fieldWidth=80)
Definition: oof4.cpp:1969
virtual dbField * clone() const
Definition: oof4.cpp:961
void operator*=(long)
Definition: oof4.cpp:389
void CompleteInit()
Definition: oof4.cpp:1712
virtual dbQueryClause * valueAsQueryLiteral() const
Definition: oof4.cpp:1655
dbBool & operator=(bool)
Definition: oof4.cpp:1035
virtual unsigned long fieldStorageLen() const
Definition: oof4.cpp:863
virtual OOF_fieldTypes fieldType() const
Definition: oof4.cpp:856
virtual void copyValueIfDifferent(const dbField *)
Definition: oof4.cpp:841
Persistent field used to store an unsigned long.
Definition: oof4.h:475
bool skipTillDigit(std::istream &, char fieldSep=dbTable::kFieldSep, char recSep=dbTable::kRecSep)
virtual void copyValueFrom(const dbField *)
Definition: oof4.cpp:617
virtual dbField * clone() const
Definition: oof4.cpp:2068
virtual dbQueryClause * valueAsQueryLiteral() const
Definition: oof4.cpp:703
oofLong()
Definition: oof4.cpp:2155
virtual ~dbLong()
Definition: oof4.cpp:1266
static char bool2char(bool)
Definition: oof4.cpp:1211
Use to have local non-persistent variable of type dbBLOB.
Definition: oof4.h:1167
void operator+=(long)
Definition: oof4.cpp:380
dbShort & calculateWith(dbShortCalculator *adoptedCalculator, bool useOnlyForDefaults=false)
Definition: oof4.cpp:537
oofShort()
Definition: oof4.cpp:2277
virtual bool insert(std::istream &, char fieldSep, char recSep)
Definition: oof4.cpp:1408
dbQueryBinary greaterThan(long) const
Definition: oof4.cpp:348
dbUshort(const char *fieldName=0)
Definition: oof4.cpp:719
virtual void generateTestData(bool generateRandom, unsigned long seedOrCount)
Definition: oof4.cpp:1436
virtual bool insert(std::istream &, char fieldSep, char recSep)
Definition: oof4.cpp:1856
Base for the RHS arguments to combinatorial queries dbQueryBinary, dbQueryTrinary.
Definition: oofquery.h:307
Use to have local non-persistent variable of type dbChar.
Definition: oof4.h:1126
Base class for persistent fields in dbTable's.
Definition: oof3.h:63
oofUlong()
Definition: oof4.cpp:2216
dbQueryBinary operator<(long) const
Definition: oof4.cpp:78
Use to have local non-persistent variable of type dbUlong.
Definition: oof4.h:1229
Persistent field used to store a long.
Definition: oof4.h:433