NCBI C++ ToolKit
stdtypes.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: stdtypes.cpp 102265 2024-04-12 16:01:26Z ucko $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Eugene Vasilchenko
27 *
28 * File Description:
29 * CTypeInfo classes for primitive leaf types.
30 */
31 
32 #include <ncbi_pch.hpp>
33 #include <serial/serialdef.hpp>
36 #include <serial/objistr.hpp>
37 #include <serial/objostr.hpp>
38 #include <serial/objcopy.hpp>
39 
40 #include <limits.h>
41 #if HAVE_WINDOWS_H
42 // In MSVC limits.h doesn't define FLT_MIN & FLT_MAX
43 # include <float.h>
44 #endif
45 #include <math.h>
46 
48 
49 
51 {
52 public:
53  static bool IsNegative(Int4 value)
54  {
55  return value < 0;
56  }
57  static bool IsNegative(Uint4 /*value*/)
58  {
59  return false;
60  }
61 #ifndef NCBI_INT8_IS_LONG
62  // add variants with long to avoid ambiguity
63  static bool IsNegative(long value)
64  {
65  return value < 0;
66  }
67  static bool IsNegative(unsigned long /*value*/)
68  {
69  return false;
70  }
71 #endif
72  static bool IsNegative(Int8 value)
73  {
74  return value < 0;
75  }
76  static bool IsNegative(Uint8 /*value*/)
77  {
78  return false;
79  }
80 };
81 
82 template<typename T>
84 {
85 public:
86  typedef T TObjectType;
87 
88  static TObjectType& Get(TObjectPtr object)
89  {
90  return CTypeConverter<TObjectType>::Get(object);
91  }
92  static const TObjectType& Get(TConstObjectPtr object)
93  {
94  return CTypeConverter<TObjectType>::Get(object);
95  }
96 
98  {
99  info->SetIOFunctions(&Read, &Write, &Copy, &Skip);
100  }
101 
103  {
104  info->SetMemFunctions(&Create,
106  &Equals, &Assign);
107  }
108 
109  static TObjectPtr Create(TTypeInfo /*typeInfo*/,
110  CObjectMemoryPool* /*memoryPool*/)
111  {
112  return new TObjectType(0);
113  }
114  static bool IsDefault(TConstObjectPtr objectPtr)
115  {
116  return Get(objectPtr) == TObjectType(0);
117  }
118  static void SetDefault(TObjectPtr objectPtr)
119  {
120  Get(objectPtr) = TObjectType(0);
121  }
122 
123  static bool Equals(TConstObjectPtr obj1, TConstObjectPtr obj2,
125  {
126  return Get(obj1) == Get(obj2);
127  }
128  static void Assign(TObjectPtr dst, TConstObjectPtr src,
130  {
131  Get(dst) = Get(src);
132  }
133 
134  static void Read(CObjectIStream& in,
135  TTypeInfo , TObjectPtr objectPtr)
136  {
137  in.ReadStd(Get(objectPtr));
138  }
139  static void Write(CObjectOStream& out,
140  TTypeInfo , TConstObjectPtr objectPtr)
141  {
142  out.WriteStd(Get(objectPtr));
143  }
144  static void Skip(CObjectIStream& in, TTypeInfo )
145  {
146  static const TObjectType data{};
147  in.SkipStd(data);
148  }
149  static void Copy(CObjectStreamCopier& copier, TTypeInfo )
150  {
152  copier.In().ReadStd(data);
153  copier.Out().SetSpecialCaseWrite(
156  copier.Out().WriteStd(data);
158  }
159 };
160 
161 #define EPSILON_(n) 1e-##n
162 #define EPSILON(n) EPSILON_(n)
163 
164 #ifndef DBL_EPSILON
165 # define DBL_EPSILON EPSILON(DBL_DIG)
166 #endif
167 
168 
169 // find distance in ULPs, see if it is low enough
170 template<typename TFloat, typename TInt>
171 bool
172 x_Practically_Equal(const TFloat v1, const TFloat v2)
173 {
174  static_assert( sizeof(TFloat) == sizeof(TInt), "sizeof(TFloat) != sizeof(TInt)");
175  static_assert( !is_signed<TInt>::value, "Use unsigned integer storage type");
176  static_assert( numeric_limits<TFloat>::is_iec559, "Non-standard floating type");
177  const TInt allowed = sizeof(TInt) >= 8 ? 64 : 4;
178 
179  size_t total_bits = 8*sizeof(TFloat);
180  TInt sign_mask = TInt(1) << (total_bits - 1);
181  TInt digit_mask = ~sign_mask;
182 
183  union {
184  TFloat dbl;
185  TInt bits;
186  } x1, x2;
187 
188  x1.dbl = v1;
189  x2.dbl = v2;
190 
191  if ((x1.bits & sign_mask) != (x2.bits & sign_mask)) {
192  return false;
193  }
194  TInt y1 = x1.bits & digit_mask;
195  TInt y2 = x2.bits & digit_mask;
196  TInt d = (y1 > y2) ? (y1 - y2) : (y2 - y1);
197  return d <= allowed;
198 }
199 
202  TConstObjectPtr obj2,
204 {
205  const double& x = Get(obj1);
206  const double& y = Get(obj2);
207  if (isnan(x) || isnan(y)) {
208  return false;
209  }
210  return (x == y || fabs(x - y) < fabs(x + y) * DBL_EPSILON || x_Practically_Equal<double, Uint8>(x,y));
211 }
212 
213 #ifndef FLT_EPSILON
214 # define FLT_EPSILON EPSILON(FLT_DIG)
215 #endif
216 
219  TConstObjectPtr obj2,
221 {
222  const float& x = Get(obj1);
223  const float& y = Get(obj2);
224  if (isnan(x) || isnan(y)) {
225  return false;
226  }
227  return (x == y || fabs(x - y) < fabs(x + y) * FLT_EPSILON || x_Practically_Equal<float, Uint4>(x,y));
228 }
229 
230 #if SIZEOF_LONG_DOUBLE != 0
231 
234  TConstObjectPtr obj2,
236 {
237  const long double& x = Get(obj1);
238  const long double& y = Get(obj2);
239  if (isnan(x) || isnan(y)) {
240  return false;
241  }
242  // We use DBL_EPSILON because I/O is double-based anyway.
243  return (x == y || fabs(x - y) < fabs(x + y) * DBL_EPSILON || x_Practically_Equal<double, Uint8>(x,y));
244 }
245 #endif
246 
248  TTypeInfo objectType)
249 {
250  string message("cannot ");
251  message += operation;
252  message += " object of type: ";
253  message += objectType->GetName();
254  NCBI_THROW(CSerialException,eIllegalCall, message);
255 }
256 
258 {
259  return true;
260 }
261 
264 {
266  return false;
267 }
268 
270 {
271 }
272 
274 {
276 }
277 
279  TObjectPtr )
280 {
281  in.ThrowError(in.fIllegalCall,
282  "CVoidTypeFunctions::Read cannot read");
283 }
284 
287 {
288  out.ThrowError(out.fIllegalCall,
289  "CVoidTypeFunctions::Write cannot write");
290 }
291 
293 {
294  copier.ThrowError(CObjectIStream::fIllegalCall,
295  "CVoidTypeFunctions::Copy cannot copy");
296 }
297 
299 {
300  in.ThrowError(in.fIllegalCall,
301  "CVoidTypeFunctions::Skip cannot skip");
302 }
303 
305  CObjectMemoryPool* /*memoryPool*/)
306 {
307  ThrowException("CVoidTypeFunctions::Create cannot create", objectType);
308  return 0;
309 }
310 
313 {
314 }
315 
317  EPrimitiveValueType valueType,
318  bool isSigned)
320  m_ValueType(valueType), m_Signed(isSigned)
321 {
322  typedef CVoidTypeFunctions TFunctions;
324  SetMemFunctions(&TFunctions::Create,
325  &TFunctions::IsDefault, &TFunctions::SetDefault,
326  &TFunctions::Equals, &TFunctions::Assign);
327 }
328 
330  EPrimitiveValueType valueType,
331  bool isSigned)
333  m_ValueType(valueType), m_Signed(isSigned)
334 {
335  typedef CVoidTypeFunctions TFunctions;
336  SetMemFunctions(&TFunctions::Create,
337  &TFunctions::IsDefault, &TFunctions::SetDefault,
338  &TFunctions::Equals, &TFunctions::Assign);
339 }
340 
341 CPrimitiveTypeInfo::CPrimitiveTypeInfo(size_t size, const string& name,
342  EPrimitiveValueType valueType,
343  bool isSigned)
345  m_ValueType(valueType), m_Signed(isSigned)
346 {
347  typedef CVoidTypeFunctions TFunctions;
348  SetMemFunctions(&TFunctions::Create,
349  &TFunctions::IsDefault, &TFunctions::SetDefault,
350  &TFunctions::Equals, &TFunctions::Assign);
351 }
352 
353 void CPrimitiveTypeInfo::SetMemFunctions(TTypeCreate create,
354  TIsDefaultFunction isDefault,
355  TSetDefaultFunction setDefault,
356  TEqualsFunction equals,
357  TAssignFunction assign)
358 {
359  SetCreateFunction(create);
360  m_IsDefault = isDefault;
361  m_SetDefault = setDefault;
362  m_Equals = equals;
363  m_Assign = assign;
364 }
365 
367  TTypeWriteFunction write,
369  TTypeSkipFunction skip)
370 {
371  SetReadFunction(read);
372  SetWriteFunction(write);
374  SetSkipFunction(skip);
375 }
376 
378 {
380  return false;
381 }
382 
384 {
385  return m_IsDefault(objectPtr);
386 }
387 
389 {
390  m_SetDefault(objectPtr);
391 }
392 
394  ESerialRecursionMode how) const
395 {
396  return m_Equals(obj1, obj2, how);
397 }
398 
400  ESerialRecursionMode how) const
401 {
402  m_Assign(dst, src, how);
403 }
404 
405 void CPrimitiveTypeInfo::SetValueBool(TObjectPtr /*objectPtr*/, bool /*value*/) const
406 {
408 }
409 
411 {
413  return 0;
414 }
415 
416 void CPrimitiveTypeInfo::SetValueChar(TObjectPtr /*objectPtr*/, char /*value*/) const
417 {
419 }
420 
422 {
424  return 0;
425 }
426 
428  Int4 /*value*/) const
429 {
431 }
432 
434 {
436  return 0;
437 }
438 
440  Uint4 /*value*/) const
441 {
443 }
444 
446 {
448  return 0;
449 }
450 
452  Int8 /*value*/) const
453 {
455 }
456 
458 {
460  return 0;
461 }
462 
464  Uint8 /*value*/) const
465 {
467 }
468 
470 {
472  return 0;
473 }
474 
476  double /*value*/) const
477 {
479 }
480 
481 #if SIZEOF_LONG_DOUBLE != 0
482 long double CPrimitiveTypeInfo::GetValueLDouble(TConstObjectPtr objectPtr) const
483 {
484  return GetValueDouble(objectPtr);
485 }
486 
487 void CPrimitiveTypeInfo::SetValueLDouble(TObjectPtr objectPtr,
488  long double value) const
489 {
490  // TODO:
491  // - remove conversion to double when CXX-5612 will be implemented
492  // - change ThrowIncompatibleValue() to _Overflow_
493 #if defined(DBL_MIN) && defined(DBL_MAX)
494  if ( value < DBL_MIN || value > DBL_MAX )
496 #endif
497  SetValueDouble(objectPtr, (double)value);
498 }
499 #endif
500 
502  string& /*value*/) const
503 {
505 }
506 
508  const string& /*value*/) const
509 {
511 }
512 
514  vector<char>& /*value*/) const
515 {
517 }
518 
520  const vector<char>& /*value*/)
521  const
522 {
524 }
525 
527  CBitString& /*value*/) const
528 {
530 }
532  const CBitString& /*value*/) const
533 {
535 }
536 
538  CAnyContentObject& /*value*/) const
539 {
541 }
542 
544  const CAnyContentObject& /*value*/)
545  const
546 {
548 }
549 
550 
553 {
557 }
558 
560 {
562 }
563 
565 {
567 }
568 
570 {
571  static TTypeInfo info = CreateTypeInfo();
572  return info;
573 }
574 
576 {
577  return new CPrimitiveTypeInfoBool();
578 }
579 
581 {
582 public:
583  static TObjectPtr Create(TTypeInfo /* type */,
584  CObjectMemoryPool* /*memoryPool*/)
585  {
586  NCBI_THROW(CSerialException,eIllegalCall,
587  "Cannot create NULL object");
588  return 0;
589  }
591  {
592  return false;
593  }
594  static void SetDefault(TObjectPtr)
595  {
596  }
597 
600  {
601  return true;
602  }
605  {
606  }
607 
608  static void Read(CObjectIStream& in, TTypeInfo ,
609  TObjectPtr /* object */)
610  {
611  in.ReadNull();
612  }
614  TConstObjectPtr /* object */)
615  {
616  out.WriteNull();
617  }
618  static void Copy(CObjectStreamCopier& copier, TTypeInfo )
619  {
620  copier.In().ReadNull();
621  copier.Out().WriteNull();
622  }
623  static void Skip(CObjectIStream& in, TTypeInfo )
624  {
625  in.SkipNull();
626  }
627 };
628 
630 {
631  static TTypeInfo info = CreateTypeInfoNullBool();
632  return info;
633 }
634 
636 {
638  typedef CNullBoolFunctions TFunctions;
639  info->SetMemFunctions(&TFunctions::Create, &TFunctions::IsDefault,
640  &TFunctions::SetDefault,&TFunctions::Equals,
641  &TFunctions::Assign);
642  info->SetIOFunctions(&TFunctions::Read, &TFunctions::Write,
643  &TFunctions::Copy, &TFunctions::Skip);
644  return info;
645 }
646 
649 {
652 }
653 
655 {
657 }
658 
660 {
662 }
663 
665  string& value) const
666 {
668 }
669 
671  const string& value) const
672 {
673  if ( value.size() != 1 )
676 }
677 
679 {
680  static TTypeInfo info = CreateTypeInfo();
681  return info;
682 }
683 
685 {
686  return new CPrimitiveTypeInfoChar();
687 }
688 
689 template<typename T>
691 {
693 public:
694  typedef T TObjectType;
695 
697  {
700 
701  info->SetMemFunctions(&CParent::Create,
703 
704  info->SetIOFunctions(&CParent::Read, &CParent::Write,
706 
709  return info;
710  }
711 
713  {
714  info->SetInt4Functions(&GetValueInt4, &SetValueInt4,
716  }
717 
719  {
720  info->SetInt8Functions(&GetValueInt8, &SetValueInt8,
722  }
723 
724  static bool IsDefault(TConstObjectPtr objectPtr)
725  {
726  return CParent::Get(objectPtr) == 0;
727  }
728  static void SetDefault(TObjectPtr objectPtr)
729  {
730  CParent::Get(objectPtr) = 0;
731  }
732  static bool Equals(TConstObjectPtr obj1, TConstObjectPtr obj2,
734  {
735  return CParent::Get(obj1) == CParent::Get(obj2);
736  }
737  static void Assign(TObjectPtr dst, TConstObjectPtr src,
739  {
740  CParent::Get(dst) = CParent::Get(src);
741  }
742 
743  static bool IsSigned(void)
744  {
745  return TObjectType(-1) < 0;
746  }
747  static bool IsUnsigned(void)
748  {
749  return TObjectType(-1) > 0;
750  }
751 
753  {
754  TObjectType value = CParent::Get(objectPtr);
755  Int4 result = Int4(value);
756  if ( IsUnsigned() ) {
757  // unsigned -> signed
758  if ( sizeof(value) == sizeof(result) ) {
759  // same size - check for sign change only
762  }
763  }
764  if ( sizeof(value) > sizeof(result) ) {
765  if ( value != TObjectType(result) )
767  }
768  return result;
769  }
771  {
772  TObjectType value = CParent::Get(objectPtr);
773  Uint4 result = Uint4(value);
774  if ( IsSigned() ) {
775  // signed -> unsigned
776  // check for negative value
777  if ( CParent::IsNegative(value) )
779  }
780  if ( sizeof(value) > sizeof(result) ) {
781  if ( value != TObjectType(result) )
783  }
784  return result;
785  }
786  static void SetValueInt4(TObjectPtr objectPtr, Int4 value)
787  {
789  if ( IsUnsigned() ) {
790  // signed -> unsigned
791  // check for negative value
792  if ( CParent::IsNegative(value) )
794  }
795  if ( sizeof(value) > sizeof(result) ) {
796  if ( value != Int4(result) )
798  }
799  CParent::Get(objectPtr) = result;
800  }
801  static void SetValueUint4(TObjectPtr objectPtr, Uint4 value)
802  {
804  if ( IsSigned() ) {
805  // unsigned -> signed
806  if ( sizeof(value) == sizeof(result) ) {
807  // same size - check for sign change only
810  }
811  }
812  if ( sizeof(value) > sizeof(result) ) {
813  if ( value != Uint4(result) )
815  }
816  CParent::Get(objectPtr) = result;
817  }
819  {
820  TObjectType value = CParent::Get(objectPtr);
821  Int8 result = Int8(value);
822  if ( IsUnsigned() ) {
823  // unsigned -> signed
824  if ( sizeof(value) == sizeof(result) ) {
825  // same size - check for sign change only
828  }
829  }
830  if ( sizeof(value) > sizeof(result) ) {
831  if ( value != TObjectType(result) )
833  }
834  return result;
835  }
837  {
838  TObjectType value = CParent::Get(objectPtr);
839  Uint8 result = Uint8(value);
840  if ( IsSigned() ) {
841  // signed -> unsigned
842  // check for negative value
843  if ( CParent::IsNegative(value) )
845  }
846  if ( sizeof(value) > sizeof(result) ) {
847  if ( value != TObjectType(result) )
849  }
850  return result;
851  }
852  static void SetValueInt8(TObjectPtr objectPtr, Int8 value)
853  {
855  if ( IsUnsigned() ) {
856  // signed -> unsigned
857  // check for negative value
858  if ( CParent::IsNegative(value) )
860  }
861  if ( sizeof(value) > sizeof(result) ) {
862  if ( value != Int8(result) )
864  }
865  CParent::Get(objectPtr) = result;
866  }
867  static void SetValueUint8(TObjectPtr objectPtr, Uint8 value)
868  {
870  if ( IsSigned() ) {
871  // unsigned -> signed
872  if ( sizeof(value) == sizeof(result) ) {
873  // same size - check for sign change only
876  }
877  }
878  if ( sizeof(value) > sizeof(result) ) {
879  if ( value != Uint8(result) )
881  }
882  CParent::Get(objectPtr) = result;
883  }
884 };
885 
887  : CParent(size, ePrimitiveValueInteger, isSigned)
888 {
890 }
891 
892 void CPrimitiveTypeInfoInt::SetInt4Functions(TGetInt4Function getInt4,
893  TSetInt4Function setInt4,
894  TGetUint4Function getUint4,
895  TSetUint4Function setUint4)
896 {
897  m_GetInt4 = getInt4;
898  m_SetInt4 = setInt4;
899  m_GetUint4 = getUint4;
900  m_SetUint4 = setUint4;
901 }
902 
903 void CPrimitiveTypeInfoInt::SetInt8Functions(TGetInt8Function getInt8,
904  TSetInt8Function setInt8,
905  TGetUint8Function getUint8,
906  TSetUint8Function setUint8)
907 {
908  m_GetInt8 = getInt8;
909  m_SetInt8 = setInt8;
910  m_GetUint8 = getUint8;
911  m_SetUint8 = setUint8;
912 }
913 
915 {
916  return m_GetInt4(objectPtr);
917 }
918 
920 {
921  return m_GetUint4(objectPtr);
922 }
923 
925  Int4 value) const
926 {
927  m_SetInt4(objectPtr, value);
928 }
929 
931  Uint4 value) const
932 {
933  m_SetUint4(objectPtr, value);
934 }
935 
937 {
938  return m_GetInt8(objectPtr);
939 }
940 
942 {
943  return m_GetUint8(objectPtr);
944 }
945 
947  Int8 value) const
948 {
949  m_SetInt8(objectPtr, value);
950 }
951 
953  Uint8 value) const
954 {
955  m_SetUint8(objectPtr, value);
956 }
957 
958 #define DECLARE_STD_INT_TYPE(Type) \
959 TTypeInfo CStdTypeInfo<Type>::GetTypeInfo(void) \
960 { \
961  static TTypeInfo info = CreateTypeInfo(); \
962  return info; \
963 } \
964 CTypeInfo* CStdTypeInfo<Type>::CreateTypeInfo(void) \
965 { \
966  return CPrimitiveTypeInfoIntFunctions<Type>::CreateTypeInfo(); \
967 }
968 
970 DECLARE_STD_INT_TYPE(unsigned char)
972 DECLARE_STD_INT_TYPE(unsigned short)
975 #ifndef NCBI_INT8_IS_LONG
977 DECLARE_STD_INT_TYPE(unsigned long)
978 #endif
981 
982 const CPrimitiveTypeInfo* CPrimitiveTypeInfo::GetIntegerTypeInfo(size_t size,
983  bool sign)
984 {
985  TTypeInfo info;
986  if ( size == sizeof(int) ) {
987  if ( sign )
989  else
991  }
992  else if ( size == sizeof(short) ) {
993  if ( sign )
995  else
997  }
998  else if ( size == sizeof(signed char) ) {
999  if ( sign )
1001  else
1003  }
1004  else if ( size == sizeof(Int8) ) {
1005  if ( sign )
1007  else
1009  }
1010  else {
1011  string message("Illegal enum size: ");
1012  message += NStr::SizetToString(size);
1013  NCBI_THROW(CSerialException,eInvalidData, message);
1014  }
1015  _ASSERT(info->GetSize() == size);
1016  _ASSERT(info->GetTypeFamily() == eTypeFamilyPrimitive);
1019 }
1020 
1023 {
1027 }
1028 
1030 {
1032 }
1033 
1035  double value) const
1036 {
1038 }
1039 
1041 {
1042  static TTypeInfo info = CreateTypeInfo();
1043  return info;
1044 }
1045 
1047 {
1048  return new CPrimitiveTypeInfoDouble();
1049 }
1050 
1053 {
1057 }
1058 
1060 {
1062 }
1063 
1065  double value) const
1066 {
1067 #if defined(FLT_MIN) && defined(FLT_MAX)
1068  if ( value < FLT_MIN || value > FLT_MAX )
1069  // TODO: change ThrowIncompatibleValue() to _Overflow_
1071 #endif
1073 }
1074 
1076 {
1077  static TTypeInfo info = CreateTypeInfo();
1078  return info;
1079 }
1080 
1082 {
1083  return new CPrimitiveTypeInfoFloat();
1084 }
1085 
1086 #if SIZEOF_LONG_DOUBLE != 0
1087 CPrimitiveTypeInfoLongDouble::CPrimitiveTypeInfoLongDouble(void)
1088  : CParent(sizeof(TObjectType), ePrimitiveValueReal, true)
1089 {
1090  SetTag(CAsnBinaryDefs::eReal);
1093 }
1094 
1095 double CPrimitiveTypeInfoLongDouble::GetValueDouble(TConstObjectPtr objectPtr) const
1096 {
1097  // TODO: remove conversion to double when CXX-5612 will be implemented
1098  return (double)CPrimitiveTypeFunctions<TObjectType>::Get(objectPtr);
1099 }
1100 
1101 void CPrimitiveTypeInfoLongDouble::SetValueDouble(TObjectPtr objectPtr,
1102  double value) const
1103 {
1104  CPrimitiveTypeFunctions<TObjectType>::Get(objectPtr) = TObjectType(value);
1105 }
1106 
1107 long double CPrimitiveTypeInfoLongDouble::GetValueLDouble(TConstObjectPtr objectPtr) const
1108 {
1110 }
1111 
1112 void CPrimitiveTypeInfoLongDouble::SetValueLDouble(TObjectPtr objectPtr,
1113  long double value) const
1114 {
1115  CPrimitiveTypeFunctions<TObjectType>::Get(objectPtr) = TObjectType(value);
1116 }
1117 
1119 {
1120  static TTypeInfo info = CreateTypeInfo();
1121  return info;
1122 }
1123 
1125 {
1126  return new CPrimitiveTypeInfoLongDouble();
1127 }
1128 #endif
1129 
1130 template<typename T>
1132 {
1134 public:
1135  static TObjectPtr Create(TTypeInfo /*typeInfo*/,
1136  CObjectMemoryPool* /*memoryPool*/)
1137  {
1138  return new T();
1139  }
1140  static bool IsDefault(TConstObjectPtr objectPtr)
1141  {
1142  return CParent::Get(objectPtr).empty();
1143  }
1144  static void SetDefault(TObjectPtr objectPtr)
1145  {
1146  CParent::Get(objectPtr).erase();
1147  }
1148  static void Read(CObjectIStream& in,
1149  TTypeInfo , TObjectPtr objectPtr)
1150  {
1151  in.ReadStd(CParent::Get(objectPtr));
1152  }
1153  static void Write(CObjectOStream& out,
1154  TTypeInfo , TConstObjectPtr objectPtr)
1155  {
1156  out.WriteStd(CParent::Get(objectPtr));
1157  }
1158  static void Copy(CObjectStreamCopier& copier, TTypeInfo )
1159  {
1160  copier.CopyString();
1161  }
1163  {
1164  in.SkipString();
1165  }
1166 };
1167 
1170  TTypeInfo , TObjectPtr objectPtr)
1171  {
1172  in.ReadString( CTypeConverter<CStringUTF8>::Get(objectPtr), eStringTypeUTF8);
1173  }
1176  TTypeInfo , TConstObjectPtr objectPtr)
1177  {
1178  out.WriteString( CTypeConverter<CStringUTF8>::Get(objectPtr), eStringTypeUTF8);
1179  }
1180 
1183  TTypeInfo )
1184 {
1185  copier.CopyString(eStringTypeUTF8);
1186 }
1187 
1190 {
1191  in.SkipString(eStringTypeUTF8);
1192 }
1193 
1194 
1196  : CParent(sizeof(string), ePrimitiveValueString), m_Type(type)
1197 {
1198  if (type == eStringTypeUTF8) {
1209  } else {
1220  }
1221 }
1222 
1224  string& value) const
1225 {
1227 }
1228 
1230  const string& value) const
1231 {
1233 }
1234 
1236 {
1237  if ( CPrimitiveTypeFunctions<TObjectType>::Get(object).size() != 1 )
1240 }
1241 
1243  char value) const
1244 {
1246 }
1247 
1249 {
1250  return this == type || type == CStdTypeInfo<string>::GetTypeInfo();
1251 // || type == CStdTypeInfo<ncbi::utf8_string_type>::GetTypeInfo();
1252 }
1253 
1255 {
1256  static TTypeInfo info = CreateTypeInfo();
1257  return info;
1258 }
1259 
1261 {
1262  return new CPrimitiveTypeInfoString();
1263 }
1264 
1266 {
1267  static TTypeInfo info = CreateTypeInfo();
1268  return info;
1269 }
1270 
1272 {
1274 }
1275 
1276 template<typename T>
1278 {
1280 public:
1282  {
1284  info->SetIOFunctions(&CParent::Read,
1287  &CParent::Skip);
1288  return info;
1289  }
1290  static void Write(CObjectOStream& out,
1291  TTypeInfo , TConstObjectPtr objectPtr)
1292  {
1293  out.SetSpecialCaseWrite( CObjectOStream::eWriteAsBigInt);
1294  out.WriteStd(CParent::Get(objectPtr));
1295  out.SetSpecialCaseWrite( CObjectOStream::eWriteAsNormal);
1296  }
1297  static void Copy(CObjectStreamCopier& copier, TTypeInfo )
1298  {
1299  typename CParent::TObjectType data;
1300  copier.In().ReadStd(data);
1303  copier.Out().WriteStd(data);
1305  }
1306 };
1307 
1309 {
1310  static TTypeInfo info = CreateTypeInfo();
1311  return info;
1312 }
1313 
1315 {
1317 }
1318 
1320 {
1321 public:
1322  static void Read(CObjectIStream& in, TTypeInfo , TObjectPtr objectPtr)
1323  {
1324  in.ReadStringStore(Get(objectPtr));
1325  }
1327  TConstObjectPtr objectPtr)
1328  {
1329  out.WriteStringStore(Get(objectPtr));
1330  }
1331  static void Copy(CObjectStreamCopier& copier, TTypeInfo )
1332  {
1333  copier.CopyStringStore();
1334  }
1336  {
1337  in.SkipStringStore();
1338  }
1339 };
1340 
1342 {
1343  static TTypeInfo info = CreateTypeInfoStringStore();
1344  return info;
1345 }
1346 
1348 {
1351  typedef CStringStoreFunctions TFunctions;
1352  info->SetIOFunctions(&TFunctions::Read, &TFunctions::Write,
1353  &TFunctions::Copy, &TFunctions::Skip);
1354  return info;
1355 }
1356 
1358 {
1360 }
1361 
1362 template<typename T>
1364 {
1366 public:
1367  static bool IsDefault(TConstObjectPtr objectPtr)
1368  {
1369  return CParent::Get(objectPtr) == 0;
1370  }
1371  static void SetDefault(TObjectPtr dst)
1372  {
1373  free(const_cast<char*>(CParent::Get(dst)));
1374  CParent::Get(dst) = 0;
1375  }
1376  static bool Equals(TConstObjectPtr object1, TConstObjectPtr object2,
1378  {
1379  return strcmp(CParent::Get(object1), CParent::Get(object2)) == 0;
1380  }
1381  static void Assign(TObjectPtr dst, TConstObjectPtr src,
1383  {
1385  = CParent::Get(src);
1386  _ASSERT(CParent::Get(dst) != value);
1387  free(const_cast<char*>(CParent::Get(dst)));
1388  if ( value )
1390  else
1391  CParent::Get(dst) = 0;
1392  }
1393 };
1394 
1395 template<typename T>
1398 {
1399  typedef CCharPtrFunctions<TObjectType> TFunctions;
1401  &TFunctions::IsDefault, &TFunctions::SetDefault,
1402  &TFunctions::Equals, &TFunctions::Assign);
1404  &TFunctions::Copy, &TFunctions::Skip);
1405 }
1406 
1407 template<typename T>
1409 {
1411  if ( !obj || obj[0] == '\0' || obj[1] != '\0' )
1413  return obj[0];
1414 }
1415 
1416 template<typename T>
1418  char value) const
1419 {
1420  char* obj = static_cast<char*>(NotNull(malloc(2)));
1421  obj[0] = value;
1422  obj[1] = '\0';
1423  CCharPtrFunctions<TObjectPtr>::Get(objectPtr) = obj;
1424 }
1425 
1426 template<typename T>
1428  string& value) const
1429 {
1431 }
1432 
1433 template<typename T>
1435  const string& value) const
1436 {
1438  NotNull(NcbiSysChar_strdup(value.c_str()));
1439 }
1440 
1442 {
1443  static TTypeInfo info = CreateTypeInfo();
1444  return info;
1445 }
1446 
1448 {
1449  return new CPrimitiveTypeInfoCharPtr<char*>();
1450 }
1451 
1453 {
1454  static TTypeInfo info = CreateTypeInfo();
1455  return info;
1456 }
1457 
1459 {
1461 }
1462 
1464 {
1465  NCBI_THROW(CSerialException,eInvalidData, "incompatible value");
1466 }
1467 
1469 {
1470  NCBI_THROW(CSerialException,eIllegalCall, "illegal call");
1471 }
1472 
1474 {
1475  NCBI_THROW(CSerialException,eOverflow, "integer overflow");
1476 }
1477 
1479 {
1480 public:
1481  static void Copy(CObjectStreamCopier& copier,
1482  TTypeInfo )
1483  {
1484  copier.CopyByteBlock();
1485  }
1487  {
1488  in.SkipByteBlock();
1489  }
1490 };
1491 
1492 template<typename Char>
1494 {
1495 public:
1496  typedef vector<Char> TObjectType;
1497  typedef Char TChar;
1498 
1499  static TObjectType& Get(TObjectPtr object)
1500  {
1501  return CTypeConverter<TObjectType>::Get(object);
1502  }
1503  static const TObjectType& Get(TConstObjectPtr object)
1504  {
1505  return CTypeConverter<TObjectType>::Get(object);
1506  }
1507 
1508  static char* ToChar(TChar* p)
1509  { return reinterpret_cast<char*>(p); }
1510  static const char* ToChar(const TChar* p)
1511  { return reinterpret_cast<const char*>(p); }
1512  static const TChar* ToTChar(const char* p)
1513  { return reinterpret_cast<const TChar*>(p); }
1514 
1515  static TObjectPtr Create(TTypeInfo /*typeInfo*/,
1516  CObjectMemoryPool* /*memoryPool*/)
1517  {
1518  return new TObjectType();
1519  }
1520  static bool IsDefault(TConstObjectPtr object)
1521  {
1522  return Get(object).empty();
1523  }
1524  static bool Equals(TConstObjectPtr object1, TConstObjectPtr object2,
1526  {
1527  return Get(object1) == Get(object2);
1528  }
1529  static void SetDefault(TObjectPtr dst)
1530  {
1531  Get(dst).clear();
1532  }
1533  static void Assign(TObjectPtr dst, TConstObjectPtr src,
1535  {
1536  Get(dst) = Get(src);
1537  }
1538 
1539  static void Read(CObjectIStream& in,
1540  TTypeInfo , TObjectPtr objectPtr)
1541  {
1542  TObjectType& o = Get(objectPtr);
1544  if ( block.KnownLength() ) {
1545  size_t length = block.GetExpectedLength();
1546 #if 1
1547  o.clear();
1548  o.reserve(length);
1549  Char buf[2048];
1550  size_t count;
1551  while ( (count = block.Read(ToChar(buf), sizeof(buf))) != 0 ) {
1552  o.insert(o.end(), buf, buf + count);
1553  }
1554 #else
1555  o.resize(length);
1556  block.Read(ToChar(&o.front()), length, true);
1557 #endif
1558  }
1559  else {
1560  // length is unknown -> copy via buffer
1561  o.clear();
1562  Char buf[4096];
1563  size_t count;
1564  while ( (count = block.Read(ToChar(buf), sizeof(buf))) != 0 ) {
1565 #ifdef RESERVE_VECTOR_SIZE
1566  size_t new_size = o.size() + count;
1567  if ( new_size > o.capacity() ) {
1568  o.reserve(RESERVE_VECTOR_SIZE(new_size));
1569  }
1570 #endif
1571  o.insert(o.end(), buf, buf + count);
1572  }
1573  }
1574  block.End();
1575  }
1576  static void Write(CObjectOStream& out,
1577  TTypeInfo , TConstObjectPtr objectPtr)
1578  {
1579  const TObjectType& o = Get(objectPtr);
1580  size_t length = o.size();
1581  CObjectOStream::ByteBlock block(out, length);
1582  if ( length > 0 )
1583  block.Write(ToChar(&o.front()), length);
1584  block.End();
1585  }
1586 };
1587 
1588 template<typename Char>
1591 {
1592  typedef CCharVectorFunctions<Char> TFunctions;
1594  SetMemFunctions(&TFunctions::Create,
1595  &TFunctions::IsDefault, &TFunctions::SetDefault,
1596  &TFunctions::Equals, &TFunctions::Assign);
1598  &TFunctions::Copy, &TFunctions::Skip);
1599 }
1600 
1601 template<typename Char>
1603  string& value) const
1604 {
1605  const TObjectType& obj = CCharVectorFunctions<TChar>::Get(objectPtr);
1606  if (!obj.empty()) {
1607  const char* buffer = CCharVectorFunctions<TChar>::ToChar(&obj.front());
1608  value.assign(buffer, buffer + obj.size());
1609  }
1610 }
1611 
1612 template<typename Char>
1614  const string& value) const
1615 {
1617  obj.clear();
1618  if (!value.empty()) {
1620  obj.insert(obj.end(), buffer, buffer + value.size());
1621  }
1622 }
1623 
1624 template<typename Char>
1626  vector<char>& value) const
1627 {
1628  const TObjectType& obj = CCharVectorFunctions<TChar>::Get(objectPtr);
1629  value.clear();
1630  if (!obj.empty()) {
1631  const char* buffer = CCharVectorFunctions<TChar>::ToChar(&obj.front());
1632  value.insert(value.end(), buffer, buffer + obj.size());
1633  }
1634 }
1635 
1636 template<typename Char>
1638  const vector<char>& value) const
1639 {
1641  obj.clear();
1642  if (!value.empty()) {
1644  obj.insert(obj.end(), buffer, buffer + value.size());
1645  }
1646 }
1647 
1649 {
1650  static TTypeInfo typeInfo = CreateTypeInfo();
1651  return typeInfo;
1652 }
1653 
1655 {
1656  static TTypeInfo typeInfo = CreateTypeInfo();
1657  return typeInfo;
1658 }
1659 
1661 {
1662  static TTypeInfo typeInfo = CreateTypeInfo();
1663  return typeInfo;
1664 }
1665 
1666 CTypeInfo* CStdTypeInfo< vector<char> >::CreateTypeInfo(void)
1667 {
1668  return new CCharVectorTypeInfo<char>;
1669 }
1670 
1672 {
1674 }
1675 
1677 {
1679 }
1680 
1681 
1682 class CAnyContentFunctions : public CPrimitiveTypeFunctions<ncbi::CAnyContentObject>
1683 {
1684 public:
1685  static TObjectPtr Create(TTypeInfo /*typeInfo*/,
1686  CObjectMemoryPool* /*memoryPool*/)
1687  {
1688  return new TObjectType();
1689  }
1690  static bool IsDefault(TConstObjectPtr objectPtr)
1691  {
1692  return Get(objectPtr) == TObjectType();
1693  }
1694  static void SetDefault(TObjectPtr objectPtr)
1695  {
1696  Get(objectPtr) = TObjectType();
1697  }
1698  static void Read(CObjectIStream& in, TTypeInfo , TObjectPtr objectPtr)
1699  {
1700  in.ReadAnyContentObject(Get(objectPtr));
1701  }
1703  TConstObjectPtr objectPtr)
1704  {
1705  out.WriteAnyContentObject(Get(objectPtr));
1706  }
1707  static void Copy(CObjectStreamCopier& copier, TTypeInfo )
1708  {
1709  copier.CopyAnyContentObject();
1710  }
1712  {
1713  in.SkipAnyContentObject();
1714  }
1715 };
1716 
1719 {
1720  m_IsCObject = true;
1725  &TFunctions::Equals, &TFunctions::Assign);
1730 }
1731 
1733 {
1734  static TTypeInfo info = CreateTypeInfo();
1735  return info;
1736 }
1737 
1739 {
1740  return new CPrimitiveTypeInfoAnyContent();
1741 }
1742 
1743 void
1746  const
1747 {
1749  value = TFunctions::Get(objectPtr);
1750 }
1751 
1752 void
1754  const CAnyContentObject& value)
1755  const
1756 {
1758  TFunctions::Get(objectPtr) = value;
1759 }
1760 
1761 
1763 {
1764 public:
1765  static TObjectPtr Create(TTypeInfo /*typeInfo*/,
1766  CObjectMemoryPool* /*memoryPool*/)
1767  {
1768  return new TObjectType();
1769  }
1770  static bool IsDefault(TConstObjectPtr objectPtr)
1771  {
1772  return Get(objectPtr) == TObjectType();
1773  }
1774  static void SetDefault(TObjectPtr objectPtr)
1775  {
1776  Get(objectPtr) = TObjectType();
1777  }
1778 };
1779 
1782 {
1783  typedef CPrimitiveTypeFunctions<ncbi::CBitString> TFunctions;
1789  &TFunctions::Assign);
1792  &TFunctions::Copy,
1793  &TFunctions::Skip);
1794 // CPrimitiveTypeFunctions<CBitString>::SetMemFunctions(this);
1795 // CPrimitiveTypeFunctions<CBitString>::SetIOFunctions(this);
1796 }
1797 
1799 {
1800  static TTypeInfo info = CreateTypeInfo();
1801  return info;
1802 }
1803 
1805 {
1806  return new CPrimitiveTypeInfoBitString();
1807 }
1808 
1810  CBitString& value) const
1811 {
1812  typedef CPrimitiveTypeFunctions<ncbi::CBitString> TFunctions;
1813  value = TFunctions::Get(objectPtr);
1814 }
1815 
1817  const CBitString& value)
1818  const
1819 {
1820  typedef CPrimitiveTypeFunctions<ncbi::CBitString> TFunctions;
1821  TFunctions::Get(objectPtr) = value;
1822 }
1823 
1824 
static void Skip(CObjectIStream &in, TTypeInfo)
Definition: stdtypes.cpp:1711
static TObjectPtr Create(TTypeInfo, CObjectMemoryPool *)
Definition: stdtypes.cpp:1685
static bool IsDefault(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:1690
static void Copy(CObjectStreamCopier &copier, TTypeInfo)
Definition: stdtypes.cpp:1707
static void SetDefault(TObjectPtr objectPtr)
Definition: stdtypes.cpp:1694
static void Read(CObjectIStream &in, TTypeInfo, TObjectPtr objectPtr)
Definition: stdtypes.cpp:1698
static void Write(CObjectOStream &out, TTypeInfo, TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:1702
Serializable object that stores any combination of parsable data.
Definition: serialbase.hpp:264
static TObjectPtr Create(TTypeInfo, CObjectMemoryPool *)
Definition: stdtypes.cpp:1765
static bool IsDefault(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:1770
static void SetDefault(TObjectPtr objectPtr)
Definition: stdtypes.cpp:1774
CPrimitiveTypeFunctions< T > CParent
Definition: stdtypes.cpp:1365
static void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode)
Definition: stdtypes.cpp:1381
static bool Equals(TConstObjectPtr object1, TConstObjectPtr object2, ESerialRecursionMode)
Definition: stdtypes.cpp:1376
static bool IsDefault(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:1367
static void SetDefault(TObjectPtr dst)
Definition: stdtypes.cpp:1371
static void Copy(CObjectStreamCopier &copier, TTypeInfo)
Definition: stdtypes.cpp:1481
static void Skip(CObjectIStream &in, TTypeInfo)
Definition: stdtypes.cpp:1486
static bool Equals(TConstObjectPtr object1, TConstObjectPtr object2, ESerialRecursionMode)
Definition: stdtypes.cpp:1524
static void SetDefault(TObjectPtr dst)
Definition: stdtypes.cpp:1529
static TObjectType & Get(TObjectPtr object)
Definition: stdtypes.cpp:1499
static const TObjectType & Get(TConstObjectPtr object)
Definition: stdtypes.cpp:1503
static TObjectPtr Create(TTypeInfo, CObjectMemoryPool *)
Definition: stdtypes.cpp:1515
static void Write(CObjectOStream &out, TTypeInfo, TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:1576
static char * ToChar(TChar *p)
Definition: stdtypes.cpp:1508
vector< Char > TObjectType
Definition: stdtypes.cpp:1496
static const TChar * ToTChar(const char *p)
Definition: stdtypes.cpp:1512
static void Read(CObjectIStream &in, TTypeInfo, TObjectPtr objectPtr)
Definition: stdtypes.cpp:1539
static bool IsDefault(TConstObjectPtr object)
Definition: stdtypes.cpp:1520
static const char * ToChar(const TChar *p)
Definition: stdtypes.cpp:1510
static void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode)
Definition: stdtypes.cpp:1533
static void Write(CObjectOStream &out, TTypeInfo, TConstObjectPtr)
Definition: stdtypes.cpp:613
static void Assign(TObjectPtr, TConstObjectPtr, ESerialRecursionMode)
Definition: stdtypes.cpp:603
static TObjectPtr Create(TTypeInfo, CObjectMemoryPool *)
Definition: stdtypes.cpp:583
static void Read(CObjectIStream &in, TTypeInfo, TObjectPtr)
Definition: stdtypes.cpp:608
static void SetDefault(TObjectPtr)
Definition: stdtypes.cpp:594
static bool IsDefault(TConstObjectPtr)
Definition: stdtypes.cpp:590
static bool Equals(TConstObjectPtr, TConstObjectPtr, ESerialRecursionMode)
Definition: stdtypes.cpp:598
static void Skip(CObjectIStream &in, TTypeInfo)
Definition: stdtypes.cpp:623
static void Copy(CObjectStreamCopier &copier, TTypeInfo)
Definition: stdtypes.cpp:618
CObjectIStream –.
Definition: objistr.hpp:93
CObjectOStream –.
Definition: objostr.hpp:83
CObjectStreamCopier –.
Definition: objcopy.hpp:71
static bool IsNegative(Uint4)
Definition: stdtypes.cpp:57
static bool IsNegative(Int4 value)
Definition: stdtypes.cpp:53
static bool IsNegative(long value)
Definition: stdtypes.cpp:63
static bool IsNegative(Int8 value)
Definition: stdtypes.cpp:72
static bool IsNegative(unsigned long)
Definition: stdtypes.cpp:67
static bool IsNegative(Uint8)
Definition: stdtypes.cpp:76
static void SetMemFunctions(CPrimitiveTypeInfo *info)
Definition: stdtypes.cpp:102
static void Write(CObjectOStream &out, TTypeInfo, TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:139
static TObjectPtr Create(TTypeInfo, CObjectMemoryPool *)
Definition: stdtypes.cpp:109
static TObjectType & Get(TObjectPtr object)
Definition: stdtypes.cpp:88
static const TObjectType & Get(TConstObjectPtr object)
Definition: stdtypes.cpp:92
static bool Equals(TConstObjectPtr obj1, TConstObjectPtr obj2, ESerialRecursionMode)
Definition: stdtypes.cpp:123
static void Copy(CObjectStreamCopier &copier, TTypeInfo)
Definition: stdtypes.cpp:149
static bool IsDefault(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:114
static void Read(CObjectIStream &in, TTypeInfo, TObjectPtr objectPtr)
Definition: stdtypes.cpp:134
static void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode)
Definition: stdtypes.cpp:128
static void SetIOFunctions(CPrimitiveTypeInfo *info)
Definition: stdtypes.cpp:97
static void SetDefault(TObjectPtr objectPtr)
Definition: stdtypes.cpp:118
static void Skip(CObjectIStream &in, TTypeInfo)
Definition: stdtypes.cpp:144
static void Write(CObjectOStream &out, TTypeInfo, TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:1290
static void Copy(CObjectStreamCopier &copier, TTypeInfo)
Definition: stdtypes.cpp:1297
static CPrimitiveTypeInfoInt * CreateTypeInfo(void)
Definition: stdtypes.cpp:1281
CPrimitiveTypeInfoIntFunctions< T > CParent
Definition: stdtypes.cpp:1279
static void SetInt4Functions(CPrimitiveTypeInfoInt *info)
Definition: stdtypes.cpp:712
static CPrimitiveTypeInfoInt * CreateTypeInfo(void)
Definition: stdtypes.cpp:696
static void SetValueUint8(TObjectPtr objectPtr, Uint8 value)
Definition: stdtypes.cpp:867
static bool IsSigned(void)
Definition: stdtypes.cpp:743
static Uint8 GetValueUint8(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:836
static Int8 GetValueInt8(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:818
static Int4 GetValueInt4(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:752
static void SetValueInt4(TObjectPtr objectPtr, Int4 value)
Definition: stdtypes.cpp:786
static void SetValueUint4(TObjectPtr objectPtr, Uint4 value)
Definition: stdtypes.cpp:801
static bool Equals(TConstObjectPtr obj1, TConstObjectPtr obj2, ESerialRecursionMode)
Definition: stdtypes.cpp:732
CPrimitiveTypeFunctions< T > CParent
Definition: stdtypes.cpp:692
static void SetInt8Functions(CPrimitiveTypeInfoInt *info)
Definition: stdtypes.cpp:718
static void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode)
Definition: stdtypes.cpp:737
static bool IsDefault(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:724
static void SetValueInt8(TObjectPtr objectPtr, Int8 value)
Definition: stdtypes.cpp:852
static void SetDefault(TObjectPtr objectPtr)
Definition: stdtypes.cpp:728
static Uint4 GetValueUint4(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:770
static bool IsUnsigned(void)
Definition: stdtypes.cpp:747
Root class for all serialization exceptions.
Definition: exception.hpp:50
static bool IsDefault(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:1140
CPrimitiveTypeFunctions< T > CParent
Definition: stdtypes.cpp:1133
static void Skip(CObjectIStream &in, TTypeInfo)
Definition: stdtypes.cpp:1162
static void Copy(CObjectStreamCopier &copier, TTypeInfo)
Definition: stdtypes.cpp:1158
static void SetDefault(TObjectPtr objectPtr)
Definition: stdtypes.cpp:1144
static void Write(CObjectOStream &out, TTypeInfo, TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:1153
static void Read(CObjectIStream &in, TTypeInfo, TObjectPtr objectPtr)
Definition: stdtypes.cpp:1148
static TObjectPtr Create(TTypeInfo, CObjectMemoryPool *)
Definition: stdtypes.cpp:1135
static void Write(CObjectOStream &out, TTypeInfo, TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:1326
static void Skip(CObjectIStream &in, TTypeInfo)
Definition: stdtypes.cpp:1335
static void Read(CObjectIStream &in, TTypeInfo, TObjectPtr objectPtr)
Definition: stdtypes.cpp:1322
static void Copy(CObjectStreamCopier &copier, TTypeInfo)
Definition: stdtypes.cpp:1331
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
#define T(s)
Definition: common.h:230
std::ofstream out("events_result.xml")
main entry point for tests
#define true
Definition: bool.h:35
char data[12]
Definition: iconv.c:80
string
Definition: cgiapp.hpp:690
#define isnan
Definition: ncbifloat.h:92
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
const CVect2< U > & v2
Definition: globals.hpp:440
ESerialRecursionMode
How to assign and compare child sub-objects of serial objects.
Definition: serialdef.hpp:191
static TObjectType & Get(TObjectPtr object)
Definition: serialutil.hpp:56
void * TObjectPtr
Definition: serialdef.hpp:55
const void * TConstObjectPtr
Definition: serialdef.hpp:59
void Read(CObjectIStream &in, TObjectPtr object, const CTypeRef &type)
Definition: serial.cpp:60
EPrimitiveValueType
Primitive value type.
Definition: serialdef.hpp:147
void Write(CObjectOStream &out, TConstObjectPtr object, const CTypeRef &type)
Definition: serial.cpp:55
static const TObjectType * SafeCast(TTypeInfo type)
Definition: serialutil.hpp:76
@ ePrimitiveValueSpecial
null, void
Definition: serialdef.hpp:148
@ ePrimitiveValueOctetString
vector<(signed|unsigned)? char>
Definition: serialdef.hpp:155
@ ePrimitiveValueString
string|char*|const char*
Definition: serialdef.hpp:153
@ ePrimitiveValueInteger
(signed|unsigned) (char|short|int|long)
Definition: serialdef.hpp:151
@ ePrimitiveValueAny
Definition: serialdef.hpp:160
@ ePrimitiveValueChar
char
Definition: serialdef.hpp:150
@ ePrimitiveValueBool
bool
Definition: serialdef.hpp:149
@ ePrimitiveValueReal
float|double
Definition: serialdef.hpp:152
@ ePrimitiveValueBitString
Definition: serialdef.hpp:156
@ eTypeFamilyPrimitive
Definition: serialdef.hpp:139
@ eStringTypeUTF8
UTF8-encoded string.
Definition: serialdef.hpp:187
void(* TTypeWriteFunction)(CObjectOStream &out, const CTypeInfo *objectType, TConstObjectPtr objectPtr)
Definition: hookfunc.hpp:57
void(* TTypeCopyFunction)(CObjectStreamCopier &copier, const CTypeInfo *objectType)
Definition: hookfunc.hpp:60
void(* TTypeReadFunction)(CObjectIStream &in, const CTypeInfo *objectType, TObjectPtr objectPtr)
Definition: hookfunc.hpp:54
void(* TTypeSkipFunction)(CObjectIStream &in, const CTypeInfo *objectType)
Definition: hookfunc.hpp:62
void WriteStd(const bool &data)
void CopyStringStore(void)
virtual void ReadNull(void)=0
void ReadStd(bool &data)
void SetSpecialCaseUsed(ESpecialCaseRead used)
Definition: objistr.hpp:1136
void Write(const void *bytes, size_t length)
bool KnownLength(void) const
void CopyByteBlock(void)
Definition: objcopy.cpp:191
size_t GetExpectedLength(void) const
void CopyString(EStringType type=eStringTypeVisible)
CObjectIStream & In(void) const
void CopyAnyContentObject(void)
CObjectOStream & Out(void) const
virtual void WriteNull(void)=0
ESpecialCaseRead GetSpecialCaseUsed(void) const
Definition: objistr.hpp:1140
size_t Read(void *dst, size_t length, bool forceLength=false)
Definition: objistr.cpp:1576
void SetSpecialCaseWrite(ESpecialCaseWrite how)
Definition: objostr.hpp:763
@ fIllegalCall
Illegal in a given context function call.
Definition: objistr.hpp:383
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
char Char
Alias for char.
Definition: ncbitype.h:93
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define EMPTY_TEMPLATE
Definition: ncbistl.hpp:159
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
Definition: ncbistr.cpp:2742
TGetUint8Function m_GetUint8
TGetInt4Function m_GetInt4
virtual Uint8 GetValueUint8(TConstObjectPtr objectPtr) const override
Definition: stdtypes.cpp:941
void SetWriteFunction(TTypeWriteFunction func)
Definition: typeinfo.cpp:487
const string & GetName(void) const
Get name of this type.
Definition: typeinfo.cpp:249
TGetInt8Function m_GetInt8
virtual void SetValueString(TObjectPtr objectPtr, const string &value) const override
Definition: stdtypes.cpp:1613
TSetUint4Function m_SetUint4
virtual bool IsDefault(TConstObjectPtr object) const override
Check, whether the object contains default value.
Definition: stdtypes.cpp:383
virtual Uint4 GetValueUint4(TConstObjectPtr objectPtr) const
Definition: stdtypes.cpp:433
virtual bool Equals(TConstObjectPtr, TConstObjectPtr, ESerialRecursionMode how=eRecursive) const override
Check if both objects contain the same values.
Definition: stdtypes.cpp:393
virtual void GetValueAnyContent(TConstObjectPtr objectPtr, CAnyContentObject &value) const override
Definition: stdtypes.cpp:1744
TEqualsFunction m_Equals
Definition: stdtypes.hpp:149
virtual void SetValueBool(TObjectPtr object, bool value) const override
Definition: stdtypes.cpp:564
virtual void GetValueAnyContent(TConstObjectPtr objectPtr, CAnyContentObject &value) const
Definition: stdtypes.cpp:537
static bool Equals(TConstObjectPtr obj1, TConstObjectPtr obj2, ESerialRecursionMode how=eRecursive)
Definition: stdtypes.cpp:262
virtual void SetDefault(TObjectPtr dst) const override
Set object to default value.
Definition: stdtypes.cpp:388
virtual void GetValueString(TConstObjectPtr object, string &value) const override
Definition: stdtypes.cpp:664
static TObjectPtr Create(TTypeInfo objectType, CObjectMemoryPool *memPool)
Definition: stdtypes.cpp:304
virtual Uint4 GetValueUint4(TConstObjectPtr objectPtr) const override
Definition: stdtypes.cpp:919
virtual void SetValueInt8(TObjectPtr objectPtr, Int8 value) const
Definition: stdtypes.cpp:451
TIsDefaultFunction m_IsDefault
Definition: stdtypes.hpp:147
virtual void SetValueInt4(TObjectPtr objectPtr, Int4 value) const
Definition: stdtypes.cpp:427
virtual CTypeInfo * SetTag(CAsnBinaryDefs::TLongTag tag, CAsnBinaryDefs::ETagClass tagclass=CAsnBinaryDefs::eUniversal, CAsnBinaryDefs::ETagType tagtype=CAsnBinaryDefs::eAutomatic)
Definition: typeinfo.cpp:172
virtual void SetValueChar(TObjectPtr objectPtr, char value) const override
Definition: stdtypes.cpp:1242
virtual void GetValueString(TConstObjectPtr objectPtr, string &value) const
Definition: stdtypes.cpp:501
void SetMemFunctions(TTypeCreate, TIsDefaultFunction, TSetDefaultFunction, TEqualsFunction, TAssignFunction)
Definition: stdtypes.cpp:353
virtual void SetValueBool(TObjectPtr objectPtr, bool value) const
Definition: stdtypes.cpp:405
virtual bool IsType(TTypeInfo type) const override
Definition: stdtypes.cpp:1248
virtual Int4 GetValueInt4(TConstObjectPtr objectPtr) const
Definition: stdtypes.cpp:421
CPrimitiveTypeInfo(size_t size, EPrimitiveValueType valueType, bool isSigned=true)
Definition: stdtypes.cpp:316
CVoidTypeInfo(void)
Definition: stdtypes.cpp:311
void ThrowIncompatibleValue(void)
Definition: stdtypes.cpp:1463
virtual void SetValueOctetString(TObjectPtr objectPtr, const vector< char > &value) const
Definition: stdtypes.cpp:519
virtual void SetValueUint4(TObjectPtr objectPtr, Uint4 value) const override
Definition: stdtypes.cpp:930
TTypeReadFunction GetReadFunction(void) const
Definition: typeinfo.cpp:482
TSetUint8Function m_SetUint8
bool m_IsCObject
Definition: typeinfo.hpp:304
TSetInt8Function m_SetInt8
virtual void SetValueInt8(TObjectPtr objectPtr, Int8 value) const override
Definition: stdtypes.cpp:946
virtual void SetValueOctetString(TObjectPtr objectPtr, const vector< char > &value) const override
Definition: stdtypes.cpp:1637
virtual void GetValueOctetString(TConstObjectPtr objectPtr, vector< char > &value) const override
Definition: stdtypes.cpp:1625
virtual void GetValueOctetString(TConstObjectPtr objectPtr, vector< char > &value) const
Definition: stdtypes.cpp:513
CPrimitiveTypeInfoInt(size_t size, bool isSigned)
Definition: stdtypes.cpp:886
void SetIOFunctions(TTypeReadFunction, TTypeWriteFunction, TTypeCopyFunction, TTypeSkipFunction)
Definition: stdtypes.cpp:366
virtual void GetValueString(TConstObjectPtr objectPtr, string &value) const override
Definition: stdtypes.cpp:1223
virtual void SetValueString(TObjectPtr objectPtr, const string &value) const override
Definition: stdtypes.cpp:1434
void ThrowIntegerOverflow(void)
Definition: stdtypes.cpp:1473
virtual bool GetValueBool(TConstObjectPtr object) const override
Definition: stdtypes.cpp:559
virtual void GetValueString(TConstObjectPtr objectPtr, string &value) const override
Definition: stdtypes.cpp:1602
virtual void GetValueBitString(TConstObjectPtr objectPtr, CBitString &value) const
Definition: stdtypes.cpp:526
virtual void SetValueChar(TObjectPtr objectPtr, char value) const
Definition: stdtypes.cpp:416
void SetSkipFunction(TTypeSkipFunction func)
Definition: typeinfo.cpp:497
vector< Char > TObjectType
virtual char GetValueChar(TConstObjectPtr objectPtr) const
Definition: stdtypes.cpp:410
virtual void SetValueBitString(TObjectPtr objectPtr, const CBitString &value) const override
Definition: stdtypes.cpp:1816
void SetInt8Functions(TGetInt8Function, TSetInt8Function, TGetUint8Function, TSetUint8Function)
Definition: stdtypes.cpp:903
CPrimitiveTypeInfoString(EType type=eStringTypeVisible)
Definition: stdtypes.cpp:1195
virtual void SetValueUint8(TObjectPtr objectPtr, Uint8 value) const
Definition: stdtypes.cpp:463
virtual void SetValueAnyContent(TObjectPtr objectPtr, const CAnyContentObject &value) const override
Definition: stdtypes.cpp:1753
virtual char GetValueChar(TConstObjectPtr object) const override
Definition: stdtypes.cpp:654
bool IsStringStore(void) const
Definition: stdtypes.cpp:1357
virtual void SetValueChar(TObjectPtr object, char value) const override
Definition: stdtypes.cpp:659
TAssignFunction m_Assign
Definition: stdtypes.hpp:150
virtual void SetValueString(TObjectPtr objectPtr, const string &value) const override
Definition: stdtypes.cpp:1229
virtual void SetValueUint4(TObjectPtr objectPtr, Uint4 value) const
Definition: stdtypes.cpp:439
static bool IsDefault(TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:257
virtual void SetValueBitString(TObjectPtr objectPtr, const CBitString &value) const
Definition: stdtypes.cpp:531
virtual void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how=eRecursive) const override
Set object to copy of another one.
Definition: stdtypes.cpp:399
virtual void GetValueString(TConstObjectPtr objectPtr, string &value) const override
Definition: stdtypes.cpp:1427
static void SetDefault(TObjectPtr objectPtr)
Definition: stdtypes.cpp:269
virtual Int8 GetValueInt8(TConstObjectPtr objectPtr) const override
Definition: stdtypes.cpp:936
virtual char GetValueChar(TConstObjectPtr objectPtr) const override
Definition: stdtypes.cpp:1408
void ThrowIllegalCall(void)
Definition: stdtypes.cpp:1468
virtual void SetValueDouble(TObjectPtr objectPtr, double value) const
Definition: stdtypes.cpp:475
static void Read(CObjectIStream &in, TTypeInfo objectType, TObjectPtr objectPtr)
Definition: stdtypes.cpp:278
void SetCreateFunction(TTypeCreate func)
Definition: typeinfo.cpp:355
virtual void SetValueInt4(TObjectPtr objectPtr, Int4 value) const override
Definition: stdtypes.cpp:924
virtual void SetValueAnyContent(TObjectPtr objectPtr, const CAnyContentObject &value) const
Definition: stdtypes.cpp:543
virtual double GetValueDouble(TConstObjectPtr objectPtr) const override
Definition: stdtypes.cpp:1059
virtual double GetValueDouble(TConstObjectPtr objectPtr) const
Definition: stdtypes.cpp:469
virtual void GetValueBitString(TConstObjectPtr objectPtr, CBitString &value) const override
Definition: stdtypes.cpp:1809
virtual char GetValueChar(TConstObjectPtr objectPtr) const override
Definition: stdtypes.cpp:1235
virtual bool GetValueBool(TConstObjectPtr objectPtr) const
Definition: stdtypes.cpp:377
static void Skip(CObjectIStream &in, TTypeInfo objectType)
Definition: stdtypes.cpp:298
static void Write(CObjectOStream &out, TTypeInfo objectType, TConstObjectPtr objectPtr)
Definition: stdtypes.cpp:285
virtual double GetValueDouble(TConstObjectPtr objectPtr) const override
Definition: stdtypes.cpp:1029
virtual void SetValueDouble(TObjectPtr objectPtr, double value) const override
Definition: stdtypes.cpp:1064
static void ThrowException(const char *operation, TTypeInfo objectType)
Definition: stdtypes.cpp:247
void SetInt4Functions(TGetInt4Function, TSetInt4Function, TGetUint4Function, TSetUint4Function)
Definition: stdtypes.cpp:892
virtual void SetValueString(TObjectPtr objectPtr, const string &value) const
Definition: stdtypes.cpp:507
virtual Int4 GetValueInt4(TConstObjectPtr objectPtr) const override
Definition: stdtypes.cpp:914
void SetCopyFunction(TTypeCopyFunction func)
Definition: typeinfo.cpp:492
virtual void SetValueUint8(TObjectPtr objectPtr, Uint8 value) const override
Definition: stdtypes.cpp:952
TSetDefaultFunction m_SetDefault
Definition: stdtypes.hpp:148
virtual void SetValueChar(TObjectPtr objectPtr, char value) const override
Definition: stdtypes.cpp:1417
CAsnBinaryDefs::ETagConstructed m_TagConstructed
Definition: typeinfo.hpp:309
virtual Int8 GetValueInt8(TConstObjectPtr objectPtr) const
Definition: stdtypes.cpp:445
static void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how=eRecursive)
Definition: stdtypes.cpp:273
virtual void SetValueString(TObjectPtr object, const string &value) const override
Definition: stdtypes.cpp:670
virtual void SetValueDouble(TObjectPtr objectPtr, double value) const override
Definition: stdtypes.cpp:1034
static void Copy(CObjectStreamCopier &copier, TTypeInfo objectType)
Definition: stdtypes.cpp:292
TGetUint4Function m_GetUint4
virtual Uint8 GetValueUint8(TConstObjectPtr objectPtr) const
Definition: stdtypes.cpp:457
void SetReadFunction(TTypeReadFunction func)
Definition: typeinfo.cpp:477
TSetInt4Function m_SetInt4
X * NotNull(X *object)
Check for not null value (after C malloc, strdup etc.).
Definition: ncbiutil.hpp:85
operation
Bit operations.
Definition: bmconst.h:191
char * buf
static MDB_envinfo info
Definition: mdb_load.c:37
const TYPE & Get(const CNamedParameterList *param)
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
int strcmp(const char *str1, const char *str2)
Definition: odbc_utils.hpp:160
static bool Equals(const CVariation::TPlacements &p1, const CVariation::TPlacements &p2)
#define fabs(v)
Definition: ncbi_dispd.c:46
std::istream & in(std::istream &in_, double &x_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
#define count
static uint8_t * buffer
Definition: pcre2test.c:1016
#define NcbiSysChar_strdup
Definition: ncbisys.hpp:178
#define DECLARE_STD_INT_TYPE(Type)
Definition: stdtypes.cpp:958
bool x_Practically_Equal(const TFloat v1, const TFloat v2)
Definition: stdtypes.cpp:172
#define FLT_EPSILON
Definition: stdtypes.cpp:214
#define DBL_EPSILON
Definition: stdtypes.cpp:165
Definition: type.c:6
#define _ASSERT
else result
Definition: token2.c:20
#define const
Definition: zconf.h:232
void free(voidpf ptr)
voidp malloc(uInt size)
Modified on Fri Sep 20 14:58:22 2024 by modify_doxy.py rev. 669887