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

Go to the SVN repository for this file.

1 /* $Id: serialobject.cpp 99878 2023-05-18 17:34:26Z 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: Aleksey Grichenko
27 *
28 * File Description:
29 * Base class for serializable objects
30 *
31 */
32 
33 #include <ncbi_pch.hpp>
35 #include <corelib/ncbimtx.hpp>
36 #include <corelib/ncbithr.hpp>
37 #include <corelib/ncbi_param.hpp>
38 #include <serial/serialbase.hpp>
39 #include <serial/typeinfo.hpp>
40 
41 #include <serial/objostr.hpp>
42 #include <serial/objistr.hpp>
43 #include <serial/objostrxml.hpp>
44 #include <serial/objistrxml.hpp>
45 #include <serial/objistrasn.hpp>
46 #include <serial/objistrasnb.hpp>
47 #include <serial/objostrasn.hpp>
48 #include <serial/objostrasnb.hpp>
49 
51 #include <serial/error_codes.hpp>
52 
53 
54 #define NCBI_USE_ERRCODE_X Serial_Core
55 
56 
58 
59 static bool IsSameTypeInfo( const CSerialObject& obj1,
60  const CSerialObject& obj2 )
61 {
62  TTypeInfo type1 = obj1.GetThisTypeInfo();
63  while (type1->GetTypeFamily() == eTypeFamilyPointer) {
64  const CPointerTypeInfo* t = dynamic_cast<const CPointerTypeInfo*>(type1);
65  type1 = t->GetPointedType();
66  }
67  TTypeInfo type2 = obj2.GetThisTypeInfo();
68  while (type2->GetTypeFamily() == eTypeFamilyPointer) {
69  const CPointerTypeInfo* t = dynamic_cast<const CPointerTypeInfo*>(type2);
70  type2 = t->GetPointedType();
71  }
72  return (type1 == type2);
73 }
74 
75 
77 {
78 }
79 
81 {
82 }
83 
85 {
86  if (this == &source) {
87  ERR_POST_X(3, Warning <<
88  "CSerialObject::Assign(): an attempt to assign a serial object to itself");
89  return;
90  }
91  if ( typeid(source) != typeid(*this) && !IsSameTypeInfo(source, *this) ) {
92  string msg("Assignment of incompatible types: ");
93  msg += typeid(*this).name();
94  msg += " = ";
95  msg += typeid(source).name();
96  NCBI_THROW(CSerialException,eIllegalCall, msg);
97  }
98  GetThisTypeInfo()->Assign(this, &source, how);
99 }
100 
101 
103 {
104  if ( typeid(object) != typeid(*this) && !IsSameTypeInfo(object, *this) ) {
105  string msg("Cannot compare types: ");
106  msg += typeid(*this).name();
107  msg += " == ";
108  msg += typeid(object).name();
109  NCBI_THROW(CSerialException,eIllegalCall, msg);
110  }
111  return GetThisTypeInfo()->Equals(this, &object, how);
112 }
113 
114 void CSerialObject::DebugDump(CDebugDumpContext ddc, unsigned int depth) const
115 {
116  ddc.SetFrame("CSerialObject");
117  CObject::DebugDump( ddc, depth);
118 // this is not good, but better than nothing
119  CNcbiOstrstream ostr;
120  ostr << "\n****** begin ASN dump ******\n";
121  {{
122  unique_ptr<CObjectOStream> oos(CObjectOStream::Open(eSerial_AsnText,
123  ostr));
124  oos->SetAutoSeparator(false);
125  oos->SetVerifyData(eSerialVerifyData_No);
126  oos->Write(this, GetThisTypeInfo());
127  }}
128  ostr << "\n****** end ASN dump ******\n";
129  ddc.Log( "Serial_AsnText", CNcbiOstrstreamToString(ostr));
130 }
131 
132 /////////////////////////////////////////////////////////////////////////////
133 // data verification setup
134 
135 const char* CSerialObject::ms_UnassignedStr = "<*unassigned*>";
136 const char CSerialObject::ms_UnassignedByte = char(0xcd);
137 
138 NCBI_PARAM_ENUM_ARRAY(ESerialVerifyData, SERIAL, VERIFY_DATA_GET)
139 {
140  {"NO", eSerialVerifyData_No},
141  {"NEVER", eSerialVerifyData_Never},
142  {"YES", eSerialVerifyData_Yes},
143  {"ALWAYS", eSerialVerifyData_Always},
144  {"DEFVALUE", eSerialVerifyData_DefValue},
145  {"DEFVALUE_ALWAYS", eSerialVerifyData_DefValueAlways}
146 };
147 NCBI_PARAM_ENUM_DECL(ESerialVerifyData, SERIAL, VERIFY_DATA_GET);
149 typedef NCBI_PARAM_TYPE(SERIAL, VERIFY_DATA_GET) TSerialVerifyData;
150 
151 
153 {
154  ESerialVerifyData now = TSerialVerifyData::GetThreadDefault();
155  if (now != eSerialVerifyData_Never &&
156  now != eSerialVerifyData_Always &&
159  TSerialVerifyData::ResetThreadDefault();
160  } else {
161  TSerialVerifyData::SetThreadDefault(verify);
162  }
163  }
164 }
165 
167 {
168  ESerialVerifyData now = TSerialVerifyData::GetDefault();
169  if (now != eSerialVerifyData_Never &&
170  now != eSerialVerifyData_Always &&
173  TSerialVerifyData::ResetDefault();
174  } else {
175  TSerialVerifyData::SetDefault(verify);
176  }
177  }
178 }
179 
181 {
182  ESerialVerifyData now = TSerialVerifyData::GetThreadDefault();
183  if (now == eSerialVerifyData_Default) {
184  now = TSerialVerifyData::GetDefault();
185  if (now == eSerialVerifyData_Default) {
186 // this is to provide compatibility with old implementation
187  const char* str = getenv(SERIAL_VERIFY_DATA_GET);
188  if (str) {
189  if (NStr::CompareNocase(str,"YES") == 0) {
190  now = eSerialVerifyData_Yes;
191  } else if (NStr::CompareNocase(str,"NO") == 0) {
192  now = eSerialVerifyData_No;
193  } else if (NStr::CompareNocase(str,"NEVER") == 0) {
195  } else if (NStr::CompareNocase(str,"ALWAYS") == 0) {
197  } else if (NStr::CompareNocase(str,"DEFVALUE") == 0) {
199  } else if (NStr::CompareNocase(str,"DEFVALUE_ALWAYS") == 0) {
201  }
202  }
203  }
204  }
205  switch (now) {
206  default:
208  break;
211  return eSerialVerifyData_No;
214  return eSerialVerifyData_Yes;
217  return eSerialVerifyData_No;
218  }
219  // change the default here, if you like
220  return eSerialVerifyData_Yes;
221 }
222 
224 
225 struct SPrintIdentifier
226 {
229 };
231 {
232  SIZE_TYPE size = s.m_String.size();
233  SIZE_TYPE e_pos = NPOS;
234  if ( size > 2 && NStr::EndsWith(s.m_String, ".E") ) {
235  e_pos = s.m_String.rfind('.', size-3);
236  if ( e_pos != NPOS ) {
237  size -= 2;
238  }
239  }
240  bool capitalize = true;
241  for ( SIZE_TYPE i = 0; i < size; ++i ) {
242  char c = s.m_String[i];
243  if ( c == '.' ) {
244  out << "::C_";
245  if ( i == e_pos ) {
246  out << "E_";
247  }
248  capitalize = true;
249  }
250  else {
251  if ( c == '-' ) {
252  c = '_';
253  }
254  if ( capitalize ) {
255  c = (char)toupper((unsigned char)c);
256  capitalize = false;
257  }
258  out << c;
259  }
260  }
261  return out;
262 }
263 
265 
267  const char* file_name,
268  int file_line) const
269 {
271  const CTypeInfo* type = GetThisTypeInfo();
272  const CClassTypeInfoBase* classtype =
273  dynamic_cast<const CClassTypeInfoBase*>(type);
274  // offset index as the argument is zero based but items are 1 based
275  string member_name;
276  if ( classtype ) {
277  index += classtype->GetItems().FirstIndex();
278  if ( index >= classtype->GetItems().FirstIndex() &&
279  index <= classtype->GetItems().LastIndex() ) {
280  member_name = classtype->GetItems().GetItemInfo(index)->GetId().GetName();
281  }
282  }
283  CNcbiOstrstream s;
284  if ( true ) {
285  // make class name
286  s << "C" << SPrintIdentifier(type->GetAccessName());
287  }
288  if ( !member_name.empty() ) {
289  // make method name
290  s << "::Get" << SPrintIdentifier(member_name) << "()";
291  }
292  s << ": Attempt to get unassigned member "
293  << type->GetAccessModuleName() <<"::"<< type->GetAccessName() << '.';
294  if ( !member_name.empty() ) {
295  s << member_name;
296  } else {
297  s << '[' << index << ']';
298  }
299 // set temporary diag compile info to use argument file name and line
300 #undef DIAG_COMPILE_INFO
301 #define DIAG_COMPILE_INFO \
302  NCBI_NS_NCBI::CDiagCompileInfo(file_name? file_name: __FILE__, \
303  file_line? file_line: __LINE__, \
304  NCBI_CURRENT_FUNCTION, \
305  NCBI_MAKE_MODULE(NCBI_MODULE))
307 // restore original diag compile info definition
308 #undef DIAG_COMPILE_INFO
309 #define DIAG_COMPILE_INFO \
310  NCBI_NS_NCBI::CDiagCompileInfo(__FILE__, \
311  __LINE__, \
312  NCBI_CURRENT_FUNCTION, \
313  NCBI_MAKE_MODULE(NCBI_MODULE))
314  }
315 }
316 
318 {
319  ThrowUnassigned(index, 0, 0);
320 }
321 
323 {
324  return GetThisTypeInfo()->HasNamespaceName();
325 }
326 
327 const string& CSerialObject::GetNamespaceName(void) const
328 {
329  return GetThisTypeInfo()->GetNamespaceName();
330 }
331 
333 {
335 }
336 
337 const string& CSerialObject::GetNamespacePrefix(void) const
338 {
340 }
341 
342 
344  const string& name, const string& ns_name, const CStringUTF8& value)
345  : m_Name(name), m_NsName(ns_name), m_Value(value)
346 {
347 }
349  : m_Name(other.m_Name), m_NsName(other.m_NsName), m_Value(other.m_Value)
350 {
351 }
352 
354 {
355 }
356 const string& CSerialAttribInfoItem::GetName(void) const
357 {
358  return m_Name;
359 }
361 {
362  return m_NsName;
363 }
365 {
366  return m_Value;
367 }
368 
369 
371 {
372 }
373 
375 {
376  x_Copy(other);
377 }
378 
380 {
381 }
382 
384 {
386 }
387 
389 {
390  m_Name.erase();
391  m_Value.erase();
392  m_NsName.erase();
393  m_NsPrefix.erase();
394  m_Attlist.clear();
395 }
396 
398 {
399  m_Name = other.m_Name;
400  m_Value= other.m_Value;
401  m_NsName= other.m_NsName;
402  m_NsPrefix= other.m_NsPrefix;
403  m_Attlist.clear();
404  vector<CSerialAttribInfoItem>::const_iterator it;
405  for (it = other.m_Attlist.begin(); it != other.m_Attlist.end(); ++it) {
406  m_Attlist.push_back( *it);
407  }
408 }
410 {
411  x_Copy(other);
412  return *this;
413 }
414 
416 {
417  return m_Name == other.GetName() &&
418  m_Value == other.GetValue() &&
419  m_NsName == other.m_NsName;
420 }
421 
422 void CAnyContentObject::SetName(const string& name)
423 {
424  m_Name = name;
425 }
426 const string& CAnyContentObject::GetName(void) const
427 {
428  return m_Name;
429 }
431 {
432  x_Decode(value);
433 }
435 {
436  return m_Value;
437 }
438 void CAnyContentObject::SetNamespaceName(const string& ns_name)
439 {
440  m_NsName = ns_name;
441 }
442 const string& CAnyContentObject::GetNamespaceName(void) const
443 {
444  return m_NsName;
445 }
446 void CAnyContentObject::SetNamespacePrefix(const string& ns_prefix)
447 {
448  m_NsPrefix = ns_prefix;
449 }
450 const string& CAnyContentObject::GetNamespacePrefix(void) const
451 {
452  return m_NsPrefix;
453 }
455 {
456  m_Value = value;
457 }
459  const string& name, const string& ns_name, const CStringUTF8& value)
460 {
461 // TODO: check if an attrib with this name+ns_name already exists
462  m_Attlist.push_back( CSerialAttribInfoItem( name,ns_name,value));
463 }
464 
465 const vector<CSerialAttribInfoItem>&
467 {
468  return m_Attlist;
469 }
470 
471 /////////////////////////////////////////////////////////////////////////////
472 // I/O stream manipulators and helpers for serializable objects
473 
474 #define eFmt_AsnText (1l << 0)
475 #define eFmt_AsnBinary (1l << 1)
476 #define eFmt_Xml (1l << 2)
477 #define eFmt_Json (1l << 3)
478 #define eFmt_All (eFmt_AsnText | eFmt_AsnBinary | eFmt_Xml | eFmt_Json)
479 
480 #define eVerify_No (1l << 8)
481 #define eVerify_Yes (1l << 9)
482 #define eVerify_DefValue (1l << 10)
483 #define eVerify_All (eVerify_No | eVerify_Yes | eVerify_DefValue)
484 
485 #define eSkipUnkMembers_No (1l << 11)
486 #define eSkipUnkMembers_Yes (1l << 12)
487 #define eSkipUnkMembers_All (eSkipUnkMembers_No | eSkipUnkMembers_Yes)
488 
489 #define eSkipUnkVariants_No (1l << 13)
490 #define eSkipUnkVariants_Yes (1l << 14)
491 #define eSkipUnkVariants_All (eSkipUnkVariants_No | eSkipUnkVariants_Yes)
492 
493 #define eEncoding_All (255l << 16)
494 #define eFmtFlags_All (255l << 24)
495 
496 #define eFixNonPrint_Default 0
497 #define eFixNonPrint_Skip 1
498 #define eFixNonPrint_Allow 2
499 #define eFixNonPrint_Replace 3
500 #define eFixNonPrint_ReplaceAndWarn 4
501 #define eFixNonPrint_Throw 5
502 #define eFixNonPrint_Abort 6
503 
504 #define eFixNonPrint_All 7
505 
506 #define eSerIndex_Format 0
507 #define eSerIndex_Verify 0
508 #define eSerIndex_SkipUnkMembers 0
509 #define eSerIndex_SkipUnkVariants 0
510 #define eSerIndex_Encoding 0
511 #define eSerIndex_FixNonPrint 1
512 #define eSerIndex_Count 2
513 
514 static
515 long& s_SerFlags(CNcbiIos& io, size_t idx)
516 {
517  static int s_SerIndex[eSerIndex_Count];
518  static atomic<bool> s_HaveIndex;
519 
520  if ( !s_HaveIndex.load(memory_order_acquire) ) {
521  // Make sure to get a unique IOS index
522  DEFINE_STATIC_FAST_MUTEX(s_IndexMutex);
523  CFastMutexGuard guard(s_IndexMutex);
524  if ( !s_HaveIndex.load(memory_order_acquire) ) {
525  for (int i = 0; i < eSerIndex_Count; ++i) {
526  s_SerIndex[i] = CNcbiIos::xalloc();
527  }
528  s_HaveIndex.store(true, memory_order_release);
529  }
530  }
531 
532  _ASSERT(idx < eSerIndex_Count);
533  return io.iword(s_SerIndex[idx]);
534 }
535 static
537 {
538  switch (s_SerFlags(io, eSerIndex_Format) & eFmt_All) {
539  case eFmt_AsnText: return eSerial_AsnText;
540  case eFmt_AsnBinary: return eSerial_AsnBinary;
541  case eFmt_Xml: return eSerial_Xml;
542  case eFmt_Json: return eSerial_Json;
543  default: return eSerial_None;
544  }
545 }
546 static
548 {
549  switch (fmt) {
550  case eSerial_AsnText: return eFmt_AsnText;
551  case eSerial_AsnBinary: return eFmt_AsnBinary;
552  case eSerial_Xml: return eFmt_Xml;
553  case eSerial_Json: return eFmt_Json;
554  default: return 0;
555  }
556 }
557 
558 static
560 {
561  switch (s_SerFlags(io, eSerIndex_Verify) & eVerify_All) {
562  case eVerify_No: return eSerialVerifyData_No;
563  case eVerify_Yes: return eSerialVerifyData_Yes;
565  default: return eSerialVerifyData_Default;
566  }
567 }
568 
569 static
571 {
572  switch (fmt) {
574  case eSerialVerifyData_No: return eVerify_No;
576  case eSerialVerifyData_Yes: return eVerify_Yes;
579  default: return 0;
580  }
581 }
582 
583 static
585 {
589  default: return eSerialSkipUnknown_Default;
590  }
591 }
592 
593 static
595 {
596  switch (fmt) {
601  default: return 0;
602  }
603 }
604 static
606 {
610  default: return eSerialSkipUnknown_Default;
611  }
612 }
613 
614 static
616 {
617  switch (fmt) {
622  default: return 0;
623  }
624 }
625 
626 static
628 {
629  long enc = (s_SerFlags(io, eSerIndex_Encoding) & eEncoding_All) >> 16;
630  switch (enc) {
631  default:
632  case 1: return eEncoding_UTF8;
633  case 2: return eEncoding_Ascii;
634  case 3: return eEncoding_ISO8859_1;
635  case 4: return eEncoding_Windows_1252;
636  }
637 }
638 
639 static
641 {
642  long enc = 0;
643  switch (fmt) {
644  default: enc = 0; break;
645  case eEncoding_UTF8: enc = 1; break;
646  case eEncoding_Ascii: enc = 2; break;
647  case eEncoding_ISO8859_1: enc = 3; break;
648  case eEncoding_Windows_1252: enc = 4; break;
649  }
650  return (enc << 16);
651 }
652 
653 static
655 {
657  switch (fnp) {
658  case eFixNonPrint_Skip: return eFNP_Skip;
659  case eFixNonPrint_Allow: return eFNP_Allow;
660  case eFixNonPrint_Replace: return eFNP_Replace;
662  case eFixNonPrint_Throw: return eFNP_Throw;
663  case eFixNonPrint_Abort: return eFNP_Abort;
664  default: return eFNP_Default;
665  }
666 }
667 
669 {
670  switch (fnp) {
671  case eFNP_Default: return eFixNonPrint_Default;
672  case eFNP_Skip: return eFixNonPrint_Skip;
673  case eFNP_Allow: return eFixNonPrint_Allow;
674  case eFNP_Replace: return eFixNonPrint_Replace;
676  case eFNP_Throw: return eFixNonPrint_Throw;
677  case eFNP_Abort: return eFixNonPrint_Abort;
678  default: break;
679  }
680  return 0;
681 }
682 
683 static
685 {
687  return t >> 24;
688 }
689 
690 static
691 long s_FormatFlagsToFlags(unsigned long flags)
692 {
693  return flags << 24;
694 }
695 
697 {
698  return s_FlagsToFormat(io) != eSerial_None;
699 }
700 
701 MSerial_Flags::MSerial_Flags(unsigned long all, unsigned long flags, int idx)
702  : m_Index(idx), m_All(all), m_Flags(flags)
703 {
704 }
706 {
707  s_SerFlags(io, m_Index) = (s_SerFlags(io, m_Index) & ~m_All) | m_Flags;
708 }
709 
711 {
713 }
714 
718 {
719 }
720 
722 {
724  return *this;
725 }
727 {
729  return *this;
730 }
732 {
734  return *this;
735 }
736 
739 {
740 }
741 
744 {
745 }
746 
749 {
750 }
751 
754 {
755 }
756 
759 {
760 }
761 
763 {
764 // s_SerFlags(io) = (s_SerFlags(io) & ~eFmt_All);
765  for (int i = 0; i < eSerIndex_Count; ++i) {
766  s_SerFlags(io, i) = 0;
767  }
768  return io;
769 }
770 
771 
772 // Class member assignment verification
774 {
776  return io;
777 }
779 {
781  return io;
782 }
784 {
786  return io;
787 }
789 {
791  return io;
792 }
793 
794 
795 // Input/output
797 {
798  return WriteObject(os,&obj,obj.GetThisTypeInfo());
799 }
800 
802 {
803  return ReadObject(is,&obj,obj.GetThisTypeInfo());
804 }
805 
807 {
808  return WriteObject(os,obj.GetObjectPtr(),obj.GetTypeInfo());
809 }
810 
812 {
813  return ReadObject(is,obj.GetObjectPtr(),obj.GetTypeInfo());
814 }
815 
817 {
818  unique_ptr<CObjectOStream> ostr( CObjectOStream::Open( s_FlagsToFormat(os), os) );
819  ostr->SetVerifyData( s_FlagsToVerify(os) );
820  ostr->SetFormattingFlags( s_FlagsToFormatFlags(os) );
821  if (ostr->GetDataFormat() == eSerial_Xml) {
822  dynamic_cast<CObjectOStreamXml*>(ostr.get())->
823  SetDefaultStringEncoding( s_FlagsToEncoding(os) );
824  }
826  ostr->Write(ptr,info);
827  return os;
828 }
830 {
831  unique_ptr<CObjectIStream> istr( CObjectIStream::Open(s_FlagsToFormat(is), is) );
832  istr->SetVerifyData(s_FlagsToVerify(is));
833  istr->SetSkipUnknownMembers( s_FlagsToSkipUnkMembers(is));
834  istr->SetSkipUnknownVariants( s_FlagsToSkipUnkVariants(is));
836  if (f != 0) {
837  ERR_POST_XX_ONCE(Serial_IStream, 9, Warning <<
838  "ReadObject: ignoring unknown formatting flags");
839  }
840  if (istr->GetDataFormat() == eSerial_Xml) {
841  dynamic_cast<CObjectIStreamXml*>(istr.get())->
842  SetDefaultStringEncoding( s_FlagsToEncoding(is) );
843  }
845  istr->Read(ptr,info);
846  return is;
847 }
848 
849 
Serializable object that stores any combination of parsable data.
Definition: serialbase.hpp:264
CConstObjectInfo –.
Definition: objectinfo.hpp:421
void SetFrame(const string &frame)
Definition: ddumpable.cpp:137
void Log(const string &name, const char *value, CDebugDumpFormatter::EValueType type=CDebugDumpFormatter::eValue, const string &comment=kEmptyStr)
Definition: ddumpable.cpp:151
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
CObjectIStreamXml –.
Definition: objistrxml.hpp:56
CObjectInfo –.
Definition: objectinfo.hpp:597
CObjectOStreamXml –.
Definition: objostrxml.hpp:54
XML attribute information item.
Definition: serialbase.hpp:240
Root class for all serialization exceptions.
Definition: exception.hpp:50
Base class for all serializable objects.
Definition: serialbase.hpp:150
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
Thrown on an attempt to write unassigned data member.
Definition: exception.hpp:84
char value[7]
Definition: config.c:431
static uch flags
static unsigned char depth[2 *(256+1+29)+1]
const char * file_name[]
std::ofstream out("events_result.xml")
main entry point for tests
static int type
Definition: getdata.c:31
#define ERR_POST_XX_ONCE(error_name, err_subcode, message)
Error posting only once during program execution with given error code name and given error subcode.
Definition: ncbidiag.hpp:643
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
Definition: ncbidiag.hpp:550
#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
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
const CMemberId & GetId(void) const
const string & GetName(void) const
const CItemInfo * GetItemInfo(TMemberIndex index) const
static TMemberIndex FirstIndex(void)
Definition: memberlist.hpp:78
TMemberIndex LastIndex(void) const
Definition: memberlist.hpp:82
ESerialRecursionMode
How to assign and compare child sub-objects of serial objects.
Definition: serialdef.hpp:191
CAnyContentObject & operator=(const CAnyContentObject &other)
unsigned int TSerial_Json_Flags
Definition: serialdef.hpp:100
virtual ~CAnyContentObject(void)
static bool HasSerialFormatting(CNcbiIos &io)
virtual void DebugDump(CDebugDumpContext ddc, unsigned int depth) const
Define method for dumping debug information.
MSerial_SkipUnknownMembers(ESerialSkipUnknown fmt)
static const CTypeInfo * GetTypeInfo(void)
bool operator==(const CAnyContentObject &other) const
ESerialSkipUnknown
Skip unknown members parameters.
Definition: serialdef.hpp:118
static void SetVerifyDataGlobal(ESerialVerifyData verify)
EFixNonPrint
How to process non-printing character in the ASN VisibleString.
Definition: serialdef.hpp:173
void * TObjectPtr
Definition: serialdef.hpp:55
CNcbiIstream & operator>>(CNcbiIstream &is, CSerialObject &obj)
const CStringUTF8 & GetValue(void) const
Get normalized value.
unsigned int TSerial_AsnText_Flags
Definition: serialdef.hpp:84
const CStringUTF8 & GetValue(void) const
Get normalized value of the information item.
size_t TMemberIndex
Type used for indexing class members and choice variants.
Definition: serialdef.hpp:230
static ESerialVerifyData x_GetVerifyData(void)
const string & GetNamespaceName(void) const
Get namespace name.
MSerial_Format(ESerialDataFormat fmt, TSerial_Format_Flags flags=0)
ESerialVerifyData
Data verification parameters.
Definition: serialdef.hpp:107
CNcbiIstream & ReadObject(CNcbiIstream &is, TObjectPtr ptr, TTypeInfo info)
const void * TConstObjectPtr
Definition: serialdef.hpp:59
CNcbiOstream & WriteObject(CNcbiOstream &os, TConstObjectPtr ptr, TTypeInfo info)
static const char ms_UnassignedByte
Definition: serialbase.hpp:173
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
#define SERIAL_VERIFY_DATA_GET
Definition: serialdef.hpp:102
void SetFlags(CNcbiIos &io) const
CNcbiIos & MSerial_VerifyNo(CNcbiIos &io)
void ThrowUnassigned(TMemberIndex index) const
const string & GetNamespaceName(void) const
Get namespace name of the information item.
CNcbiIos & MSerial_None(CNcbiIos &io)
Reset all formatting flags for the I/O stream.
void SetName(const string &name)
Set local name.
MSerial_Format & operator()(TSerial_Json_Flags flags)
void AddAttribute(const string &name, const string &ns_name, const CStringUTF8 &value)
Add attribute.
MSerial_Format & operator()(TSerial_AsnText_Flags flags)
const string & GetNamespaceName(void) const
Get namespace name.
bool HasNamespaceName(void) const
Check if object data type has namespace name.
void SetFormatFlags(unsigned long flags)
MSerial_SkipUnknownVariants(ESerialSkipUnknown fmt)
unsigned long m_Flags
Definition: serialbase.hpp:547
void SetNamespacePrefix(const string &ns_prefix)
Set namespace prefix.
unsigned long m_All
Definition: serialbase.hpp:546
MSerial_Flags(void)
CSerialAttribInfoItem(const string &name, const string &ns_name, const CStringUTF8 &value)
const string & GetNamespacePrefix(void) const
Get namespace prefix.
void x_Decode(const CStringUTF8 &value)
static void SetVerifyDataThread(ESerialVerifyData verify)
MSerial_FixNonPrint(EFixNonPrint fnp)
void x_Copy(const CAnyContentObject &other)
void SetNamespaceName(const string &ns_name)
Set namespace name.
const string & GetName(void) const
Get local name of the information item.
virtual ~CSerialAttribInfoItem(void)
virtual const CTypeInfo * GetThisTypeInfo(void) const =0
CNcbiIos & MSerial_VerifyDefault(CNcbiIos &io)
Define verification of un-initialized data members.
vector< CSerialAttribInfoItem > m_Attlist
Definition: serialbase.hpp:310
CStringUTF8 m_Value
Definition: serialbase.hpp:307
static const char * ms_UnassignedStr
Definition: serialbase.hpp:172
bool HasNamespacePrefix(void) const
Check if data type has namespace prefix.
unsigned int TSerial_Format_Flags
MSerial_Format –.
Definition: serialbase.hpp:571
MSerialXml_DefaultStringEncoding(EEncoding fmt)
unsigned int TSerial_Xml_Flags
Definition: serialdef.hpp:94
MSerial_VerifyData(ESerialVerifyData fmt)
const string & GetName(void) const
Get local name.
void SetValue(const CStringUTF8 &value)
Set normalized value.
virtual bool Equals(const CSerialObject &object, ESerialRecursionMode how=eRecursive) const
Check if both objects contain the same values.
MSerial_Format & operator()(TSerial_Xml_Flags flags)
const string & GetNamespacePrefix(void) const
Get namespace prefix.
ESerialDataFormat
Data file format.
Definition: serialdef.hpp:71
CNcbiIos & MSerial_VerifyYes(CNcbiIos &io)
const vector< CSerialAttribInfoItem > & GetAttributes(void) const
Get object attributes.
virtual ~CSerialObject(void)
CNcbiIos & MSerial_VerifyDefValue(CNcbiIos &io)
@ eSerialSkipUnknown_Never
never skip (even if set to skip later on)
Definition: serialdef.hpp:121
@ eSerialSkipUnknown_No
do not skip (throw exception)
Definition: serialdef.hpp:120
@ eSerialSkipUnknown_Yes
do skip
Definition: serialdef.hpp:122
@ eSerialSkipUnknown_Always
always skip (even if set not to later on)
Definition: serialdef.hpp:123
@ eSerialSkipUnknown_Default
use current default
Definition: serialdef.hpp:119
@ eFNP_Allow
pass through unchanged, post no error message
Definition: serialdef.hpp:175
@ eFNP_Skip
skip, post no error message
Definition: serialdef.hpp:174
@ eFNP_Throw
replace with '#', throw an exception
Definition: serialdef.hpp:178
@ eFNP_Abort
replace with '#', post an error of severity FATAL
Definition: serialdef.hpp:179
@ eFNP_ReplaceAndWarn
replace with '#', post an error of severity ERROR
Definition: serialdef.hpp:177
@ eFNP_Default
Definition: serialdef.hpp:181
@ eFNP_Replace
replace with '#' silently
Definition: serialdef.hpp:176
@ eSerialVerifyData_Never
never verify (even if set to verify later on)
Definition: serialdef.hpp:110
@ eSerialVerifyData_DefValueAlways
initialize field with default
Definition: serialdef.hpp:114
@ eSerialVerifyData_DefValue
initialize field with default
Definition: serialdef.hpp:113
@ eSerialVerifyData_Yes
do verify
Definition: serialdef.hpp:111
@ eSerialVerifyData_Always
always verify (even if set not to later on)
Definition: serialdef.hpp:112
@ eSerialVerifyData_No
do not verify
Definition: serialdef.hpp:109
@ eSerialVerifyData_Default
use current default
Definition: serialdef.hpp:108
@ eTypeFamilyPointer
Definition: serialdef.hpp:143
@ eSerial_AsnText
ASN.1 text.
Definition: serialdef.hpp:73
@ eSerial_Xml
XML.
Definition: serialdef.hpp:75
@ eSerial_Json
JSON.
Definition: serialdef.hpp:76
@ eSerial_None
Definition: serialdef.hpp:72
@ eSerial_AsnBinary
ASN.1 binary.
Definition: serialdef.hpp:74
EFixNonPrint FixNonPrint(EFixNonPrint how)
Definition: objistr.hpp:355
TObjectPtr GetObjectPtr(void) const
Get pointer to object.
static CObjectOStream * Open(ESerialDataFormat format, CNcbiOstream &outStream, bool deleteOutStream)
Create serial object writer and attach it to an output stream.
Definition: objostr.cpp:126
TTypeInfo GetTypeInfo(void) const
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
Definition: objistr.cpp:195
EFixNonPrint FixNonPrint(EFixNonPrint how)
Definition: objostr.hpp:203
TConstObjectPtr GetObjectPtr(void) const
Get pointer to object.
virtual void DebugDump(CDebugDumpContext ddc, unsigned int depth) const
Define method for dumping debug information.
Definition: ncbiobj.cpp:988
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
std::string CStringUTF8
Definition: ncbistl.hpp:254
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
IO_PREFIX::ios CNcbiIos
Portable alias for ios.
Definition: ncbistre.hpp:140
NCBI_NS_STD::string::size_type SIZE_TYPE
Definition: ncbistr.hpp:132
EEncoding
Definition: ncbistr.hpp:199
size_type rfind(const CTempString match, size_type pos=npos) const
Find the first instance of the entire matching string within the current string in a backward directi...
Definition: tempstr.hpp:705
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
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
Definition: ncbistr.hpp:5430
#define NPOS
Definition: ncbistr.hpp:133
size_type size(void) const
Return the length of the represented array.
Definition: tempstr.hpp:327
@ eEncoding_Windows_1252
Definition: ncbistr.hpp:207
@ eEncoding_Ascii
Definition: ncbistr.hpp:202
@ eEncoding_ISO8859_1
Note: From the point of view of the C++.
Definition: ncbistr.hpp:203
@ eEncoding_UTF8
Definition: ncbistr.hpp:201
#define DEFINE_STATIC_FAST_MUTEX(id)
Define static fast mutex and initialize it.
Definition: ncbimtx.hpp:496
bool HasNamespaceName(void) const
Check if data type has namespace name.
Definition: typeinfo.cpp:187
const CItemsInfo & GetItems(void) const
ETypeFamily GetTypeFamily(void) const
const string & GetNamespacePrefix(void) const
Get namespace prefix.
Definition: typeinfo.cpp:221
const string & GetNamespaceName(void) const
Get namespace name.
Definition: typeinfo.cpp:192
bool HasNamespacePrefix(void) const
Check if data type has namespace prefix.
Definition: typeinfo.cpp:216
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.
Definition of all error codes used in serial libraries (xser.lib, xcser.lib).
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is smart and slim</td> n<td> orig</td> n</tr> n<tr> n<td> last_modified</td> n<td> optional</td> n<td> Integer</td> n<td class=\"description\"> The blob last modification If provided then the exact match will be requested with n the Cassandra storage corresponding field value</td> n<td> Positive integer Not provided means that the most recent match will be selected</td> n<td></td> n</tr> n<tr> n<td> use_cache</td> n<td> optional</td> n<td> String</td> n<td class=\"description\"> The option controls if the Cassandra LMDB cache and or database should be used It n affects the seq id resolution step and the blob properties lookup step The following n options are BIOSEQ_INFO and BLOB_PROP at all
int i
static MDB_envinfo info
Definition: mdb_load.c:37
const struct ncbi::grid::netcache::search::fields::SIZE size
const CharType(& source)[N]
Definition: pointer.h:1149
#define verify(expr)
Definition: ncbi_assert.h:51
EIPRangeType t
Definition: ncbi_localip.c:101
Static variables safety - create on demand, destroy on application termination.
int toupper(Uchar c)
Definition: ncbictype.hpp:73
Multi-threading – mutexes; rw-locks; semaphore.
Multi-threading – classes, functions, and features.
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
@ eGet
Definition: ns_types.hpp:55
#define eEncoding_All
static EFixNonPrint s_FlagsToFixNonPrint(CNcbiIos &io)
typedef NCBI_PARAM_TYPE(SERIAL, VERIFY_DATA_GET) TSerialVerifyData
#define eFmt_AsnText
static long s_SkipUnkMembersToFlags(ESerialSkipUnknown fmt)
#define eVerify_No
#define eSerIndex_Count
#define eFixNonPrint_Skip
#define eSerIndex_SkipUnkVariants
#define eFmt_All
#define eFixNonPrint_Replace
#define eVerify_Yes
#define eSkipUnkVariants_Yes
#define eSerIndex_SkipUnkMembers
static long & s_SerFlags(CNcbiIos &io, size_t idx)
static ESerialVerifyData s_FlagsToVerify(CNcbiIos &io)
#define eFmt_AsnBinary
#define eSerIndex_Encoding
static ESerialDataFormat s_FlagsToFormat(CNcbiIos &io)
BEGIN_LOCAL_NAMESPACE
#define eVerify_All
static long s_VerifyToFlags(ESerialVerifyData fmt)
static TSerial_Format_Flags s_FlagsToFormatFlags(CNcbiIos &io)
#define eSkipUnkMembers_No
#define eSkipUnkVariants_No
static long s_FixNonPrintToFlags(EFixNonPrint fnp)
NCBI_PARAM_ENUM_ARRAY(ESerialVerifyData, SERIAL, VERIFY_DATA_GET)
#define eVerify_DefValue
static long s_EncodingToFlags(EEncoding fmt)
#define eSkipUnkMembers_Yes
static bool IsSameTypeInfo(const CSerialObject &obj1, const CSerialObject &obj2)
NCBI_PARAM_ENUM_DECL(ESerialVerifyData, SERIAL, VERIFY_DATA_GET)
static long s_FormatFlagsToFlags(unsigned long flags)
static long s_SkipUnkVariantsToFlags(ESerialSkipUnknown fmt)
NCBI_PARAM_ENUM_DEF(ESerialVerifyData, SERIAL, VERIFY_DATA_GET, eSerialVerifyData_Default)
END_LOCAL_NAMESPACE
#define eFixNonPrint_Throw
#define eFixNonPrint_Allow
static ESerialSkipUnknown s_FlagsToSkipUnkMembers(CNcbiIos &io)
#define eFixNonPrint_All
#define eSkipUnkVariants_All
#define eFixNonPrint_ReplaceAndWarn
static ESerialSkipUnknown s_FlagsToSkipUnkVariants(CNcbiIos &io)
static EEncoding s_FlagsToEncoding(CNcbiIos &io)
#define eFixNonPrint_Default
#define eFmtFlags_All
#define eFmt_Xml
#define eSerIndex_Verify
CNcbiOstream & operator<<(CNcbiOstream &out, SPrintIdentifier s)
#define eSerIndex_Format
#define eFmt_Json
static long s_FormatToFlags(ESerialDataFormat fmt)
#define eFixNonPrint_Abort
#define eSkipUnkMembers_All
#define eSerIndex_FixNonPrint
static const char * str(char *buf, int n)
Definition: stats.c:84
CTempString m_String
Definition: exception.cpp:84
SPrintIdentifier(const CTempString &s)
Definition: type.c:6
#define _ASSERT
Modified on Wed Feb 28 07:13:30 2024 by modify_doxy.py rev. 669887