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

Go to the SVN repository for this file.

1 /* $Id: choice.cpp 86517 2019-05-20 18:09:55Z gouriano $
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 * !!! PUT YOUR DESCRIPTION HERE !!!
30 */
31 
32 #include <ncbi_pch.hpp>
33 #include <serial/impl/choice.hpp>
34 #include <serial/objostr.hpp>
35 #include <serial/objistr.hpp>
36 #include <serial/objcopy.hpp>
37 #include <serial/delaybuf.hpp>
38 #include <serial/serialbase.hpp>
39 #include <serial/objhook.hpp>
40 
42 
44 {
45 public:
46  static void ReadChoiceSimple(CObjectIStream& in,
47  TTypeInfo objectType,
48  TObjectPtr objectPtr);
49  static void ReadChoiceDefault(CObjectIStream& in,
50  TTypeInfo objectType,
51  TObjectPtr objectPtr);
53  TTypeInfo objectType,
54  TConstObjectPtr objectPtr);
55  static void SkipChoiceSimple(CObjectIStream& in,
56  TTypeInfo objectType);
57  static void SkipChoiceDefault(CObjectIStream& in,
58  TTypeInfo objectType);
59  static void CopyChoiceDefault(CObjectStreamCopier& copier,
60  TTypeInfo objectType);
61  static void AssignDefault(TTypeInfo typeInfo,
62  TObjectPtr dst, TConstObjectPtr src,
64  static void AssignSimple(TTypeInfo typeInfo,
65  TObjectPtr dst, TConstObjectPtr src,
67 };
68 
70 
71 CChoiceTypeInfo::CChoiceTypeInfo(size_t size, const char* name,
72  const void* nonCObject,
73  TTypeCreate createFunc,
74  const type_info& ti,
75  TWhichFunction whichFunc,
76  TSelectFunction selectFunc,
77  TResetFunction resetFunc)
78  : CParent(eTypeFamilyChoice, size, name, nonCObject, createFunc, ti),
79  m_WhichFunction(whichFunc),
80  m_ResetFunction(resetFunc), m_SelectFunction(selectFunc)
81 {
83 }
84 
85 CChoiceTypeInfo::CChoiceTypeInfo(size_t size, const char* name,
86  const CObject* cObject,
87  TTypeCreate createFunc,
88  const type_info& ti,
89  TWhichFunction whichFunc,
90  TSelectFunction selectFunc,
91  TResetFunction resetFunc)
92  : CParent(eTypeFamilyChoice, size, name, cObject, createFunc, ti),
93  m_WhichFunction(whichFunc),
94  m_ResetFunction(resetFunc), m_SelectFunction(selectFunc)
95 {
97 }
98 
99 CChoiceTypeInfo::CChoiceTypeInfo(size_t size, const string& name,
100  const void* nonCObject,
101  TTypeCreate createFunc,
102  const type_info& ti,
103  TWhichFunction whichFunc,
104  TSelectFunction selectFunc,
105  TResetFunction resetFunc)
106  : CParent(eTypeFamilyChoice, size, name, nonCObject, createFunc, ti),
107  m_WhichFunction(whichFunc),
108  m_ResetFunction(resetFunc), m_SelectFunction(selectFunc)
109 {
111 }
112 
113 CChoiceTypeInfo::CChoiceTypeInfo(size_t size, const string& name,
114  const CObject* cObject,
115  TTypeCreate createFunc,
116  const type_info& ti,
117  TWhichFunction whichFunc,
118  TSelectFunction selectFunc,
119  TResetFunction resetFunc)
120  : CParent(eTypeFamilyChoice, size, name, cObject, createFunc, ti),
121  m_WhichFunction(whichFunc),
122  m_ResetFunction(resetFunc), m_SelectFunction(selectFunc)
123 {
125 }
126 
128 {
129  SetReadFunction(&TFunc::ReadChoiceDefault);
130  SetWriteFunction(&TFunc::WriteChoiceDefault);
131  SetCopyFunction(&TFunc::CopyChoiceDefault);
132  SetSkipFunction(&TFunc::SkipChoiceDefault);
134  m_AllowEmpty = false;
135  m_WhichOffset = 0;
136  m_WhichSize = 0;
137 }
138 
140 {
141  m_AllowEmpty = GetVariants().Size() == 0 || (
144  if ( !m_AllowEmpty &&
146  // simple
147  SetReadFunction(&TFunc::ReadChoiceSimple);
148  SetSkipFunction(&TFunc::SkipChoiceSimple);
149  }
150 }
151 
153  const void* memberPtr,
154  const CTypeRef& memberType)
155 {
156  CVariantInfo* variantInfo = new CVariantInfo(this, memberId,
157  TPointerOffsetType(memberPtr),
158  memberType);
159  GetItems().AddItem(variantInfo);
160  return variantInfo;
161 }
162 
164  const void* memberPtr,
165  const CTypeRef& memberType)
166 {
167  CVariantInfo* variantInfo = new CVariantInfo(this, memberId,
168  TPointerOffsetType(memberPtr),
169  memberType);
170  GetItems().AddItem(variantInfo);
171  return variantInfo;
172 }
173 
175 {
176  return GetIndex(object) == kEmptyChoice;
177 }
178 
179 
180 static inline
181 TObjectPtr GetMember(const CMemberInfo* memberInfo, TObjectPtr object)
182 {
183  if ( memberInfo->CanBeDelayed() )
184  memberInfo->GetDelayBuffer(object).Update();
185  return memberInfo->GetItemPtr(object);
186 }
187 
188 static inline
190  TConstObjectPtr object)
191 {
192  if ( memberInfo->CanBeDelayed() )
193  const_cast<CDelayBuffer&>(memberInfo->GetDelayBuffer(object)).Update();
194  return memberInfo->GetItemPtr(object);
195 }
196 
198  ESerialRecursionMode how) const
199 {
200  // User defined comparison
201  if ( IsCObject() ) {
202  if ( const CSerialUserOp* op1 = AsCSerialUserOp(object1) ) {
203  if ( const CSerialUserOp* op2 = AsCSerialUserOp(object2) ) {
204  if ( !op1->UserOp_Equals(*op2) )
205  return false;
206  }
207  }
208  }
209 
210  TMemberIndex index;
211 
212  index = GetVariants().FirstIndex();
213  const CVariantInfo* variantInfo = GetVariantInfo(index);
214  if (variantInfo->GetId().IsAttlist()) {
215  const CMemberInfo* info =
216  dynamic_cast<const CMemberInfo*>(GetVariants().GetItemInfo(index));
217  if ( !info->GetTypeInfo()->Equals(GetMember(info, object1),
218  GetMember(info, object2), how) ) {
219  return false;
220  }
221  }
222 
223  // Default comparison
224  index = GetIndex(object1);
225  if ( index != GetIndex(object2) )
226  return false;
227  if ( index == kEmptyChoice )
228  return true;
229  return
230  GetVariantInfo(index)->GetTypeInfo()->Equals(GetData(object1, index),
231  GetData(object2, index), how);
232 }
233 
235 {
236  ResetIndex(dst);
237 }
238 
239 inline
241  TConstObjectPtr src) const
242 {
243  // User defined assignment
244  if ( IsCObject() ) {
245  if ( const CSerialUserOp* opsrc = AsCSerialUserOp(src) ) {
246  if ( CSerialUserOp* opdst = AsCSerialUserOp(dst) ) {
247  opdst->UserOp_Assign(*opsrc);
248  }
249  }
250  }
251 }
252 
254  ESerialRecursionMode how) const
255 {
256  TMemberIndex index;
257 
258  index = GetVariants().FirstIndex();
259  const CVariantInfo* variantInfo = GetVariantInfo(index);
260  if (variantInfo->GetId().IsAttlist()) {
261  const CMemberInfo* info =
262  dynamic_cast<const CMemberInfo*>(GetVariants().GetItemInfo(index));
263  info->GetTypeInfo()->Assign(GetMember(info, dst),
264  GetMember(info, src),how);
265  }
266 
267  index = GetIndex(src);
268  if ( index == kEmptyChoice )
269  ResetIndex(dst);
270  else {
271  _ASSERT(index >= GetVariants().FirstIndex() &&
272  index <= GetVariants().LastIndex());
273  SetIndex(dst, index);
274  GetVariantInfo(index)->GetTypeInfo()->Assign(GetData(dst, index),
275  GetData(src, index), how);
276  }
277 
278  // User defined assignment
279  CallUserOp_Assign(dst, src);
280 }
281 
283  TObjectPtr dst,
284  TConstObjectPtr src,
286 {
287  const CChoiceTypeInfo* choiceType =
288  static_cast<const CChoiceTypeInfo*>(typeInfo);
289  TMemberIndex index;
290 
291  index = choiceType->GetVariants().FirstIndex();
292  const CVariantInfo* variantInfo = choiceType->GetVariantInfo(index);
293  if (variantInfo->GetId().IsAttlist()) {
294  const CMemberInfo* info =
295  static_cast<const CMemberInfo*>(choiceType->GetVariants().GetItemInfo(index));
296  info->GetTypeInfo()->Assign(GetMember(info, dst),
297  GetMember(info, src),how);
298  }
299 
300  index = choiceType->GetIndex(src);
301  if ( index == kEmptyChoice )
302  choiceType->ResetIndex(dst);
303  else {
304  _ASSERT(index >= choiceType->GetVariants().FirstIndex() &&
305  index <= choiceType->GetVariants().LastIndex());
306  choiceType->SetIndex(dst, index);
307  choiceType->GetVariantInfo(index)->GetTypeInfo()->Assign(choiceType->GetData(dst, index),
308  choiceType->GetData(src, index), how);
309  }
310 
311  choiceType->CallUserOp_Assign(dst, src);
312 }
313 
314 
316  TObjectPtr dst,
317  TConstObjectPtr src,
319 {
320  const CChoiceTypeInfo* choiceType =
321  static_cast<const CChoiceTypeInfo*>(typeInfo);
322  TMemberIndex index = choiceType->GetIndex(src);
323  if ( index == kEmptyChoice ) {
324  choiceType->ResetIndex(dst);
325  return;
326  }
327  const CVariantInfo* variantInfo = choiceType->GetVariantInfo(index);
328  choiceType->SetIndex(dst, index);
329  variantInfo->GetTypeInfo()->Assign(variantInfo->GetVariantPtr(dst),
330  variantInfo->GetVariantPtr(src),
331  how);
332 }
333 
334 
335 void CChoiceTypeInfo::SetSelectDelay(TSelectDelayFunction func)
336 {
338  _ASSERT(func != 0);
339  m_SelectDelayFunction = func;
340 }
341 
342 void CChoiceTypeInfo::SetSelectorInfo(const void* offset, size_t sz)
343 {
345  m_WhichSize = sz;
346 }
347 
348 TMemberIndex CChoiceTypeInfo::Which(const void* object) const
349 {
350  _ASSERT(m_WhichSize != 0);
351  const void* p = CRawPointer::Add(object, m_WhichOffset);
352  switch (m_WhichSize) {
353  case 1:
355  case 2:
357  case 4:
359  default:
360  break;
361  }
363 }
364 
366  TMemberIndex index) const
367 {
368  m_SelectDelayFunction(this, objectPtr, index);
369 }
370 
372  TTypeInfo objectType,
373  TObjectPtr objectPtr)
374 {
375  const CChoiceTypeInfo* choiceType =
377  BEGIN_OBJECT_FRAME_OF3(in, eFrameChoice, choiceType, objectPtr);
378  in.BeginChoice(choiceType);
379  BEGIN_OBJECT_FRAME_OF(in, eFrameChoiceVariant);
380  TMemberIndex index = in.BeginChoiceVariant(choiceType);
381  if ( index == kInvalidMember ) {
382  if (choiceType->MayBeEmpty() || in.CanSkipUnknownVariants()) {
383  in.SkipAnyContentVariant();
384  } else {
385  in.ThrowError(in.fFormatError, "choice variant id expected");
386  }
387  } else {
388  for (;;) {
389  const CVariantInfo* variantInfo = choiceType->GetVariantInfo(index);
390  if (variantInfo->GetId().IsAttlist()) {
391  const CMemberInfo* memberInfo =
392  static_cast<const CMemberInfo*>(
393  choiceType->GetVariants().GetItemInfo(index));
394  memberInfo->ReadMember(in,objectPtr);
395  in.EndChoiceVariant();
396  index = in.BeginChoiceVariant(choiceType);
397  if ( index == kInvalidMember ) {
398  if (in.CanSkipUnknownVariants()) {
399  in.SkipAnyContentVariant();
400  break;
401  } else {
402  in.ThrowError(in.fFormatError, "choice variant id expected");
403  }
404  }
405  variantInfo = choiceType->GetVariantInfo(index);
406  }
407  in.SetTopMemberId(variantInfo->GetId());
408 
409  variantInfo->ReadVariant(in, objectPtr);
410  in.EndChoiceVariant();
411  break;
412  }
413  }
415  in.EndChoice();
417 }
418 
420  TTypeInfo objectType,
421  TObjectPtr objectPtr)
422 {
423  const CChoiceTypeInfo* choiceType =
425  in.ReadChoiceSimple(choiceType, objectPtr);
426 }
427 
429  TTypeInfo objectType,
430  TConstObjectPtr objectPtr)
431 {
432  const CChoiceTypeInfo* choiceType =
434 
435  BEGIN_OBJECT_FRAME_OF3(out, eFrameChoice, choiceType, objectPtr);
436  out.BeginChoice(choiceType);
437  TMemberIndex index = choiceType->GetVariants().FirstIndex();
438  const CVariantInfo* variantInfo = choiceType->GetVariantInfo(index);
439  if (variantInfo->GetId().IsAttlist()) {
440  const CMemberInfo* memberInfo =
441  dynamic_cast<const CMemberInfo*>(
442  choiceType->GetVariants().GetItemInfo(index));
443  memberInfo->WriteMember(out,objectPtr);
444  }
445 
446  index = choiceType->GetIndex(objectPtr);
447  if ( index == kInvalidMember ) {
448  if (!choiceType->MayBeEmpty()) {
449  out.ThrowError(out.fInvalidData, "cannot write empty choice");
450  }
451  } else {
452  variantInfo = choiceType->GetVariantInfo(index);
453  BEGIN_OBJECT_FRAME_OF2(out, eFrameChoiceVariant, variantInfo->GetId());
454  out.BeginChoiceVariant(choiceType, variantInfo->GetId());
455 
456  variantInfo->WriteVariant(out, objectPtr);
457 
458  out.EndChoiceVariant();
460  }
461 
462  out.EndChoice();
464 }
465 
467  TTypeInfo objectType)
468 {
470 }
471 
473  TTypeInfo objectType)
474 {
475  const CChoiceTypeInfo* choiceType =
477  BEGIN_OBJECT_FRAME_OF2(in, eFrameChoice, choiceType);
478  in.BeginChoice(choiceType);
479  BEGIN_OBJECT_FRAME_OF(in, eFrameChoiceVariant);
480  TMemberIndex index = in.BeginChoiceVariant(choiceType);
481  if ( index == kInvalidMember ) {
482  if (choiceType->MayBeEmpty() || in.CanSkipUnknownVariants()) {
483  in.SkipAnyContentVariant();
484  } else {
485  in.ThrowError(in.fFormatError, "choice variant id expected");
486  }
487  } else {
488  for (;;) {
489  const CVariantInfo* variantInfo = choiceType->GetVariantInfo(index);
490  if (variantInfo->GetId().IsAttlist()) {
491  const CMemberInfo* memberInfo =
492  dynamic_cast<const CMemberInfo*>(
493  choiceType->GetVariants().GetItemInfo(index));
494  memberInfo->SkipMember(in);
495  in.EndChoiceVariant();
496  index = in.BeginChoiceVariant(choiceType);
497  if ( index == kInvalidMember ) {
498  if (in.CanSkipUnknownVariants()) {
499  in.SkipAnyContentVariant();
500  break;
501  } else {
502  in.ThrowError(in.fFormatError, "choice variant id expected");
503  }
504  }
505  variantInfo = choiceType->GetVariantInfo(index);
506  }
507  in.SetTopMemberId(variantInfo->GetId());
508 
509  variantInfo->SkipVariant(in);
510  in.EndChoiceVariant();
511  break;
512  }
513  }
514 
516  in.EndChoice();
518 }
519 
520 
522  TTypeInfo objectType)
523 {
524  const CChoiceTypeInfo* choiceType =
526  in.SkipChoiceSimple(choiceType);
527 }
528 
529 
531  CReadChoiceVariantHook* hook_ptr)
532 {
533  CRef<CReadChoiceVariantHook> hook(hook_ptr);
534  if ( variants == "*" ) {
535  for ( CIterator i(this); i.Valid(); ++i ) {
536  const_cast<CVariantInfo*>(GetVariantInfo(i))->
537  SetGlobalReadHook(hook);
538  }
539  }
540  else {
541  vector<CTempString> tokens;
542  NStr::Split(variants, ",", tokens);
543  ITERATE ( vector<CTempString>, it, tokens ) {
544  const_cast<CVariantInfo*>(GetVariantInfo(*it))->
545  SetGlobalReadHook(hook);
546  }
547  }
548 }
549 
550 
static TObjectPtr GetMember(const CMemberInfo *memberInfo, TObjectPtr object)
Definition: choice.cpp:181
CChoiceTypeInfoFunctions TFunc
Definition: choice.cpp:69
static void ReadChoiceSimple(CObjectIStream &in, TTypeInfo objectType, TObjectPtr objectPtr)
Definition: choice.cpp:419
static void AssignSimple(TTypeInfo typeInfo, TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how)
Definition: choice.cpp:315
static void SkipChoiceSimple(CObjectIStream &in, TTypeInfo objectType)
Definition: choice.cpp:521
static void ReadChoiceDefault(CObjectIStream &in, TTypeInfo objectType, TObjectPtr objectPtr)
Definition: choice.cpp:371
static void WriteChoiceDefault(CObjectOStream &out, TTypeInfo objectType, TConstObjectPtr objectPtr)
Definition: choice.cpp:428
static void SkipChoiceDefault(CObjectIStream &in, TTypeInfo objectType)
Definition: choice.cpp:472
static void AssignDefault(TTypeInfo typeInfo, TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how)
Definition: choice.cpp:282
static void CopyChoiceDefault(CObjectStreamCopier &copier, TTypeInfo objectType)
Definition: choice.cpp:466
CDelayBuffer.
Definition: delaybuf.hpp:58
CObjectIStream –.
Definition: objistr.hpp:93
CObjectOStream –.
Definition: objostr.hpp:83
CObjectStreamCopier –.
Definition: objcopy.hpp:71
CObject –.
Definition: ncbiobj.hpp:180
Read hook for a choice variant (CHOICE)
Definition: objhook.hpp:117
CRef –.
Definition: ncbiobj.hpp:618
Base class for user-defined serializable classes to allow for objects assignment and comparison.
Definition: serialbase.hpp:319
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
std::ofstream out("events_result.xml")
main entry point for tests
int offset
Definition: replacements.h:160
static void * Add(void *object, ssize_t offset)
add offset to object reference (to get object's member)
Definition: ncbimisc.hpp:1137
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
static const CItemInfo * FindNextMandatory(const CItemInfo *info)
Definition: memberlist.cpp:338
const CMemberId & GetId(void) const
bool IsAttlist(void) const
void WriteVariant(CObjectOStream &out, TConstObjectPtr choicePtr) const
void WriteMember(CObjectOStream &out, TConstObjectPtr classPtr) const
size_t Size(void) const
Definition: memberlist.hpp:73
TObjectPtr GetItemPtr(TObjectPtr object) const
void SkipMember(CObjectIStream &in) const
void ReadVariant(CObjectIStream &in, TObjectPtr choicePtr) const
TConstObjectPtr GetVariantPtr(TConstObjectPtr choicePtr) const
CDelayBuffer & GetDelayBuffer(TObjectPtr object) const
const CItemInfo * GetItemInfo(TMemberIndex index) const
static TMemberIndex FirstIndex(void)
Definition: memberlist.hpp:78
void SkipVariant(CObjectIStream &in) const
bool CanBeDelayed(void) const
bool HaveNoPrefix(void) const
TTypeInfo GetTypeInfo(void) const
void AddItem(CItemInfo *item)
Definition: memberlist.cpp:70
void ReadMember(CObjectIStream &in, TObjectPtr classPtr) const
ESerialRecursionMode
How to assign and compare child sub-objects of serial objects.
Definition: serialdef.hpp:191
const TMemberIndex kEmptyChoice
Special value for marking empty choice.
Definition: serialdef.hpp:239
void * TObjectPtr
Definition: serialdef.hpp:55
size_t TMemberIndex
Type used for indexing class members and choice variants.
Definition: serialdef.hpp:230
const TMemberIndex kFirstMemberIndex
Start if member indexing.
Definition: serialdef.hpp:235
const TMemberIndex kInvalidMember
Special value returned from FindMember.
Definition: serialdef.hpp:237
const void * TConstObjectPtr
Definition: serialdef.hpp:59
ssize_t TPointerOffsetType
Definition: serialdef.hpp:241
static const TObjectType * SafeCast(TTypeInfo type)
Definition: serialutil.hpp:76
@ eTypeFamilyChoice
Definition: serialdef.hpp:141
void Update(void)
Parse stored data.
Definition: delaybuf.hpp:80
void CopyChoice(const CChoiceTypeInfo *choiceType)
#define BEGIN_OBJECT_FRAME_OF(Stream, Type)
Definition: objstack.hpp:217
#define BEGIN_OBJECT_FRAME_OF2(Stream, Type, Arg)
Definition: objstack.hpp:219
#define BEGIN_OBJECT_FRAME_OF3(Stream, Type, Arg1, Arg2)
Definition: objstack.hpp:221
#define END_OBJECT_FRAME_OF(Stream)
Definition: objstack.hpp:201
#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 list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
void SetWriteFunction(TTypeWriteFunction func)
Definition: typeinfo.cpp:487
TPointerOffsetType m_WhichOffset
Definition: choice.hpp:151
void SetSelectDelay(TSelectDelayFunction func)
Definition: choice.cpp:335
virtual bool Equals(TConstObjectPtr obj1, TConstObjectPtr obj2, ESerialRecursionMode how=eRecursive) const override
Check if both objects contain the same values.
Definition: choice.cpp:197
TConstObjectPtr GetData(TConstObjectPtr object, TMemberIndex index) const
const CItemsInfo & GetItems(void) const
void CallUserOp_Assign(TObjectPtr dst, TConstObjectPtr src) const
Definition: choice.cpp:240
void AdjustChoiceTypeInfoFunctions(void)
Definition: choice.cpp:139
const CSerialUserOp * AsCSerialUserOp(TConstObjectPtr obj) const
Definition: typeinfo.cpp:335
void InitChoiceTypeInfoFunctions(void)
Definition: choice.cpp:127
const CItemsInfo & GetVariants(void) const
bool MayBeEmpty(void) const
Definition: choice.hpp:129
TMemberIndex GetIndex(TConstObjectPtr object) const
bool IsCObject(void) const
Check is this TypeInfo object is kind of CClassTypeInfoBase.
virtual bool IsDefault(TConstObjectPtr object) const override
Check, whether the object contains default value.
Definition: choice.cpp:174
const CVariantInfo * GetVariantInfo(TMemberIndex index) const
virtual void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how=eRecursive) const =0
Set object to copy of another one.
virtual void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how=eRecursive) const override
Set object to copy of another one.
Definition: choice.cpp:253
void SetSkipFunction(TTypeSkipFunction func)
Definition: typeinfo.cpp:497
bool m_AllowEmpty
Definition: choice.hpp:150
void SetGlobalReadHook(CReadObjectHook *hook)
Set global (for all input streams) read hook.
Definition: typeinfo.cpp:367
void SetDelayIndex(TObjectPtr object, TMemberIndex index) const
Definition: choice.cpp:365
TMemberIndex Which(const void *object) const
Definition: choice.cpp:348
void SetSelectorInfo(const void *offset, size_t sz)
Definition: choice.cpp:342
virtual void SetDefault(TObjectPtr dst) const override
Set object to default value.
Definition: choice.cpp:234
virtual bool Equals(TConstObjectPtr object1, TConstObjectPtr object2, ESerialRecursionMode how=eRecursive) const =0
Check if both objects contain the same values.
void SetGlobalHook(const CTempString &variant_names, CReadChoiceVariantHook *hook)
Definition: choice.cpp:530
TSelectDelayFunction m_SelectDelayFunction
Definition: choice.hpp:149
CChoiceTypeInfo(size_t size, const char *name, const void *nonCObject, TTypeCreate createFunc, const type_info &ti, TWhichFunction whichFunc, TSelectFunction selectFunc, TResetFunction resetFunc)
Definition: choice.cpp:71
void SetCopyFunction(TTypeCopyFunction func)
Definition: typeinfo.cpp:492
CVariantInfo * AddVariant(const char *variantId, const void *variantPtr, const CTypeRef &variantType)
Definition: choice.cpp:152
void ResetIndex(TObjectPtr object) const
size_t m_WhichSize
Definition: choice.hpp:152
void SetIndex(TObjectPtr object, TMemberIndex index, CObjectMemoryPool *pool=0) const
void SetReadFunction(TTypeReadFunction func)
Definition: typeinfo.cpp:477
int i
static MDB_envinfo info
Definition: mdb_load.c:37
const struct ncbi::grid::netcache::search::fields::SIZE size
std::istream & in(std::istream &in_, double &x_)
#define _ASSERT
Modified on Sun May 19 04:39:59 2024 by modify_doxy.py rev. 669887