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

Go to the SVN repository for this file.

1 /* $Id: member.cpp 99791 2023-05-10 18:00:42Z vasilche $
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 */
33 
34 #include <ncbi_pch.hpp>
35 #include <corelib/ncbistd.hpp>
36 #include <corelib/ncbimtx.hpp>
37 
38 #include <serial/impl/member.hpp>
39 #include <serial/objectinfo.hpp>
40 #include <serial/objectiter.hpp>
41 #include <serial/objistr.hpp>
42 #include <serial/objostr.hpp>
43 #include <serial/objcopy.hpp>
44 #include <serial/delaybuf.hpp>
45 #include <serial/serialimpl.hpp>
46 #include <serial/error_codes.hpp>
47 #ifdef _DEBUG
48 #include <serial/serialbase.hpp>
49 #endif
50 #include <memory>
51 
52 
53 #define NCBI_USE_ERRCODE_X Serial_MemberInfo
54 
56 
58 {
59 public:
60  static TConstObjectPtr GetConstSimpleMember(const CMemberInfo* memberInfo,
61  TConstObjectPtr classPtr);
62  static TConstObjectPtr GetConstDelayedMember(const CMemberInfo* memberInfo,
63  TConstObjectPtr classPtr);
64  static TObjectPtr GetSimpleMember(const CMemberInfo* memberInfo,
65  TObjectPtr classPtr);
66  static TObjectPtr GetWithSetFlagMember(const CMemberInfo* memberInfo,
67  TObjectPtr classPtr);
68  static TObjectPtr GetDelayedMember(const CMemberInfo* memberInfo,
69  TObjectPtr classPtr);
70 
71 
72  static void ReadSimpleMember(CObjectIStream& in,
73  const CMemberInfo* memberInfo,
74  TObjectPtr classPtr);
76  const CMemberInfo* memberInfo,
77  TObjectPtr classPtr);
79  const CMemberInfo* memberInfo,
80  TObjectPtr classPtr);
81  static void ReadLongMember(CObjectIStream& in,
82  const CMemberInfo* memberInfo,
83  TObjectPtr classPtr);
84  static void ReadHookedMember(CObjectIStream& in,
85  const CMemberInfo* memberInfo,
86  TObjectPtr classPtr);
88  const CMemberInfo* memberInfo,
89  TObjectPtr classPtr);
91  const CMemberInfo* memberInfo,
92  TObjectPtr classPtr);
94  const CMemberInfo* memberInfo,
95  TObjectPtr classPtr);
97  const CMemberInfo* memberInfo,
98  TObjectPtr classPtr);
100  const CMemberInfo* memberInfo,
101  TConstObjectPtr classPtr);
103  const CMemberInfo* memberInfo,
104  TConstObjectPtr classPtr);
106  const CMemberInfo* memberInfo,
107  TConstObjectPtr classPtr);
109  const CMemberInfo* memberInfo,
110  TConstObjectPtr classPtr);
112  const CMemberInfo* memberInfo,
113  TConstObjectPtr classPtr);
114  static void WriteLongMember(CObjectOStream& out,
115  const CMemberInfo* memberInfo,
116  TConstObjectPtr classPtr);
117  static void WriteHookedMember(CObjectOStream& out,
118  const CMemberInfo* memberInfo,
119  TConstObjectPtr classPtr);
120  static void SkipSimpleMember(CObjectIStream& in,
121  const CMemberInfo* memberInfo);
123  const CMemberInfo* memberInfo);
125  const CMemberInfo* memberInfo);
127  const CMemberInfo* memberInfo);
128  static void SkipHookedMember(CObjectIStream& in,
129  const CMemberInfo* memberInfo);
131  const CMemberInfo* memberInfo);
132  static void CopySimpleMember(CObjectStreamCopier& copier,
133  const CMemberInfo* memberInfo);
134  static void CopyWithDefaultMemberX(CObjectStreamCopier& copier,
135  const CMemberInfo* memberInfo);
136  static void CopyHookedMember(CObjectStreamCopier& copier,
137  const CMemberInfo* memberInfo);
138  static void CopyMissingSimpleMember(CObjectStreamCopier& copier,
139  const CMemberInfo* memberInfo);
141  const CMemberInfo* memberInfo);
142  static void CopyMissingHookedMember(CObjectStreamCopier& copier,
143  const CMemberInfo* memberInfo);
144 
145 
146  static void ReadParentClass(CObjectIStream& in,
147  const CMemberInfo* memberInfo,
148  TObjectPtr objectPtr);
150  const CMemberInfo* memberInfo,
151  TObjectPtr objectPtr);
152  static void WriteParentClass(CObjectOStream& out,
153  const CMemberInfo* memberInfo,
154  TConstObjectPtr objectPtr);
155  static void CopyParentClass(CObjectStreamCopier& copier,
156  const CMemberInfo* memberInfo);
157  static void CopyMissingParentClass(CObjectStreamCopier& copier,
158  const CMemberInfo* memberInfo);
159  static void SkipParentClass(CObjectIStream& in,
160  const CMemberInfo* memberInfo);
162  const CMemberInfo* memberInfo);
163 private:
164  static TConstObjectPtr x_GetMemberDefault(const CMemberInfo* memberInfo);
165 };
166 
168 
171  const CTypeRef& type)
172  : CParent(id, offset, type),
173  m_ClassType(classType), m_Default(0),
174  m_SetFlagOffset(eNoOffset), m_BitSetMask(0),
175  m_DelayOffset(eNoOffset),
176  m_GetConstFunction(&TFunc::GetConstSimpleMember),
177  m_GetFunction(&TFunc::GetSimpleMember),
178  m_ReadHookData(make_pair(&TFunc::ReadSimpleMember,
179  &TFunc::ReadMissingSimpleMember),
180  make_pair(&TFunc::ReadHookedMember,
181  &TFunc::ReadMissingHookedMember)),
182  m_WriteHookData(&TFunc::WriteSimpleMember, &TFunc::WriteHookedMember),
183  m_SkipHookData(make_pair(&TFunc::SkipSimpleMember,
184  &TFunc::SkipMissingSimpleMember),
185  make_pair(&TFunc::SkipHookedMember,
186  &TFunc::SkipMissingHookedMember)),
187  m_CopyHookData(make_pair(&TFunc::CopySimpleMember,
188  &TFunc::CopyMissingSimpleMember),
189  make_pair(&TFunc::CopyHookedMember,
190  &TFunc::CopyMissingHookedMember))
191 {
192 }
193 
196  TTypeInfo type)
197  : CParent(id, offset, type),
198  m_ClassType(classType), m_Default(0),
199  m_SetFlagOffset(eNoOffset), m_BitSetMask(0),
200  m_DelayOffset(eNoOffset),
201  m_GetConstFunction(&TFunc::GetConstSimpleMember),
202  m_GetFunction(&TFunc::GetSimpleMember),
203  m_ReadHookData(make_pair(&TFunc::ReadSimpleMember,
204  &TFunc::ReadMissingSimpleMember),
205  make_pair(&TFunc::ReadHookedMember,
206  &TFunc::ReadMissingHookedMember)),
207  m_WriteHookData(&TFunc::WriteSimpleMember, &TFunc::WriteHookedMember),
208  m_SkipHookData(make_pair(&TFunc::SkipSimpleMember,
209  &TFunc::SkipMissingSimpleMember),
210  make_pair(&TFunc::SkipHookedMember,
211  &TFunc::SkipMissingHookedMember)),
212  m_CopyHookData(make_pair(&TFunc::CopySimpleMember,
213  &TFunc::CopyMissingSimpleMember),
214  make_pair(&TFunc::CopyHookedMember,
215  &TFunc::CopyMissingHookedMember))
216 {
217 }
218 
220  const char* id, TPointerOffsetType offset,
221  const CTypeRef& type)
222  : CParent(id, offset, type),
223  m_ClassType(classType), m_Default(0),
224  m_SetFlagOffset(eNoOffset), m_BitSetMask(0),
225  m_DelayOffset(eNoOffset),
226  m_GetConstFunction(&TFunc::GetConstSimpleMember),
227  m_GetFunction(&TFunc::GetSimpleMember),
228  m_ReadHookData(make_pair(&TFunc::ReadSimpleMember,
229  &TFunc::ReadMissingSimpleMember),
230  make_pair(&TFunc::ReadHookedMember,
231  &TFunc::ReadMissingHookedMember)),
232  m_WriteHookData(&TFunc::WriteSimpleMember, &TFunc::WriteHookedMember),
233  m_SkipHookData(make_pair(&TFunc::SkipSimpleMember,
234  &TFunc::SkipMissingSimpleMember),
235  make_pair(&TFunc::SkipHookedMember,
236  &TFunc::SkipMissingHookedMember)),
237  m_CopyHookData(make_pair(&TFunc::CopySimpleMember,
238  &TFunc::CopyMissingSimpleMember),
239  make_pair(&TFunc::CopyHookedMember,
240  &TFunc::CopyMissingHookedMember))
241 {
242 }
243 
245  const char* id, TPointerOffsetType offset,
246  TTypeInfo type)
247  : CParent(id, offset, type),
248  m_ClassType(classType), m_Default(0),
249  m_SetFlagOffset(eNoOffset), m_BitSetMask(0),
250  m_DelayOffset(eNoOffset),
251  m_GetConstFunction(&TFunc::GetConstSimpleMember),
252  m_GetFunction(&TFunc::GetSimpleMember),
253  m_ReadHookData(make_pair(&TFunc::ReadSimpleMember,
254  &TFunc::ReadMissingSimpleMember),
255  make_pair(&TFunc::ReadHookedMember,
256  &TFunc::ReadMissingHookedMember)),
257  m_WriteHookData(&TFunc::WriteSimpleMember, &TFunc::WriteHookedMember),
258  m_SkipHookData(make_pair(&TFunc::SkipSimpleMember,
259  &TFunc::SkipMissingSimpleMember),
260  make_pair(&TFunc::SkipHookedMember,
261  &TFunc::SkipMissingHookedMember)),
262  m_CopyHookData(make_pair(&TFunc::CopySimpleMember,
263  &TFunc::CopyMissingSimpleMember),
264  make_pair(&TFunc::CopyHookedMember,
265  &TFunc::CopyMissingHookedMember))
266 {
267 }
268 
270 {
271  GetId().SetParentTag();
272  m_ReadHookData.SetDefaultFunctions(make_pair(&TFunc::ReadParentClass,
273  &TFunc::ReadMissingParentClass));
274  m_WriteHookData.SetDefaultFunction(&TFunc::WriteParentClass);
275  m_SkipHookData.SetDefaultFunctions(make_pair(&TFunc::SkipParentClass,
276  &TFunc::SkipMissingParentClass));
277  m_CopyHookData.SetDefaultFunctions(make_pair(&TFunc::CopyParentClass,
278  &TFunc::CopyMissingParentClass));
279 }
280 
282 {
283  enum State {
284  eUnset,
285  eEnabled,
286  eDisabled
287  };
288  static State state = eUnset;
289  if ( state == eUnset ) {
291  string value;
292  if ( app ) {
293  value = app->GetConfig().Get("SERIAL", "DISABLE_DELAY_BUFFERS");
294  }
295  if ( value.empty() ) {
296  const char* str = getenv("SERIAL_DISABLE_DELAY_BUFFERS");
297  if ( str ) {
298  value = str;
299  }
300  }
301  if ( value == "1" || NStr::CompareNocase(value,"YES") == 0 ) {
302  LOG_POST_X(1, Info << "SERIAL: delay buffers are disabled");
303  state = eDisabled;
304  }
305  else {
306  state = eEnabled;
307  }
308  }
309  return state == eEnabled;
310 }
311 
312 
314 {
315  if ( EnabledDelayBuffers() ) {
317  UpdateFunctions();
318  }
319  return this;
320 }
321 
323 {
324  m_Optional = true;
325  UpdateFunctions();
326  return this;
327 }
328 
330 {
331  GetId().SetNillable();
332  UpdateFunctions();
333  return this;
334 }
335 
337 {
338  GetId().SetNoPrefix();
339  UpdateFunctions();
340  return this;
341 }
342 
344 {
345  GetId().SetAttlist();
346  return this;
347 }
348 
350 {
351  GetId().SetNotag();
352  return this;
353 }
354 
356 {
357  GetId().SetAnyContent();
358  return this;
359 }
360 
362 {
363  GetId().SetCompressed();
364  return this;
365 }
366 
368 {
369  GetId().SetNsQualified(qualified);
370  return this;
371 }
372 
374 {
375  m_Default = def;
376  UpdateFunctions();
377  return this;
378 }
379 
381 {
382  return SetDefault(def);
383 }
384 
386 {
387 // _ASSERT(Optional());
389  m_BitSetMask = 0;
390  UpdateFunctions();
391  return this;
392 }
393 
395 {
396  size_t offset = GetIndex()-1;
397  m_SetFlagOffset = TPointerOffsetType(setFlag) + (offset/16)*4;
398  m_BitSetMask = 3<<(offset%16*2);
399  UpdateFunctions();
400  return this;
401 }
402 
404  TConstObjectPtr object2) const
405 {
406  return GetSetFlagNo(object1) == GetSetFlagNo(object2);
407 }
408 
410 {
411  m_Optional = true;
412  return SetSetFlag(setFlag);
413 }
414 
416 {
417  // determine function pointers
418  TMemberGetConst getConstFunc;
419  TMemberGet getFunc;
420  pair<TMemberReadFunction, TMemberReadFunction> readFuncs;
421  TMemberWriteFunction writeFunc;
422  pair<TMemberSkipFunction, TMemberSkipFunction> skipFuncs;
423  pair<TMemberCopyFunction, TMemberCopyFunction> copyFuncs;
424 
425  // get/readmain/write
426  if ( CanBeDelayed() ) {
427  getConstFunc = &TFunc::GetConstDelayedMember;
428  getFunc = &TFunc::GetDelayedMember;
429  readFuncs.first = &TFunc::ReadLongMember;
430  writeFunc = &TFunc::WriteLongMember;
431  }
432  else if ( !HaveSetFlag() ) {
433  getConstFunc = &TFunc::GetConstSimpleMember;
434  getFunc = &TFunc::GetSimpleMember;
435  readFuncs.first = &TFunc::ReadSimpleMember;
436 
437  if ( GetDefault() )
438  writeFunc = &TFunc::WriteWithDefaultMember;
439  else if ( Optional() || Nillable() )
440  writeFunc = &TFunc::WriteOptionalMember;
441  else
442  writeFunc = &TFunc::WriteSimpleMember;
443  }
444  else {
445  // have set flag
446  getConstFunc = &TFunc::GetConstSimpleMember;
447  getFunc = &TFunc::GetWithSetFlagMember;
448  readFuncs.first = &TFunc::ReadWithSetFlagMember;
449  writeFunc = &TFunc::WriteWithSetFlagMember;
450  if ( (GetDefault() || Nillable()) && GetId().HaveNoPrefix()) {
451  readFuncs.first = &TFunc::ReadWithDefaultMemberX;
452  writeFunc = &TFunc::WriteWithDefaultMemberX;
453  }
454  }
455 
456  // copymain/skipmain
457  copyFuncs.first = &TFunc::CopySimpleMember;
458  skipFuncs.first = &TFunc::SkipSimpleMember;
459  if ( (GetDefault() || Nillable()) && GetId().HaveNoPrefix()) {
460  copyFuncs.first = &TFunc::CopyWithDefaultMemberX;
461  skipFuncs.first = &TFunc::SkipWithDefaultMemberX;
462  }
463 
464  // readmissing/copymissing/skipmissing
465  if ( Optional() ) {
466  if ( HaveSetFlag() ) {
467  readFuncs.second = &TFunc::ReadMissingWithSetFlagMember;
468  }
469  else {
470  readFuncs.second = &TFunc::ReadMissingOptionalMember;
471  }
472  copyFuncs.second = &TFunc::CopyMissingOptionalMember;
473  skipFuncs.second = &TFunc::SkipMissingOptionalMember;
474  }
475  else {
476  readFuncs.second = &TFunc::ReadMissingSimpleMember;
477  copyFuncs.second = &TFunc::CopyMissingSimpleMember;
478  skipFuncs.second = &TFunc::SkipMissingSimpleMember;
479  }
480 
481  // update function pointers
482  m_GetConstFunction = getConstFunc;
483  m_GetFunction = getFunc;
488 }
489 
491  TObjectPtr classPtr) const
492 {
494  _ASSERT(GetDelayBuffer(classPtr).GetIndex() == GetIndex());
495 
496  BEGIN_OBJECT_FRAME_OF2(in, eFrameClass, GetClassType());
497  BEGIN_OBJECT_FRAME_OF2(in, eFrameClassMember, GetId());
498  GetTypeInfo()->ReadData(in, GetItemPtr(classPtr));
501 }
502 
504 {
506 }
507 
509 {
511 }
512 
514 {
516 }
517 
519 {
521 }
522 
524 {
526 }
527 
529 {
531 }
532 
534 {
536 }
537 
539 {
542 }
543 
545  CReadClassMemberHook* hook)
546 {
549 }
550 
552 {
555 }
556 
558 {
561 }
562 
564  CReadClassMemberHook* hook)
565 {
567  m_ReadHookData.SetPathHook(in,path,hook);
568 }
569 
571 {
574 }
575 
577  CWriteClassMemberHook* hook)
578 {
581 }
582 
584 {
587 }
588 
590 {
593 }
594 
596  CWriteClassMemberHook* hook)
597 {
599  m_WriteHookData.SetPathHook(out,path,hook);
600 }
601 
603  CSkipClassMemberHook* hook)
604 {
607 }
608 
610 {
613 }
614 
616  CSkipClassMemberHook* hook)
617 {
619  m_SkipHookData.SetPathHook(in,path,hook);
620 }
621 
623 {
626 }
627 
629  CCopyClassMemberHook* hook)
630 {
633 }
634 
636 {
639 }
640 
642 {
645 }
646 
647 void CMemberInfo::SetPathCopyHook(CObjectStreamCopier* stream, const string& path,
648  CCopyClassMemberHook* hook)
649 {
651  m_CopyHookData.SetPathHook(stream ? &(stream->In()) : 0,path,hook);
652 }
653 
655 {
656  return GetClassType()->Create();
657 }
658 
661  TConstObjectPtr classPtr)
662 {
663  _ASSERT(!memberInfo->CanBeDelayed());
664  return memberInfo->GetItemPtr(classPtr);
665 }
666 
669  TConstObjectPtr classPtr)
670 {
671  _ASSERT(memberInfo->CanBeDelayed());
672  const_cast<CDelayBuffer&>(memberInfo->GetDelayBuffer(classPtr)).Update();
673  return memberInfo->GetItemPtr(classPtr);
674 }
675 
677  TObjectPtr classPtr)
678 {
679  _ASSERT(!memberInfo->CanBeDelayed());
680  _ASSERT(!memberInfo->HaveSetFlag());
681  return memberInfo->GetItemPtr(classPtr);
682 }
683 
685  TObjectPtr classPtr)
686 {
687  _ASSERT(!memberInfo->CanBeDelayed());
688  _ASSERT(memberInfo->HaveSetFlag());
689  return memberInfo->GetItemPtr(classPtr);
690 }
691 
693  TObjectPtr classPtr)
694 {
695  _ASSERT(memberInfo->CanBeDelayed());
696  memberInfo->GetDelayBuffer(classPtr).Update();
697  memberInfo->UpdateSetFlagYes(classPtr);
698  return memberInfo->GetItemPtr(classPtr);
699 }
700 
702  const CMemberInfo* memberInfo,
703  TObjectPtr classPtr)
704 {
705  _ASSERT(!memberInfo->CanBeDelayed());
706  _ASSERT(!memberInfo->HaveSetFlag());
707  if (memberInfo->Nillable()) {
708  in.SetMemberNillable();
709  }
710  in.ReadObject(memberInfo->GetItemPtr(classPtr),
711  memberInfo->GetTypeInfo());
712  in.UnsetMemberNillable();
713 }
714 
716  const CMemberInfo* memberInfo,
717  TObjectPtr classPtr)
718 {
719  _ASSERT(!memberInfo->CanBeDelayed());
720  _ASSERT(memberInfo->HaveSetFlag());
721  memberInfo->UpdateSetFlagYes(classPtr);
722  try {
723  in.ReadObject(memberInfo->GetItemPtr(classPtr),
724  memberInfo->GetTypeInfo());
725  if (in.GetVerifyData() == eSerialVerifyData_Yes) {
726  memberInfo->Validate(classPtr, in);
727  }
728  }
729  catch (CSerialException& e) {
731  if ( memberInfo->HaveSetFlag() ) {
732  memberInfo->UpdateSetFlagNo(classPtr);
733  } else {
734  NCBI_RETHROW(e, CSerialException, eFormatError,
735  "null value " + memberInfo->GetId().GetName());
736  }
737  } else if (e.GetErrCode() == CSerialException::eMissingValue) {
738  if ( memberInfo->Optional() && memberInfo->HaveSetFlag() ) {
739  in.SetFailFlags(CObjectIStream::fNoError);
740  if ( memberInfo->UpdateSetFlagNo(classPtr) ) {
741  memberInfo->GetTypeInfo()->SetDefault(
742  memberInfo->GetItemPtr(classPtr));
743  if (memberInfo->GetDefault()) {
744  memberInfo->GetTypeInfo()->Assign(memberInfo->GetItemPtr(classPtr),memberInfo->GetDefault());
745  }
746  }
747  } else {
748  NCBI_RETHROW(e, CSerialException, eFormatError,
749  "missing value " + memberInfo->GetId().GetName());
750  }
751  } else {
753  "error while reading " + memberInfo->GetId().GetName());
754  }
755  }
756 }
757 
759  const CMemberInfo* memberInfo)
760 {
761  ETypeFamily family = memberInfo->GetTypeInfo()->GetTypeFamily();
762  TConstObjectPtr defptr = memberInfo->GetDefault();
763  if (!defptr || family == eTypeFamilyPrimitive || family == eTypeFamilyContainer) {
764  //noop
765  }
766  else if (family == eTypeFamilyPointer) {
767  bool resolved = false;
769  family = p->GetPointedType()->GetTypeFamily();
770  if (family == eTypeFamilyPrimitive || family == eTypeFamilyContainer) {
771  resolved = true;
772  }
773  else if (family == eTypeFamilyClass) {
774  const CClassTypeInfo* classType =
776  if (classType->Implicit()) {
777  const CMemberInfo* mi = classType->GetMemberInfo(CItemsInfo::FirstIndex());
779  defptr = mi->GetItemPtr(p->GetObjectPointer(defptr));
780  resolved = true;
781  }
782  }
783  }
784  if (!resolved) {
785  defptr = NULL;
786  }
787  } else {
788  defptr = NULL;
789  }
790  return defptr;
791 }
792 
794  const CMemberInfo* memberInfo,
795  TObjectPtr classPtr)
796 {
797  _ASSERT(!memberInfo->CanBeDelayed());
798  _ASSERT(memberInfo->HaveSetFlag());
799  memberInfo->UpdateSetFlagYes(classPtr);
800  in.SetMemberDefault(x_GetMemberDefault(memberInfo));
801  if (memberInfo->Nillable()) {
802  in.SetMemberNillable();
803  }
804  try {
805  in.ReadObject(memberInfo->GetItemPtr(classPtr),
806  memberInfo->GetTypeInfo());
807  if (in.GetSpecialCaseUsed()) {
808  memberInfo->UpdateSetFlagNo(classPtr);
809  if (in.GetSpecialCaseUsed() == CObjectIStream::eReadAsDefault) {
810  memberInfo->UpdateSetFlagMaybe(classPtr);
811  }
812  }
813  else if (in.GetVerifyData() == eSerialVerifyData_Yes) {
814  memberInfo->Validate(classPtr, in);
815  }
816  in.UnsetMemberSpecialCase();
817  }
818  catch (CSerialException& e) {
819  in.UnsetMemberSpecialCase();
821  if ( memberInfo->HaveSetFlag() && memberInfo->Nillable() ) {
822  memberInfo->UpdateSetFlagNo(classPtr);
823  } else {
824  NCBI_RETHROW(e, CSerialException, eFormatError,
825  "null value " + memberInfo->GetId().GetName());
826  }
827  } else if (e.GetErrCode() == CSerialException::eMissingValue) {
828  if ( memberInfo->Optional() && memberInfo->HaveSetFlag() ) {
829  in.SetFailFlags(CObjectIStream::fNoError);
830  if ( memberInfo->UpdateSetFlagNo(classPtr) ) {
831  memberInfo->GetTypeInfo()->SetDefault(
832  memberInfo->GetItemPtr(classPtr));
833  if (memberInfo->GetDefault()) {
834  memberInfo->GetTypeInfo()->Assign(memberInfo->GetItemPtr(classPtr),memberInfo->GetDefault());
835  }
836  }
837  } else {
838  NCBI_RETHROW(e, CSerialException, eFormatError,
839  "missing value " + memberInfo->GetId().GetName());
840  }
841  } else {
843  "error while reading " + memberInfo->GetId().GetName());
844  }
845  }
846 }
847 
849  const CMemberInfo* memberInfo,
850  TObjectPtr classPtr)
851 {
852  if ( memberInfo->CanBeDelayed() ) {
853  CDelayBuffer& buffer = memberInfo->GetDelayBuffer(classPtr);
854  if ( !buffer ) {
855  if (!in.ShouldParseDelayBuffer()) {
856  memberInfo->UpdateSetFlagYes(classPtr);
857  in.StartDelayBuffer();
858  memberInfo->GetTypeInfo()->SkipData(in);
859  in.EndDelayBuffer(buffer, memberInfo, classPtr);
860  return;
861  }
862  }
863  buffer.Update();
864  }
865 
866  memberInfo->UpdateSetFlagYes(classPtr);
867  in.ReadObject(memberInfo->GetItemPtr(classPtr),
868  memberInfo->GetTypeInfo());
869 }
870 
872  const CMemberInfo* memberInfo,
873  TObjectPtr classPtr)
874 {
875  _ASSERT(!memberInfo->Optional());
876  in.ExpectedMember(memberInfo);
877 
878  if (memberInfo->HaveSetFlag()) {
879  memberInfo->UpdateSetFlagNo(classPtr);
880  }
881  memberInfo->GetTypeInfo()->SetDefault(memberInfo->GetItemPtr(classPtr));
882 #ifdef _DEBUG
883  if (in.GetVerifyData() == eSerialVerifyData_No) {
884  if (memberInfo->GetTypeInfo()->GetTypeFamily() == eTypeFamilyPrimitive) {
885  CObjectInfo objinfo(memberInfo->GetItemPtr(classPtr),
886  memberInfo->GetTypeInfo());
887  if (objinfo.GetPrimitiveValueType() == ePrimitiveValueString) {
889  } else {
890  size_t size = memberInfo->GetTypeInfo()->GetSize();
891  if (size <= sizeof(long)) {
892  char* tmp = static_cast<char*>(
893  memberInfo->GetItemPtr(classPtr));
894  for (; size != 0; --size, ++tmp) {
896  }
897  }
898  }
899  }
900  }
901 #endif
902 }
903 
904 void
906  const CMemberInfo* memberInfo,
907  TObjectPtr classPtr)
908 {
909  _ASSERT(memberInfo->Optional());
910  memberInfo->GetTypeInfo()->SetDefault(memberInfo->GetItemPtr(classPtr));
911 }
912 
913 void
915  const CMemberInfo* memberInfo,
916  TObjectPtr classPtr)
917 {
918  _ASSERT(!memberInfo->CanBeDelayed());
919  _ASSERT(memberInfo->HaveSetFlag());
920  if ( memberInfo->UpdateSetFlagNo(classPtr) ) {
921  memberInfo->GetTypeInfo()->SetDefault(memberInfo->GetItemPtr(classPtr));
922  if (memberInfo->GetDefault()) {
923  memberInfo->GetTypeInfo()->Assign(memberInfo->GetItemPtr(classPtr),memberInfo->GetDefault());
924  }
925  }
926 }
927 
929  const CMemberInfo* memberInfo,
930  TConstObjectPtr classPtr)
931 {
932  _ASSERT(!memberInfo->CanBeDelayed());
933  _ASSERT(!memberInfo->Optional());
934  out.WriteClassMember(memberInfo->GetId(),
935  memberInfo->GetTypeInfo(),
936  memberInfo->GetItemPtr(classPtr));
937 }
938 
940  const CMemberInfo* memberInfo,
941  TConstObjectPtr classPtr)
942 {
943  _ASSERT(!memberInfo->CanBeDelayed());
944  _ASSERT(memberInfo->Optional() || memberInfo->Nillable());
945  TTypeInfo memberType = memberInfo->GetTypeInfo();
946  TConstObjectPtr memberPtr = memberInfo->GetItemPtr(classPtr);
947  if ( memberType->IsDefault(memberPtr) ) {
948  if (memberInfo->Nillable()) {
949  out.WriteClassMemberSpecialCase( memberInfo->GetId(),
950  memberType, memberPtr, CObjectOStream::eWriteAsNil);
951  }
952  return;
953  }
954 
955  out.WriteClassMember(memberInfo->GetId(), memberType, memberPtr);
956 }
957 
959  const CMemberInfo* memberInfo,
960  TConstObjectPtr classPtr)
961 {
962  _ASSERT(!memberInfo->CanBeDelayed());
963  _ASSERT(memberInfo->GetDefault());
964  TTypeInfo memberType = memberInfo->GetTypeInfo();
965  TConstObjectPtr memberPtr = memberInfo->GetItemPtr(classPtr);
966  if (!out.IsWritingDefaultValuesEnforced() &&
967  memberType->Equals(memberPtr, memberInfo->GetDefault()) ) {
968  return;
969  }
970  out.WriteClassMember(memberInfo->GetId(), memberType, memberPtr);
971 }
972 
974  CObjectOStream& out, const CMemberInfo* memberInfo,
975  TConstObjectPtr classPtr)
976 {
977  _ASSERT(!memberInfo->CanBeDelayed());
978  _ASSERT(memberInfo->GetDefault() || memberInfo->Nillable());
979  TTypeInfo memberType = memberInfo->GetTypeInfo();
980  TConstObjectPtr memberPtr = memberInfo->GetItemPtr(classPtr);
981  CMemberInfo::ESetFlag flag = memberInfo->GetSetFlag(classPtr);
982  if (out.IsWritingDefaultValuesEnforced() && memberInfo->GetDefault()) {
983  goto do_write;
984  }
985  if (flag == CMemberInfo::eSetNo) {
986  if (memberInfo->Optional()) {
987  return;
988  }
989  if (memberInfo->Nillable()) {
990  out.WriteClassMemberSpecialCase( memberInfo->GetId(),
991  memberType, memberPtr, CObjectOStream::eWriteAsNil);
992  return;
993  }
994  ESerialVerifyData verify = out.GetVerifyData();
995  if (verify == eSerialVerifyData_Yes) {
996  out.ThrowError(CObjectOStream::fUnassigned,
997  memberInfo->GetId().GetName());
998  }
999  return;
1000  } else if (flag == CMemberInfo::eSetMaybe &&
1001  memberType->GetTypeFamily() != eTypeFamilyContainer) {
1002  if ( memberType->Equals(memberPtr, memberInfo->GetDefault()) ) {
1003  out.WriteClassMemberSpecialCase(memberInfo->GetId(),
1004  memberType, memberPtr, CObjectOStream::eWriteAsDefault);
1005  return;
1006  }
1007  }
1008  if (out.GetVerifyData() == eSerialVerifyData_Yes) {
1009  memberInfo->Validate(classPtr, out);
1010  }
1011 do_write:
1012  out.WriteClassMember(memberInfo->GetId(), memberType, memberPtr);
1013 }
1014 
1016  const CMemberInfo* memberInfo,
1017  TConstObjectPtr classPtr)
1018 {
1019  _ASSERT(!memberInfo->CanBeDelayed());
1020  _ASSERT(memberInfo->HaveSetFlag());
1021  if (out.IsWritingDefaultValuesEnforced() && memberInfo->GetDefault()) {
1022  goto do_write;
1023  }
1024  if ( memberInfo->GetSetFlagNo(classPtr) ) {
1025  if (memberInfo->Optional()) {
1026  return;
1027  }
1028  ESerialVerifyData verify = out.GetVerifyData();
1029  if (verify == eSerialVerifyData_Yes) {
1030  out.ThrowError(CObjectOStream::fUnassigned,
1031  memberInfo->GetId().GetName());
1032  } else if (verify == eSerialVerifyData_No) {
1033  return;
1034  }
1035  }
1036  if (!memberInfo->Optional() &&
1037  out.GetVerifyData() == eSerialVerifyData_Yes &&
1038  out.GetDataFormat() == eSerial_Xml &&
1039  memberInfo->GetId().HaveNoPrefix() &&
1040  memberInfo->GetTypeInfo()->GetTypeFamily() == eTypeFamilyContainer &&
1041  memberInfo->GetSetFlag(classPtr) == CMemberInfo::eSetMaybe) {
1042  CConstObjectInfo objinfo(memberInfo->GetItemPtr(classPtr),
1043  memberInfo->GetTypeInfo());
1045  if (!ei.Valid()) {
1046  out.ThrowError(CObjectOStream::fUnassigned,
1047  memberInfo->GetId().GetName());
1048  }
1049  }
1050 #ifdef _DEBUG
1051  if (memberInfo->GetSetFlag(classPtr) == CMemberInfo::eSetMaybe &&
1052  memberInfo->GetTypeInfo()->GetTypeFamily() == eTypeFamilyPrimitive) {
1053  bool do_err_post = false;
1054  CConstObjectInfo objinfo(memberInfo->GetItemPtr(classPtr),
1055  memberInfo->GetTypeInfo());
1056  if (objinfo.GetPrimitiveValueType() == ePrimitiveValueString) {
1057  string tmp;
1058  objinfo.GetPrimitiveValueString(tmp);
1059  do_err_post = (tmp == CSerialObject::ms_UnassignedStr);
1060  } else {
1061  size_t size = memberInfo->GetTypeInfo()->GetSize();
1062  const char* tmp = static_cast<const char*>(
1063  memberInfo->GetItemPtr(classPtr));
1064  for (; size != 0 && *tmp == CSerialObject::ms_UnassignedByte; --size, ++tmp)
1065  ;
1066  do_err_post = (size == 0);
1067  }
1068  if (do_err_post) {
1069  ERR_POST_X(2, Error << "CObjectOStream: at "<< out.GetPosition()<<
1070  ": Member \""<< memberInfo->GetId().GetName()<<
1071  "\" seems to be unassigned");
1072  }
1073  }
1074 #endif
1075  if (out.GetVerifyData() == eSerialVerifyData_Yes) {
1076  memberInfo->Validate(classPtr, out);
1077  }
1078 do_write:
1079  out.WriteClassMember(memberInfo->GetId(),
1080  memberInfo->GetTypeInfo(),
1081  memberInfo->GetItemPtr(classPtr));
1082 }
1083 
1085  const CMemberInfo* memberInfo,
1086  TConstObjectPtr classPtr)
1087 {
1088  bool haveSetFlag = memberInfo->HaveSetFlag();
1089  if ( haveSetFlag && memberInfo->GetSetFlagNo(classPtr) ) {
1090  // not set -> skip this member
1091  return;
1092  }
1093 
1094  if ( memberInfo->CanBeDelayed() ) {
1095  const CDelayBuffer& buffer = memberInfo->GetDelayBuffer(classPtr);
1096  if ( buffer ) {
1097  if (!out.ShouldParseDelayBuffer()) {
1098  if ( out.WriteClassMember(memberInfo->GetId(), buffer) )
1099  return;
1100  }
1101 
1102  // cannot write delayed buffer -> proceed after update
1103  const_cast<CDelayBuffer&>(buffer).Update();
1104  }
1105  }
1106 
1107  TTypeInfo memberType = memberInfo->GetTypeInfo();
1108  TConstObjectPtr memberPtr = memberInfo->GetItemPtr(classPtr);
1109  if ( !haveSetFlag && memberInfo->Optional() ) {
1110  TConstObjectPtr defaultPtr = memberInfo->GetDefault();
1111  if ( !defaultPtr ) {
1112  if ( memberType->IsDefault(memberPtr) )
1113  return; // DEFAULT
1114  }
1115  else {
1116  if ( memberType->Equals(memberPtr, defaultPtr) )
1117  return; // OPTIONAL
1118  }
1119  }
1120 
1121  out.WriteClassMember(memberInfo->GetId(), memberType, memberPtr);
1122 }
1123 
1125  const CMemberInfo* memberInfo)
1126 {
1127  copier.CopyObject(memberInfo->GetTypeInfo());
1128 }
1129 
1131  const CMemberInfo* memberInfo)
1132 {
1133  copier.In().SetMemberDefault(x_GetMemberDefault(memberInfo));
1134  if (memberInfo->Nillable()) {
1135  copier.In().SetMemberNillable();
1136  }
1137  copier.CopyObject(memberInfo->GetTypeInfo());
1138  copier.In().UnsetMemberSpecialCase();
1139 }
1140 
1142  const CMemberInfo* memberInfo)
1143 {
1144  _ASSERT(!memberInfo->Optional());
1145  copier.ExpectedMember(memberInfo);
1146 }
1147 
1149  const CMemberInfo* _DEBUG_ARG(memberInfo))
1150 {
1151  _ASSERT(memberInfo->Optional());
1152 }
1153 
1155  const CMemberInfo* memberInfo)
1156 {
1157  in.SkipObject(memberInfo->GetTypeInfo());
1158 }
1159 
1161  const CMemberInfo* memberInfo)
1162 {
1163  in.SetMemberDefault(x_GetMemberDefault(memberInfo));
1164  if (memberInfo->Nillable()) {
1165  in.SetMemberNillable();
1166  }
1167  in.SkipObject(memberInfo->GetTypeInfo());
1168  in.UnsetMemberSpecialCase();
1169 }
1170 
1172  const CMemberInfo* memberInfo)
1173 {
1174  _ASSERT(!memberInfo->Optional());
1175  in.ExpectedMember(memberInfo);
1176 }
1177 
1179  const CMemberInfo* _DEBUG_ARG(memberInfo))
1180 {
1181  _ASSERT(memberInfo->Optional());
1182 }
1183 
1185  const CMemberInfo* memberInfo,
1186  TObjectPtr classPtr)
1187 {
1188  CReadClassMemberHook* hook =
1189  memberInfo->m_ReadHookData.GetHook(stream.m_ClassMemberHookKey);
1190  if ( !hook ) {
1191  hook = memberInfo->m_ReadHookData.GetPathHook(stream);
1192  }
1193  if ( hook ) {
1194  CObjectInfo object(classPtr, memberInfo->GetClassType());
1195  TMemberIndex index = memberInfo->GetIndex();
1196  CObjectInfo::CMemberIterator member(object, index);
1197  _ASSERT(member.Valid());
1198  hook->ReadClassMember(stream, member);
1199  }
1200  else
1201  memberInfo->DefaultReadMember(stream, classPtr);
1202 }
1203 
1205  const CMemberInfo* memberInfo,
1206  TObjectPtr classPtr)
1207 {
1208  CReadClassMemberHook* hook =
1209  memberInfo->m_ReadHookData.GetHook(stream.m_ClassMemberHookKey);
1210  if ( !hook ) {
1211  hook = memberInfo->m_ReadHookData.GetPathHook(stream);
1212  }
1213  if ( hook ) {
1214  memberInfo->GetTypeInfo()->
1215  SetDefault(memberInfo->GetItemPtr(classPtr));
1216  CObjectInfo object(classPtr, memberInfo->GetClassType());
1217  TMemberIndex index = memberInfo->GetIndex();
1218  CObjectInfo::CMemberIterator member(object, index);
1219  _ASSERT(member.Valid());
1220  hook->ReadMissingClassMember(stream, member);
1221  }
1222  else
1223  memberInfo->DefaultReadMissingMember(stream, classPtr);
1224 }
1225 
1227  const CMemberInfo* memberInfo,
1228  TConstObjectPtr classPtr)
1229 {
1230  CWriteClassMemberHook* hook =
1231  memberInfo->m_WriteHookData.GetHook(stream.m_ClassMemberHookKey);
1232  if ( !hook ) {
1233  hook = memberInfo->m_WriteHookData.GetPathHook(stream);
1234  }
1235  if ( hook ) {
1236  CConstObjectInfo object(classPtr, memberInfo->GetClassType());
1237  TMemberIndex index = memberInfo->GetIndex();
1238  CConstObjectInfo::CMemberIterator member(object, index);
1239  _ASSERT(member.Valid());
1240  hook->WriteClassMember(stream, member);
1241  }
1242  else
1243  memberInfo->DefaultWriteMember(stream, classPtr);
1244 }
1245 
1247  const CMemberInfo* memberInfo)
1248 {
1249  CSkipClassMemberHook* hook =
1250  memberInfo->m_SkipHookData.GetHook(stream.m_ClassMemberSkipHookKey);
1251  if ( !hook ) {
1252  hook = memberInfo->m_SkipHookData.GetPathHook(stream);
1253  }
1254  if ( hook ) {
1255  CObjectTypeInfo type(memberInfo->GetClassType());
1256  TMemberIndex index = memberInfo->GetIndex();
1257  CObjectTypeInfo::CMemberIterator member(type, index);
1258  _ASSERT(member.Valid());
1259  hook->SkipClassMember(stream, member);
1260  }
1261  else
1262  memberInfo->DefaultSkipMember(stream);
1263 }
1264 
1266  const CMemberInfo* memberInfo)
1267 {
1268  CSkipClassMemberHook* hook =
1269  memberInfo->m_SkipHookData.GetHook(stream.m_ClassMemberSkipHookKey);
1270  if ( !hook ) {
1271  hook = memberInfo->m_SkipHookData.GetPathHook(stream);
1272  }
1273  if ( hook ) {
1274  CObjectTypeInfo type(memberInfo->GetClassType());
1275  TMemberIndex index = memberInfo->GetIndex();
1276  CObjectTypeInfo::CMemberIterator member(type, index);
1277  _ASSERT(member.Valid());
1278  hook->SkipMissingClassMember(stream, member);
1279  }
1280  else
1281  memberInfo->DefaultSkipMissingMember(stream);
1282 }
1283 
1285  const CMemberInfo* memberInfo)
1286 {
1287  CCopyClassMemberHook* hook =
1288  memberInfo->m_CopyHookData.GetHook(stream.m_ClassMemberHookKey);
1289  if ( !hook ) {
1290  hook = memberInfo->m_CopyHookData.GetPathHook(stream.In());
1291  }
1292  if ( hook ) {
1293  CObjectTypeInfo type(memberInfo->GetClassType());
1294  TMemberIndex index = memberInfo->GetIndex();
1295  CObjectTypeInfo::CMemberIterator member(type, index);
1296  _ASSERT(member.Valid());
1297  hook->CopyClassMember(stream, member);
1298  }
1299  else
1300  memberInfo->DefaultCopyMember(stream);
1301 }
1302 
1304  const CMemberInfo* memberInfo)
1305 {
1306  CCopyClassMemberHook* hook =
1307  memberInfo->m_CopyHookData.GetHook(stream.m_ClassMemberHookKey);
1308  if ( !hook ) {
1309  hook = memberInfo->m_CopyHookData.GetPathHook(stream.In());
1310  }
1311  if ( hook ) {
1312  CObjectTypeInfo type(memberInfo->GetClassType());
1313  TMemberIndex index = memberInfo->GetIndex();
1314  CObjectTypeInfo::CMemberIterator member(type, index);
1315  _ASSERT(member.Valid());
1316  hook->CopyMissingClassMember(stream, member);
1317  }
1318  else
1319  memberInfo->DefaultCopyMissingMember(stream);
1320 }
1321 
1323  const CMemberInfo* memberInfo,
1324  TObjectPtr objectPtr)
1325 {
1326  _ASSERT(!memberInfo->CanBeDelayed());
1327  _ASSERT(!memberInfo->HaveSetFlag());
1328  in.ReadObject(memberInfo->GetItemPtr(objectPtr),
1329  memberInfo->GetTypeInfo());
1330 }
1331 
1333  const CMemberInfo* memberInfo,
1334  TObjectPtr /*objectPtr*/)
1335 {
1336  _ASSERT(!memberInfo->Optional());
1337  in.ExpectedMember(memberInfo);
1338 }
1339 
1341  const CMemberInfo* memberInfo,
1342  TConstObjectPtr objectPtr)
1343 {
1344  _ASSERT(!memberInfo->CanBeDelayed());
1345  _ASSERT(!memberInfo->Optional());
1346  out.WriteClassMember(memberInfo->GetId(),
1347  memberInfo->GetTypeInfo(),
1348  memberInfo->GetItemPtr(objectPtr));
1349 }
1350 
1352  const CMemberInfo* memberInfo)
1353 {
1354  copier.CopyObject(memberInfo->GetTypeInfo());
1355 }
1356 
1358  const CMemberInfo* memberInfo)
1359 {
1360  _ASSERT(!memberInfo->Optional());
1361  copier.ExpectedMember(memberInfo);
1362 }
1363 
1365  const CMemberInfo* memberInfo)
1366 {
1367  in.SkipObject(memberInfo->GetTypeInfo());
1368 }
1369 
1371  const CMemberInfo* memberInfo)
1372 {
1373  _ASSERT(!memberInfo->Optional());
1374  in.ExpectedMember(memberInfo);
1375 }
1376 
1377 
CConstObjectInfoEI –.
Definition: objectiter.hpp:56
CConstObjectInfoMI –.
Definition: objectiter.hpp:397
CConstObjectInfo –.
Definition: objectinfo.hpp:421
Copy hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:266
CDelayBuffer.
Definition: delaybuf.hpp:58
static void CopyHookedMember(CObjectStreamCopier &copier, const CMemberInfo *memberInfo)
Definition: member.cpp:1284
static void WriteWithDefaultMemberX(CObjectOStream &out, const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: member.cpp:973
static void CopyMissingParentClass(CObjectStreamCopier &copier, const CMemberInfo *memberInfo)
Definition: member.cpp:1357
static void ReadWithSetFlagMember(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:715
static void WriteLongMember(CObjectOStream &out, const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: member.cpp:1084
static void CopyMissingSimpleMember(CObjectStreamCopier &copier, const CMemberInfo *memberInfo)
Definition: member.cpp:1141
static TConstObjectPtr x_GetMemberDefault(const CMemberInfo *memberInfo)
Definition: member.cpp:758
static void CopyWithDefaultMemberX(CObjectStreamCopier &copier, const CMemberInfo *memberInfo)
Definition: member.cpp:1130
static void ReadLongMember(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:848
static void ReadMissingSimpleMember(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:871
static TObjectPtr GetSimpleMember(const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:676
static TConstObjectPtr GetConstSimpleMember(const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: member.cpp:660
static void WriteHookedMember(CObjectOStream &out, const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: member.cpp:1226
static void WriteWithSetFlagMember(CObjectOStream &out, const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: member.cpp:1015
static void SkipParentClass(CObjectIStream &in, const CMemberInfo *memberInfo)
Definition: member.cpp:1364
static TObjectPtr GetWithSetFlagMember(const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:684
static void SkipMissingParentClass(CObjectIStream &in, const CMemberInfo *memberInfo)
Definition: member.cpp:1370
static void WriteSimpleMember(CObjectOStream &out, const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: member.cpp:928
static void ReadMissingWithSetFlagMember(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:914
static void ReadSimpleMember(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:701
static void ReadMissingHookedMember(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:1204
static void ReadParentClass(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr objectPtr)
Definition: member.cpp:1322
static void CopyParentClass(CObjectStreamCopier &copier, const CMemberInfo *memberInfo)
Definition: member.cpp:1351
static void SkipMissingHookedMember(CObjectIStream &in, const CMemberInfo *memberInfo)
Definition: member.cpp:1265
static void ReadWithDefaultMemberX(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:793
static void ReadMissingOptionalMember(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:905
static TConstObjectPtr GetConstDelayedMember(const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: member.cpp:668
static void SkipWithDefaultMemberX(CObjectIStream &in, const CMemberInfo *memberInfo)
Definition: member.cpp:1160
static void ReadMissingParentClass(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr objectPtr)
Definition: member.cpp:1332
static void WriteWithDefaultMember(CObjectOStream &out, const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: member.cpp:958
static void CopyMissingHookedMember(CObjectStreamCopier &copier, const CMemberInfo *memberInfo)
Definition: member.cpp:1303
static void CopySimpleMember(CObjectStreamCopier &copier, const CMemberInfo *memberInfo)
Definition: member.cpp:1124
static TObjectPtr GetDelayedMember(const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:692
static void ReadHookedMember(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.cpp:1184
static void SkipMissingOptionalMember(CObjectIStream &in, const CMemberInfo *memberInfo)
Definition: member.cpp:1178
static void SkipHookedMember(CObjectIStream &in, const CMemberInfo *memberInfo)
Definition: member.cpp:1246
static void SkipSimpleMember(CObjectIStream &in, const CMemberInfo *memberInfo)
Definition: member.cpp:1154
static void CopyMissingOptionalMember(CObjectStreamCopier &copier, const CMemberInfo *memberInfo)
Definition: member.cpp:1148
static void SkipMissingSimpleMember(CObjectIStream &in, const CMemberInfo *memberInfo)
Definition: member.cpp:1171
static void WriteParentClass(CObjectOStream &out, const CMemberInfo *memberInfo, TConstObjectPtr objectPtr)
Definition: member.cpp:1340
static void WriteOptionalMember(CObjectOStream &out, const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: member.cpp:939
CObjectIStream –.
Definition: objistr.hpp:93
CObjectInfoMI –.
Definition: objectiter.hpp:432
CObjectInfo –.
Definition: objectinfo.hpp:597
CObjectOStream –.
Definition: objostr.hpp:83
CObjectStreamCopier –.
Definition: objcopy.hpp:71
CObjectTypeInfoMI –.
Definition: objectiter.hpp:246
CObjectTypeInfo –.
Definition: objectinfo.hpp:94
Read hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:78
Root class for all serialization exceptions.
Definition: exception.hpp:50
Skip hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:223
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
Write hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:175
Include a standard set of the NCBI C++ Toolkit most basic headers.
std::ofstream out("events_result.xml")
main entry point for tests
static int type
Definition: getdata.c:31
static const char * str(char *buf, int n)
Definition: stats.c:84
static char tmp[3200]
Definition: utf8.c:42
int offset
Definition: replacements.h:160
static CNcbiApplicationGuard InstanceGuard(void)
Singleton method.
Definition: ncbiapp.cpp:133
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
#define NULL
Definition: ncbistd.hpp:225
#define _DEBUG_ARG(arg)
Definition: ncbidbg.hpp:134
#define LOG_POST_X(err_subcode, message)
Definition: ncbidiag.hpp:553
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
TErrCode GetErrCode(void) const
Get error code.
Definition: ncbiexpt.cpp:453
#define NCBI_RETHROW_SAME(prev_exception, message)
Generic macro to re-throw the same exception.
Definition: ncbiexpt.hpp:749
#define NCBI_RETHROW(prev_exception, exception_class, err_code, message)
Generic macro to re-throw an exception.
Definition: ncbiexpt.hpp:737
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
CMemberInfo * SetNoPrefix(void)
Definition: member.cpp:336
void ResetLocalSkipHook(CObjectIStream &in)
Definition: member.cpp:609
CMemberInfo * SetDefault(TConstObjectPtr def)
Definition: member.cpp:373
void SetAttlist(void)
Definition: memberid.cpp:126
void SetPathCopyHook(CObjectStreamCopier *copier, const string &path, CCopyClassMemberHook *hook)
Definition: member.cpp:647
bool m_Optional
Definition: item.hpp:128
Uint4 m_BitSetMask
Definition: member.hpp:205
void SetPathReadHook(CObjectIStream *in, const string &path, CReadClassMemberHook *hook)
Definition: member.cpp:563
bool Optional(void) const
CMemberInfo * SetNillable(void)
Definition: member.cpp:329
const CMemberId & GetId(void) const
void SetLocalSkipHook(CObjectIStream &in, CSkipClassMemberHook *hook)
Definition: member.cpp:602
const CClassTypeInfoBase * GetClassType(void) const
void SetGlobalWriteHook(CWriteClassMemberHook *hook)
Definition: member.cpp:570
TConstObjectPtr(* TMemberGetConst)(const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: member.hpp:70
void DefaultReadMissingMember(CObjectIStream &in, TObjectPtr classPtr) const
CMemberInfo * SetOptional(void)
Definition: member.cpp:322
void SetSkipMissingFunction(TMemberSkipFunction func)
Definition: member.cpp:523
void SetNoPrefix(void)
Definition: memberid.cpp:121
const string & GetName(void) const
CMemberInfo * SetAttlist(void)
Definition: member.cpp:343
CHookPairData< CCopyClassMemberHook, TMemberCopyFunction > m_CopyHookData
Definition: member.hpp:215
TMemberGetConst m_GetConstFunction
Definition: member.hpp:209
void SetAnyContent(void)
Definition: memberid.cpp:136
void ResetGlobalReadHook(void)
Definition: member.cpp:551
void ResetLocalWriteHook(CObjectOStream &out)
Definition: member.cpp:589
bool UpdateSetFlagNo(TObjectPtr object) const
set 'setFlag' to eSetNo and return true if previous value wasn't eSetNo
bool GetSetFlagNo(TConstObjectPtr object) const
true if 'setFlag' is eSetNo
virtual void UpdateFunctions(void) override
Definition: member.cpp:415
TConstObjectPtr GetDefault(void) const
TMemberGet m_GetFunction
Definition: member.hpp:210
CMemberInfo * SetDelayBuffer(CDelayBuffer *buffer)
Definition: member.cpp:313
TObjectPtr GetItemPtr(TObjectPtr object) const
void SetReadMissingFunction(TMemberReadFunction func)
Definition: member.cpp:508
void SetCopyFunction(TMemberCopyFunction func)
Definition: member.cpp:528
TConstObjectPtr m_Default
Definition: member.hpp:202
void DefaultCopyMember(CObjectStreamCopier &copier) const
void DefaultSkipMissingMember(CObjectIStream &in) const
TObjectPtr(* TMemberGet)(const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: member.hpp:72
void UpdateSetFlagYes(TObjectPtr object) const
set 'setFlag' to eSetYes
CMemberInfo * SetElementDefault(TConstObjectPtr def)
Definition: member.cpp:380
void SetLocalReadHook(CObjectIStream &in, CReadClassMemberHook *hook)
Definition: member.cpp:544
void UpdateSetFlagMaybe(TObjectPtr object) const
set 'setFlag' to eSetMaybe
CHookData< CWriteClassMemberHook, TMemberWriteFunction > m_WriteHookData
Definition: member.hpp:213
CMemberInfo * SetNsQualified(bool qualified)
Definition: member.cpp:367
bool Nillable(void) const
CMemberInfo * SetAnyContent(void)
Definition: member.cpp:355
TPointerOffsetType m_DelayOffset
Definition: member.hpp:207
void SetPathWriteHook(CObjectOStream *out, const string &path, CWriteClassMemberHook *hook)
Definition: member.cpp:595
CDelayBuffer & GetDelayBuffer(TObjectPtr object) const
void SetNotag(void)
Definition: memberid.cpp:131
TMemberIndex GetIndex(void) const
void SetLocalCopyHook(CObjectStreamCopier &copier, CCopyClassMemberHook *hook)
Definition: member.cpp:628
void SetCompressed(void)
Definition: memberid.cpp:141
void ResetLocalReadHook(CObjectIStream &in)
Definition: member.cpp:557
TObjectPtr CreateClass(void) const
Definition: member.cpp:654
void ResetGlobalCopyHook(void)
Definition: member.cpp:635
CMemberInfo(const CClassTypeInfoBase *classType, const CMemberId &id, TPointerOffsetType offset, const CTypeRef &type)
Definition: member.cpp:169
void SetCopyMissingFunction(TMemberCopyFunction func)
Definition: member.cpp:533
CHookPairData< CReadClassMemberHook, TMemberReadFunction > m_ReadHookData
Definition: member.hpp:212
ESetFlag GetSetFlag(TConstObjectPtr object) const
return current value of 'setFlag'
static TMemberIndex FirstIndex(void)
Definition: memberlist.hpp:78
void SetReadFunction(TMemberReadFunction func)
Definition: member.cpp:503
virtual void UpdateDelayedBuffer(CObjectIStream &in, TObjectPtr classPtr) const override
Definition: member.cpp:490
TPointerOffsetType m_SetFlagOffset
Definition: member.hpp:204
bool CanBeDelayed(void) const
bool HaveNoPrefix(void) const
void SetGlobalCopyHook(CCopyClassMemberHook *hook)
Definition: member.cpp:622
CMemberInfo * SetNotag(void)
Definition: member.cpp:349
void ResetGlobalWriteHook(void)
Definition: member.cpp:583
void SetNsQualified(bool qualified)
Definition: memberid.cpp:155
void SetGlobalReadHook(CReadClassMemberHook *hook)
Definition: member.cpp:538
TTypeInfo GetTypeInfo(void) const
bool HaveSetFlag(void) const
CHookPairData< CSkipClassMemberHook, TMemberSkipFunction > m_SkipHookData
Definition: member.hpp:214
void SetLocalWriteHook(CObjectOStream &out, CWriteClassMemberHook *hook)
Definition: member.cpp:576
void SetWriteFunction(TMemberWriteFunction func)
Definition: member.cpp:513
void ResetLocalCopyHook(CObjectStreamCopier &copier)
Definition: member.cpp:641
void SetSkipFunction(TMemberSkipFunction func)
Definition: member.cpp:518
void DefaultSkipMember(CObjectIStream &in) const
void SetNillable(void)
Definition: memberid.cpp:146
void SetParentClass(void)
Definition: member.cpp:269
void DefaultWriteMember(CObjectOStream &out, TConstObjectPtr classPtr) const
bool CompareSetFlags(TConstObjectPtr object1, TConstObjectPtr object2) const
Definition: member.cpp:403
void DefaultCopyMissingMember(CObjectStreamCopier &copier) const
void SetParentTag(void)
Definition: memberid.cpp:106
CMemberInfo * SetSetFlag(const bool *setFlag)
Definition: member.cpp:385
void DefaultReadMember(CObjectIStream &in, TObjectPtr classPtr) const
CMemberInfo * SetCompressed(void)
Definition: member.cpp:361
void Validate(TConstObjectPtr classPtr, const CObjectStack &stk) const
void SetPathSkipHook(CObjectIStream *in, const string &path, CSkipClassMemberHook *hook)
Definition: member.cpp:615
void * TObjectPtr
Definition: serialdef.hpp:55
size_t TMemberIndex
Type used for indexing class members and choice variants.
Definition: serialdef.hpp:230
ESerialVerifyData
Data verification parameters.
Definition: serialdef.hpp:107
const void * TConstObjectPtr
Definition: serialdef.hpp:59
static const char ms_UnassignedByte
Definition: serialbase.hpp:173
ETypeFamily
Type family.
Definition: serialdef.hpp:138
ssize_t TPointerOffsetType
Definition: serialdef.hpp:241
#define XSERIAL_TYPEINFO_WRITELOCK
Definition: serialimpl.hpp:277
static const char * ms_UnassignedStr
Definition: serialbase.hpp:172
static const TObjectType * SafeCast(TTypeInfo type)
Definition: serialutil.hpp:76
@ eSerialVerifyData_Yes
do verify
Definition: serialdef.hpp:111
@ eSerialVerifyData_No
do not verify
Definition: serialdef.hpp:109
@ ePrimitiveValueString
string|char*|const char*
Definition: serialdef.hpp:153
@ eTypeFamilyClass
Definition: serialdef.hpp:140
@ eTypeFamilyContainer
Definition: serialdef.hpp:142
@ eTypeFamilyPointer
Definition: serialdef.hpp:143
@ eTypeFamilyPrimitive
Definition: serialdef.hpp:139
@ eSerial_Xml
XML.
Definition: serialdef.hpp:75
void(* TMemberReadFunction)(CObjectIStream &in, const CMemberInfo *memberInfo, TObjectPtr classPtr)
Definition: hookfunc.hpp:65
void SetDefaultFunction1st(TFunction func)
Definition: hookdata.hpp:242
void ResetGlobalHook(void)
Definition: hookdata.hpp:278
void SetPathHook(CObjectStack *stk, const string &path, THook *hook)
Definition: hookdata.hpp:267
void SetLocalHook(TLocalHooks &key, THook *hook)
Definition: hookdata.hpp:257
void SetDefaultFunction2nd(TFunction func)
Definition: hookdata.hpp:249
void SetDefaultFunction(TFunction func)
Definition: hookdata.hpp:133
void SetPathHook(CObjectStack *stk, const string &path, THook *hook)
Definition: hookdata.hpp:151
void ResetLocalHook(TLocalHooks &key)
Definition: hookdata.hpp:273
void ResetGlobalHook(void)
Definition: hookdata.hpp:162
void SetLocalHook(TLocalHooks &key, THook *hook)
Definition: hookdata.hpp:141
void SetGlobalHook(THook *hook)
Definition: hookdata.hpp:262
THook * GetPathHook(CObjectStack &stk) const
Definition: hookdata.hpp:177
THook * GetHook(const TLocalHooks &key) const
Definition: hookdata.hpp:289
void(* TMemberWriteFunction)(CObjectOStream &out, const CMemberInfo *memberInfo, TConstObjectPtr classPtr)
Definition: hookfunc.hpp:68
void SetGlobalHook(THook *hook)
Definition: hookdata.hpp:146
void(* TMemberSkipFunction)(CObjectIStream &in, const CMemberInfo *memberInfo)
Definition: hookfunc.hpp:73
THook * GetHook(const TLocalHooks &key) const
Definition: hookdata.hpp:173
THook * GetPathHook(CObjectStack &stk) const
Definition: hookdata.hpp:293
void ResetLocalHook(TLocalHooks &key)
Definition: hookdata.hpp:157
void SetDefaultFunctions(TFunctions funcs)
Definition: hookdata.hpp:235
void(* TMemberCopyFunction)(CObjectStreamCopier &copier, const CMemberInfo *memberInfo)
Definition: hookfunc.hpp:71
bool Valid(void) const
Is iterator valid.
virtual void CopyMissingClassMember(CObjectStreamCopier &copier, const CObjectTypeInfoMI &member)
Definition: objhook.cpp:160
bool Valid(void) const
Is iterator valid.
void Update(void)
Parse stored data.
Definition: delaybuf.hpp:80
void SetMemberNillable()
Definition: objistr.hpp:1117
virtual void SkipMissingClassMember(CObjectIStream &stream, const CObjectTypeInfoMI &member)
Definition: objhook.cpp:121
virtual void SkipClassMember(CObjectIStream &stream, const CObjectTypeInfoMI &member)=0
virtual void CopyClassMember(CObjectStreamCopier &copier, const CObjectTypeInfoMI &member)=0
void SetPrimitiveValueString(const string &value)
Definition: objectinfo.cpp:282
void SetMemberDefault(TConstObjectPtr def)
Definition: objistr.hpp:1103
CLocalHookSet< CReadClassMemberHook > m_ClassMemberHookKey
Definition: objistr.hpp:1147
virtual void ReadMissingClassMember(CObjectIStream &in, const CObjectInfoMI &member)
Definition: objhook.cpp:52
#define BEGIN_OBJECT_FRAME_OF2(Stream, Type, Arg)
Definition: objstack.hpp:219
CObjectIStream & In(void) const
void ExpectedMember(const CMemberInfo *memberInfo)
CLocalHookSet< CCopyClassMemberHook > m_ClassMemberHookKey
Definition: objcopy.hpp:159
virtual void WriteClassMember(CObjectOStream &out, const CConstObjectInfoMI &member)=0
void UnsetMemberSpecialCase(void)
Definition: objistr.hpp:1111
CLocalHookSet< CWriteClassMemberHook > m_ClassMemberHookKey
Definition: objostr.hpp:831
void GetPrimitiveValueString(string &value) const
Get string data.
Definition: objectinfo.cpp:199
CElementIterator BeginElements(void) const
Create container elements iterator.
CLocalHookSet< CSkipClassMemberHook > m_ClassMemberSkipHookKey
Definition: objistr.hpp:1150
EPrimitiveValueType GetPrimitiveValueType(void) const
Get type of primitive value.
Definition: objectinfo.cpp:109
#define END_OBJECT_FRAME_OF(Stream)
Definition: objstack.hpp:201
void CopyObject(TTypeInfo type)
Copy object, omitting file header both in input and output streams.
virtual void ReadClassMember(CObjectIStream &in, const CObjectInfoMI &member)=0
This method will be called at approriate time when the object of requested type is to be read.
@ fNoError
No error.
Definition: objistr.hpp:371
@ fUnassigned
Mandatory object member is unassigned Normally this results in throwing CUnassignedMember exception.
Definition: objostr.hpp:333
@ eMissingValue
Mandatory value was missing in the input.
Definition: exception.hpp:63
@ eNullValue
Data value is null.
Definition: exception.hpp:64
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
virtual const string & Get(const string &section, const string &name, TFlags flags=0) const
Get the parameter value.
Definition: ncbireg.cpp:262
#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 int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
Definition: ncbistr.cpp:219
virtual bool IsDefault(TConstObjectPtr object) const =0
Check, whether the object contains default value.
ETypeFamily GetTypeFamily(void) const
TTypeInfo GetPointedType(void) const
const CMemberInfo * GetMemberInfo(TMemberIndex index) const
bool Implicit(void) const
void ReadData(CObjectIStream &in, TObjectPtr object) const
virtual void Assign(TObjectPtr dst, TConstObjectPtr src, ESerialRecursionMode how=eRecursive) const =0
Set object to copy of another one.
virtual bool Equals(TConstObjectPtr object1, TConstObjectPtr object2, ESerialRecursionMode how=eRecursive) const =0
Check if both objects contain the same values.
TConstObjectPtr GetObjectPointer(TConstObjectPtr object) const
size_t GetSize(void) const
Get size of data object in memory (like sizeof in C)
virtual void SetDefault(TObjectPtr dst) const =0
Set object to default value.
void SkipData(CObjectIStream &in) const
TObjectPtr Create(CObjectMemoryPool *memoryPool=0) const
Create object of this type on heap (can be deleted by operator delete)
#define NCBI_XSERIAL_EXPORT
Definition: ncbi_export.h:1435
Definition of all error codes used in serial libraries (xser.lib, xcser.lib).
CMemberInfoFunctions TFunc
Definition: member.cpp:167
bool EnabledDelayBuffers(void)
Definition: member.cpp:281
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
#define verify(expr)
Definition: ncbi_assert.h:51
Multi-threading – mutexes; rw-locks; semaphore.
std::istream & in(std::istream &in_, double &x_)
static pcre_uint8 * buffer
Definition: pcretest.c:1051
Definition: type.c:6
#define _ASSERT
Modified on Wed Apr 17 13:10:50 2024 by modify_doxy.py rev. 669887