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

Go to the SVN repository for this file.

1 /* $Id: objistrasnb.cpp 95875 2022-01-10 13:54:54Z grichenk $
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 #include <ncbi_pch.hpp>
34 #include <corelib/ncbistd.hpp>
35 #include <corelib/ncbi_limits.hpp>
36 #include <corelib/ncbi_param.hpp>
37 
38 #include <serial/objistrasnb.hpp>
39 #include <serial/impl/member.hpp>
40 #include <serial/impl/memberid.hpp>
41 #include <serial/enumvalues.hpp>
43 #include <serial/objhook.hpp>
45 #include <serial/impl/choice.hpp>
46 #include <serial/impl/continfo.hpp>
48 #include <serial/pack_string.hpp>
49 #include <serial/error_codes.hpp>
50 #include <math.h>
51 
52 #undef _TRACE
53 #define _TRACE(arg) ((void)0)
54 
55 #define USE_OLD_TAGS 0
56 
58 
59 #define NCBI_USE_ERRCODE_X Serial_IStream
60 
62 {
63  return new CObjectIStreamAsnBinary();
64 }
65 
66 
69 {
70  FixNonPrint(how);
72 }
73 
75  EFixNonPrint how)
77 {
78  FixNonPrint(how);
80  Open(in);
81 }
82 
84  bool deleteIn,
85  EFixNonPrint how)
87 {
88  FixNonPrint(how);
90  Open(in, deleteIn ? eTakeOwnership : eNoOwnership);
91 }
92 
94  EOwnership deleteIn,
95  EFixNonPrint how)
97 {
98  FixNonPrint(how);
100  Open(in, deleteIn);
101 }
102 
104  EFixNonPrint how)
106 {
107  FixNonPrint(how);
108  ResetThisState();
109  Open(reader);
110 }
111 
113  size_t size,
114  EFixNonPrint how)
116 {
117  FixNonPrint(how);
118  ResetThisState();
120 }
121 
123 {
124 #if CHECK_INSTREAM_STATE
125  m_CurrentTagState = eTagStart;
126 #endif
127 #if CHECK_INSTREAM_LIMITS
128  m_CurrentTagLimit = 0;
129  while (!m_Limits.empty()) {
130  m_Limits.pop();
131  }
132 #endif
133  m_CurrentTagLength = 0;
134  m_SkipNextTag = false;
135 #if USE_DEF_LEN
136  m_CurrentDataLimit = 0;
137  m_DataLimits.clear();
138  m_DataLimits.reserve(16);
139 #endif
140 }
141 
143 {
145  if (GetStackDepth() > 1) {
146  return;
147  }
148  ResetThisState();
149 }
150 
153 {
154  TLongTag tag = 0;
155  size_t i = 1;
156  const size_t KBitsInByte = 8; // ?
157  const size_t KTagBits = sizeof(tag) * KBitsInByte - 1;
158  TByte byte;
159  do {
160  if ( tag >= (1 << (KTagBits - 7)) ) {
162  "tag number is too big: "+NStr::IntToString(tag));
163  }
164  byte = PeekTagByte(i++);
165  tag = (tag << 7) | (byte & 0x7f);
166  } while ( (byte & 0x80) != 0 );
167 #if CHECK_INSTREAM_STATE
168  m_CurrentTagState = eTagParsed;
169 #endif
171  return tag;
172 }
173 
175  TByte expected_class_byte)
176 {
177  ThrowError(fFormatError, "unexpected tag: " +
178  TagToString(first_tag_byte) + ", should be " +
179  TagToString(expected_class_byte));
180 }
181 
183  size_t expected_length)
184 {
186  "unexpected length: " + NStr::SizetToString(got_length) +
187  ", should be: " + NStr::SizetToString(expected_length));
188 }
189 
191 {
192  ThrowError(fFormatError, "IndefiniteLengthByte is expected");
193 }
194 
196 {
197  ThrowError(eFormatError, "EndOfContentsByte expected");
198 }
199 
201 {
202  ThrowError(fFormatError, "ShortLength expected");
203 }
204 
206  TLongTag tag_got, TLongTag tag_expected)
207 {
208  string s("Unexpected tag: ");
209  if (tag_class == eApplication) {
210  s += "Application ";
211  } else if (tag_class == ePrivate) {
212  s += "Private ";
213  }
214  s += NStr::NumericToString(tag_got) + ", expected: " +
215  NStr::NumericToString(tag_expected);
217 }
218 
220 {
221  TByte byte = StartTag(PeekTagByte());
222  if ( GetTagValue(byte) != eLongTag ) {
223  ThrowError(fFormatError, "LongTag expected");
224  }
225  string name;
226  size_t i = 1;
227  TByte c;
228  while ( ((c = PeekTagByte(i++)) & 0x80) != 0 ) {
229  name += char(c & 0x7f);
230  if ( i > 1024 ) {
231  ThrowError(fOverflow, "tag number is too big (greater than 1024)");
232  }
233  }
234 #if CHECK_INSTREAM_STATE
235  m_CurrentTagState = eTagParsed;
236 #endif
238  name += char(c & 0x7f);
239  return name;
240 }
241 
242 inline
245 {
246  TByte fByte = StartTag(PeekTagByte());
247  if ( GetTagValue(fByte) != eLongTag ) {
248 #if CHECK_INSTREAM_STATE
249  m_CurrentTagState = eTagParsed;
250 #endif
251  m_CurrentTagLength = 1;
252  return fByte;
253  }
254  size_t i = 1;
255  TByte byte;
256  do {
257  if ( i > 1024 ) {
258  ThrowError(fOverflow, "tag number is too big (greater than 1024)");
259  }
260  byte = PeekTagByte(i++);
261  } while ( (byte & 0x80) != 0 );
262 #if CHECK_INSTREAM_STATE
263  m_CurrentTagState = eTagParsed;
264 #endif
266  return fByte;
267 }
268 
269 NCBI_PARAM_DECL(bool, SERIAL, READ_ANY_UTF8STRING_TAG);
270 NCBI_PARAM_DEF_EX(bool, SERIAL, READ_ANY_UTF8STRING_TAG, true,
271  eParam_NoThread, SERIAL_READ_ANY_UTF8STRING_TAG);
272 
273 // int value meaning for READ_ANY_VISBLESTRING_TAG:
274 // 0 - disallow, throws an exception
275 // 1 - allow, but warn once (default)
276 // 2 - allow without warning
277 NCBI_PARAM_DECL(int, SERIAL, READ_ANY_VISIBLESTRING_TAG);
278 NCBI_PARAM_DEF_EX(int, SERIAL, READ_ANY_VISIBLESTRING_TAG, 1,
279  eParam_NoThread, SERIAL_READ_ANY_VISIBLESTRING_TAG);
280 
282 {
283  if (m_SkipNextTag) {
284  m_SkipNextTag = false;
285  return;
286  }
287  if ( type == eStringTypeUTF8 ) {
288  static CSafeStatic<NCBI_PARAM_TYPE(SERIAL, READ_ANY_UTF8STRING_TAG)> sx_ReadAnyUtf8;
289  if ( sx_ReadAnyUtf8->Get() ) {
290  // may be eVisibleString
292  if ( PeekTagByte() == alt_tag ) {
293  ExpectSysTagByte(alt_tag);
294  return;
295  }
296  }
298  }
299  else {
300  static CSafeStatic<NCBI_PARAM_TYPE(SERIAL, READ_ANY_VISIBLESTRING_TAG)> sx_ReadAny;
301  if ( sx_ReadAny->Get() ) {
302  // may be eUTF8String
304  if ( PeekTagByte() == alt_tag ) {
305  // optionally issue a warning
306  if ( sx_ReadAny->Get() == 1 ) {
308  "CObjectIStreamAsnBinary: UTF8String data for VisibleString member "<<GetStackTraceASN()<<", ASN.1 specification may need an update");
309  }
310  ExpectSysTagByte(alt_tag);
311  return;
312  }
313  }
315  }
316 }
317 
319 {
320  const char *cls, *con;
321 
322  switch (byte & eTagClassMask) {
323  default:
324  case eUniversal: cls = ""; break;
325  case eApplication: cls = "application/"; break;
326  case eContextSpecific: cls = "contextspecific/";break;
327  case ePrivate: cls = "private/"; break;
328  }
329  string str(cls);
330  switch (byte & eTagConstructedMask) {
331  default:
332  case ePrimitive: con = ""; break;
333  case eConstructed: con = "constructed/"; break;
334  }
335  str += con;
336  if ((byte & eTagClassMask) == eUniversal) {
337  const char *v;
338  switch (byte & eTagValueMask) {
339  case eNone: v= "None"; break;
340  case eBoolean: v= "Boolean"; break;
341  case eInteger: v= "Integer"; break;
342  case eBitString: v= "BitString"; break;
343  case eOctetString: v= "OctetString"; break;
344  case eNull: v= "Null"; break;
345  case eObjectIdentifier: v= "ObjectIdentifier"; break;
346  case eObjectDescriptor: v= "ObjectDescriptor"; break;
347  case eExternal: v= "External"; break;
348  case eReal: v= "Real"; break;
349  case eEnumerated: v= "Enumerated"; break;
350  case eSequence: v= "Sequence"; break;
351  case eSet: v= "Set"; break;
352  case eNumericString: v= "NumericString"; break;
353  case ePrintableString: v= "PrintableString"; break;
354  case eTeletextString: v= "TeletextString"; break;
355  case eVideotextString: v= "VideotextString"; break;
356  case eIA5String: v= "IA5String"; break;
357  case eUTCTime: v= "UTCTime"; break;
358  case eGeneralizedTime: v= "GeneralizedTime"; break;
359  case eGraphicString: v= "GraphicString"; break;
360  case eVisibleString: v= "VisibleString"; break;
361  case eUTF8String: v= "UTF8String"; break;
362  case eGeneralString: v= "GeneralString"; break;
363  case eMemberReference: v= "MemberReference"; break;
364  case eObjectReference: v= "ObjectReference"; break;
365  default: v= "unknown"; break;
366  }
367  str += v;
368  } else {
370  }
371  return str += " (" + NStr::NumericToString(byte) + ")";
372 }
373 
375 {
376  TByte got = PeekTagByte();
377  ThrowError(fFormatError, "unexpected tag: " + TagToString(got) +
378  ", should be: " + TagToString(tag_byte));
379 }
380 
382 {
384  "byte " + NStr::IntToString(byte) + " expected");
385 }
386 
388 {
389  return ReadLengthInlined();
390 }
391 
392 #define ReadLength ReadLengthInlined
393 
395 {
396  size_t lengthLength = byte - 0x80;
397  if ( lengthLength == 0 ) {
398  ThrowError(fFormatError, "unexpected indefinite length");
399  }
400  if ( lengthLength > sizeof(size_t) ) {
401  ThrowError(fOverflow, "length overflow");
402  }
403  size_t length = m_Input.GetChar() & 0xff;
404  if ( length == 0 ) {
405  ThrowError(fFormatError, "illegal length start");
406  }
407  while ( --lengthLength > 0 ) {
408  length = (length << 8) | (m_Input.GetChar() & 0xff);
409  }
410  return StartTagData(length);
411 }
412 
414 {
415 #if CHECK_INSTREAM_STATE
416  if ( m_CurrentTagState != eData ) {
417  ThrowError(fIllegalCall, "illegal ReadBytes call");
418  }
419 #endif
420  if ( count == 0 )
421  return;
422 #if CHECK_INSTREAM_LIMITS
423  Int8 cur_pos = m_Input.GetStreamPosAsInt8();
424  Int8 end_pos = cur_pos + count;
425  if ( end_pos < cur_pos ||
426  (m_CurrentTagLimit != 0 && end_pos > m_CurrentTagLimit) )
427  ThrowError(fOverflow, "tag size overflow");
428 #endif
429  m_Input.GetChars(buffer, count);
430 }
431 
432 void CObjectIStreamAsnBinary::ReadBytes(string& str, size_t count)
433 {
434 #if CHECK_INSTREAM_STATE
435  if ( m_CurrentTagState != eData ) {
436  ThrowError(fIllegalCall, "illegal ReadBytes call");
437  }
438 #endif
439  if ( count == 0 ) {
440  if ( !str.empty() ) {
441  str.erase();
442  }
443  return;
444  }
445 #if CHECK_INSTREAM_LIMITS
446  Int8 cur_pos = m_Input.GetStreamPosAsInt8();
447  Int8 end_pos = cur_pos + count;
448  if ( end_pos < cur_pos ||
449  (m_CurrentTagLimit != 0 && end_pos > m_CurrentTagLimit) )
450  ThrowError(fOverflow, "tag size overflow");
451 #endif
452  m_Input.GetChars(str, count);
453 }
454 
455 inline
457 {
458 #if CHECK_INSTREAM_STATE
459  if ( m_CurrentTagState != eData ) {
460  ThrowError(fIllegalCall, "illegal ReadBytes call");
461  }
462 #endif
463  if ( count == 0 )
464  return;
465 #if CHECK_INSTREAM_LIMITS
466  Int8 cur_pos = m_Input.GetStreamPosAsInt8();
467  Int8 end_pos = cur_pos + count;
468  if ( end_pos < cur_pos ||
469  (m_CurrentTagLimit != 0 && end_pos > m_CurrentTagLimit) )
470  ThrowError(fOverflow, "tag size overflow");
471 #endif
472  m_Input.GetChars(count);
473 }
474 
475 template<typename T>
477 {
478  size_t length = in.ReadShortLength();
479  if ( length == 0 ) {
480  in.ThrowError(in.fFormatError, "zero length of number");
481  }
482  T n;
483  if ( length > sizeof(data) ) {
484  // skip
485  --length;
486  Int1 c = in.ReadSByte();
487  if ( c != 0 && c != -1 ) {
488  in.ThrowError(in.fOverflow, "overflow error");
489  }
490  while ( length > sizeof(data) ) {
491  --length;
492  if ( in.ReadSByte() != c ) {
493  in.ThrowError(in.fOverflow, "overflow error");
494  }
495  }
496  --length;
497  n = in.ReadSByte();
498  if ( ((n ^ c) & 0x80) != 0 ) {
499  in.ThrowError(in.fOverflow, "overflow error");
500  }
501  }
502  else {
503  --length;
504  n = in.ReadSByte();
505  }
506  while ( length > 0 ) {
507  --length;
508  n = (n << 8) | in.ReadByte();
509  }
510  data = n;
511  in.EndOfTag();
512 }
513 
514 template<typename T>
516 {
517  size_t length = in.ReadShortLength();
518  if ( length == 0 ) {
519  in.ThrowError(in.fFormatError, "zero length of number");
520  }
521  T n;
522  if ( length > sizeof(data) ) {
523  // skip
524  while ( length > sizeof(data) ) {
525  --length;
526  if ( in.ReadSByte() != 0 ) {
527  in.ThrowError(in.fOverflow, "overflow error");
528  }
529  }
530  --length;
531  n = in.ReadByte();
532  }
533  else if ( length == sizeof(data) ) {
534  --length;
535  n = in.ReadByte();
536  if ( (n & 0x80) != 0 ) {
537  in.ThrowError(in.fOverflow, "overflow error");
538  }
539  }
540  else {
541  n = 0;
542  }
543  while ( length > 0 ) {
544  --length;
545  n = (n << 8) | in.ReadByte();
546  }
547  data = n;
548  in.EndOfTag();
549 }
550 
552 {
555  bool ret = ReadByte() != 0;
556  EndOfTag();
557  return ret;
558 }
559 
561 {
564  char ret = ReadByte();
565  EndOfTag();
566  return ret;
567 }
568 
570 {
572  Int4 data;
573  ReadStdSigned(*this, data);
574  return data;
575 }
576 
578 {
580  Uint4 data;
581  ReadStdUnsigned(*this, data);
582  return data;
583 }
584 
586 {
588  Uint8 data;
589  ReadStdSigned(*this, data);
590  return data;
591 }
592 
594 {
596  Uint8 data;
597  ReadStdUnsigned(*this, data);
598  return data;
599 }
600 
601 static const size_t kMaxDoubleLength = 256;
602 
604 {
606  size_t length = ReadLength();
607  if ( length < 2 ) {
608  if ( length == 0 ) {
609  EndOfTag();
610  return 0.;
611  }
612  Uint1 special = ReadByte();
613  EndOfTag();
614  if (special == ePositiveInfinity) {
615  return HUGE_VAL;
616  } else if (special == eNegativeInfinity) {
617  return -HUGE_VAL;
618  } else if (special == eNotANumber) {
619  return HUGE_VAL/HUGE_VAL; /* NCBI_FAKE_WARNING */
620  } else if (special == eNegativeZero) {
621  return -0.;
622  }
623  ThrowError(fFormatError, "Unrecognized REAL data");
624  }
625  if ( length > kMaxDoubleLength ) {
626  ThrowError(fFormatError, "too long REAL data: length > "
628  }
629 
630  Uint1 type = ReadByte();
631  if ((type & eDecimalEncoding) != eDecimal) {
632  ThrowError(fNotImplemented, "Unsupported encoding of REAL data: encoding = "
634  }
635  length--;
636  char buffer[kMaxDoubleLength + 2];
637  ReadBytes(buffer, length);
638  EndOfTag();
639  buffer[length] = 0;
640  char* endptr;
642  if ( *endptr != 0 ) {
643  ThrowError(fFormatError, "bad REAL data string");
644  }
645  return result;
646 }
647 
648 inline
649 bool BadVisibleChar(char c)
650 {
651  return Uint1(c-' ') > Uint1('~' - ' ');
652 }
653 
654 bool CObjectIStreamAsnBinary::FixVisibleChars(char* buffer, size_t& count, EFixNonPrint fix_method)
655 {
656  _ASSERT(fix_method != eFNP_Allow);
657  bool result = false;
658  char subst = x_FixCharsSubst();
659  if (fix_method == eFNP_Replace && subst != '\0') {
660  for(size_t i=0; i<count; ++i) {
661  if ( BadVisibleChar(buffer[i]) ) {
662 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING
663  size_t more=0;
664  if (CUtf8::EvaluateFirst(buffer[i], more)) {
665  i += more;
666  }
667  else
668 #endif
669  {
670  buffer[i] = subst;
671  result = true;
672  }
673  }
674  }
675  } else {
676  CTempString original(buffer, count);
677  for(size_t i=0; i<count; ++i) {
678  if ( BadVisibleChar(buffer[i]) ) {
679 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING
680  size_t more=0;
681  if (CUtf8::EvaluateFirst(buffer[i], more)) {
682  i += more;
683  }
684  else
685 #endif
686  {
687  char c = ReplaceVisibleChar(buffer[i], fix_method, this, original, subst);
688  if (c != '\0') {
689  buffer[i] = subst;
690  } else {
691  memmove(buffer+i, buffer+i+1, count-i-1);
692  --i;
693  --count;
694  }
695  result = true;
696  }
697  }
698  }
699  }
700  return result;
701 }
702 
704 {
705  _ASSERT(fix_method != eFNP_Allow);
706  bool result = false;
707  char subst = x_FixCharsSubst();
708  string::iterator to = str.end();
709  if (fix_method == eFNP_Replace && subst != '\0') {
710  for(string::iterator i = str.begin(); i < to; ++i) {
711  if ( BadVisibleChar(*i) ) {
712 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING
713  size_t more=0;
714  if (CUtf8::EvaluateFirst(*i, more)) {
715  i += more;
716  }
717  else
718 #endif
719  {
720  *i = subst;
721  result = true;
722  }
723  }
724  }
725  } else {
726  for(string::iterator i = str.begin(); i < to; ++i) {
727  if ( BadVisibleChar(*i) ) {
728 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING
729  size_t more=0;
730  if (CUtf8::EvaluateFirst(*i, more)) {
731  i += more;
732  }
733  else
734 #endif
735  {
736  char c = ReplaceVisibleChar(*i, fix_method, this, str, subst);
737  if (c != '\0') {
738  *i = subst;
739  } else {
740  str.erase(i);
741  to = str.end();
742  }
743  result = true;
744  }
745  }
746  }
747  }
748  return result;
749 }
750 
752  CPackString& pack_string,
754 {
756  size_t length = ReadLength();
757  static const size_t BUFFER_SIZE = 1024;
758  char buffer[BUFFER_SIZE];
759  if ( length > BUFFER_SIZE || length > pack_string.GetLengthLimit() ) {
760  pack_string.Skipped();
761  ReadStringValue(length, s,
763  }
764  else {
765  ReadBytes(buffer, length);
766  EndOfTag();
767  pair<CPackString::iterator, bool> found =
768  pack_string.Locate(buffer, length);
769  if ( found.second ) {
770  pack_string.AddOld(s, found.first);
771  }
772  else {
773  if ( type == eStringTypeVisible &&
775  FixVisibleChars(buffer, length, x_FixCharsMethod()) ) {
776  // do not remember fixed strings
777  pack_string.Pack(s, buffer, length);
778  return;
779  }
780  pack_string.AddNew(s, buffer, length, found.first);
781  }
782  }
783 }
784 
786 {
790 }
791 
792 
794 {
795  if (m_SkipNextTag) {
796  m_SkipNextTag = false;
797  } else {
799  }
801 }
802 
804  string& s,
805  EFixNonPrint fix_method)
806 {
807  static const size_t BUFFER_SIZE = 1024;
808  if ( length != s.size() || length > BUFFER_SIZE ) {
809  // new string
810  ReadBytes(s, length);
811  if (fix_method != eFNP_Allow) {
812  FixVisibleChars(s, fix_method);
813  }
814  }
815  else {
816  char buffer[BUFFER_SIZE];
817  // try to reuse old value
818  ReadBytes(buffer, length);
819  if (fix_method != eFNP_Allow) {
820  FixVisibleChars(buffer, length, fix_method);
821  }
822  if ( memcmp(s.data(), buffer, length) != 0 ) {
823  s.assign(buffer, length);
824  }
825  }
826  EndOfTag();
827 }
828 
830 {
832  size_t length = ReadLength();
833  char* s = static_cast<char*>(malloc(length + 1));
834  ReadBytes(s, length);
835  s[length] = 0;
836  if (x_FixCharsMethod() != eFNP_Allow) {
837  FixVisibleChars(s, length, x_FixCharsMethod());
838  }
839  EndOfTag();
840  return s;
841 }
842 
844 {
845 #if !USE_OLD_TAGS
846  bool need_eoc = false;
847  if (namedTypeInfo->HasTag()) {
848  if (!m_SkipNextTag) {
849  need_eoc = namedTypeInfo->IsTagConstructed();
850  ExpectTag(namedTypeInfo->GetTagClass(),
851  namedTypeInfo->GetTagConstructed(),
852  namedTypeInfo->GetTag());
853  if (need_eoc) {
855  }
856  }
857  m_SkipNextTag = namedTypeInfo->IsTagImplicit();
858  }
859  TopFrame().SetNoEOC(!need_eoc);
860 #endif
861 }
862 
864 {
865 #if !USE_OLD_TAGS
866  m_SkipNextTag = false;
867  if (!TopFrame().GetNoEOC()) {
869  }
870 #endif
871 }
872 
873 #ifdef VIRTUAL_MID_LEVEL_IO
875  TTypeInfo namedTypeInfo,TTypeInfo typeInfo, TObjectPtr object)
876 {
877 #if USE_OLD_TAGS
878 #ifndef VIRTUAL_MID_LEVEL_IO
879  BEGIN_OBJECT_FRAME2(eFrameNamed, namedTypeInfo);
880  BeginNamedType(namedTypeInfo);
881 #endif
882  ReadObject(object, typeInfo);
883 #ifndef VIRTUAL_MID_LEVEL_IO
884  EndNamedType();
886 #endif
887 
888 #else
889  bool need_eoc = false;
890  if (namedTypeInfo->HasTag()) {
891  if (!m_SkipNextTag) {
892  need_eoc = namedTypeInfo->IsTagConstructed();
893  ExpectTag(namedTypeInfo->GetTagClass(),
894  namedTypeInfo->GetTagConstructed(),
895  namedTypeInfo->GetTag());
896  if (need_eoc) {
898  }
899  }
900  m_SkipNextTag = namedTypeInfo->IsTagImplicit();
901  }
902 
903  ReadObject(object, typeInfo);
904  if (need_eoc) {
906  }
907 #endif
908 }
910  TTypeInfo namedTypeInfo,TTypeInfo typeInfo)
911 {
912  BEGIN_OBJECT_FRAME2(eFrameNamed, namedTypeInfo);
913  BeginNamedType(namedTypeInfo);
914 
915  SkipObject(typeInfo);
916 
917  EndNamedType();
919 }
920 
922 {
923 #if USE_OLD_TAGS
925 #else
926  _ASSERT(cType->HasTag());
927  _ASSERT(cType->IsTagConstructed());
928  bool need_eoc = !m_SkipNextTag;
929  if (!m_SkipNextTag) {
930  ExpectTag(cType->GetTagClass(), eConstructed, cType->GetTag());
932  }
933  m_SkipNextTag = cType->IsTagImplicit();
934  TopFrame().SetNoEOC(!need_eoc);
935 #endif
936 }
937 
939 {
940 #if USE_OLD_TAGS
942 #else
943  m_SkipNextTag = false;
944  if (!TopFrame().GetNoEOC()) {
946  }
947 #endif
948 }
949 
951 {
952  return HaveMoreElements();
953 }
954 
956  TObjectPtr containerPtr)
957 {
958 #if USE_OLD_TAGS
960 #else
961  BEGIN_OBJECT_FRAME2(eFrameArray, cType);
962  _ASSERT(cType->HasTag());
963  _ASSERT(cType->IsTagConstructed());
964  bool need_eoc = !m_SkipNextTag;
965  if (!m_SkipNextTag) {
966  ExpectTag(cType->GetTagClass(), eConstructed, cType->GetTag());
968  }
969  m_SkipNextTag = cType->IsTagImplicit();
970 #endif
971 
972  BEGIN_OBJECT_FRAME(eFrameArrayElement);
973 
975  bool old_element = cType->InitIterator(iter, containerPtr);
976  TTypeInfo elementType = cType->GetElementType();
977  while ( HaveMoreElements() ) {
978  if ( old_element ) {
979  elementType->ReadData(*this, cType->GetElementPtr(iter));
980  old_element = cType->NextElement(iter);
981  }
982  else {
983  cType->AddElement(containerPtr, *this);
984  }
985  }
986  if ( old_element ) {
987  cType->EraseAllElements(iter);
988  }
989 
991 
992 #if USE_OLD_TAGS
994 #else
995  if (need_eoc) {
997  }
999 #endif
1000 }
1001 
1003 {
1004 #if USE_OLD_TAGS
1006 #else
1007  BEGIN_OBJECT_FRAME2(eFrameArray, cType);
1009 #endif
1010 
1011  TTypeInfo elementType = cType->GetElementType();
1012  BEGIN_OBJECT_FRAME(eFrameArrayElement);
1013 
1014  while ( HaveMoreElements() ) {
1015  SkipObject(elementType);
1016  }
1017 
1018  END_OBJECT_FRAME();
1019 
1020 #if USE_OLD_TAGS
1022 #else
1024  END_OBJECT_FRAME();
1025 #endif
1026 }
1027 #endif
1028 
1030 {
1031 #if USE_OLD_TAGS
1032  ExpectContainer(classType->RandomOrder());
1033 #else
1034  _ASSERT(classType->HasTag());
1035  _ASSERT(classType->IsTagConstructed());
1036  bool need_eoc = !m_SkipNextTag;
1037  if (!m_SkipNextTag) {
1038  ExpectTag(classType->GetTagClass(), eConstructed, classType->GetTag());
1040  }
1041  m_SkipNextTag = classType->IsTagImplicit();
1042  TopFrame().SetNoEOC(!need_eoc);
1043 #endif
1044 }
1045 
1047 {
1048 #if USE_OLD_TAGS
1050 #else
1051  m_SkipNextTag = false;
1052  if (!TopFrame().GetNoEOC()) {
1054  }
1055 #endif
1056 }
1057 
1059 {
1060  string message ="unexpected member: ["+NStr::IntToString(tag)+
1061  "], should be one of: ";
1062  for ( CItemsInfo::CIterator i(items); i.Valid(); ++i ) {
1063  message += items.GetItemInfo(i)->GetId().GetName()+ "[" +
1064  NStr::IntToString(items.GetItemInfo(i)->GetId().GetTag()) + "] ";
1065  }
1066  ThrowError(fFormatError, message);
1067 }
1068 
1071 {
1072 #if USE_DEF_LEN
1073  if (!HaveMoreElements()) {
1074  return kInvalidMember;
1075  }
1076  TByte first_tag_byte = PeekTagByte();
1077 #else
1078  TByte first_tag_byte = PeekTagByte();
1079  if ( first_tag_byte == eEndOfContentsByte )
1080  return kInvalidMember;
1081 #endif
1082 
1083 #if !USE_OLD_TAGS
1084  if (classType->GetTagType() != eAutomatic) {
1085  TLongTag tag = PeekTag(first_tag_byte);
1086  TMemberIndex index = classType->GetMembers().Find(tag, GetTagClass(first_tag_byte));
1087  if ( index == kInvalidMember ) {
1088  UnexpectedMember(tag, classType->GetItems());
1089  }
1090  if (!classType->GetMemberInfo(index)->GetId().HasTag()) {
1091  UndoPeekTag();
1092  TopFrame().SetNoEOC(true);
1093  m_SkipNextTag = false;
1094  return index;
1095  }
1096  bool need_eoc = IsTagConstructed(first_tag_byte);
1097  if (need_eoc) {
1099  }
1100  TopFrame().SetNoEOC(!need_eoc);
1101  m_SkipNextTag = classType->GetMemberInfo(index)->GetId().IsTagImplicit();
1102  return index;
1103  }
1104 #endif
1105  TLongTag tag = PeekTag(first_tag_byte, eContextSpecific, eConstructed);
1107  TMemberIndex index = classType->GetMembers().Find(tag, eContextSpecific);
1108  if ( index == kInvalidMember ) {
1109  if (CanSkipUnknownMembers()) {
1111  SkipAnyContent();
1113  return BeginClassMember(classType);
1114  }
1115  else {
1116  UnexpectedMember(tag, classType->GetItems());
1117  }
1118  }
1119  return index;
1120 }
1121 
1124  TMemberIndex pos)
1125 {
1126 #if USE_DEF_LEN
1127  if (!HaveMoreElements()) {
1128  return kInvalidMember;
1129  }
1130  TByte first_tag_byte = PeekTagByte();
1131 #else
1132  TByte first_tag_byte = PeekTagByte();
1133  if ( first_tag_byte == eEndOfContentsByte )
1134  return kInvalidMember;
1135 #endif
1136 
1137 #if !USE_OLD_TAGS
1138  if (classType->GetTagType() != eAutomatic) {
1139  TLongTag tag = PeekTag(first_tag_byte);
1140  TMemberIndex index = classType->GetMembers().Find(tag, GetTagClass(first_tag_byte), pos);
1141  if ( index == kInvalidMember ) {
1142  UnexpectedMember(tag, classType->GetItems());
1143  }
1144  if (!classType->GetMemberInfo(index)->GetId().HasTag()) {
1145  UndoPeekTag();
1146  TopFrame().SetNoEOC(true);
1147  m_SkipNextTag = false;
1148  return index;
1149  }
1150  bool need_eoc = IsTagConstructed(first_tag_byte);
1151  if (need_eoc) {
1153  }
1154  TopFrame().SetNoEOC(!need_eoc);
1155  m_SkipNextTag = classType->GetMemberInfo(index)->GetId().IsTagImplicit();
1156  return index;
1157  }
1158 #endif
1159  TLongTag tag = PeekTag(first_tag_byte, eContextSpecific, eConstructed);
1161  TMemberIndex index = classType->GetMembers().Find(tag, eContextSpecific, pos);
1162  if ( index == kInvalidMember ) {
1163  if (CanSkipUnknownMembers()) {
1165  SkipAnyContent();
1167  return BeginClassMember(classType, pos);
1168  }
1169  else {
1170  UnexpectedMember(tag, classType->GetItems());
1171  }
1172  }
1173  return index;
1174 }
1175 
1177 {
1178  m_SkipNextTag = false;
1179  if (!TopFrame().GetNoEOC()) {
1181  }
1182 }
1183 
1184 #ifdef VIRTUAL_MID_LEVEL_IO
1186  TObjectPtr classPtr)
1187 {
1188  BEGIN_OBJECT_FRAME3(eFrameClass, classType, classPtr);
1189 #if USE_OLD_TAGS
1190  ExpectContainer(classType->RandomOrder());
1191 #else
1193 #endif
1194  ReadClassRandomContentsBegin(classType);
1195 
1196  TMemberIndex index;
1197  while ( (index = CObjectIStreamAsnBinary::BeginClassMember(classType)) != kInvalidMember ) {
1199 // ExpectEndOfContent();
1201  }
1202 
1204 // ExpectEndOfContent();
1206  END_OBJECT_FRAME();
1207 }
1208 
1209 void
1211  TObjectPtr classPtr)
1212 {
1213  BEGIN_OBJECT_FRAME3(eFrameClass, classType, classPtr);
1214 #if USE_OLD_TAGS
1215  ExpectContainer(classType->RandomOrder());
1216 #else
1218 #endif
1220 
1221  TMemberIndex index;
1222  while ( (index = CObjectIStreamAsnBinary::BeginClassMember(classType,*pos)) != kInvalidMember ) {
1224 #if USE_OLD_TAGS
1226 #else
1228 #endif
1229  }
1230 
1232 #if USE_OLD_TAGS
1234 #else
1236 #endif
1237  END_OBJECT_FRAME();
1238 }
1239 
1241 {
1242  BEGIN_OBJECT_FRAME2(eFrameClass, classType);
1243 #if USE_OLD_TAGS
1244  ExpectContainer(classType->RandomOrder());
1245 #else
1247 #endif
1248  SkipClassRandomContentsBegin(classType);
1249 
1250  TMemberIndex index;
1251  while ( (index = CObjectIStreamAsnBinary::BeginClassMember(classType)) != kInvalidMember ) {
1253 #if USE_OLD_TAGS
1255 #else
1257 #endif
1258  }
1259 
1261 #if USE_OLD_TAGS
1263 #else
1265 #endif
1266  END_OBJECT_FRAME();
1267 }
1268 
1269 void
1271 {
1272  BEGIN_OBJECT_FRAME2(eFrameClass, classType);
1273 #if USE_OLD_TAGS
1274  ExpectContainer(classType->RandomOrder());
1275 #else
1277 #endif
1279 
1280  TMemberIndex index;
1281  while ( (index = CObjectIStreamAsnBinary::BeginClassMember(classType,*pos)) != kInvalidMember ) {
1283 #if USE_OLD_TAGS
1285 #else
1287 #endif
1288  }
1289 
1291 #if USE_OLD_TAGS
1293 #else
1295 #endif
1296  END_OBJECT_FRAME();
1297 }
1298 #endif
1299 
1301 {
1302  if (choiceType->GetVariantInfo(kFirstMemberIndex)->GetId().IsAttlist()) {
1303  TopFrame().SetNotag();
1304  ExpectContainer(false);
1305  }
1306 }
1307 
1309 {
1310  if (TopFrame().GetNotag()) {
1313  }
1314 }
1315 
1318 {
1319 #if !USE_OLD_TAGS
1320  if (choiceType->GetTagType() != eAutomatic) {
1321  TByte first_tag_byte = PeekTagByte();
1322  TLongTag tag = PeekTag(first_tag_byte);
1323 
1324  TMemberIndex index = choiceType->GetVariants().Find(tag, GetTagClass(first_tag_byte));
1325  if ( index == kInvalidMember ) {
1326  UnexpectedMember(tag, choiceType->GetItems());
1327  }
1328  if (!choiceType->GetVariantInfo(index)->GetId().HasTag()) {
1329  UndoPeekTag();
1330  TopFrame().SetNoEOC(true);
1331  m_SkipNextTag = false;
1332  return index;
1333  }
1334  bool need_eoc = IsTagConstructed(first_tag_byte);
1335  if (need_eoc) {
1337  }
1338  TopFrame().SetNoEOC(!need_eoc);
1339  m_SkipNextTag = choiceType->GetVariantInfo(index)->GetId().IsTagImplicit();
1340  return index;
1341  }
1342 #endif
1343 
1346  TMemberIndex index = choiceType->GetVariants().Find(tag, eContextSpecific);
1347  if ( index == kInvalidMember ) {
1348  if (CanSkipUnknownVariants()) {
1350  } else {
1351  UnexpectedMember(tag, choiceType->GetItems());
1352  }
1353  return index;
1354  }
1355  if (index != kFirstMemberIndex && FetchFrameFromTop(1).GetNotag()) {
1356  if (index != kFirstMemberIndex+1) {
1357  UnexpectedMember(tag, choiceType->GetItems());
1358  }
1361  index = choiceType->GetVariants().Find(tag, eContextSpecific)+1;
1362  }
1363  return index;
1364 }
1365 
1367 {
1368 #if USE_OLD_TAGS
1370 #else
1371  m_SkipNextTag = false;
1372  if (!TopFrame().GetNoEOC()) {
1374  }
1375 #endif
1376 }
1377 
1378 #ifdef VIRTUAL_MID_LEVEL_IO
1379 
1381  TObjectPtr choicePtr)
1382 {
1383  BEGIN_OBJECT_FRAME3(eFrameChoice, choiceType, choicePtr);
1384  BEGIN_OBJECT_FRAME(eFrameChoiceVariant);
1385  TMemberIndex index;
1386  if (choiceType->GetTagType() != eAutomatic) {
1387  index = CObjectIStreamAsnBinary::BeginChoiceVariant(choiceType);
1388  } else {
1391  index = choiceType->GetVariants().Find(tag, eContextSpecific);
1392  if ( index == kInvalidMember ) {
1393  if (!CanSkipUnknownVariants()) {
1394  UnexpectedMember(tag, choiceType->GetItems());
1395  }
1397  SkipAnyContent();
1398  }
1399  }
1400  if ( index != kInvalidMember ) {
1401  const CVariantInfo* variantInfo = choiceType->GetVariantInfo(index);
1402  SetTopMemberId(variantInfo->GetId());
1403  variantInfo->ReadVariant(*this, choicePtr);
1404  }
1405  if (choiceType->GetTagType() != eAutomatic) {
1407  } else {
1409  }
1410  END_OBJECT_FRAME();
1411  END_OBJECT_FRAME();
1412 }
1413 
1415 {
1416  BEGIN_OBJECT_FRAME2(eFrameChoice, choiceType);
1417  BEGIN_OBJECT_FRAME(eFrameChoiceVariant);
1418  TMemberIndex index;
1419  if (choiceType->GetTagType() != eAutomatic) {
1420  index = CObjectIStreamAsnBinary::BeginChoiceVariant(choiceType);
1421  } else {
1424  index = choiceType->GetVariants().Find(tag, eContextSpecific);
1425  if ( index == kInvalidMember ) {
1426  if (!CanSkipUnknownVariants()) {
1427  UnexpectedMember(tag, choiceType->GetItems());
1428  }
1430  SkipAnyContent();
1431  }
1432  }
1433  if ( index != kInvalidMember ) {
1434  const CVariantInfo* variantInfo = choiceType->GetVariantInfo(index);
1435  SetTopMemberId(variantInfo->GetId());
1436  variantInfo->SkipVariant(*this);
1437  }
1438  if (choiceType->GetTagType() != eAutomatic) {
1440  } else {
1442  }
1443  END_OBJECT_FRAME();
1444  END_OBJECT_FRAME();
1445 }
1446 #endif
1447 
1449 {
1451  TByte bt = PeekByte();
1453  type = eOctetString;
1454  } else if (bt == MakeTagByte(eUniversal, ePrimitive, eBitString)) {
1455  type = eBitString;
1456  } else if (m_SkipNextTag) {
1457  const CChoiceTypeInfo* choiceType =
1458  dynamic_cast<const CChoiceTypeInfo*>(FetchFrameFromTop(1).GetTypeInfo());
1460  TopFrame().GetMemberId().GetName())->GetTypeInfo()->GetTag();
1461  }
1462  if (type == eOctetString) {
1464  block.SetLength(ReadLength());
1465  } else if (type == eBitString) {
1467  block.SetLength(ReadLength()-1);
1468  ReadByte();
1469  } else {
1471  "Unable to identify the type of byte block");
1472  }
1473 }
1474 
1476  char* dst, size_t length)
1477 {
1478  ReadBytes(dst, length);
1479  return length;
1480 }
1481 
1483 {
1484  EndOfTag();
1485 }
1486 
1488 {
1490  block.SetLength(ReadLength());
1491 }
1492 
1494  char* dst, size_t length)
1495 {
1496  ReadBytes(dst, length);
1497  return length;
1498 }
1499 
1501 {
1502  EndOfTag();
1503 }
1504 
1506 {
1508  ExpectShortLength(0);
1509  EndOfTag();
1510 }
1511 
1513 {
1515  "CObjectIStreamAsnBinary::ReadAnyContentObject: "
1516  "unable to read AnyContent object in ASN binary");
1517 }
1518 
1520 {
1521 #if 0
1522  TByte byte = PeekAnyTagFirstByte();
1523  if ( GetTagConstructed(byte) && PeekIndefiniteLength() ) {
1525  }
1526  else {
1527  size_t length = ReadLength();
1528  if (length) {
1529  SkipBytes(length);
1530  }
1531  EndOfTag();
1532  return;
1533  }
1534  int depth = 1;
1535  for ( ;; ) {
1536  if ( !HaveMoreElements() ) {
1538  if ( --depth == 0 ) {
1539  break;
1540  }
1541  }
1542  else {
1543  byte = PeekAnyTagFirstByte();
1544  if ( GetTagConstructed(byte) && PeekIndefiniteLength() ) {
1546  ++depth;
1547  }
1548  else {
1549  size_t length = ReadLength();
1550  if (length) {
1551  SkipBytes(length);
1552  }
1553  EndOfTag();
1554  }
1555  }
1556  }
1557 #else
1558  int depth = 0;
1559  do {
1560  if ( depth != 0 && !HaveMoreElements() ) {
1562  --depth;
1563  }
1564  else {
1565  TByte byte = PeekAnyTagFirstByte();
1566  if ( IsTagConstructed(byte) && PeekIndefiniteLength() ) {
1568  ++depth;
1569  }
1570  else {
1571  size_t length = ReadLength();
1572  if (length) {
1573  SkipBytes(length);
1574  }
1575  EndOfTag();
1576  }
1577  }
1578  } while (depth != 0);
1579 #endif
1580 }
1581 
1584  size_t max_length,
1585  size_t max_bytes)
1586 {
1587  set<TTypeInfo> matching_types;
1588  vector<int> pattern;
1589 
1590  // save state
1591  size_t pos0 = m_Input.SetBufferLock(max_bytes);
1592 #if CHECK_INSTREAM_STATE
1593  ETagState state = m_CurrentTagState;
1594 #endif
1595 #if CHECK_INSTREAM_LIMITS
1596  Int8 lim = m_CurrentTagLimit;
1597 #endif
1598 
1599  try {
1600  GetTagPattern(pattern, max_length*3);
1601  }
1602  catch ( CIOException& exc ) {
1603  if ( exc.GetErrCode() != CIOException::eOverflow ) {
1604  // restore state
1605  m_Input.ResetBufferLock(pos0);
1606 #if CHECK_INSTREAM_STATE
1607  m_CurrentTagState = state;
1608 #endif
1609 #if CHECK_INSTREAM_LIMITS
1610  m_CurrentTagLimit = lim;
1611 #endif
1612  m_CurrentTagLength = 0;
1613  throw;
1614  }
1615  }
1616  catch ( ... ) {
1617  // restore state
1618  m_Input.ResetBufferLock(pos0);
1619 #if CHECK_INSTREAM_STATE
1620  m_CurrentTagState = state;
1621 #endif
1622 #if CHECK_INSTREAM_LIMITS
1623  m_CurrentTagLimit = lim;
1624 #endif
1625  m_CurrentTagLength = 0;
1626  throw;
1627  }
1628  // restore state
1629  m_Input.ResetBufferLock(pos0);
1630 #if CHECK_INSTREAM_STATE
1631  m_CurrentTagState = state;
1632 #endif
1633 #if CHECK_INSTREAM_LIMITS
1634  m_CurrentTagLimit = lim;
1635 #endif
1636  m_CurrentTagLength = 0;
1637 
1638  if (pattern.size() != 0) {
1639  ITERATE( set<TTypeInfo>, t, known_types) {
1640  size_t pos = 0;
1641  CObjectTypeInfo ti(*t);
1642  if (ti.MatchPattern(pattern,pos,0) && pos == pattern.size()) {
1643  matching_types.insert(*t);
1644  }
1645  }
1646  }
1647  return matching_types;
1648 }
1649 
1650 // based on SkipAnyContent() method
1651 void CObjectIStreamAsnBinary::GetTagPattern(vector<int>& pattern, size_t max_length)
1652 {
1653  int counter = 0;
1654  TByte memtag = 0;
1655  pattern.clear();
1656 
1657  TByte prevbyte = 0, byte = PeekAnyTagFirstByte();
1658  pattern.push_back(0);
1659  pattern.push_back(0);
1660  if (byte & CAsnBinaryDefs::eContextSpecific) {
1661  pattern.push_back(0);
1662  prevbyte = byte;
1663  } else {
1664  pattern.push_back((int)(byte & CAsnBinaryDefs::eTagValueMask));
1665  }
1666 
1667  if ( IsTagConstructed(byte) && PeekIndefiniteLength() ) {
1669  }
1670  else {
1671  pattern.clear();
1672  return;
1673  }
1674  int depth = 1;
1675  for ( ;; ) {
1676  if ( !HaveMoreElements() ) {
1678  if ( --depth == 0 ) {
1679  break;
1680  }
1681  }
1682  else {
1683  byte = PeekAnyTagFirstByte();
1684  ++counter;
1685  if ((counter%2 != 0 && (byte & CAsnBinaryDefs::eContextSpecific) == 0) ||
1686  (prevbyte & CAsnBinaryDefs::eContextSpecific) != 0) {
1687  memtag = prevbyte;
1688  ++counter;
1689  }
1690  if (counter%2 == 0) {
1691  pattern.push_back(depth);
1692  pattern.push_back((int)(memtag & CAsnBinaryDefs::eTagValueMask));
1693  if (byte & CAsnBinaryDefs::eContextSpecific) {
1694  pattern.push_back(0);
1695  prevbyte = byte;
1696  } else {
1697  pattern.push_back((int)(byte & CAsnBinaryDefs::eTagValueMask));
1698  prevbyte = 0;
1699  }
1700  if (pattern.size() >= max_length) {
1701  return;
1702  }
1703  } else {
1704  memtag = byte;
1705  }
1706  if ( IsTagConstructed(byte) && PeekIndefiniteLength() ) {
1708  ++depth;
1709  }
1710  else {
1711  size_t length = ReadLength();
1712  if (length) {
1713  SkipBytes(length);
1714  }
1715  EndOfTag();
1716  }
1717  }
1718  }
1719 }
1720 
1722 {
1723  SkipAnyContent();
1724 }
1725 
1727 {
1728  SkipAnyContent();
1730 }
1731 
1733 {
1734  obj.clear();
1735 #if !BITSTRING_AS_VECTOR
1736  if (IsCompressed()) {
1738  return;
1739  }
1740 #endif
1742  size_t length = ReadLength();
1743  if (length == 0) {
1744  return;
1745  }
1746  Uint1 unused = ReadByte();
1747 
1748 #if BITSTRING_AS_VECTOR
1749  obj.reserve((--length)*8);
1750 #else
1751  obj.resize(CBitString::size_type((--length)*8));
1753 #endif
1754 
1755  size_t count;
1756  const size_t step = 128;
1757  char bytes[step];
1758  while ( length != 0 ) {
1759  ReadBytes(bytes, count= min(length,step));
1760  length -= count;
1761  for (size_t i=0; i<count; ++i) {
1762  Uint1 byte = bytes[i];
1763 #if BITSTRING_AS_VECTOR
1764  for (Uint1 mask= 0x80; mask != 0; mask >>= 1) {
1765  obj.push_back( (byte & mask) != 0 );
1766  }
1767 #else
1768  if (byte) {
1769  for (Uint1 mask= 0x80; mask != 0; mask = Uint1(mask >> 1), ++len) {
1770  if ((byte & mask) != 0 ) {
1771  obj.set_bit(len);
1772  }
1773  }
1774  } else {
1775  len += 8;
1776  }
1777 #endif
1778  }
1779  }
1780  obj.resize( obj.size() - unused);
1781  EndOfTag();
1782 }
1783 
1784 inline
1786 {
1787  SkipBytes(ReadLength());
1788  EndOfTag();
1789 }
1790 
1792 {
1794  SkipTagData();
1795 }
1796 
1798 {
1799  TByte byte = PeekTagByte();
1800  // variants:
1801  // eUniversal, !constructed, eNull -> NULL
1802  // eApplication, constructed, eMemberReference -> member reference
1803  // eApplication, constructed, eLongTag -> other class
1804  // eApplication, !constructed, eObjectReference -> object reference
1805  // any other -> this class
1806  if ( byte == MakeTagByte(eUniversal, ePrimitive, eNull) ) {
1807 #if CHECK_INSTREAM_STATE
1808  m_CurrentTagState = eTagParsed;
1809 #endif
1810  m_CurrentTagLength = 1;
1811  ExpectShortLength(0);
1812  EndOfTag();
1813  return eNullPointer;
1814  }
1815  else if ( byte == MakeTagByte(eApplication, eConstructed, eLongTag) ) {
1816  return eOtherPointer;
1817  }
1818  else if ( byte == MakeTagByte(eApplication, ePrimitive, eObjectReference) ) {
1819  return eObjectPointer;
1820  }
1821  // by default: try this class
1822  return eThisPointer;
1823 }
1824 
1825 static inline
1826 TTypeInfo MapType(const string& name)
1827 {
1829 }
1830 
1832 {
1834  ReadStdSigned(*this, data);
1835  return data;
1836 }
1837 
1839 {
1840  string className = PeekClassTag();
1842  return className;
1843 }
1844 
1846 {
1848 }
1849 
1850 static unsigned cnt[256];
1851 struct SPrint {
1853  for ( int i = 0; i < 256; ++i ) {
1854  if ( cnt[i] ) {
1855  cout << i << ": " << cnt[i] << endl;
1856  }
1857  }
1858  }
1860 
1861 pair<TObjectPtr, TTypeInfo>
1863 {
1864  _TRACE("CObjectIStream::ReadPointer("<<declaredType->GetName()<<")");
1865  TObjectPtr objectPtr = 0;
1866  TTypeInfo objectType = 0;
1867  TByte byte = PeekTagByte();
1868  //cnt[byte] += 1;
1869  // variants:
1870  // eUniversal, !constructed, eNull -> NULL
1871  // eApplication, constructed, eMemberReference -> member reference
1872  // eApplication, constructed, eLongTag -> other class
1873  // eApplication, !constructed, eObjectReference -> object reference
1874  // any other -> this class
1875  switch ( byte ) {
1876  case ASN_BINARY_MAKE_TAG_BYTE(eUniversal, ePrimitive, eNull):
1877  {
1878  _TRACE("CObjectIStream::ReadPointer: null");
1879 #if CHECK_INSTREAM_STATE
1880  m_CurrentTagState = eTagParsed;
1881 #endif
1882  m_CurrentTagLength = 1;
1883  ExpectShortLength(0);
1884  EndOfTag();
1885  return pair<TObjectPtr, TTypeInfo>((TObjectPtr)0, declaredType);
1886  }
1887  case ASN_BINARY_MAKE_TAG_BYTE(eApplication, ePrimitive, eObjectReference):
1888  {
1889  _TRACE("CObjectIStream::ReadPointer: @...");
1890  TObjectIndex index = ReadObjectPointer();
1891  _TRACE("CObjectIStream::ReadPointer: @" << index);
1892  const CReadObjectInfo& info = GetRegisteredObject(index);
1893  objectType = info.GetTypeInfo();
1894  objectPtr = info.GetObjectPtr();
1895  if ( !objectPtr ) {
1897  "invalid reference to skipped object: object ptr is NULL");
1898  }
1899  break;
1900  }
1901  case ASN_BINARY_MAKE_TAG_BYTE(eApplication, eConstructed, eLongTag):
1902  {
1903  _TRACE("CObjectIStream::ReadPointer: new...");
1904  string className = ReadOtherPointer();
1905  _TRACE("CObjectIStream::ReadPointer: new " << className);
1906  objectType = MapType(className);
1907 
1908  BEGIN_OBJECT_FRAME2(eFrameNamed, objectType);
1909 
1910  CRef<CObject> ref;
1911  if ( objectType->IsCObject() ) {
1912  objectPtr = objectType->Create(GetMemoryPool());
1913  ref.Reset(static_cast<CObject*>(objectPtr));
1914  }
1915  else {
1916  objectPtr = objectType->Create();
1917  }
1918  RegisterObject(objectPtr, objectType);
1919  ReadObject(objectPtr, objectType);
1920  if ( objectType->IsCObject() )
1921  ref.Release();
1922 
1923  END_OBJECT_FRAME();
1924 
1926  break;
1927  }
1928  case eContainterTagByte:
1929  case eContainterTagByte+1:
1930  default:
1931  {
1932  _TRACE("CObjectIStream::ReadPointer: new");
1933  CRef<CObject> ref;
1934  if ( declaredType->IsCObject() ) {
1935  objectPtr = declaredType->Create(GetMemoryPool());
1936  ref.Reset(static_cast<CObject*>(objectPtr));
1937  }
1938  else {
1939  objectPtr = declaredType->Create();
1940  }
1941  RegisterObject(objectPtr, declaredType);
1942  ReadObject(objectPtr, declaredType);
1943  if ( declaredType->IsCObject() )
1944  ref.Release();
1945  return make_pair(objectPtr, declaredType);
1946  }
1947  }
1948  while ( objectType != declaredType ) {
1949  // try to check parent class pointer
1950  if ( objectType->GetTypeFamily() != eTypeFamilyClass ) {
1951  ThrowError(fFormatError,"incompatible member type");
1952  }
1953  const CClassTypeInfo* parentClass =
1954  CTypeConverter<CClassTypeInfo>::SafeCast(objectType)->GetParentClassInfo();
1955  if ( parentClass ) {
1956  objectType = parentClass;
1957  }
1958  else {
1959  ThrowError(fFormatError,"incompatible member type");
1960  }
1961  }
1962  return make_pair(objectPtr, objectType);
1963 }
1964 
1966 {
1967  _TRACE("CObjectIStream::SkipPointer("<<declaredType->GetName()<<")");
1968  TByte byte = PeekTagByte();
1969  // variants:
1970  // eUniversal, !constructed, eNull -> NULL
1971  // eApplication, constructed, eMemberReference -> member reference
1972  // eApplication, constructed, eLongTag -> other class
1973  // eApplication, !constructed, eObjectReference -> object reference
1974  // any other -> this class
1975  switch ( byte ) {
1976  case ASN_BINARY_MAKE_TAG_BYTE(eUniversal, ePrimitive, eNull):
1977  {
1978  _TRACE("CObjectIStream::SkipPointer: null");
1979 #if CHECK_INSTREAM_STATE
1980  m_CurrentTagState = eTagParsed;
1981 #endif
1982  m_CurrentTagLength = 1;
1983  ExpectShortLength(0);
1984  EndOfTag();
1985  return;
1986  }
1987  return;
1988  case ASN_BINARY_MAKE_TAG_BYTE(eApplication, ePrimitive, eObjectReference):
1989  {
1990  _TRACE("CObjectIStream::SkipPointer: @...");
1991  TObjectIndex index = ReadObjectPointer();
1992  _TRACE("CObjectIStream::SkipPointer: @" << index);
1993  GetRegisteredObject(index);
1994  break;
1995  }
1996  case ASN_BINARY_MAKE_TAG_BYTE(eApplication, eConstructed, eLongTag):
1997  {
1998  _TRACE("CObjectIStream::ReadPointer: new...");
1999  string className = ReadOtherPointer();
2000  _TRACE("CObjectIStream::ReadPointer: new " << className);
2001  TTypeInfo typeInfo = MapType(className);
2002  BEGIN_OBJECT_FRAME2(eFrameNamed, typeInfo);
2003 
2004  RegisterObject(typeInfo);
2005  SkipObject(typeInfo);
2006 
2007  END_OBJECT_FRAME();
2009  break;
2010  }
2011  case eContainterTagByte:
2012  case eContainterTagByte+1:
2013  default:
2014  {
2015  _TRACE("CObjectIStream::ReadPointer: new");
2016  RegisterObject(declaredType);
2017  SkipObject(declaredType);
2018  break;
2019  }
2020  }
2021 }
2022 
2025 {
2027  if ( values.IsInteger() ) {
2028  // allow any integer
2029  ExpectIntegerTag();
2030  ReadStdSigned(*this, value);
2031  }
2032  else {
2033  // enum element by value
2035  ReadStdSigned(*this, value);
2036  values.FindName(value, false); // check value
2037  }
2038  return value;
2039 }
2040 
2042 {
2043  if ( PeekTagByte() == eEndOfContentsByte &&
2045  return false;
2046  TByte byte = PeekAnyTagFirstByte();
2047  if ( IsTagConstructed(byte) ) {
2048  // constructed
2050  while ( SkipRealValue() )
2051  ;
2053  }
2054  else {
2055  SkipTagData();
2056  }
2057  return true;
2058 }
2059 
2060 
2062 {
2064  ExpectShortLength(1);
2065  ReadByte();
2066  EndOfTag();
2067 }
2068 
2070 {
2072  ExpectShortLength(1);
2073  ReadByte();
2074  EndOfTag();
2075 }
2076 
2078 {
2079  ExpectIntegerTag();
2080  SkipTagData();
2081 }
2082 
2084 {
2085  ExpectIntegerTag();
2086  SkipTagData();
2087 }
2088 
2090 {
2092  size_t length = ReadLength();
2093  if ( length != 0 ) {
2094  if ( length > kMaxDoubleLength )
2095  ThrowError(fFormatError, "too long REAL data: length > "
2097 
2098  ReadByte();
2099  length--;
2100  SkipBytes(length);
2101  }
2102  EndOfTag();
2103 }
2104 
2106 {
2108  SkipTagData();
2109 }
2110 
2112 {
2114  SkipTagData();
2115 }
2116 
2118 {
2120  ExpectShortLength(0);
2121  EndOfTag();
2122 }
2123 
2125 {
2127  SkipTagData();
2128 }
2129 
ncbi::TMaskedQueryRegions mask
Serializable object that stores any combination of parsable data.
Definition: serialbase.hpp:264
CObjectIStreamAsnBinary –.
Definition: objistrasnb.hpp:59
CObjectIStream –.
Definition: objistr.hpp:93
CObjectTypeInfo –.
Definition: objectinfo.hpp:94
CObject –.
Definition: ncbiobj.hpp:180
bool Pack(string &s)
size_t GetLengthLimit(void) const
pair< iterator, bool > Locate(const char *data, size_t size)
void AddOld(string &s, const iterator &iter)
void Skipped(void)
bool AddNew(string &s, const char *data, size_t size, iterator iter)
CSafeStatic<>::
T & Get(void)
Create the variable if not created yet, return the reference.
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
void resize(size_type new_size)
Change size of the bvector.
Definition: bm.h:2463
size_type size() const noexcept
Returns bvector's capacity (number of bits it can store)
Definition: bm.h:1300
bool set_bit(size_type n, bool val=true)
Sets bit n.
Definition: bm.h:4227
bvector_size_type size_type
Definition: bm.h:121
void clear(const size_type *ids, size_type ids_size, bm::sort_order so=bm::BM_UNKNOWN)
clear list of bits in this bitset
Definition: bm.h:4149
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
Include a standard set of the NCBI C++ Toolkit most basic headers.
static unsigned char depth[2 *(256+1+29)+1]
#define T(s)
Definition: common.h:230
static const int BUFFER_SIZE
Definition: fileutil.cpp:46
static const char * str(char *buf, int n)
Definition: stats.c:84
char data[12]
Definition: iconv.c:80
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
@ eTakeOwnership
An object can take ownership of another.
Definition: ncbi_types.h:136
@ eNoOwnership
No ownership is assumed.
Definition: ncbi_types.h:135
#define ERR_POST_X_ONCE(err_subcode, message)
Error posting only once during program execution with default error code and given error subcode.
Definition: ncbidiag.hpp:621
TErrCode GetErrCode(void) const
Get error code.
Definition: ncbiexpt.cpp:453
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
const string & FindName(TEnumValueType value, bool allowBadValue) const
Find name of the enum by its numeric value.
Definition: enumerated.cpp:146
const CMemberId & GetId(void) const
bool IsAttlist(void) const
const string & GetName(void) const
TMemberIndex Find(const CTempString &name) const
Definition: memberlist.cpp:256
void ReadVariant(CObjectIStream &in, TObjectPtr choicePtr) const
bool IsTagImplicit(void) const
const CItemInfo * GetItemInfo(TMemberIndex index) const
TTag GetTag(void) const
void SkipVariant(CObjectIStream &in) const
bool HasTag(void) const
bool IsInteger(void) const
Check whether the type is defined as INTEGER in ASN.1 spec.
Definition: enumvalues.hpp:75
EFixNonPrint
How to process non-printing character in the ASN VisibleString.
Definition: serialdef.hpp:173
void * TObjectPtr
Definition: serialdef.hpp:55
int TEnumValueType
Definition: serialdef.hpp:232
size_t TMemberIndex
Type used for indexing class members and choice variants.
Definition: serialdef.hpp:230
const TMemberIndex kFirstMemberIndex
Start if member indexing.
Definition: serialdef.hpp:235
const TMemberIndex kInvalidMember
Special value returned from FindMember.
Definition: serialdef.hpp:237
EStringType
String type.
Definition: serialdef.hpp:185
static const TObjectType * SafeCast(TTypeInfo type)
Definition: serialutil.hpp:76
@ eFNP_Allow
pass through unchanged, post no error message
Definition: serialdef.hpp:175
@ eFNP_Replace
replace with '#' silently
Definition: serialdef.hpp:176
@ eTypeFamilyClass
Definition: serialdef.hpp:140
@ eStringTypeUTF8
UTF8-encoded string.
Definition: serialdef.hpp:187
@ eStringTypeVisible
VisibleString (in ASN.1 sense)
Definition: serialdef.hpp:186
@ eSerial_AsnBinary
ASN.1 binary.
Definition: serialdef.hpp:74
CIStreamBuffer m_Input
Definition: objistr.hpp:1048
vector< Int8 > m_DataLimits
void ExpectContainer(bool random)
virtual void SkipAnyContentVariant(void) override
virtual void ReadNull(void) override
static ETagValue GetTagValue(TByte byte)
static ETagConstructed GetTagConstructed(TByte byte)
virtual void SkipPointer(TTypeInfo declaredType) override
char ReplaceVisibleChar(char c, EFixNonPrint fix_method, const CObjectStack *io, const CTempString &str, char subst)
Definition: objistr.cpp:1855
virtual void ReadOtherPointerEnd(void) override
void ExpectSysTagByte(TByte byte)
virtual void ReadPackedString(string &s, CPackString &pack_string, EStringType type) override
TByte StartTag(TByte first_tag_byte)
TByte PeekAnyTagFirstByte(void)
MLIOVIR void ReadClassSequential(const CClassTypeInfo *classType, TObjectPtr classPtr)
Definition: objistr.cpp:1398
virtual Uint4 ReadUint4(void) override
static ETagClass GetTagClass(TByte byte)
virtual size_t ReadBytes(ByteBlock &block, char *dst, size_t length) override
virtual void ResetState(void) override
void GetTagPattern(vector< int > &pattern, size_t max_length)
CObjectIStreamAsnBinary(EFixNonPrint how=eFNP_Default)
Constructor.
Definition: objistrasnb.cpp:67
MLIOVIR void SkipChoiceSimple(const CChoiceTypeInfo *choiceType)
Definition: objistr.cpp:1503
virtual void SkipNull(void) override
virtual void SkipBitString(void) override
virtual void BeginContainer(const CContainerTypeInfo *containerType) override
#define BEGIN_OBJECT_FRAME(Type)
Definition: objstack.hpp:224
#define ThrowError(flag, mess)
Definition: objstack.hpp:113
static bool IsTagConstructed(TByte byte)
void RegisterObject(TTypeInfo typeInfo)
Definition: objistr.cpp:861
bool PeekIndefiniteLength(void)
virtual void SkipUNumber(void) override
virtual void SkipStringStore(void) override
virtual void EndClass(void) override
virtual void SkipSNumber(void) override
EFixNonPrint FixNonPrint(EFixNonPrint how)
Definition: objistr.hpp:355
virtual TMemberIndex BeginChoiceVariant(const CChoiceTypeInfo *choiceType) override
bool IsCompressed(void) const
Definition: objstack.cpp:193
virtual void SkipFNumber(void) override
#define BEGIN_OBJECT_FRAME2(Type, Arg)
Definition: objstack.hpp:225
virtual Uint8 ReadUint8(void) override
MLIOVIR void ReadContainer(const CContainerTypeInfo *containerType, TObjectPtr containerPtr)
Definition: objistr.cpp:1318
virtual void ReadBitString(CBitString &obj) override
void UnexpectedLongLength(void)
const CReadObjectInfo & GetRegisteredObject(TObjectIndex index)
Definition: objistr.cpp:874
void SkipObject(const CObjectTypeInfo &objectType)
Skip child object.
Definition: objistr.cpp:1102
virtual void SkipString(EStringType type=eStringTypeVisible) override
virtual TEnumValueType ReadEnum(const CEnumeratedTypeValues &values) override
virtual void EndChoice(void) override
virtual EPointerType ReadPointerType(void) override
void ExpectSysTag(ETagClass tag_class, ETagConstructed tag_constructed, ETagValue tag_value)
virtual double ReadDouble(void) override
CObjectInfo ReadObject(void)
Definition: objistr.cpp:1075
virtual void ResetState(void) override
Definition: objistr.cpp:486
void SetNotag(bool set=true)
void ReadStringValue(size_t length, string &s, EFixNonPrint fix_type)
bool CanSkipUnknownMembers(void)
Simple check if it's allowed to skip unknown members.
virtual void ReadStringStore(string &s) override
virtual char ReadChar(void) override
size_t ReadLengthInlined(void)
TFrame & FetchFrameFromTop(size_t index)
virtual void EndChars(const CharBlock &block) override
void UnexpectedTagClassByte(TByte first_tag_byte, TByte expected_class_byte)
string GetStackTraceASN(void) const
Definition: objstack.cpp:80
void ExpectShortLength(size_t length)
void SetLength(size_t length)
virtual void BeginChars(CharBlock &block) override
virtual pair< TObjectPtr, TTypeInfo > ReadPointer(TTypeInfo declaredType) override
bool MatchPattern(vector< int > &pattern, size_t &pos, int depth, const CItemInfo *item=NULL) const
Definition: objectinfo.cpp:524
virtual string ReadOtherPointer(void) override
void UnexpectedContinuation(void)
void UnexpectedByte(TByte byte)
virtual void EndNamedType(void) override
virtual void BeginNamedType(TTypeInfo namedTypeInfo) override
#define END_OBJECT_FRAME()
Definition: objstack.hpp:227
size_t GetStackDepth(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
void SetNoEOC(bool set=true)
TByte PeekByte(size_t index=0)
bool FixVisibleChars(char *buffer, size_t &count, EFixNonPrint fix_method)
virtual void EndClassMember(void) override
const TFrame & TopFrame(void) const
TTypeInfo GetTypeInfo(void) const
virtual void BeginChoice(const CChoiceTypeInfo *choiceType) override
virtual void BeginClass(const CClassTypeInfo *classInfo) override
virtual TMemberIndex BeginClassMember(const CClassTypeInfo *classType) override
EFixNonPrint x_FixCharsMethod(void) const
Definition: objistr.cpp:311
virtual bool BeginContainerElement(TTypeInfo elementType) override
size_t ReadLengthLong(TByte byte)
TFailFlags SetFailFlags(TFailFlags flags, const char *message=0)
Set fail flags.
Definition: objistr.cpp:552
virtual void SkipChar(void) override
MLIOVIR void ReadChoiceSimple(const CChoiceTypeInfo *choiceType, TObjectPtr choicePtr)
Definition: objistr.cpp:1482
virtual size_t ReadChars(CharBlock &block, char *dst, size_t length) override
void UnexpectedFixedLength(void)
void SetTopMemberId(const CMemberId &memberId)
virtual char * ReadCString(void) override
const CMemberId & GetMemberId(void) const
TByte PeekTagByte(size_t index=0)
void ExpectEndOfContent(void)
size_t StartTagData(size_t length)
MLIOVIR void ReadNamedType(TTypeInfo namedTypeInfo, TTypeInfo typeInfo, TObjectPtr object)
Definition: objistr.cpp:1284
virtual void SkipByteBlock(void) override
size_t TObjectIndex
Definition: objistr.hpp:1029
virtual TObjectIndex ReadObjectPointer(void) override
virtual void BeginBytes(ByteBlock &block) override
MLIOVIR void SkipContainer(const CContainerTypeInfo *containerType)
Definition: objistr.cpp:1349
MLIOVIR void SkipClassSequential(const CClassTypeInfo *classType)
Definition: objistr.cpp:1451
void ExpectStringTag(EStringType type)
void SetLength(size_t length)
string TagToString(TByte byte)
TLongTag PeekTag(TByte first_tag_byte)
static CObjectIStream * CreateObjectIStreamAsnBinary(void)
Definition: objistrasnb.cpp:61
virtual void SkipAnyContentObject(void) override
void ExpectIndefiniteLength(void)
virtual void SkipBool(void) override
bool CanSkipUnknownVariants(void)
Simple check if it's allowed to skip unknown variants.
void UnexpectedMember(TLongTag tag, const CItemsInfo &items)
static TByte MakeTagByte(ETagClass tag_class, ETagConstructed tag_constructed, ETagValue tag_value)
virtual bool ReadBool(void) override
void UnexpectedTagValue(ETagClass tag_class, TLongTag tag_got, TLongTag tag_expected)
#define BEGIN_OBJECT_FRAME3(Type, Arg1, Arg2)
Definition: objstack.hpp:226
CObjectMemoryPool * GetMemoryPool(void)
Definition: objistr.hpp:810
virtual void ReadString(string &s, EStringType type=eStringTypeVisible) override
virtual set< TTypeInfo > GuessDataType(const set< TTypeInfo > &known_types, size_t max_length=16, size_t max_bytes=1024 *1024) override
Identify the type of data in the stream.
void UnexpectedSysTagByte(TByte byte)
char x_FixCharsSubst(void) const
Definition: objistr.hpp:1044
void SkipBytes(size_t count)
virtual void EndContainer(void) override
void ExpectTag(ETagClass tag_class, ETagConstructed tag_constructed, TLongTag tag_value)
void OpenFromBuffer(const char *buffer, size_t size)
Attach reader to a data source.
Definition: objistr.cpp:501
MLIOVIR void SkipClassRandom(const CClassTypeInfo *classType)
Definition: objistr.cpp:1430
virtual void EndBytes(const ByteBlock &block) override
void UnexpectedShortLength(size_t got_length, size_t expected_length)
virtual Int4 ReadInt4(void) override
MLIOVIR void SkipNamedType(TTypeInfo namedTypeInfo, TTypeInfo typeInfo)
Definition: objistr.cpp:1302
virtual Int8 ReadInt8(void) override
void ReadCompressedBitString(CBitString &data)
Definition: objistr.cpp:1842
MLIOVIR void ReadClassRandom(const CClassTypeInfo *classType, TObjectPtr classPtr)
Definition: objistr.cpp:1376
TLongTag PeekLongTag(void)
virtual void EndChoiceVariant(void) override
virtual void ReadAnyContentObject(CAnyContentObject &obj) override
@ fOverflow
Data read is beyond the allowed limits.
Definition: objistr.hpp:379
@ fIllegalCall
Illegal in a given context function call.
Definition: objistr.hpp:383
@ fNotImplemented
Method is not implemented.
Definition: objistr.hpp:389
@ fUnknownValue
Unknown value was present in the input.
Definition: objistr.hpp:399
@ fFormatError
Input file formatting does not conform with specification.
Definition: objistr.hpp:377
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
TObjectType * Release(void)
Release a reference to the object and return a pointer to the object.
Definition: ncbiobj.hpp:846
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
Definition: ncbi_param.hpp:149
@ eParam_NoThread
Do not use per-thread values.
Definition: ncbi_param.hpp:418
uint8_t Uint1
1-byte (8-bit) unsigned integer
Definition: ncbitype.h:99
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
int8_t Int1
1-byte (8-bit) signed integer
Definition: ncbitype.h:98
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
void ResetBufferLock(size_t pos)
Definition: strbuffer.cpp:157
Int8 GetStreamPosAsInt8(void) const
void GetChars(char *buffer, size_t count)
Definition: strbuffer.cpp:471
size_t SetBufferLock(size_t size)
Definition: strbuffer.cpp:148
char GetChar(void)
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
Definition: ncbistr.cpp:2751
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static double StringToDoublePosix(const char *str, char **endptr=0, TStringToNumFlags flags=0)
Convert string to double-precision value (analog of strtod function)
Definition: ncbistr.cpp:984
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
static bool EvaluateFirst(char ch, SIZE_TYPE &more)
Check that the character is valid first byte of an UTF8 byte sequence.
Definition: ncbistr.hpp:4160
@ fDecimalPosixFinite
StringToDouble*(): Keep result finite and normalized: if DBL_MAX < result < INF, result becomes DBL_M...
Definition: ncbistr.hpp:302
const string & GetName(void) const
Get name of this type.
Definition: typeinfo.cpp:249
CAsnBinaryDefs::ETagClass GetTagClass(void) const
Definition: typeinfo.hpp:262
CAsnBinaryDefs::ETagConstructed GetTagConstructed(void) const
Definition: typeinfo.hpp:265
bool HasTag(void) const
Definition: typeinfo.hpp:259
const CItemsInfo & GetItems(void) const
bool RandomElementsOrder(void) const
CAsnBinaryDefs::ETagType GetTagType(void) const
Definition: typeinfo.hpp:247
ETypeFamily GetTypeFamily(void) const
TObjectPtr AddElement(TObjectPtr containerPtr, TConstObjectPtr elementPtr, ESerialRecursionMode how=eRecursive) const
bool RandomOrder(void) const
const CItemsInfo & GetVariants(void) const
const CMemberInfo * GetMemberInfo(TMemberIndex index) const
static TTypeInfo GetClassInfoByName(const string &name)
Definition: classinfob.cpp:244
bool IsCObject(void) const
Check is this TypeInfo object is kind of CClassTypeInfoBase.
const CVariantInfo * GetVariantInfo(TMemberIndex index) const
void ReadData(CObjectIStream &in, TObjectPtr object) const
CAsnBinaryDefs::TLongTag GetTag(void) const
Definition: typeinfo.hpp:256
bool IsTagConstructed(void) const
Definition: typeinfo.hpp:268
TConstObjectPtr GetElementPtr(const CConstIterator &it) const
bool InitIterator(CConstIterator &it, TConstObjectPtr containerPtr) const
bool IsTagImplicit(void) const
Definition: typeinfo.hpp:250
bool NextElement(CConstIterator &it) const
void EraseAllElements(CIterator &it) const
const CItemsInfo & GetMembers(void) const
TTypeInfo GetElementType(void) const
TObjectPtr Create(CObjectMemoryPool *memoryPool=0) const
Create object of this type on heap (can be deleted by operator delete)
enum ENcbiOwnership EOwnership
Ownership relations between objects.
Definition of all error codes used in serial libraries (xser.lib, xcser.lib).
int i
yy_size_t n
int len
static const CS_INT unused
Definition: long_binary.c:20
static void byte(MDB_val *v)
Definition: mdb_dump.c:81
static MDB_envinfo info
Definition: mdb_load.c:37
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
EIPRangeType t
Definition: ncbi_localip.c:101
const char * tag
T min(T x_, T y_)
std::istream & in(std::istream &in_, double &x_)
NCBI_PARAM_DEF_EX(bool, SERIAL, READ_ANY_UTF8STRING_TAG, true, eParam_NoThread, SERIAL_READ_ANY_UTF8STRING_TAG)
NCBI_PARAM_DECL(bool, SERIAL, READ_ANY_UTF8STRING_TAG)
bool BadVisibleChar(char c)
#define _TRACE(arg)
Definition: objistrasnb.cpp:53
void ReadStdSigned(CObjectIStreamAsnBinary &in, T &data)
static TTypeInfo MapType(const string &name)
static const size_t kMaxDoubleLength
struct SPrint s_print
void ReadStdUnsigned(CObjectIStreamAsnBinary &in, T &data)
static unsigned cnt[256]
#define SkipClassSequentialContentsEnd()
#define SkipClassRandomContentsMember()
Definition: objistrimpl.hpp:81
#define ReadClassSequentialContentsEnd(classPtr)
#define SkipClassSequentialContentsBegin(classType)
#define ReadClassRandomContentsBegin(classType)
Definition: objistrimpl.hpp:72
#define ReadClassSequentialContentsMember(classPtr)
#define ReadClassSequentialContentsBegin(classType)
#define ReadClassRandomContentsMember(classPtr)
Definition: objistrimpl.hpp:74
#define SkipClassSequentialContentsMember()
#define SkipClassRandomContentsEnd()
Definition: objistrimpl.hpp:83
#define SkipClassRandomContentsBegin(classType)
Definition: objistrimpl.hpp:79
#define ReadClassRandomContentsEnd()
Definition: objistrimpl.hpp:76
#define memmove(a, b, c)
static pcre_uint8 * buffer
Definition: pcretest.c:1051
Definition: type.c:6
#define _ASSERT
else result
Definition: token2.c:20
voidp malloc(uInt size)
Modified on Tue May 28 05:53:25 2024 by modify_doxy.py rev. 669887