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

Go to the SVN repository for this file.

1 /* $Id: objostrasn.cpp 94379 2021-07-29 12:05:45Z gouriano $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Eugene Vasilchenko
27 *
28 * File Description:
29 * !!! PUT YOUR DESCRIPTION HERE !!!
30 *
31 */
32 
33 #include <ncbi_pch.hpp>
34 #include <corelib/ncbistd.hpp>
35 #include <corelib/ncbi_limits.h>
36 
37 #include <serial/objostrasn.hpp>
38 #include <serial/objistr.hpp>
39 #include <serial/objcopy.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>
47 #include <serial/delaybuf.hpp>
48 #include <serial/error_codes.hpp>
49 
50 #include <stdio.h>
51 #include <math.h>
52 
53 
54 #define NCBI_USE_ERRCODE_X Serial_OStream
55 
57 
59  EOwnership deleteOut)
60 {
61  return new CObjectOStreamAsn(out, deleteOut);
62 }
63 
65  EFixNonPrint how)
67 {
68  FixNonPrint(how);
70  SetSeparator("\n");
71  SetAutoSeparator(true);
72 }
73 
75  bool deleteOut,
76  EFixNonPrint how)
78 {
79  FixNonPrint(how);
81  SetSeparator("\n");
82  SetAutoSeparator(true);
83 }
84 
86  EOwnership deleteOut,
87  EFixNonPrint how)
88  : CObjectOStream(eSerial_AsnText, out, deleteOut)
89 {
90  FixNonPrint(how);
92  SetSeparator("\n");
93  SetAutoSeparator(true);
94 }
95 
97 {
98 }
99 
101 {
102  return "line "+NStr::SizetToString(m_Output.GetLine());
103 }
104 
106 {
107  if ( true || m_Output.ZeroIndentLevel() ) {
108  WriteId(type->GetName());
109  m_Output.PutString(" ::= ");
110  }
111 }
112 
114  const CEnumeratedTypeValues& values,
115  TEnumValueType value, const string& valueName)
116 {
117  if (valueName.empty() || (m_WriteNamedIntegersByValue && values.IsInteger())) {
119  } else {
120 // names coming from XML can begin with uppercase char;
121 // in ASN, they must begin with lowercase one.
122  m_Output.PutChar((char)tolower((unsigned char)valueName[0]));
123  m_Output.PutString(valueName.data()+1, valueName.size()-1);
124  }
125 }
126 
129 {
130  WriteEnum(values,value,values.FindNameEx(value, values.IsInteger()));
131 }
132 
135 {
136  TEnumValueType value = in.ReadEnum(values);
137  WriteEnum(values, value, values.FindNameEx(value, values.IsInteger()));
138 }
139 
141 {
142  if ( data )
143  m_Output.PutString("TRUE");
144  else
145  m_Output.PutString("FALSE");
146 }
147 
149 {
150  m_Output.PutChar('\'');
152  m_Output.PutChar('\'');
153 }
154 
156 {
158 }
159 
161 {
163 }
164 
166 {
168 }
169 
171 {
173 }
174 
175 void CObjectOStreamAsn::WriteDouble2(double data, unsigned digits)
176 {
177 #if 0
178  if (isnan(data)) {
179  ThrowError(fInvalidData, "invalid double: not a number");
180  }
181  if (!finite(data)) {
182  ThrowError(fInvalidData, "invalid double: infinite");
183  }
184 #else
185  if (isnan(data)) {
186  m_Output.PutString("NOT-A-NUMBER");
187  return;
188  }
189  if (!finite(data)) {
190  if (data > 0) {
191  m_Output.PutString("PLUS-INFINITY");
192  } else {
193  m_Output.PutString("MINUS-INFINITY");
194  }
195  return;
196  }
197 #endif
198  if ( data == 0.0 ) {
199  double zero = 0.;
200  if (memcmp(&data, &zero, sizeof(double)) == 0) {
201  m_Output.PutString("{ 0, 10, 0 }");
202  } else {
203  m_Output.PutString("{ -0, 10, 0 }");
204  }
205  return;
206  }
207 
208  char buffer[128];
209  if (m_FastWriteDouble) {
210  int dec, sign;
212  data, digits, buffer, sizeof(buffer), &dec, &sign);
213  _ASSERT(len > 0);
214  m_Output.PutString("{ ");
215  if (sign < 0) {
216  m_Output.PutString("-");
217  }
219  m_Output.PutString(", 10, ");
220  m_Output.PutInt4(dec - (int)(len-1));
221  m_Output.PutString(" }");
222 
223  } else {
224  // ensure buffer is large enough to fit result
225  // (additional bytes are for sign, dot and exponent)
226  _ASSERT(sizeof(buffer) > digits + 16);
227 #if !defined(NCBI_COMPILER_MSVC)
228  int width = sprintf(buffer, "%.*e", int(digits-1), data);
229  if ( width <= 0 || width >= int(sizeof(buffer) - 1) )
230  ThrowError(fOverflow, "buffer overflow");
231  _ASSERT(int(strlen(buffer)) == width);
232  char* dotPos = strchr(buffer, '.');
233  if (!dotPos) {
234  dotPos = strchr(buffer, ','); // non-C locale?
235  }
236  _ASSERT(dotPos);
237  char* ePos = strchr(dotPos, 'e');
238  _ASSERT(ePos);
239 
240  // now we have:
241  // mantissa with dot - buffer:ePos
242  // exponent - (ePos+1):
243 
244  int exp;
245  // calculate exponent
246  if ( sscanf(ePos + 1, "%d", &exp) != 1 )
247  ThrowError(fInvalidData, "double value conversion error");
248 
249  // remove trailing zeroes
250  int fractDigits = int(ePos - dotPos - 1);
251  while ( fractDigits > 0 && ePos[-1] == '0' ) {
252  --ePos;
253  --fractDigits;
254  }
255 
256  // now we have:
257  // mantissa with dot without trailing zeroes - buffer:ePos
258 
259  m_Output.PutString("{ ");
260  m_Output.PutString(buffer, dotPos - buffer);
261  m_Output.PutString(dotPos + 1, fractDigits);
262  m_Output.PutString(", 10, ");
263  m_Output.PutInt4(exp - fractDigits);
264  m_Output.PutString(" }");
265 #else
266  int width = sprintf(buffer, "%.*g", int(digits), data);
267  if ( width <= 0 || width >= int(sizeof(buffer) - 1) )
268  ThrowError(fOverflow, "buffer overflow");
269  _ASSERT(int(strlen(buffer)) == width);
270 
271  int exp = 0;
272  const char* ePos = strchr(buffer, 'e');
273  if (ePos) {
274  if ( sscanf(ePos + 1, "%d", &exp) != 1 )
275  ThrowError(fInvalidData, "double value conversion error");
276  } else {
277  ePos = buffer + strlen(buffer);
278  }
279  char* dotPos = strchr(buffer, '.');
280  if (!dotPos) {
281  dotPos = strchr(buffer, ','); // non-C locale?
282  }
283  if (dotPos) {
284  exp -= (int)(ePos - dotPos - 1);
285  memmove(dotPos, dotPos+1, strlen(dotPos+1));
286  --ePos;
287  }
288  while ( ePos[-1] == '0' ) {
289  ++exp;
290  --ePos;
291  }
292  const char *start = buffer;
293  while ( *start == '0' ) {
294  ++start;
295  }
296  m_Output.PutString("{ ");
297  m_Output.PutString(start, ePos - start);
298  m_Output.PutString(", 10, ");
300  m_Output.PutString(" }");
301 #endif
302  }
303 }
304 
306 {
307  WriteDouble2(data, DBL_DIG);
308 }
309 
311 {
312  WriteDouble2(data, FLT_DIG);
313 }
314 
316 {
317  m_Output.PutString("NULL");
318 }
319 
321 {
322 #if 0
324  "CObjectOStreamAsn::WriteAnyContentObject: "
325  "unable to write AnyContent object in ASN");
326 #else
327  m_Output.PutString(obj.GetName());
328  m_Output.PutChar(' ');
329  m_Output.PutString(obj.GetValue());
330 #endif
331 }
332 
334 {
336  "CObjectOStreamAsn::CopyAnyContentObject: "
337  "unable to copy AnyContent object in ASN");
338 }
339 
341 {
342  static const char ToHex[] = "0123456789ABCDEF";
343  bool hex = obj.size()%8 == 0;
344  m_Output.PutChar('\'');
345 #if BITSTRING_AS_VECTOR
346 // CBitString is vector<bool>
347  if (hex) {
348  Uint1 data, mask;
349  for ( CBitString::const_iterator i = obj.begin(); i != obj.end(); ) {
350  for (data=0, mask=0x8; mask!=0; mask >>= 1, ++i) {
351  if (*i) {
352  data |= mask;
353  }
354  }
355  m_Output.WrapAt(78, false);
356  m_Output.PutChar(ToHex[data]);
357  }
358  } else {
359  ITERATE ( CBitString, i, obj) {
360  m_Output.WrapAt(78, false);
361  m_Output.PutChar( *i ? '1' : '0');
362  }
363  }
364 #else
365  if (IsCompressed()) {
367  CBitString::statistics st;
368  obj.calc_stat(&st);
369  char* buf = (char*)malloc(st.max_serialize_mem);
370  size_t len = bm::serialize(obj, (unsigned char*)buf, tmp_block);
371  WriteBytes(buf,len);
372  free(buf);
373  bm::aligned_free(tmp_block);
374  hex = true;
375  } else {
377  CBitString::size_type ilast = obj.size();
378  CBitString::enumerator e = obj.first();
379  if (hex) {
380  Uint1 data, mask;
381  while (i < ilast) {
382  for (data=0, mask=0x8; mask!=0; mask = Uint1(mask >> 1), ++i) {
383  if (i == *e) {
384  data |= mask;
385  ++e;
386  }
387  }
388  m_Output.WrapAt(78, false);
389  m_Output.PutChar(ToHex[data]);
390  }
391  } else {
392  for (; i < ilast; ++i) {
393  m_Output.WrapAt(78, false);
394  m_Output.PutChar( (i == *e) ? '1' : '0');
395  if (i == *e) {
396  ++e;
397  }
398  }
399  }
400  }
401 #endif
402  m_Output.PutChar('\'');
403  m_Output.PutChar(hex ? 'H' : 'B');
404 }
405 
407 {
408  CBitString obj;
409  in.ReadBitString(obj);
410  WriteBitString(obj);
411 }
412 
413 void CObjectOStreamAsn::WriteString(const char* ptr, size_t length)
414 {
415  m_Output.PutChar('"');
416  CTempString original(ptr, length);
417  size_t valid=0;
418  while ( length > 0 ) {
419  char c = *ptr;
420  if ( x_FixCharsMethod() != eFNP_Allow ) {
421  if ( !GoodVisibleChar(c) ) {
422  if (valid == 0) {
423 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_WRITING
424  valid = CUtf8::EvaluateSymbolLength(CTempString(ptr,length));
425 #endif
426  if (valid == 0) {
427  c = ReplaceVisibleChar(c, x_FixCharsMethod(), this, original, x_FixCharsSubst());
428  }
429  }
430  }
431  }
432  ++ptr;
433  --length;
434  if (valid != 0) {
435  --valid;
436  }
437  if (c == 0) {
438  continue;
439  }
440  m_Output.WrapAt(78, true);
441  m_Output.PutChar(c);
442  if ( c == '"' ) {
443  m_Output.PutChar('"');
444  }
445  }
446  m_Output.PutChar('"');
447 }
448 
450 {
451  if ( str == 0 ) {
452  WriteNull();
453  }
454  else {
455  WriteString(str, strlen(str));
456  }
457 }
458 
460 {
462  if (type == eStringTypeUTF8) {
464  }
465  WriteString(str.data(), str.size());
466  FixNonPrint( fix );
467 }
468 
470 {
471  WriteString(str.data(), str.size());
472 }
473 
476 {
477  string s;
478  in.ReadString(s, type);
479  WriteString(s, type);
480 }
481 
483 {
484  string s;
485  in.ReadStringStore(s);
486  WriteString(s.data(), s.size());
487 }
488 
489 void CObjectOStreamAsn::WriteId(const string& str, bool checkCase)
490 {
491  if ( str.find(' ') != NPOS || str.find('<') != NPOS ||
492  str.find(':') != NPOS ) {
493  m_Output.PutChar('[');
495  m_Output.PutChar(']');
496  } else {
497  if (checkCase && !str.empty()) {
498  m_Output.PutChar((char)tolower((unsigned char)str[0]));
499  m_Output.PutString(str.data()+1, str.size()-1);
500  } else {
502  }
503  }
504 }
505 
507 {
508  m_Output.PutString("NULL");
509 }
510 
512 {
513  m_Output.PutChar('@');
514  if ( sizeof(TObjectIndex) == sizeof(Int4) )
515  m_Output.PutInt4(Int4(index));
516  else if ( sizeof(TObjectIndex) == sizeof(Int8) )
517  m_Output.PutInt8(index);
518  else
519  ThrowError(fIllegalCall, "invalid size of TObjectIndex: "
520  "must be either sizeof(Int4) or sizeof(Int8)");
521 }
522 
524 {
525  m_Output.PutString(": ");
526  WriteId(typeInfo->GetName());
527  m_Output.PutChar(' ');
528 }
529 
531  TTypeInfo typeInfo)
532 {
533  m_Output.PutString(": ");
534  WriteId(typeInfo->GetName());
535  m_Output.PutChar(' ');
536  WriteObject(object, typeInfo);
537 }
538 
540 {
541  m_Output.PutChar('{');
543  m_BlockStart = true;
544 }
545 
547 {
549  m_Output.PutEol();
550  m_Output.PutChar('}');
551  m_BlockStart = false;
552 }
553 
555 {
556  if ( m_BlockStart )
557  m_BlockStart = false;
558  else
559  m_Output.PutChar(',');
560  m_Output.PutEol();
561 }
562 
564 {
565  StartBlock();
566 }
567 
569 {
570  EndBlock();
571 }
572 
574 {
575  NextElement();
576 }
577 
578 #ifdef VIRTUAL_MID_LEVEL_IO
580  TConstObjectPtr containerPtr)
581 {
582  BEGIN_OBJECT_FRAME2(eFrameArray, cType);
583  StartBlock();
584 
586  if ( cType->InitIterator(i, containerPtr) ) {
587  TTypeInfo elementType = cType->GetElementType();
588  BEGIN_OBJECT_FRAME2(eFrameArrayElement, elementType);
589 
590  const CPointerTypeInfo* pointerType =
591  dynamic_cast<const CPointerTypeInfo*>(elementType);
592  do {
593  TConstObjectPtr elementPtr = cType->GetElementPtr(i);
594  if ( pointerType &&
595  !pointerType->GetObjectPointer(elementPtr) ) {
598  "NULL element while writing container "+
599  cType->GetName());
600  }
601  continue;
602  }
603 
604  NextElement();
605 
606  WriteObject(elementPtr, elementType);
607 
608  } while ( cType->NextElement(i) );
609 
611  }
612 
613  EndBlock();
615 }
616 
618  CObjectStreamCopier& copier)
619 {
620  BEGIN_OBJECT_FRAME_OF2(copier.In(), eFrameArray, cType);
621  copier.In().BeginContainer(cType);
622 
623  StartBlock();
624 
625  TTypeInfo elementType = cType->GetElementType();
626  BEGIN_OBJECT_2FRAMES_OF2(copier, eFrameArrayElement, elementType);
627 
628  while ( copier.In().BeginContainerElement(elementType) ) {
629  NextElement();
630 
631  CopyObject(elementType, copier);
632 
633  copier.In().EndContainerElement();
634  }
635 
636  END_OBJECT_2FRAMES_OF(copier);
637 
638  EndBlock();
639 
640  copier.In().EndContainer();
641  END_OBJECT_FRAME_OF(copier.In());
642 }
643 #endif
644 
645 
647 {
648  auto tn = [this]()->const string& {
649  const string& r(m_TypeAlias->GetName());
650  m_TypeAlias = nullptr;
651  return r;
652  };
653  const string& name = (m_TypeAlias && id.HasNotag()) ? tn() : id.GetName();
654 
655  if ( !name.empty() ) {
656  if (id.HaveNoPrefix() && isupper((unsigned char)name[0])) {
657  m_Output.PutChar((char)tolower((unsigned char)name[0]));
658  m_Output.PutString(name.data()+1, name.size()-1);
659  } else {
660  m_Output.PutString(name);
661  }
662  m_Output.PutChar(' ');
663  }
664  else if ( id.HaveExplicitTag() ) {
665  m_Output.PutString("[" + NStr::IntToString(id.GetTag()) + "] ");
666  }
667 }
668 
670 {
671  StartBlock();
672 }
673 
675 {
676  EndBlock();
677 }
678 
680 {
681  NextElement();
682 
683  WriteMemberId(id);
684 }
685 
686 #ifdef VIRTUAL_MID_LEVEL_IO
687 void CObjectOStreamAsn::WriteClass(const CClassTypeInfo* classType,
688  TConstObjectPtr classPtr)
689 {
690  BEGIN_OBJECT_FRAME2(eFrameClass, classType);
691  StartBlock();
692 
693  for ( CClassTypeInfo::CIterator i(classType); i.Valid(); ++i ) {
694  classType->GetMemberInfo(*i)->WriteMember(*this, classPtr);
695  }
696 
697  EndBlock();
699 }
700 
702  TTypeInfo memberType,
703  TConstObjectPtr memberPtr)
704 {
705  NextElement();
706 
707  BEGIN_OBJECT_FRAME2(eFrameClassMember, memberId);
708 
709  WriteMemberId(memberId);
710 
711  WriteObject(memberPtr, memberType);
712 
714 }
715 
717  const CDelayBuffer& buffer)
718 {
719  if ( !buffer.HaveFormat(eSerial_AsnText) )
720  return false;
721 
722  NextElement();
723 
724  BEGIN_OBJECT_FRAME2(eFrameClassMember, memberId);
725 
726  WriteMemberId(memberId);
727 
728  Write(buffer.GetSource());
729 
731 
732  return true;
733 }
734 
736  CObjectStreamCopier& copier)
737 {
738  BEGIN_OBJECT_2FRAMES_OF2(copier, eFrameClass, classType);
739  copier.In().BeginClass(classType);
740 
741  StartBlock();
742 
743  vector<Uint1> read(classType->GetMembers().LastIndex() + 1);
744 
745  BEGIN_OBJECT_2FRAMES_OF(copier, eFrameClassMember);
746 
747  TMemberIndex index;
748  while ( (index = copier.In().BeginClassMember(classType)) !=
749  kInvalidMember ) {
750  const CMemberInfo* memberInfo = classType->GetMemberInfo(index);
751  copier.In().SetTopMemberId(memberInfo->GetId());
752  SetTopMemberId(memberInfo->GetId());
753  copier.SetPathHooks(*this, true);
754 
755  if ( read[index] ) {
756  copier.DuplicatedMember(memberInfo);
757  }
758  else {
759  read[index] = true;
760 
761  NextElement();
762  WriteMemberId(memberInfo->GetId());
763 
764  memberInfo->CopyMember(copier);
765  }
766  copier.SetPathHooks(*this, false);
767  copier.In().EndClassMember();
768  }
769 
770  END_OBJECT_2FRAMES_OF(copier);
771 
772  // init all absent members
773  for ( CClassTypeInfo::CIterator i(classType); i.Valid(); ++i ) {
774  if ( !read[*i] ) {
775  classType->GetMemberInfo(*i)->CopyMissingMember(copier);
776  }
777  }
778 
779  EndBlock();
780 
781  copier.In().EndClass();
782  END_OBJECT_2FRAMES_OF(copier);
783 }
784 
786  CObjectStreamCopier& copier)
787 {
788  BEGIN_OBJECT_2FRAMES_OF2(copier, eFrameClass, classType);
789  copier.In().BeginClass(classType);
790 
791  StartBlock();
792 
793  CClassTypeInfo::CIterator pos(classType);
794  BEGIN_OBJECT_2FRAMES_OF(copier, eFrameClassMember);
795 
796  TMemberIndex index;
797  while ( (index = copier.In().BeginClassMember(classType, *pos)) !=
798  kInvalidMember ) {
799  const CMemberInfo* memberInfo = classType->GetMemberInfo(index);
800  copier.In().SetTopMemberId(memberInfo->GetId());
801  SetTopMemberId(memberInfo->GetId());
802  copier.SetPathHooks(*this, true);
803 
804  for ( TMemberIndex i = *pos; i < index; ++i ) {
805  // init missing member
806  classType->GetMemberInfo(i)->CopyMissingMember(copier);
807  }
808 
809  NextElement();
810  WriteMemberId(memberInfo->GetId());
811 
812  memberInfo->CopyMember(copier);
813 
814  pos.SetIndex(index + 1);
815 
816  copier.SetPathHooks(*this, false);
817  copier.In().EndClassMember();
818  }
819 
820  END_OBJECT_2FRAMES_OF(copier);
821 
822  // init all absent members
823  for ( ; pos.Valid(); ++pos ) {
824  classType->GetMemberInfo(*pos)->CopyMissingMember(copier);
825  }
826 
827  EndBlock();
828 
829  copier.In().EndClass();
830  END_OBJECT_2FRAMES_OF(copier);
831 }
832 #endif
833 
835 {
836  if (choiceType->GetVariantInfo(kFirstMemberIndex)->GetId().IsAttlist()) {
837  TopFrame().SetNotag();
838  StartBlock();
839  }
840  m_BlockStart = true;
841 }
843 {
844  if (TopFrame().GetNotag()) {
845  EndBlock();
846  }
847  m_BlockStart = false;
848 }
849 
851  const CMemberId& id)
852 {
853  if ( m_BlockStart ) {
854  m_BlockStart = false;
855  } else {
856  NextElement();
857  if (m_TypeAlias) {
858  WriteId(m_TypeAlias->GetName(), id.HaveNoPrefix());
859  m_TypeAlias = nullptr;
860  } else {
861  WriteId(choiceType->GetName(), id.HaveNoPrefix());
862  }
863  m_Output.PutChar(' ');
864  }
865  WriteMemberId(id);
866 }
867 
869 {
870  m_Output.PutChar('\'');
871 }
872 
873 static const char HEX[] = "0123456789ABCDEF";
874 
876  const char* bytes, size_t length)
877 {
878  WriteBytes(bytes, length);
879 }
880 
881 void CObjectOStreamAsn::WriteBytes(const char* bytes, size_t length)
882 {
883  while ( length-- > 0 ) {
884  char c = *bytes++;
885  m_Output.WrapAt(78, false);
886  m_Output.PutChar(HEX[(c >> 4) & 0xf]);
887  m_Output.PutChar(HEX[c & 0xf]);
888  }
889 }
890 
892 {
893  m_Output.WrapAt(78, false);
894  m_Output.PutString("\'H");
895 }
896 
898 {
899  m_Output.PutChar('"');
900 }
901 
903  const char* chars, size_t length)
904 {
905  size_t valid=0;
906  CTempString original(chars, length);
907  while ( length > 0 ) {
908  char c = *chars;
909  if ( !GoodVisibleChar(c) ) {
910  if (valid == 0) {
911 #if SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_WRITING
913 #endif
914  if (valid == 0) {
915  c = ReplaceVisibleChar(c, x_FixCharsMethod(), this, original, x_FixCharsSubst());
916  }
917  }
918  }
919  ++chars;
920  --length;
921  if (valid != 0) {
922  --valid;
923  }
924  if (c == 0) {
925  continue;
926  }
927  m_Output.WrapAt(78, true);
928  m_Output.PutChar(c);
929  if ( c == '"' )
930  m_Output.PutChar('"');
931  }
932 }
933 
935 {
936  m_Output.WrapAt(78, false);
937  m_Output.PutChar('"');
938 }
939 
940 
942 {
944  FlushBuffer();
945 }
946 
947 
ncbi::TMaskedQueryRegions mask
Serializable object that stores any combination of parsable data.
Definition: serialbase.hpp:264
CDelayBuffer.
Definition: delaybuf.hpp:58
CObjectIStream –.
Definition: objistr.hpp:93
CObjectOStreamAsn –.
Definition: objostrasn.hpp:53
CObjectOStream –.
Definition: objostr.hpp:83
CObjectStreamCopier –.
Definition: objcopy.hpp:71
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
size_type size() const noexcept
Returns bvector's capacity (number of bits it can store)
Definition: bm.h:1300
friend class enumerator
Definition: bm.h:793
bvector_size_type size_type
Definition: bm.h:121
enumerator first() const
Returns enumerator pointing on the first non-zero bit.
Definition: bm.h:1871
enumerator end() const
Returns enumerator pointing on the next bit after the last.
Definition: bm.h:1877
void calc_stat(struct bm::bvector< Alloc >::statistics *st) const noexcept
Calculates bitvector statistics.
Definition: bm.h:3978
Include a standard set of the NCBI C++ Toolkit most basic headers.
std::ofstream out("events_result.xml")
main entry point for tests
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 isnan
Definition: ncbifloat.h:89
#define finite
Define value of finite (Is Finite).
Definition: ncbifloat.h:109
const CMemberId & GetId(void) const
bool IsAttlist(void) const
void WriteMember(CObjectOStream &out, TConstObjectPtr classPtr) const
void CopyMissingMember(CObjectStreamCopier &copier) const
void CopyMember(CObjectStreamCopier &copier) const
TMemberIndex LastIndex(void) const
Definition: memberlist.hpp:82
const string & FindNameEx(TEnumValueType value, bool allowBadValue) const
Definition: enumerated.cpp:163
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
const CStringUTF8 & GetValue(void) const
Get normalized value.
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
const void * TConstObjectPtr
Definition: serialdef.hpp:59
EStringType
String type.
Definition: serialdef.hpp:185
const string & GetName(void) const
Get local name.
@ eFNP_Allow
pass through unchanged, post no error message
Definition: serialdef.hpp:175
@ eSerialVerifyData_Yes
do verify
Definition: serialdef.hpp:111
@ eStringTypeUTF8
UTF8-encoded string.
Definition: serialdef.hpp:187
@ eSerial_AsnText
ASN.1 text.
Definition: serialdef.hpp:73
virtual void BeginBytes(const ByteBlock &block) override
Definition: objostrasn.cpp:868
virtual void CopyString(CObjectIStream &in, EStringType type=eStringTypeVisible) override
Definition: objostrasn.cpp:474
virtual void WriteInt8(Int8 data) override
Definition: objostrasn.cpp:165
char ReplaceVisibleChar(char c, EFixNonPrint fix_method, const CObjectStack *io, const CTempString &str, char subst)
Definition: objistr.cpp:1855
bool m_FastWriteDouble
Definition: objostr.hpp:806
virtual void EndClassMember(void)
Definition: objistr.cpp:1372
virtual void WriteCString(const char *str) override
Definition: objostrasn.cpp:449
void WriteClassMember(const CConstObjectInfoMI &member)
Definition: objostr.cpp:571
EFixNonPrint x_FixCharsMethod(void) const
Definition: objostr.cpp:287
void SetAutoSeparator(bool value)
Set separator auto-output paramater.
virtual void EndChars(const CharBlock &block) override
Definition: objostrasn.cpp:934
CObjectOStreamAsn(CNcbiOstream &out, EFixNonPrint how=eFNP_Default)
Constructor.
Definition: objostrasn.cpp:64
void StartBlock(void)
Definition: objostrasn.cpp:539
#define END_OBJECT_2FRAMES_OF(Stream)
Definition: objstack.hpp:234
virtual void EndContainerElement(void)
Definition: objistr.cpp:1314
virtual void WriteInt4(Int4 data) override
Definition: objostrasn.cpp:155
bool GoodVisibleChar(char c)
virtual void EndClass(void) override
Definition: objostrasn.cpp:674
virtual void WriteChars(const CharBlock &block, const char *chars, size_t length) override
Definition: objostrasn.cpp:902
virtual void CopyStringStore(CObjectIStream &in) override
Definition: objostrasn.cpp:482
void CopyObject(TTypeInfo objectType, CObjectStreamCopier &copier)
virtual void WriteUint4(Uint4 data) override
Definition: objostrasn.cpp:160
static CObjectOStream * OpenObjectOStreamAsn(CNcbiOstream &out, EOwnership deleteOut)
Definition: objostrasn.cpp:58
virtual void WriteOther(TConstObjectPtr object, TTypeInfo typeInfo) override
Definition: objostrasn.cpp:530
#define ThrowError(flag, mess)
Definition: objstack.hpp:113
virtual void EndContainer(void)=0
virtual void BeginClassMember(const CMemberId &id) override
Definition: objostrasn.cpp:679
void EndBlock(void)
Definition: objostrasn.cpp:546
virtual void WriteBytes(const ByteBlock &block, const char *bytes, size_t length) override
Definition: objostrasn.cpp:875
virtual void WriteOtherBegin(TTypeInfo typeInfo) override
Definition: objostrasn.cpp:523
virtual void WriteObjectReference(TObjectIndex index) override
Definition: objostrasn.cpp:511
virtual void EndContainer(void) override
Definition: objostrasn.cpp:568
void DuplicatedMember(const CMemberInfo *memberInfo)
virtual TMemberIndex BeginClassMember(const CClassTypeInfo *classType)=0
bool IsCompressed(void) const
Definition: objstack.cpp:193
#define BEGIN_OBJECT_FRAME2(Type, Arg)
Definition: objstack.hpp:225
virtual void WriteFloat(float data) override
Definition: objostrasn.cpp:310
virtual void EndBytes(const ByteBlock &block) override
Definition: objostrasn.cpp:891
MLIOVIR void WriteContainer(const CContainerTypeInfo *containerType, TConstObjectPtr containerPtr)
Definition: objostr.cpp:810
void SetNotag(bool set=true)
void SetPathHooks(CObjectStack &stk, bool set)
Definition: objcopy.cpp:249
virtual void WriteBool(bool data) override
Definition: objostrasn.cpp:140
virtual void CopyBitString(CObjectIStream &in) override
Definition: objostrasn.cpp:406
void WriteObject(const CConstObjectInfo &object)
Definition: objostr.cpp:566
virtual void WriteString(const string &str, EStringType type=eStringTypeVisible) override
Definition: objostrasn.cpp:459
#define BEGIN_OBJECT_2FRAMES_OF(Stream, Type)
Definition: objstack.hpp:247
void Write(const CConstObjectInfo &object)
Definition: objostr.cpp:593
virtual void BeginContainer(const CContainerTypeInfo *containerType)=0
virtual void WriteSeparator(void) override
Definition: objostrasn.cpp:941
virtual void BeginChoiceVariant(const CChoiceTypeInfo *choiceType, const CMemberId &id) override
Definition: objostrasn.cpp:850
virtual ~CObjectOStreamAsn(void)
Destructor.
Definition: objostrasn.cpp:96
virtual void WriteBitString(const CBitString &obj) override
Definition: objostrasn.cpp:340
#define END_OBJECT_FRAME()
Definition: objstack.hpp:227
#define BEGIN_OBJECT_FRAME_OF2(Stream, Type, Arg)
Definition: objstack.hpp:219
virtual void WriteNullPointer(void) override
Definition: objostrasn.cpp:506
virtual void WriteUint8(Uint8 data) override
Definition: objostrasn.cpp:170
CObjectIStream & In(void) const
size_t TObjectIndex
Definition: objostr.hpp:775
virtual void BeginContainer(const CContainerTypeInfo *containerType) override
Definition: objostrasn.cpp:563
virtual void WriteChar(char data) override
Definition: objostrasn.cpp:148
virtual void WriteDouble(double data) override
Definition: objostrasn.cpp:305
const TFrame & TopFrame(void) const
char x_FixCharsSubst(void) const
Definition: objostr.hpp:790
MLIOVIR void WriteClass(const CClassTypeInfo *objectType, TConstObjectPtr objectPtr)
Definition: objostr.cpp:892
void WriteId(const string &str, bool checkCase=false)
Definition: objostrasn.cpp:489
COStreamBuffer m_Output
Definition: objostr.hpp:796
void SetTopMemberId(const CMemberId &memberId)
void WriteMemberId(const CMemberId &id)
Definition: objostrasn.cpp:646
virtual void CopyEnum(const CEnumeratedTypeValues &values, CObjectIStream &in) override
Definition: objostrasn.cpp:133
MLIOVIR void CopyClassRandom(const CClassTypeInfo *objectType, CObjectStreamCopier &copier)
Definition: objostr.cpp:935
#define BEGIN_OBJECT_2FRAMES_OF2(Stream, Type, Arg)
Definition: objstack.hpp:249
void FlushBuffer(void)
virtual void EndChoice(void) override
Definition: objostrasn.cpp:842
virtual bool BeginContainerElement(TTypeInfo elementType)=0
virtual void BeginChars(const CharBlock &block) override
Definition: objostrasn.cpp:897
void NextElement(void)
Definition: objostrasn.cpp:554
virtual void CopyAnyContentObject(CObjectIStream &in) override
Definition: objostrasn.cpp:333
TTypeInfo m_TypeAlias
Definition: objostr.hpp:808
void SetSeparator(const string sep)
Set separator.
virtual void WriteStringStore(const string &str) override
Definition: objostrasn.cpp:469
virtual void BeginClass(const CClassTypeInfo *classInfo) override
Definition: objostrasn.cpp:669
string GetSeparator(void) const
Get separator.
EFixNonPrint FixNonPrint(EFixNonPrint how)
Definition: objostr.hpp:203
bool m_WriteNamedIntegersByValue
Definition: objostr.hpp:805
MLIOVIR void CopyContainer(const CContainerTypeInfo *containerType, CObjectStreamCopier &copier)
Definition: objostr.cpp:858
virtual void BeginChoice(const CChoiceTypeInfo *choiceType) override
Definition: objostrasn.cpp:834
virtual void EndClass(void)
Definition: objistr.cpp:1368
virtual void BeginClass(const CClassTypeInfo *classInfo)=0
void WriteDouble2(double data, unsigned digits)
Definition: objostrasn.cpp:175
virtual void BeginContainerElement(TTypeInfo elementType) override
Definition: objostrasn.cpp:573
#define END_OBJECT_FRAME_OF(Stream)
Definition: objstack.hpp:201
virtual string GetPosition(void) const override
Get current stream position as string.
Definition: objostrasn.cpp:100
ESerialVerifyData GetVerifyData(void) const
Get output data verification parameter.
virtual void WriteEnum(const CEnumeratedTypeValues &values, TEnumValueType value) override
Definition: objostrasn.cpp:127
virtual void WriteAnyContentObject(const CAnyContentObject &obj) override
Definition: objostrasn.cpp:320
virtual void WriteNull(void) override
Definition: objostrasn.cpp:315
virtual void WriteFileHeader(TTypeInfo type) override
Definition: objostrasn.cpp:105
MLIOVIR void CopyClassSequential(const CClassTypeInfo *objectType, CObjectStreamCopier &copier)
Definition: objostr.cpp:984
@ fIllegalCall
Illegal in a given context function call.
Definition: objostr.hpp:324
@ fInvalidData
Output data is incorrect.
Definition: objostr.hpp:322
@ fNotImplemented
Method is not implemented.
Definition: objostr.hpp:330
@ fUnassigned
Mandatory object member is unassigned Normally this results in throwing CUnassignedMember exception.
Definition: objostr.hpp:333
@ fOverflow
Internal buffer overflow.
Definition: objostr.hpp:320
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
void IncIndentLevel(size_t step=2)
void SetBackLimit(size_t limit)
void PutChar(char c)
size_t GetLine(void) const
void PutString(const char *str, size_t length)
void PutInt8(Int8 v)
Definition: strbuffer.cpp:1001
void PutEol(bool indent=true)
void WrapAt(size_t lineLength, bool keepWord)
void PutUint4(Uint4 v)
Definition: strbuffer.cpp:975
void DecIndentLevel(size_t step=2)
void PutUint8(Uint8 v)
Definition: strbuffer.cpp:1045
bool ZeroIndentLevel(void) const
void PutInt4(Int4 v)
Definition: strbuffer.cpp:950
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
static string SizetToString(size_t value, TNumToStringFlags flags=0, int base=10)
Convert size_t to string.
Definition: ncbistr.cpp:2751
#define NPOS
Definition: ncbistr.hpp:133
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static SIZE_TYPE EvaluateSymbolLength(const CTempString &src)
Check buffer for presence of UTF-8 byte sequence and return length of first symbol.
Definition: ncbistr.cpp:7111
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 SIZE_TYPE DoubleToString_Ecvt(double value, unsigned int precision, char *buf, SIZE_TYPE buf_size, int *dec, int *sign)
Convert double to string with specified precision.
Definition: ncbistr.cpp:2451
const string & GetName(void) const
Get name of this type.
Definition: typeinfo.cpp:249
const CMemberInfo * GetMemberInfo(TMemberIndex index) const
const CVariantInfo * GetVariantInfo(TMemberIndex index) const
TConstObjectPtr GetElementPtr(const CConstIterator &it) const
bool InitIterator(CConstIterator &it, TConstObjectPtr containerPtr) const
bool NextElement(CConstIterator &it) const
TConstObjectPtr GetObjectPointer(TConstObjectPtr object) const
const CItemsInfo & GetMembers(void) const
TTypeInfo GetElementType(void) const
enum ENcbiOwnership EOwnership
Ownership relations between objects.
size_t serialize(const BV &bv, unsigned char *buf, bm::word_t *temp_block=0, unsigned serialization_flags=0)
Saves bitvector into memory.
Definition: bmserial.h:3071
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
Definition of all error codes used in serial libraries (xser.lib, xcser.lib).
char * buf
int i
int len
static void hex(unsigned char c)
Definition: mdb_dump.c:56
unsigned int word_t
Definition: bmconst.h:39
void aligned_free(void *ptr) BMNOEXCEPT
Aligned free.
Definition: bmalloc.h:464
void * aligned_new_malloc(size_t size)
Aligned malloc (unlike classic malloc it throws bad_alloc exception)
Definition: bmalloc.h:436
const unsigned set_block_alloc_size
Definition: bmconst.h:61
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
static const BitmapCharRec *const chars[]
Definition: ncbi_10x20.c:1829
int tolower(Uchar c)
Definition: ncbictype.hpp:72
int isupper(Uchar c)
Definition: ncbictype.hpp:70
std::istream & in(std::istream &in_, double &x_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static const char HEX[]
Definition: objostrasn.cpp:873
#define memmove(a, b, c)
static pcre_uint8 * buffer
Definition: pcretest.c:1051
Definition: type.c:6
#define _ASSERT
void free(voidpf ptr)
voidp malloc(uInt size)
Modified on Sat Apr 13 11:46:17 2024 by modify_doxy.py rev. 669887