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

Go to the SVN repository for this file.

1 /* $Id: objistrasn.cpp 97030 2022-06-10 12:57:23Z ludwigf $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Eugene Vasilchenko
27 *
28 * File Description:
29 * !!! PUT YOUR DESCRIPTION HERE !!!
30 */
31 
32 #include <ncbi_pch.hpp>
33 #include <corelib/ncbistd.hpp>
34 #include <corelib/ncbiutil.hpp>
35 #include <corelib/ncbifloat.h>
36 #include <serial/objistrasn.hpp>
37 #include <serial/impl/member.hpp>
38 #include <serial/enumvalues.hpp>
40 #include <serial/objhook.hpp>
42 #include <serial/impl/choice.hpp>
43 #include <serial/impl/continfo.hpp>
45 #include <math.h>
46 #if !defined(DBL_MAX_10_EXP) || !defined(FLT_MAX)
47 # include <float.h>
48 #endif
49 
51 
53 {
54  return new CObjectIStreamAsn();
55 }
56 
59 {
60  FixNonPrint(how);
61 }
62 
64  EFixNonPrint how)
66 {
67  FixNonPrint(how);
68  Open(in);
69 }
70 
72  bool deleteIn,
73  EFixNonPrint how)
75 {
76  FixNonPrint(how);
77  Open(in, deleteIn ? eTakeOwnership : eNoOwnership);
78 }
79 
81  EOwnership deleteIn,
82  EFixNonPrint how)
84 {
85  FixNonPrint(how);
86  Open(in, deleteIn);
87 }
88 
90  size_t size,
91  EFixNonPrint how)
93 {
94  FixNonPrint(how);
96 }
97 
99 {
101  return true;
102  }
103  try {
104  SkipWhiteSpace();
105  } catch (...) {
106  return true;
107  }
108  return false;
109 }
110 
111 void CObjectIStreamAsn::Location(string& loc_type, size_t& loc) const
112 {
113  loc_type = "line";
114  loc = m_Input.GetLine();
115 }
116 
117 inline
119 {
120  return isalpha((unsigned char) c) || c == '_';
121 }
122 
123 inline
125 {
126  return isalnum((unsigned char) c) || c == '_' || c == '.';
127 }
128 
129 inline
131 {
132  return m_Input.GetChar();
133 }
134 
135 inline
137 {
138  return m_Input.PeekChar();
139 }
140 
141 inline
143 {
145 }
146 
147 inline
149 {
150  char c = SkipWhiteSpace();
151  m_Input.SkipChar();
152  return c;
153 }
154 
155 inline
156 char CObjectIStreamAsn::GetChar(bool skipWhiteSpace)
157 {
158  return skipWhiteSpace? SkipWhiteSpaceAndGetChar(): m_Input.GetChar();
159 }
160 
161 inline
162 char CObjectIStreamAsn::PeekChar(bool skipWhiteSpace)
163 {
164  return skipWhiteSpace? SkipWhiteSpace(): m_Input.PeekChar();
165 }
166 
167 inline
168 bool CObjectIStreamAsn::GetChar(char expect, bool skipWhiteSpace)
169 {
170  if ( PeekChar(skipWhiteSpace) != expect ) {
171  return false;
172  }
173  m_Input.SkipChar();
174  return true;
175 }
176 
177 void CObjectIStreamAsn::Expect(char expect, bool skipWhiteSpace)
178 {
179  if ( !GetChar(expect, skipWhiteSpace) ) {
180  string msg("\'");
181  msg += expect;
182  msg += "' expected";
183  ThrowError(fFormatError, msg);
184  }
185 }
186 
187 bool CObjectIStreamAsn::Expect(char choiceTrue, char choiceFalse,
188  bool skipWhiteSpace)
189 {
190  char c = GetChar(skipWhiteSpace);
191  if ( c == choiceTrue ) {
192  return true;
193  }
194  else if ( c == choiceFalse ) {
195  return false;
196  }
197  m_Input.UngetChar(c);
198  string msg("\'");
199  msg += choiceTrue;
200  msg += "' or '";
201  msg += choiceFalse;
202  msg += "' expected";
203  ThrowError(fFormatError, msg);
204  return false;
205 }
206 
208 {
209  try { // catch CEofException
210  for ( ;; ) {
211  char c = m_Input.SkipSpaces();
212  switch ( c ) {
213  case '\t':
214  m_Input.SkipChar();
215  continue;
216  case '\r':
217  case '\n':
218  m_Input.SkipChar();
219  SkipEndOfLine(c);
220  continue;
221  case '-':
222  // check for comments
223  if ( m_Input.PeekChar(1) != '-' ) {
224  return '-';
225  }
226  m_Input.SkipChars(2);
227  // skip comments
228  SkipComments();
229  continue;
230  default:
231  return c;
232  }
233  }
234  } catch (CEofException& e) {
235  if (GetStackDepth() <= 2) {
236  throw;
237  } else {
238  // There should be no eof here, report as error
239  ThrowError(fEOF, e.what());
240  }
241  }
242  return '\0';
243 }
244 
246 {
247  try {
248  for ( ;; ) {
249  char c = GetChar();
250  switch ( c ) {
251  case '\r':
252  case '\n':
253  SkipEndOfLine(c);
254  return;
255  case '-':
256  c = GetChar();
257  switch ( c ) {
258  case '\r':
259  case '\n':
260  SkipEndOfLine(c);
261  return;
262  case '-':
263  return;
264  }
265  continue;
266  default:
267  continue;
268  }
269  }
270  }
271  catch ( CEofException& /* ignored */ ) {
272  return;
273  }
274 }
275 
277 {
278  if ( isId ) {
279  for ( size_t i = 1; ; ++i ) {
280  char c = m_Input.PeekCharNoEOF(i);
281  if ( !IdChar(c) &&
282  (c != '-' || !IdChar(m_Input.PeekChar(i + 1))) ) {
283  const char* ptr = m_Input.GetCurrentPos();
285  return CTempString(ptr, i);
286  }
287  }
288  }
289  return CTempString();
290 }
291 
293 {
294  if ( c == '[' ) {
295  for ( size_t i = 1; ; ++i ) {
296  switch ( m_Input.PeekChar(i) ) {
297  case '\r':
298  case '\n':
299  ThrowError(fFormatError, "end of line: expected ']'");
300  break;
301  case ']':
302  {
303  const char* ptr = m_Input.GetCurrentPos();
305  return CTempString(ptr + 1, i - 2);
306  }
307  }
308  }
309  }
310  else {
311  return ScanEndOfId(FirstIdChar(c));
312  }
313 }
314 
316 {
317  char c = SkipWhiteSpace();
318  if ( c != '-' && c != '+' && !isdigit((unsigned char) c) )
319  ThrowError(fFormatError, "invalid number");
320  for ( size_t i = 1; ; ++i ) {
321  c = m_Input.PeekChar(i);
322  if ( !isdigit((unsigned char) c) ) {
323  const char* ptr = m_Input.GetCurrentPos();
325  return CTempString(ptr, i);
326  }
327  }
328 }
329 
330 inline
332 {
333  return ScanEndOfId(isupper((unsigned char) c) != 0);
334 }
335 
336 inline
338 {
339  return ScanEndOfId(islower((unsigned char) c) != 0);
340 }
341 
342 inline
344 {
345  if ( c == '[' ) {
346  for ( size_t i = 1; ; ++i ) {
347  switch ( m_Input.PeekChar(i) ) {
348  case '\r':
349  case '\n':
350  ThrowError(fFormatError, "end of line: expected ']'");
351  break;
352  case ']':
353  {
354  const char* ptr = m_Input.GetCurrentPos();
355  m_Input.SkipChars(++i);
356  return CTempString(ptr + 1, i - 2);
357  }
358  }
359  }
360  }
361  else {
362  return ScanEndOfId(islower((unsigned char) c) != 0);
363  }
364 }
365 
367  const CClassTypeInfoBase* classType,
368  const CTempString& id,
369  const TMemberIndex pos /*= kInvalidMember*/)
370 {
372  if (!id.empty()) {
373  const CItemsInfo& info = classType->GetItems();
374  string id_alt = string(id);
375  id_alt[0] = (char)toupper((unsigned char)id_alt[0]);
376  if (pos != kInvalidMember) {
377  idx = info.Find(CTempString(id_alt),pos);
378  } else {
379  idx = info.Find(CTempString(id_alt));
380  }
381  if (idx != kInvalidMember &&
382  !info.GetItemInfo(idx)->GetId().HaveNoPrefix()) {
383  idx = kInvalidMember;
384  }
385  }
386  return idx;
387 }
388 
390  (const CClassTypeInfo* classType,
391  const CTempString& id)
392 {
393  TMemberIndex idx;
394  if (!id.empty() && isdigit((unsigned char) id[0])) {
395  idx = classType->GetMembers().Find
397  }
398  else {
399  idx = classType->GetMembers().Find(id);
400  if (idx == kInvalidMember) {
401  idx = GetAltItemIndex(classType,id);
402  }
403  }
404  return idx;
405 }
406 
408  (const CClassTypeInfo* classType,
409  const CTempString& id,
410  const TMemberIndex pos)
411 {
412  TMemberIndex idx;
413  if (!id.empty() && isdigit((unsigned char) id[0])) {
414  idx = classType->GetMembers().Find
416  }
417  else {
418  idx = classType->GetMembers().Find(id, pos);
419  if (idx == kInvalidMember) {
420  idx = GetAltItemIndex(classType,id,pos);
421  }
422  }
423  return idx;
424 }
425 
427  (const CChoiceTypeInfo* choiceType,
428  const CTempString& id)
429 {
430  TMemberIndex idx;
431  if (!id.empty() && isdigit((unsigned char) id[0])) {
432  idx = choiceType->GetVariants().Find
434  }
435  else {
436  idx = choiceType->GetVariants().Find(id);
437  if (idx == kInvalidMember) {
438  idx = GetAltItemIndex(choiceType,id);
439  }
440  }
441  return idx;
442 }
443 
445 {
446  if ( SkipWhiteSpace() == 'N' &&
447  m_Input.PeekCharNoEOF(1) == 'U' &&
448  m_Input.PeekCharNoEOF(2) == 'L' &&
449  m_Input.PeekCharNoEOF(3) == 'L' &&
450  !IdChar(m_Input.PeekCharNoEOF(4)) ) {
451  m_Input.SkipChars(4);
452  }
453  else
454  ThrowError(fFormatError, "'NULL' expected");
455 }
456 
458 {
459  char buf[128];
460  size_t pos=0;
461  const size_t maxpos=128;
462 
463  char to = GetChar(true);
464  buf[pos++] = to;
465  if (to == '{') {
466  to = '}';
467  } else if (to == '\"') {
468  } else {
469  to = '\0';
470  }
471 
472  bool space = false;
473  for (char c = m_Input.PeekChar(); ; c = m_Input.PeekChar()) {
474  if (to != '\"') {
475  if (to != '}' && c == '\n') {
476  value.append(buf,pos);
477  return;
478  }
479  if (isspace((unsigned char) c)) {
480  if (space) {
481  m_Input.SkipChar();
482  continue;
483  }
484  c = ' ';
485  space = true;
486  } else {
487  space = false;;
488  }
489  if (to != '}' && (c == ',' || c == '}')) {
490  value.append(buf,pos);
491  return;
492  } else if (c == '\"' || c == '{') {
493  value.append(buf,pos);
495  pos = 0;
496  continue;
497  }
498  }
499  if (c == to) {
500  if (pos >= maxpos) {
501  value.append(buf,pos);
502  pos = 0;
503  }
504  buf[pos++] = c;
505  value.append(buf,pos);
506  m_Input.SkipChar();
507  return;
508  }
509  if (c == '\"' || c == '{') {
510  value.append(buf,pos);
512  pos = 0;
513  continue;
514  }
515  if (pos >= maxpos) {
516  value.append(buf,pos);
517  pos = 0;
518  }
519  buf[pos++] = c;
520  m_Input.SkipChar();
521  }
522 }
523 
525 {
527  string value;
530 }
531 
533 {
534  bool ap = false;
535  char to = GetChar(true);
536  if (to == '{') {
537  to = '}';
538  } else if (to == '\"') {
539  } else if (to == '\'') {
540  ap = true;
541  to = '\0';
542  } else {
543  to = '\0';
544  }
545  for (char c = m_Input.PeekChar(); ; c = m_Input.PeekChar()) {
546  if (!ap && to != '\"') {
547  if (to != '}' && (c == '\n' || c == ',' || c == '}')) {
548  return;
549  } else if (c == '\"' || c == '{') {
550  SkipAnyContent();
551  continue;
552  }
553  }
554  if (c == to) {
555  m_Input.SkipChar();
556  return;
557  }
558  if (c == '\"' || (c == '{' && to != '\"')) {
559  SkipAnyContent();
560  continue;
561  }
562  if (c == '\'' && to != '\"') {
563  ap = !ap;
564  }
565  m_Input.SkipChar();
566  if (c == '\n') {
567  SkipEndOfLine(c);
568  }
569  }
570 }
571 
573 {
574  SkipAnyContent();
575 }
576 
578 {
579  obj.clear();
580 #if BITSTRING_AS_VECTOR
581 // CBitString is vector<bool>
582  Expect('\'', true);
583  string data;
584  size_t reserve;
585  const size_t step=128;
586  data.reserve(reserve=step);
587  bool hex=false;
588  int c;
589  for ( ; !hex; hex= c > 0x1) {
590  c = GetHexChar();
591  if (c < 0) {
592  break;
593  }
594  data.append(1, char(c));
595  if (--reserve == 0) {
596  data.reserve(data.size() + (reserve=step));
597  }
598  }
599  if (c<0 && !hex) {
600  hex = m_Input.PeekChar() == 'H';
601  }
602  if (hex) {
603  obj.reserve( data.size() * 4 );
604  Uint1 byte;
605  ITERATE( string, i, data) {
606  byte = *i;
607  for (Uint1 mask= 0x8; mask != 0; mask = Uint1(mask >> 1)) {
608  obj.push_back( (byte & mask) != 0 );
609  }
610  }
611  if (c > 0) {
612  obj.reserve(obj.size() + (reserve=step));
613  for (c= GetHexChar(); c >= 0; c= GetHexChar()) {
614  byte = c;
615  for (Uint1 mask= 0x8; mask != 0; mask >>= 1) {
616  obj.push_back( (byte & mask) != 0 );
617  if (--reserve == 0) {
618  obj.reserve(obj.size() + (reserve=step));
619  }
620  }
621  }
622  }
623  Expect('H');
624  } else {
625  obj.reserve( data.size() );
626  ITERATE( string, i, data) {
627  obj.push_back( *i != 0 );
628  }
629  Expect('B');
630  }
631  obj.reserve(obj.size());
632 #else
633  obj.resize(0);
634  if (IsCompressed()) {
636  return;
637  }
638  Expect('\'', true);
639  string data;
640  size_t reserve;
641  const size_t step=128;
642  data.reserve(reserve=step);
643  bool hex=false;
644  int c;
645  for ( ; !hex; hex= c > 0x1) {
646  c = GetHexChar();
647  if (c < 0) {
648  break;
649  }
650  data.append(1, char(c));
651  if (--reserve == 0) {
652  data.reserve(data.size() + (reserve=step));
653  }
654  }
655  if (c<0 && !hex) {
656  hex = m_Input.PeekChar() == 'H';
657  }
659  if (hex) {
660  Uint1 byte;
661  obj.resize(CBitString::size_type(4*data.size()));
662  ITERATE( string, i, data) {
663  byte = *i;
664  if (byte) {
665  for (Uint1 mask=0x8; mask != 0; mask = Uint1(mask >> 1), ++len) {
666  if ((byte & mask) != 0) {
667  obj.set_bit(len);
668  }
669  }
670  } else {
671  len += 4;
672  }
673  }
674  if (c > 0) {
675  for (c= GetHexChar(); c >= 0; c= GetHexChar()) {
676  obj.resize( 4 + obj.size());
677  byte = (Uint1)c;
678  if (byte) {
679  for (Uint1 mask= 0x8; mask != 0; mask = Uint1(mask >> 1), ++len) {
680  if ((byte & mask) != 0) {
681  obj.set_bit(len);
682  }
683  }
684  } else {
685  len += 4;
686  }
687  }
688  }
689  Expect('H');
690  } else {
691  obj.resize(CBitString::size_type(data.size()));
692  ITERATE( string, i, data) {
693  if ( *i != 0 ) {
694  obj.set_bit(len);
695  }
696  ++len;
697  }
698  Expect('B');
699  }
700  obj.resize(len);
701 #endif
702 }
703 
705 {
706  SkipByteBlock();
707 }
708 
710 {
712  string s(id);
713  if ( SkipWhiteSpace() == ':' &&
714  m_Input.PeekCharNoEOF(1) == ':' &&
715  m_Input.PeekCharNoEOF(2) == '=' ) {
716  m_Input.SkipChars(3);
717  }
718  else
719  ThrowError(fFormatError, "'::=' expected");
720  return s;
721 }
722 
724 {
725  // not integer
727  if ( !id.empty() ) {
728  // enum element by name
729  return values.FindValue(id);
730  }
731  // enum element by value
733  if ( !values.IsInteger() ) // check value
734  values.FindName(value, false);
735 
736  return value;
737 }
738 
740 {
741  switch ( SkipWhiteSpace() ) {
742  case 'T':
743  if ( m_Input.PeekCharNoEOF(1) == 'R' &&
744  m_Input.PeekCharNoEOF(2) == 'U' &&
745  m_Input.PeekCharNoEOF(3) == 'E' &&
746  !IdChar(m_Input.PeekCharNoEOF(4)) ) {
747  m_Input.SkipChars(4);
748  return true;
749  }
750  break;
751  case 'F':
752  if ( m_Input.PeekCharNoEOF(1) == 'A' &&
753  m_Input.PeekCharNoEOF(2) == 'L' &&
754  m_Input.PeekCharNoEOF(3) == 'S' &&
755  m_Input.PeekCharNoEOF(4) == 'E' &&
756  !IdChar(m_Input.PeekCharNoEOF(5)) ) {
757  m_Input.SkipChars(5);
758  return false;
759  }
760  break;
761  }
762  ThrowError(fFormatError, "TRUE or FALSE expected");
763  return false;
764 }
765 
767 {
768  string s;
769  ReadString(s);
770  if ( s.size() != 1 ) {
772  "\"" + s + "\": one char string expected");
773  }
774  return s[0];
775 }
776 
778 {
779  SkipWhiteSpace();
780  return m_Input.GetInt4();
781 }
782 
784 {
785  SkipWhiteSpace();
786  return m_Input.GetUint4();
787 }
788 
790 {
791  SkipWhiteSpace();
792  return m_Input.GetInt8();
793 }
794 
796 {
797  SkipWhiteSpace();
798  return m_Input.GetUint8();
799 }
800 
802 {
803  double result = 0;
804  if (PeekChar(true) != '{') {
805  CTempString tmp( ScanEndOfId(true) );
806  if (NStr::strncasecmp(tmp.data(), "PLUS-INFINITY", 13) == 0) {
807  return HUGE_VAL;
808  } else if (NStr::strncasecmp(tmp.data(),"MINUS-INFINITY", 14) == 0) {
809  return -HUGE_VAL;
810  } else if (NStr::strncasecmp(tmp.data(),"NOT-A-NUMBER", 12) == 0) {
811  return HUGE_VAL/HUGE_VAL; /* NCBI_FAKE_WARNING */
812  }
813  char* endptr;
814  return NStr::StringToDoublePosix( string(tmp).c_str(), &endptr, NStr::fDecimalPosixFinite );
815  }
816  Expect('{', true);
817  bool is_negative = PeekChar(true) == '-';
818  CTempString mantissaStr = ReadNumber();
819  size_t mantissaLength = mantissaStr.size();
820  char buffer[128];
821  if ( mantissaLength >= sizeof(buffer) - 1 )
822  ThrowError(fOverflow, "buffer overflow");
823  memcpy(buffer, mantissaStr.data(), mantissaLength);
824  buffer[mantissaLength] = '\0';
825  char* endptr;
826  double mantissa = NStr::StringToDoublePosix(buffer, &endptr);
827  if ( *endptr != 0 )
828  ThrowError(fFormatError, "bad double in line "
830  Expect(',', true);
831  unsigned base = ReadUint4();
832  Expect(',', true);
833  int exp = ReadInt4();
834  Expect('}', true);
835  if ( base != 2 && base != 10 ) {
836  ThrowError(fFormatError, "illegal REAL base (must be 2 or 10)");
837  }
838  if (mantissa == 0.) {
839  return mantissa;
840  }
841  if (is_negative) {
842  mantissa = -mantissa;
843  }
844 
845  if ( base == 10 ) {
846  result = mantissa * pow((double)10.0, exp);
847  } else {
848  result = ldexp( mantissa, exp);
849  }
850 
851  if (result >= 0 && result <= DBL_MIN) {
852  result = DBL_MIN;
853  } else if (!finite(result)) {
854  result = DBL_MAX;
855  }
856  return is_negative ? -result : result;
857 }
858 
859 void CObjectIStreamAsn::BadStringChar(size_t startLine, char c)
860 {
862  "bad char in string starting at line "+
863  NStr::SizetToString(startLine)+": "+
864  NStr::IntToString(c));
865 }
866 
867 void CObjectIStreamAsn::UnendedString(size_t startLine)
868 {
870  "unclosed string starts at line "+
871  NStr::SizetToString(startLine));
872 }
873 
874 
875 inline
877  size_t count,
878  EFixNonPrint fix_method,
879  size_t /*line*/)
880 {
881  const char* data = m_Input.GetCurrentPos();
882  if ( fix_method != eFNP_Allow ) {
883  size_t done = 0, valid = 0;
884  for ( size_t i = 0; i < count; ++i ) {
885  char c = data[i];
886  if ( !GoodVisibleChar(c) ) {
887 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING
888  if (valid == 0) {
889  if (CUtf8::EvaluateFirst(c, valid)) {
890  ++valid;
891  }
892  }
893 #endif
894  if (valid == 0) {
895  if ( i > done ) {
896  s.append(data + done, i - done);
897  }
898  c = ReplaceVisibleChar(c, fix_method, this, CTempString(data,count), x_FixCharsSubst());
899  if (c != 0) {
900  s += c;
901  }
902  done = i + 1;
903  }
904  }
905  if (valid != 0) {
906  --valid;
907  }
908  }
909  if ( done < count ) {
910  s.append(data + done, count - done);
911  }
912  }
913  else {
914  s.append(data, count);
915  }
916  if ( count > 0 ) {
917  m_Input.SkipChars(count);
918  }
919 }
920 
921 
923  size_t count,
924  EFixNonPrint fix_method,
925  size_t line)
926 {
927  // Reserve extra-space to reduce heap reallocation
928  if ( s.empty() ) {
929  s.reserve(count*2);
930  }
931  else if ( s.capacity() < double(s.size()+1)*1.1 ) {
932  s.reserve(s.size()*2);
933  }
934  AppendStringData(s, count, fix_method, line);
935 }
936 
937 
939 {
940  Expect('\"', true);
941  size_t startLine = m_Input.GetLine();
942  size_t i = 0;
943  s.erase();
944  try {
945  for (;;) {
946  char c = m_Input.PeekChar(i);
947  switch ( c ) {
948  case '\r':
949  case '\n':
950  // flush string
951  AppendLongStringData(s, i, fix_method, startLine);
952  m_Input.SkipChar(); // '\r' or '\n'
953  i = 0;
954  // skip end of line
955  SkipEndOfLine(c);
956  break;
957  case '\"':
958  s.reserve(s.size() + i);
959  AppendStringData(s, i, fix_method, startLine);
960  m_Input.SkipChar(); // quote
961  if ( m_Input.PeekCharNoEOF() != '\"' ) {
962  // end of string
963  return;
964  }
965  else {
966  // double quote -> one quote
967  i = 1;
968  }
969  break;
970  default:
971  // ok: append char
972  if ( ++i == 128 ) {
973  // too long string -> flush it
974  AppendLongStringData(s, i, fix_method, startLine);
975  i = 0;
976  }
977  break;
978  }
979  }
980  }
981  catch ( CEofException& ) {
983  UnendedString(startLine);
984  throw;
985  }
986 }
987 
989 {
991 }
992 
994 {
995  switch ( SkipWhiteSpace() ) {
996  case 'T':
997  if ( m_Input.PeekCharNoEOF(1) == 'R' &&
998  m_Input.PeekCharNoEOF(2) == 'U' &&
999  m_Input.PeekCharNoEOF(3) == 'E' &&
1000  !IdChar(m_Input.PeekCharNoEOF(4)) ) {
1001  m_Input.SkipChars(4);
1002  return;
1003  }
1004  break;
1005  case 'F':
1006  if ( m_Input.PeekCharNoEOF(1) == 'A' &&
1007  m_Input.PeekCharNoEOF(2) == 'L' &&
1008  m_Input.PeekCharNoEOF(3) == 'S' &&
1009  m_Input.PeekCharNoEOF(4) == 'E' &&
1010  !IdChar(m_Input.PeekCharNoEOF(5)) ) {
1011  m_Input.SkipChars(5);
1012  return;
1013  }
1014  break;
1015  }
1016  ThrowError(fFormatError, "TRUE or FALSE expected");
1017 }
1018 
1020 {
1021  // TODO: check string length to be 1
1022  SkipString();
1023 }
1024 
1026 {
1027  size_t i;
1028  char c = SkipWhiteSpace();
1029  switch ( c ) {
1030  case '-':
1031  case '+':
1032  c = m_Input.PeekChar(1);
1033  // next char
1034  i = 2;
1035  break;
1036  default:
1037  // next char
1038  i = 1;
1039  break;
1040  }
1041  if ( c < '0' || c > '9' ) {
1042  ThrowError(fFormatError, "bad signed integer in line "
1044  }
1045  while ( (c = m_Input.PeekChar(i)) >= '0' && c <= '9' ) {
1046  ++i;
1047  }
1048  m_Input.SkipChars(i);
1049 }
1050 
1052 {
1053  size_t i;
1054  char c = SkipWhiteSpace();
1055  switch ( c ) {
1056  case '+':
1057  c = m_Input.PeekChar(1);
1058  // next char
1059  i = 2;
1060  break;
1061  default:
1062  // next char
1063  i = 1;
1064  break;
1065  }
1066  if ( c < '0' || c > '9' ) {
1067  ThrowError(fFormatError, "bad unsigned integer in line "
1069  }
1070  while ( (c = m_Input.PeekCharNoEOF(i)) >= '0' && c <= '9' ) {
1071  ++i;
1072  }
1073  m_Input.SkipChars(i);
1074 }
1075 
1077 {
1078  if (PeekChar(true) != '{') {
1079  ScanEndOfId(true);
1080  return;
1081  }
1082  Expect('{', true);
1083  SkipSNumber();
1084  Expect(',', true);
1085  unsigned base = ReadUint4();
1086  Expect(',', true);
1087  SkipSNumber();
1088  Expect('}', true);
1089  if ( base != 2 && base != 10 )
1090  ThrowError(fFormatError, "illegal REAL base (must be 2 or 10)");
1091 }
1092 
1094 {
1095  Expect('\"', true);
1096  size_t startLine = m_Input.GetLine();
1097  size_t i = 0, valid = 0;
1098  try {
1099  for (;;) {
1100  char c = m_Input.PeekChar(i);
1101  switch ( c ) {
1102  case '\r':
1103  case '\n':
1104  // flush string
1105  m_Input.SkipChars(i + 1);
1106  i = 0;
1107  // skip end of line
1108  SkipEndOfLine(c);
1109  break;
1110  case '\"':
1111  if ( m_Input.PeekCharNoEOF(i + 1) == '\"' ) {
1112  // double quote -> one quote
1113  m_Input.SkipChars(i + 2);
1114  i = 0;
1115  }
1116  else {
1117  // end of string
1118  m_Input.SkipChars(i + 1);
1119  return;
1120  }
1121  break;
1122  default:
1123  if (type == eStringTypeVisible) {
1124  if ( !GoodVisibleChar(c) ) {
1125 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING
1126  if (valid == 0) {
1127  if (CUtf8::EvaluateFirst(c, valid)) {
1128  ++valid;
1129  }
1130  }
1131 #endif
1132  if (valid == 0) {
1134  }
1135  }
1136  }
1137  // ok: skip char
1138  if ( ++i == 128 ) {
1139  // too long string -> flush it
1140  m_Input.SkipChars(i);
1141  i = 0;
1142  }
1143  break;
1144  }
1145  if (valid != 0) {
1146  --valid;
1147  }
1148  }
1149  }
1150  catch ( CEofException& ) {
1151  SetFailFlags(fEOF);
1152  UnendedString(startLine);
1153  throw;
1154  }
1155 }
1156 
1158 {
1159  if ( SkipWhiteSpace() == 'N' &&
1160  m_Input.PeekCharNoEOF(1) == 'U' &&
1161  m_Input.PeekCharNoEOF(2) == 'L' &&
1162  m_Input.PeekCharNoEOF(3) == 'L' &&
1163  !IdChar(m_Input.PeekCharNoEOF(4)) ) {
1164  m_Input.SkipChars(4);
1165  return;
1166  }
1167  ThrowError(fFormatError, "NULL expected");
1168 }
1169 
1171 {
1172  Expect('\'', true);
1173  for ( ;; ) {
1174  char c = GetChar();
1175  if ( c >= '0' && c <= '9' ) {
1176  continue;
1177  }
1178  else if ( c >= 'A' && c <= 'F' ) {
1179  continue;
1180  }
1181  else if ( c >= 'a' && c <= 'f' ) {
1182  continue;
1183  }
1184  else if ( c == '\'' ) {
1185  break;
1186  }
1187  else if ( c == '\r' || c == '\n' ) {
1188  SkipEndOfLine(c);
1189  }
1190  else {
1191  m_Input.UngetChar(c);
1192  ThrowError(fFormatError, "bad char in octet string: #"
1193  + NStr::IntToString(c));
1194  }
1195  }
1196  Expect('H', 'B', true);
1197 }
1198 
1200 {
1201  Expect('{', true);
1202  m_BlockStart = true;
1203 }
1204 
1206 {
1207  char c = SkipWhiteSpace();
1208  if ( m_BlockStart ) {
1209  // first element
1210  m_BlockStart = false;
1211  return c != '}';
1212  }
1213  else {
1214  // next element
1215  if ( c == ',' ) {
1216  m_Input.SkipChar();
1217  return true;
1218  }
1219  else if ( c != '}' )
1220  ThrowError(fFormatError, "',' or '}' expected");
1221  return false;
1222  }
1223 }
1224 
1226 {
1227  Expect('}');
1228 }
1229 
1231 {
1232  StartBlock();
1233 }
1234 
1236 {
1237  EndBlock();
1238 }
1239 
1241 {
1242  return NextElement();
1243 }
1244 
1245 #ifdef VIRTUAL_MID_LEVEL_IO
1247  TObjectPtr contPtr)
1248 {
1249  BEGIN_OBJECT_FRAME2(eFrameArray, contType);
1250  StartBlock();
1251 
1252  BEGIN_OBJECT_FRAME(eFrameArrayElement);
1253 
1255  bool old_element = contType->InitIterator(iter, contPtr);
1256  TTypeInfo elementType = contType->GetElementType();
1257  while ( NextElement() ) {
1258  if ( old_element ) {
1259  elementType->ReadData(*this, contType->GetElementPtr(iter));
1260  old_element = contType->NextElement(iter);
1261  }
1262  else {
1263  contType->AddElement(contPtr, *this);
1264  }
1265  }
1266  if ( old_element ) {
1267  contType->EraseAllElements(iter);
1268  }
1269 
1270  END_OBJECT_FRAME();
1271 
1272  EndBlock();
1273  END_OBJECT_FRAME();
1274 }
1275 
1277 {
1278  BEGIN_OBJECT_FRAME2(eFrameArray, contType);
1279  StartBlock();
1280 
1281  TTypeInfo elementType = contType->GetElementType();
1282  BEGIN_OBJECT_FRAME(eFrameArrayElement);
1283 
1284  while ( NextElement() ) {
1285  SkipObject(elementType);
1286  }
1287 
1288  END_OBJECT_FRAME();
1289 
1290  EndBlock();
1291  END_OBJECT_FRAME();
1292 }
1293 #endif
1294 
1296 {
1297  StartBlock();
1298 }
1299 
1301 {
1302  EndBlock();
1303 }
1304 
1306  const CItemsInfo& items)
1307 {
1308  string message =
1309  "\""+string(id)+"\": unexpected member, should be one of: ";
1310  for ( CItemsInfo::CIterator i(items); i.Valid(); ++i ) {
1311  message += '\"' + items.GetItemInfo(i)->GetId().ToString() + "\" ";
1312  }
1313  ThrowError(fFormatError, message);
1314 }
1315 
1318 {
1319  if ( !NextElement() )
1320  return kInvalidMember;
1321 
1323  TMemberIndex index = GetMemberIndex(classType, id);
1324  if ( index == kInvalidMember ) {
1325  if (CanSkipUnknownMembers()) {
1327  SkipAnyContent();
1328  return BeginClassMember(classType);
1329  } else {
1330  UnexpectedMember(id, classType->GetMembers());
1331  }
1332  }
1333  return index;
1334 }
1335 
1338  TMemberIndex pos)
1339 {
1340  if ( !NextElement() )
1341  return kInvalidMember;
1342 
1344  TMemberIndex index = GetMemberIndex(classType, id, pos);
1345  if ( index == kInvalidMember ) {
1346  if (m_TypeAlias && classType->GetMembers().GetItemInfo(pos)->GetId().HasNotag()) {
1347  m_TypeAlias = nullptr;
1348  return pos;
1349  } else if (CanSkipUnknownMembers()) {
1351  SkipAnyContent();
1352  return BeginClassMember(classType, pos);
1353  } else {
1354  UnexpectedMember(id, classType->GetMembers());
1355  }
1356  }
1357  return index;
1358 }
1359 
1360 #ifdef VIRTUAL_MID_LEVEL_IO
1362  TObjectPtr classPtr)
1363 {
1364  BEGIN_OBJECT_FRAME3(eFrameClass, classType, classPtr);
1365  StartBlock();
1366 
1367  ReadClassRandomContentsBegin(classType);
1368 
1369  TMemberIndex index;
1370  while ( (index = BeginClassMember(classType)) != kInvalidMember ) {
1372  }
1373 
1375 
1376  EndBlock();
1377  END_OBJECT_FRAME();
1378 }
1379 
1381  TObjectPtr classPtr)
1382 {
1383  BEGIN_OBJECT_FRAME3(eFrameClass, classType, classPtr);
1384  StartBlock();
1385 
1387 
1388  TMemberIndex index;
1389  while ( (index = BeginClassMember(classType,*pos)) != kInvalidMember ) {
1391  }
1392 
1394 
1395  EndBlock();
1396  END_OBJECT_FRAME();
1397 }
1398 
1400 {
1401  BEGIN_OBJECT_FRAME2(eFrameClass, classType);
1402  StartBlock();
1403 
1404  SkipClassRandomContentsBegin(classType);
1405 
1406  TMemberIndex index;
1407  while ( (index = BeginClassMember(classType)) != kInvalidMember ) {
1409  }
1410 
1412 
1413  EndBlock();
1414  END_OBJECT_FRAME();
1415 }
1416 
1418 {
1419  BEGIN_OBJECT_FRAME2(eFrameClass, classType);
1420  StartBlock();
1421 
1423 
1424  TMemberIndex index;
1425  while ( (index = BeginClassMember(classType,*pos)) != kInvalidMember ) {
1427  }
1428 
1430 
1431  EndBlock();
1432  END_OBJECT_FRAME();
1433 }
1434 #endif
1435 
1437 {
1438  if (choiceType->GetVariantInfo(kFirstMemberIndex)->GetId().IsAttlist()) {
1439  TopFrame().SetNotag();
1440  StartBlock();
1441  }
1442  m_BlockStart = true;
1443 }
1445 {
1446  if (TopFrame().GetNotag()) {
1447  SkipWhiteSpace();
1448  EndBlock();
1449  }
1450  m_BlockStart = false;
1451 }
1452 
1454 {
1455  bool skipname = !m_BlockStart;
1456  if ( !NextElement() )
1457  return kInvalidMember;
1459  if (skipname) {
1460  id = ReadMemberId(SkipWhiteSpace());
1461  }
1462  if ( id.empty() )
1463  ThrowError(fFormatError, "choice variant id expected");
1464 
1465  TMemberIndex index = GetChoiceIndex(choiceType, id);
1466  if ( index == kInvalidMember ) {
1467  if (CanSkipUnknownVariants()) {
1469  } else {
1470  UnexpectedMember(id, choiceType->GetVariants());
1471  }
1472  }
1473 
1474  return index;
1475 }
1476 
1478 {
1479  Expect('\'', true);
1480 }
1481 
1483 {
1484  for ( ;; ) {
1485  char c = GetChar();
1486  if ( c >= '0' && c <= '9' ) {
1487  return c - '0';
1488  }
1489  else if ( c >= 'A' && c <= 'F' ) {
1490  return c - 'A' + 10;
1491  }
1492  else if ( c >= 'a' && c <= 'f' ) {
1493  return c - 'a' + 10;
1494  }
1495  switch ( c ) {
1496  case '\'':
1497  return -1;
1498  case '\r':
1499  case '\n':
1500  SkipEndOfLine(c);
1501  break;
1502  default:
1503  m_Input.UngetChar(c);
1504  ThrowError(fFormatError, "bad char in octet string: #"
1505  + NStr::IntToString(c));
1506  }
1507  }
1508 }
1509 
1511  char* dst, size_t length)
1512 {
1513  size_t count = 0;
1514  while ( length-- > 0 ) {
1515  int c1 = GetHexChar();
1516  if ( c1 < 0 ) {
1517  block.EndOfBlock();
1518  return count;
1519  }
1520  int c2 = GetHexChar();
1521  if ( c2 < 0 ) {
1522  *dst++ = char(c1 << 4);
1523  count++;
1524  block.EndOfBlock();
1525  return count;
1526  }
1527  else {
1528  *dst++ = char((c1 << 4) | c2);
1529  count++;
1530  }
1531  }
1532  return count;
1533 }
1534 
1536 {
1537  Expect('H');
1538 }
1539 
1541 {
1542  Expect('\"', true);
1543 }
1544 
1546  char* dst, size_t length)
1547 {
1548  size_t count = 0, valid = 0;
1549  try {
1550  while (length-- > 0) {
1551  char c = m_Input.GetChar();
1552  switch ( c ) {
1553  case '\r':
1554  case '\n':
1555  break;
1556  case '\"':
1557  if ( m_Input.PeekCharNoEOF() == '\"' ) {
1558  m_Input.SkipChar();
1559  dst[count++] = c;
1560  }
1561  else {
1562  // end of string
1563  // Check the string for non-printable characters
1564  EFixNonPrint fix_method = x_FixCharsMethod();
1565  if ( fix_method != eFNP_Allow ) {
1566  for (size_t i = 0; i < count; i++) {
1567  if ( !GoodVisibleChar(dst[i]) ) {
1568 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING
1569  if (valid == 0) {
1570  if (CUtf8::EvaluateFirst(dst[i], valid)) {
1571  ++valid;
1572  }
1573  }
1574 #endif
1575  if (valid == 0) {
1576  char c = ReplaceVisibleChar(dst[i], fix_method, this, CTempString(dst, count), x_FixCharsSubst());
1577  dst[i] = c == '\0' ? '#' : c;
1578  }
1579  }
1580  if (valid != 0) {
1581  --valid;
1582  }
1583  }
1584  }
1585  block.EndOfBlock();
1586  return count;
1587  }
1588  break;
1589  default:
1590  // ok: append char
1591  {
1592  dst[count++] = c;
1593  }
1594  break;
1595  }
1596  }
1597  }
1598  catch ( CEofException& ) {
1599  SetFailFlags(fEOF);
1601  throw;
1602  }
1603  return count;
1604 }
1605 
1607 {
1608  switch ( PeekChar(true) ) {
1609  case 'N':
1610  if ( m_Input.PeekCharNoEOF(1) == 'U' &&
1611  m_Input.PeekCharNoEOF(2) == 'L' &&
1612  m_Input.PeekCharNoEOF(3) == 'L' &&
1613  !IdChar(m_Input.PeekCharNoEOF(4)) ) {
1614  // "NULL"
1615  m_Input.SkipChars(4);
1616  return eNullPointer;
1617  }
1618  break;
1619  case '@':
1620  m_Input.SkipChar();
1621  return eObjectPointer;
1622  case ':':
1623  m_Input.SkipChar();
1624  return eOtherPointer;
1625  default:
1626  break;
1627  }
1628  return eThisPointer;
1629 }
1630 
1632 {
1633  if ( sizeof(TObjectIndex) == sizeof(Int4) )
1634  return ReadInt4();
1635  else if ( sizeof(TObjectIndex) == sizeof(Int8) )
1636  return TObjectIndex(ReadInt8());
1637  else
1638  ThrowError(fIllegalCall, "invalid size of TObjectIndex:"
1639  " must be either sizeof(Int4) or sizeof(Int8)");
1640  return 0;
1641 }
1642 
1644 {
1645  return ReadTypeId(SkipWhiteSpace());
1646 }
1647 
1649 {
1650  SkipWhiteSpace();
1652 }
1653 
ncbi::TMaskedQueryRegions mask
Serializable object that stores any combination of parsable data.
Definition: serialbase.hpp:264
CObjectIStreamAsn –.
Definition: objistrasn.hpp:54
CObjectIStream –.
Definition: objistr.hpp:93
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
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const char * expect
Definition: tables.c:54
static char tmp[3200]
Definition: utf8.c:42
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
string
Definition: cgiapp.hpp:687
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
#define finite
Define value of finite (Is Finite).
Definition: ncbifloat.h:109
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
TMemberIndex Find(const CTempString &name) const
Definition: memberlist.cpp:256
CAsnBinaryDefs::TLongTag TTag
Definition: memberid.hpp:54
const CItemInfo * GetItemInfo(TMemberIndex index) const
bool HasNotag(void) const
TEnumValueType FindValue(const CTempString &name) const
Find numeric value by the name of the enum.
Definition: enumerated.cpp:124
bool IsInteger(void) const
Check whether the type is defined as INTEGER in ASN.1 spec.
Definition: enumvalues.hpp:75
string ToString(void) const
Definition: memberid.cpp:113
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
void SetName(const string &name)
Set local name.
EStringType
String type.
Definition: serialdef.hpp:185
void SetValue(const CStringUTF8 &value)
Set normalized value.
@ eFNP_Allow
pass through unchanged, post no error message
Definition: serialdef.hpp:175
@ eStringTypeUTF8
UTF8-encoded string.
Definition: serialdef.hpp:187
@ eStringTypeVisible
VisibleString (in ASN.1 sense)
Definition: serialdef.hpp:186
@ eSerial_AsnText
ASN.1 text.
Definition: serialdef.hpp:73
CIStreamBuffer m_Input
Definition: objistr.hpp:1048
void EndBlock(void)
void AppendStringData(string &s, size_t count, EFixNonPrint fix_method, size_t line)
Definition: objistrasn.cpp:876
virtual void SkipChar(void) override
void SkipEndOfLine(char c)
Definition: objistrasn.cpp:142
char ReplaceVisibleChar(char c, EFixNonPrint fix_method, const CObjectStack *io, const CTempString &str, char subst)
Definition: objistr.cpp:1855
virtual void SkipSNumber(void) override
virtual void StartDelayBuffer(void) override
CTempString ScanEndOfId(bool isId)
Definition: objistrasn.cpp:276
virtual void ReadBitString(CBitString &obj) override
Definition: objistrasn.cpp:577
CObjectIStreamAsn(EFixNonPrint how=eFNP_Default)
Constructor.
Definition: objistrasn.cpp:57
MLIOVIR void ReadClassSequential(const CClassTypeInfo *classType, TObjectPtr classPtr)
Definition: objistr.cpp:1398
virtual bool BeginContainerElement(TTypeInfo elementType) override
virtual Int8 ReadInt8(void) override
Definition: objistrasn.cpp:789
virtual bool EndOfData(void) override
Check if there is still some meaningful data that can be read; this function will skip white spaces a...
Definition: objistrasn.cpp:98
virtual size_t ReadBytes(ByteBlock &block, char *dst, size_t length) override
bool GoodVisibleChar(char c)
void ReadStringValue(string &s, EFixNonPrint fix_method)
Definition: objistrasn.cpp:938
virtual void BeginClass(const CClassTypeInfo *classInfo) override
virtual void SkipNull(void) override
#define BEGIN_OBJECT_FRAME(Type)
Definition: objstack.hpp:224
char SkipWhiteSpaceAndGetChar(void)
Definition: objistrasn.cpp:148
#define ThrowError(flag, mess)
Definition: objstack.hpp:113
virtual bool ReadBool(void) override
Definition: objistrasn.cpp:739
virtual Uint8 ReadUint8(void) override
Definition: objistrasn.cpp:795
virtual void SkipUNumber(void) override
static bool IdChar(char c)
Definition: objistrasn.cpp:124
virtual void EndContainer(void) override
void BadStringChar(size_t startLine, char c)
Definition: objistrasn.cpp:859
void Expect(char c, bool skipWhiteSpace=false)
Definition: objistrasn.cpp:177
virtual EPointerType ReadPointerType(void) override
EFixNonPrint FixNonPrint(EFixNonPrint how)
Definition: objistr.hpp:355
virtual bool EndOfData(void)
Check if there is still some meaningful data that can be read; in text streams this function will ski...
Definition: objistr.cpp:588
CTempString ReadLCaseId(char firstChar)
Definition: objistrasn.cpp:337
bool IsCompressed(void) const
Definition: objstack.cpp:193
void UnexpectedMember(const CTempString &id, const CItemsInfo &items)
virtual Int4 ReadInt4(void) override
Definition: objistrasn.cpp:777
#define BEGIN_OBJECT_FRAME2(Type, Arg)
Definition: objstack.hpp:225
virtual void SkipFNumber(void) override
static CObjectIStream * CreateObjectIStreamAsn(void)
Definition: objistrasn.cpp:52
MLIOVIR void ReadContainer(const CContainerTypeInfo *containerType, TObjectPtr containerPtr)
Definition: objistr.cpp:1318
virtual void Location(string &, size_t &) const override
Get current stream location as tuple (positiontype:string, size_t).
Definition: objistrasn.cpp:111
char GetChar(void)
Definition: objistrasn.cpp:130
void SkipObject(const CObjectTypeInfo &objectType)
Skip child object.
Definition: objistr.cpp:1102
virtual char ReadChar(void) override
Definition: objistrasn.cpp:766
virtual void SkipAnyContentObject(void) override
Definition: objistrasn.cpp:572
virtual void SkipString(EStringType type=eStringTypeVisible) override
virtual void ReadAnyContentObject(CAnyContentObject &obj) override
Definition: objistrasn.cpp:524
virtual double ReadDouble(void) override
Definition: objistrasn.cpp:801
void SetNotag(bool set=true)
virtual TObjectIndex ReadObjectPointer(void) override
bool CanSkipUnknownMembers(void)
Simple check if it's allowed to skip unknown members.
static bool FirstIdChar(char c)
Definition: objistrasn.cpp:118
bool NextElement(void)
virtual void SkipBitString(void) override
Definition: objistrasn.cpp:704
int GetHexChar(void)
char PeekChar(void)
Definition: objistrasn.cpp:136
virtual void BeginChars(CharBlock &block) override
virtual void SkipByteBlock(void) override
virtual size_t ReadChars(CharBlock &block, char *dst, size_t length) override
virtual void ReadNull(void) override
Definition: objistrasn.cpp:444
void StartBlock(void)
virtual void SkipBool(void) override
Definition: objistrasn.cpp:993
TTypeInfo m_TypeAlias
Definition: objistr.hpp:1052
#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
char SkipWhiteSpace(void)
Definition: objistrasn.cpp:207
const TFrame & TopFrame(void) const
CTempString ReadMemberId(char firstChar)
Definition: objistrasn.cpp:343
EFixNonPrint x_FixCharsMethod(void) const
Definition: objistr.cpp:311
virtual void ReadString(string &s, EStringType type=eStringTypeVisible) override
Definition: objistrasn.cpp:988
TFailFlags SetFailFlags(TFailFlags flags, const char *message=0)
Set fail flags.
Definition: objistr.cpp:552
void SkipComments(void)
Definition: objistrasn.cpp:245
TMemberIndex GetAltItemIndex(const CClassTypeInfoBase *classType, const CTempString &id, const TMemberIndex pos=kInvalidMember)
Definition: objistrasn.cpp:366
void UnendedString(size_t startLine)
Definition: objistrasn.cpp:867
CTempString ReadUCaseId(char firstChar)
Definition: objistrasn.cpp:331
void AppendLongStringData(string &s, size_t count, EFixNonPrint fix_method, size_t line)
Definition: objistrasn.cpp:922
virtual void BeginChoice(const CChoiceTypeInfo *choiceType) override
CTempString ReadTypeId(char firstChar)
Definition: objistrasn.cpp:292
size_t TObjectIndex
Definition: objistr.hpp:1029
virtual TMemberIndex BeginClassMember(const CClassTypeInfo *classType) override
TMemberIndex GetMemberIndex(const CClassTypeInfo *classType, const CTempString &id)
Definition: objistrasn.cpp:390
MLIOVIR void SkipContainer(const CContainerTypeInfo *containerType)
Definition: objistr.cpp:1349
MLIOVIR void SkipClassSequential(const CClassTypeInfo *classType)
Definition: objistr.cpp:1451
virtual TMemberIndex BeginChoiceVariant(const CChoiceTypeInfo *choiceType) override
virtual void EndClass(void) override
virtual void BeginContainer(const CContainerTypeInfo *containerType) override
bool CanSkipUnknownVariants(void)
Simple check if it's allowed to skip unknown variants.
#define BEGIN_OBJECT_FRAME3(Type, Arg1, Arg2)
Definition: objstack.hpp:226
virtual void EndChoice(void) override
virtual void StartDelayBuffer(void)
Definition: objistr.cpp:1014
virtual void EndBytes(const ByteBlock &block) override
void ReadAnyContent(string &value)
Definition: objistrasn.cpp:457
char x_FixCharsSubst(void) const
Definition: objistr.hpp:1044
virtual Uint4 ReadUint4(void) override
Definition: objistrasn.cpp:783
virtual void BeginBytes(ByteBlock &block) override
virtual string ReadFileHeader(void) override
Read file header.
Definition: objistrasn.cpp:709
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 TEnumValueType ReadEnum(const CEnumeratedTypeValues &values) override
Definition: objistrasn.cpp:723
TMemberIndex GetChoiceIndex(const CChoiceTypeInfo *choiceType, const CTempString &id)
Definition: objistrasn.cpp:427
virtual string ReadOtherPointer(void) override
void ReadCompressedBitString(CBitString &data)
Definition: objistr.cpp:1842
CTempString ReadNumber(void)
Definition: objistrasn.cpp:315
MLIOVIR void ReadClassRandom(const CClassTypeInfo *classType, TObjectPtr classPtr)
Definition: objistr.cpp:1376
void SkipAnyContent(void)
Definition: objistrasn.cpp:532
@ fEOF
End of file in the middle of reading an object.
Definition: objistr.hpp:373
@ fOverflow
Data read is beyond the allowed limits.
Definition: objistr.hpp:379
@ fIllegalCall
Illegal in a given context function call.
Definition: objistr.hpp:383
@ 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
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
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
Uint4 GetUint4(void)
Definition: strbuffer.cpp:671
char PeekChar(size_t offset=0)
Int8 GetInt8(void)
Definition: strbuffer.cpp:702
Uint8 GetUint8(void)
Definition: strbuffer.cpp:748
char SkipSpaces(void)
Definition: strbuffer.cpp:213
Int4 GetInt4(void)
Definition: strbuffer.cpp:625
void UngetChar(char c)
void SkipEndOfLine(char lastChar)
Definition: strbuffer.cpp:525
void SkipChar(void)
char GetChar(void)
size_t GetLine(void) const
void SkipChars(size_t count)
const char * GetCurrentPos(void) const
char PeekCharNoEOF(size_t offset=0)
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
#define kEmptyStr
Definition: ncbistr.hpp:123
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static int strncasecmp(const char *s1, const char *s2, size_t n)
Case-insensitive comparison of two zero-terminated strings, narrowed to the specified number of chara...
Definition: ncbistr.hpp:5247
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
const char * data(void) const
Return a pointer to the array represented.
Definition: tempstr.hpp:313
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 CStringUTF8 AsUTF8(const CTempString &src, EEncoding encoding, EValidate validate=eNoValidate)
Convert into UTF8 from a C/C++ string.
Definition: ncbistr.hpp:3889
size_type size(void) const
Return the length of the represented array.
Definition: tempstr.hpp:327
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
@ eEncoding_UTF8
Definition: ncbistr.hpp:201
@ fDecimalPosixFinite
StringToDouble*(): Keep result finite and normalized: if DBL_MAX < result < INF, result becomes DBL_M...
Definition: ncbistr.hpp:302
const CItemsInfo & GetItems(void) const
TObjectPtr AddElement(TObjectPtr containerPtr, TConstObjectPtr elementPtr, ESerialRecursionMode how=eRecursive) const
const CItemsInfo & GetVariants(void) const
const CVariantInfo * GetVariantInfo(TMemberIndex index) const
void ReadData(CObjectIStream &in, TObjectPtr object) const
TConstObjectPtr GetElementPtr(const CConstIterator &it) const
bool InitIterator(CConstIterator &it, TConstObjectPtr containerPtr) const
bool NextElement(CConstIterator &it) const
void EraseAllElements(CIterator &it) const
const CItemsInfo & GetMembers(void) const
TTypeInfo GetElementType(void) const
enum ENcbiOwnership EOwnership
Ownership relations between objects.
char * buf
int i
int len
static void hex(unsigned char c)
Definition: mdb_dump.c:56
static void byte(MDB_val *v)
Definition: mdb_dump.c:81
static MDB_envinfo info
Definition: mdb_load.c:37
constexpr bool empty(list< Ts... >) noexcept
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
int isalpha(Uchar c)
Definition: ncbictype.hpp:61
int isspace(Uchar c)
Definition: ncbictype.hpp:69
int isalnum(Uchar c)
Definition: ncbictype.hpp:62
int isdigit(Uchar c)
Definition: ncbictype.hpp:64
int toupper(Uchar c)
Definition: ncbictype.hpp:73
int islower(Uchar c)
Definition: ncbictype.hpp:66
int isupper(Uchar c)
Definition: ncbictype.hpp:70
Floating-point support routines.
Useful/utility classes and methods.
std::istream & in(std::istream &in_, double &x_)
#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
static pcre_uint8 * buffer
Definition: pcretest.c:1051
Definition: type.c:6
done
Definition: token1.c:1
else result
Definition: token2.c:20
Modified on Wed Apr 17 13:10:30 2024 by modify_doxy.py rev. 669887