NCBI C++ ToolKit
objistr.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef SERIAL___OBJISTR__HPP
2 #define SERIAL___OBJISTR__HPP
3 
4 /* $Id: objistr.hpp 102264 2024-04-12 15:49:00Z ucko $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Eugene Vasilchenko
30 *
31 * File Description:
32 * Base class of object input stream classes.
33 * It reads data from an input stream, parses it, and creates a data object
34 */
35 
36 #include <corelib/ncbistd.hpp>
37 #include <corelib/ncbiobj.hpp>
38 #include <corelib/ncbimempool.hpp>
39 #include <corelib/ncbiutil.hpp>
40 #include <util/strbuffer.hpp>
41 #include <serial/impl/objlist.hpp>
42 #include <serial/objhook.hpp>
44 #include <serial/impl/pathhook.hpp>
45 
46 
47 /** @addtogroup ObjStreamSupport
48  *
49  * @{
50  */
51 
52 
53 struct asnio;
54 
56 
57 class CMemberId;
58 class CItemsInfo;
59 class CItemInfo;
60 class CMemberInfo;
61 class CVariantInfo;
62 class CDelayBuffer;
63 class CByteSource;
64 class CByteSourceReader;
65 
66 class CObjectInfo;
67 class CObjectInfoMI;
68 
69 class CClassTypeInfo;
70 class CChoiceTypeInfo;
71 class CContainerTypeInfo;
73 class CAliasTypeInfo;
74 
75 class CReadObjectHook;
78 class CSkipObjectHook;
81 
82 class CReadObjectInfo;
83 class CReadObjectList;
84 
85 class CPackString;
86 
87 /////////////////////////////////////////////////////////////////////////////
88 ///
89 /// CObjectIStream --
90 ///
91 /// Base class of serial object stream decoders
93 {
94 public:
95  /// Destructor.
96  ///
97  /// Constructors are protected;
98  /// use any one of 'Create' methods to construct the stream
99  virtual ~CObjectIStream(void);
100 
101 //---------------------------------------------------------------------------
102 // Create methods
103  // CObjectIStream will be created on heap, and must be deleted later on
104 
105  /// Create serial object reader and attach it to an input stream.
106  ///
107  /// @param format
108  /// Format of the input data
109  /// @param inStream
110  /// Input stream
111  /// @param deleteInStream
112  /// When TRUE, the input stream will be deleted automatically
113  /// when the reader is deleted
114  /// @return
115  /// Reader (created on heap)
116  /// @deprecated
117  /// Use one with EOwnership enum instead
119  CNcbiIstream& inStream,
120  bool deleteInStream);
121 
122  /// Create serial object reader and attach it to an input stream.
123  ///
124  /// @param format
125  /// Format of the input data
126  /// @param inStream
127  /// Input stream
128  /// @param deleteInStream
129  /// When eTakeOwnership, the input stream will be deleted automatically
130  /// when the reader is deleted
131  /// @return
132  /// Reader (created on heap)
134  CNcbiIstream& inStream,
135  EOwnership deleteInStream = eNoOwnership);
136 
137  /// Create serial object reader and attach it to a file stream.
138  ///
139  /// @param format
140  /// Format of the input data
141  /// @param fileName
142  /// Input file name
143  /// @param openFlags
144  /// File open flags
145  /// @return
146  /// Reader (created on heap)
147  /// @sa ESerialOpenFlags
149  const string& fileName,
150  TSerialOpenFlags openFlags = 0);
151 
152  /// Create serial object reader and attach it to a file stream.
153  ///
154  /// @param fileName
155  /// Input file name
156  /// @param format
157  /// Format of the input data
158  /// @return
159  /// Reader (created on heap)
160  static CObjectIStream* Open(const string& fileName,
162 
163  /// Create serial object reader.
164  /// The reader must be attached to a data source later on.
165  ///
166  /// @param format
167  /// Format of the input data
168  /// @return
169  /// Reader (created on heap)
170  static CObjectIStream* Create(ESerialDataFormat format);
171 
172  /// Create serial object reader and attach it to a data source
173  ///
174  /// @param format
175  /// Format of the input data
176  /// @param source
177  /// Data source
178  /// @return
179  /// Reader (created on heap)
180  /// @sa CByteSource
181  static CObjectIStream* Create(ESerialDataFormat format,
183 
184  /// Create serial object reader and attach it to a data source
185  ///
186  /// @param format
187  /// Format of the input data
188  /// @param reader
189  /// Data source
190  /// @return
191  /// Reader (created on heap)
192  /// @sa CByteSourceReader
193  static CObjectIStream* Create(ESerialDataFormat format,
194  CByteSourceReader& reader);
195 
196  /// Create serial object reader and attach it to a data source
197  ///
198  /// @param format
199  /// Format of the input data
200  /// @param buffer
201  /// Data source memory buffer
202  /// @param size
203  /// Memory buffer size
204  /// @return
205  /// Reader (created on heap)
206  static CObjectIStream* CreateFromBuffer(ESerialDataFormat format,
207  const char* buffer, size_t size);
208  /// Get data format
209  ///
210  /// @return
211  /// Input data format
213 
214 //---------------------------------------------------------------------------
215 // Open methods
216 
217  /// Attach reader to a data source
218  ///
219  /// @param reader
220  /// Data source
221  void Open(CByteSourceReader& reader);
222 
223  /// Attach reader to a data source
224  ///
225  /// @param source
226  /// Data source
227  void Open(CByteSource& source);
228 
229  /// Attach reader to an input stream
230  ///
231  /// @param inStream
232  /// Input stream
233  /// @param deleteInStream
234  /// When TRUE, the input stream will be deleted automatically
235  /// when the reader is deleted
236  /// @deprecated
237  /// Use one with EOwnership enum instead
238  void NCBI_DEPRECATED Open(CNcbiIstream& inStream, bool deleteInStream);
239 
240  /// Attach reader to an input stream
241  ///
242  /// @param inStream
243  /// Input stream
244  /// @param deleteInStream
245  /// When eTakeOwnership, the input stream will be deleted automatically
246  /// when the reader is deleted
247  void Open(CNcbiIstream& inStream, EOwnership deleteInStream = eNoOwnership);
248 
249  /// Attach reader to a data source
250  ///
251  /// @param buffer
252  /// Data source memory buffer
253  /// @param size
254  /// Memory buffer size
255  void OpenFromBuffer(const char* buffer, size_t size);
256 
257  /// Detach reader from a data source
258  void Close(void);
259 
260 //---------------------------------------------------------------------------
261 // Data verification setup
262 
263  /// Set up input data verification for this particular stream
264  ///
265  /// @param verify
266  /// Data verification parameter
268 
269  /// Get input data verification parameter.
270  /// When verification is enabled, stream verifies data on input
271  /// and throws CSerialException with eFormatError err.code
272  ///
273  /// @return
274  /// Data verification parameter
276 
277  /// Set up default input data verification for streams
278  /// created by the current thread
279  ///
280  /// @param verify
281  /// Data verification parameter
282  static void SetVerifyDataThread(ESerialVerifyData verify);
283 
284  /// Set up default input data verification for streams
285  /// created by the current process
286  ///
287  /// @param verify
288  /// Data verification parameter
289  static void SetVerifyDataGlobal(ESerialVerifyData verify);
290 
291  /// Set up skipping unknown members for this particular stream
292  ///
293  /// @param skip
294  /// Skip unknown members parameter
296 
297  /// Get skip unknown members parameter
298  ///
299  /// @return
300  /// Skip unknown members parameter
302 
303  /// Set up default skipping unknown members for streams
304  /// created by the current thread
305  ///
306  /// @param skip
307  /// Skip unknown members parameter
308  static void SetSkipUnknownThread(ESerialSkipUnknown skip);
309 
310  /// Set up default skipping unknown members for streams
311  /// created by the current process
312  ///
313  /// @param skip
314  /// Skip unknown members parameter
315  static void SetSkipUnknownGlobal(ESerialSkipUnknown skip);
316 
317  /// Set up skipping unknown choice variants for
318  /// this particular stream
319  ///
320  /// @param skip
321  /// Skip unknown choice variants parameter
322  /// @note
323  /// Skipping unknown variants can result in invalid object - with unset choice
325 
326  /// Get skip unknown choice variants parameter
327  ///
328  /// @return
329  /// Skip unknown choice variants parameter
331 
332  /// Set up default skipping unknown choice variants for streams
333  /// created by the current thread
334  ///
335  /// @param skip
336  /// Skip unknown choice variants parameter
337  static void SetSkipUnknownVariantsThread(ESerialSkipUnknown skip);
338 
339  /// Set up default skipping unknown choice variants for streams
340  /// created by the current process
341  ///
342  /// @param skip
343  /// Skip unknown choice variants parameter
344  static void SetSkipUnknownVariantsGlobal(ESerialSkipUnknown skip);
345 
346  /// Simple check if it's allowed to skip unknown members
348  /// Simple check if it's allowed to skip unknown variants
350  /// Update skip unknown members option to non-default value
351  ESerialSkipUnknown UpdateSkipUnknownMembers(void);
352  /// Update skip unknown variants option to non-default value
353  ESerialSkipUnknown UpdateSkipUnknownVariants(void);
354 
356  {
357  EFixNonPrint tmp = m_FixMethod;
358  m_FixMethod = how == eFNP_Default ? x_GetFixCharsMethodDefault() : how;
359  return tmp;
360  }
361  void FixNonPrintSubst(char subst) {
362  m_NonPrintSubst = subst;
363  }
364 
365 //---------------------------------------------------------------------------
366 // Stream state
367 
368  /// Fail flags
369  enum EFailFlags {
370  /// No error
371  fNoError = 0, eNoError = fNoError,
372  /// End of file in the middle of reading an object
373  fEOF = 1 << 0, eEOF = fEOF,
374  /// An unknown error when reading the input file
375  fReadError = 1 << 1, eReadError = fReadError,
376  /// Input file formatting does not conform with specification
377  fFormatError = 1 << 2, eFormatError = fFormatError,
378  /// Data read is beyond the allowed limits
379  fOverflow = 1 << 3, eOverflow = fOverflow,
380  /// Input data is incorrect (e.g. invalid enum)
381  fInvalidData = 1 << 4, eInvalidData = fInvalidData,
382  /// Illegal in a given context function call
383  fIllegalCall = 1 << 5, eIllegalCall = fIllegalCall,
384  /// Internal error, the real reason is unclear
385  fFail = 1 << 6, eFail = fFail,
386  /// No input file
387  fNotOpen = 1 << 7, eNotOpen = fNotOpen,
388  /// Method is not implemented
389  fNotImplemented= 1 << 8, eNotImplemented = fNotImplemented,
390  /// Mandatory value was missing in the input.
391  /// This is the variant of fFormatError.
392  /// Normally stream throws an exception, but client can request
393  /// not to throw one; in this case this flag is set instead.
394  fMissingValue = 1 << 9, eMissingValue= fMissingValue,
395  /// Unknown value was present in the input.
396  /// This is the variant of fFormatError.
397  /// Normally stream throws an exception, but client can request
398  /// not to throw one; in this case this flag is set instead.
399  fUnknownValue = 1 << 10, eUnknownValue= fUnknownValue,
400  /// Input value is 'null'
401  fNullValue = 1 << 11, eNullValue= fNullValue
402  };
403  typedef int TFailFlags;
404 
405  /// Check if any of fail flags is set
406  ///
407  /// @return
408  /// TRUE or FALSE
409  bool fail(void) const;
410 
411  /// Get fail flags
412  ///
413  /// @return
414  /// Fail flags
416 
417  /// Set fail flags
418  ///
419  /// @param flags
420  /// Fail flags
421  /// @param message
422  /// Optional text message
423  TFailFlags SetFailFlags(TFailFlags flags, const char* message=0);
424 
425  /// Reset fail flags
426  ///
427  /// @param flags
428  /// Flags to reset
430 
431  /// Check fail flags and also the state of input data source
432  ///
433  /// @return
434  /// TRUE is there is no errors
435  bool InGoodState(void);
436 
437  /// Check if there is still some meaningful data that can be read;
438  /// in text streams this function will skip white spaces and comments
439  ///
440  /// @return
441  /// TRUE if there is no more data
442  virtual bool EndOfData(void);
443 
444 
445  /// Set cancellation check callback.
446  /// The stream will periodically check for a cancellation request and
447  /// throw an exception when requested.
448  void SetCanceledCallback(const ICanceled* callback);
449 
450  /// @deprecated
451  /// Use GetStreamPos() instead
452  /// @sa GetStreamPos()
453  NCBI_DEPRECATED CNcbiStreampos GetStreamOffset(void) const;
454 
455  /// Get the current stream position
456  ///
457  /// NOTE:
458  /// This is not the same as istream::tellg();
459  /// rather, this is an offset in the current input
460  ///
461  /// @return
462  /// stream position
463  CNcbiStreampos GetStreamPos(void) const;
464 
465  /// @deprecated
466  /// Use SetStreamPos() instead
467  /// @sa SetStreamPos()
468  NCBI_DEPRECATED void SetStreamOffset(CNcbiStreampos pos);
469 
470  /// Set the current read position in underlying input stream
471  /// This is the same as istream::seekg()
472  ///
473  /// @param pos
474  /// stream position
475  /// @note
476  /// Potentially, this is a dangerous method.
477  /// Serial stream is a state machine, which should be set correctly.
478  /// Setting stream position resets the state, which is enough
479  /// in many practically interesting scenarios - for example,
480  /// when reading whole objects in client app
481  void SetStreamPos(CNcbiStreampos pos);
482 
483  /// Get current stack trace as string.
484  /// Useful for diagnostic and information messages.
485  ///
486  /// @return
487  /// string
488  virtual string GetStackTrace(void) const override;
489 
490  /// Get current stream position as string.
491  /// Useful for diagnostic and information messages.
492  ///
493  /// @return
494  /// string
495  virtual string GetPosition(void) const override;
496 
497  /// Get current stream location as tuple (positiontype:string, size_t).
498  /// Useful for customized diagnostic and information messages.
499  /// The meaning of positiontype depends on the implementation and coincides
500  /// with the prefix of the string returned by GetPosition().
501  ///
502  virtual void Location(string&, size_t&) const;
503 
504 //---------------------------------------------------------------------------
505 // Local read hooks
506  void SetPathReadObjectHook( const string& path, CReadObjectHook* hook);
507  void SetPathSkipObjectHook( const string& path, CSkipObjectHook* hook);
508  void SetPathReadMemberHook( const string& path, CReadClassMemberHook* hook);
509  void SetPathSkipMemberHook( const string& path, CSkipClassMemberHook* hook);
510  void SetPathReadVariantHook(const string& path, CReadChoiceVariantHook* hook);
511  void SetPathSkipVariantHook(const string& path, CSkipChoiceVariantHook* hook);
512 
513  void SetMonitorType(TTypeInfo type);
514  void AddMonitorType(TTypeInfo type);
515  void ResetMonitorType(void);
516 
517  /// DelayBuffer parsing policy
519  /// Parse only if local hook are present
521  /// Parse always
523  /// Never parse
524  eDelayBufferPolicyNeverParse
525  };
526  void SetDelayBufferParsingPolicy(EDelayBufferParsing policy);
527  EDelayBufferParsing GetDelayBufferParsingPolicy(void) const;
528  bool ShouldParseDelayBuffer(void) const;
529 
530 //---------------------------------------------------------------------------
531 // User interface
532 
533  /// Identify the type of data in the stream.
534  ///
535  /// Method matches each of the supplied known types against
536  /// the stream data. Ideally, only ony type matches.
537  /// Shorter lookup depth can result in mutiple matches;
538  /// longer depth does not necessarily improve the result.
539  ///
540  /// @param known_types
541  /// Set of known types.
542  /// @param max_length
543  /// Maximum depth of the lookup.
544  /// @param max_bytes
545  /// Maximum number of input bytes to use for the lookup.
546  /// @return
547  /// Set of matching types.
548  virtual set<TTypeInfo> GuessDataType(const set<TTypeInfo>& known_types,
549  size_t max_length = 16,
550  size_t max_bytes = 1024*1024);
551  // root reader
552 
553  /// Read object of know type
554  void Read(const CObjectInfo& object);
555  /// Read object of know type
556  void Read(TObjectPtr object, TTypeInfo type);
557  /// Read object of know type
559  /// Read object of know type
561  /// Skip object of know type
562  void Skip(const CObjectTypeInfo& type);
563  /// Skip object of know type
564  void Skip(TTypeInfo type);
565 
566  /// Read file header
567  ///
568  /// Text data files have data type name in the very beginning of a file.
569  /// By inspecting the header, we know what to expect next.
570  /// Binary ASN.1 input files have no such information; so, the data type
571  /// should be known in advance.
572  ///
573  /// @return
574  /// Data type name
575  virtual string ReadFileHeader(void);
576 
577  /// Read file header and compare the type name with the expected one
578  ///
579  /// @param typeInfo
580  /// Expected data type
581  void SkipFileHeader(TTypeInfo typeInfo);
582 
584  eNoFileHeader
585  };
586 
587  /// Read object of know type when the file header is already read
588  void Read(const CObjectInfo& object, ENoFileHeader noFileHeader);
589 
590  /// Read object of know type when the file header is already read
591  void Read(TObjectPtr object, TTypeInfo type, ENoFileHeader noFileHeader);
592 
593  /// Skip object of know type when the file header is already read
594  void Skip(TTypeInfo type, ENoFileHeader noFileHeader);
595 
596  /// Read child object
597  ///
598  /// Newly created child object will be instantiated as a member
599  /// of its parent object.
600  void ReadObject(const CObjectInfo& object);
601 
602  /// Read child object
603  ///
604  /// Newly created child object will be instantiated as a member
605  /// of its parent object.
606  void ReadObject(TObjectPtr object, TTypeInfo typeInfo);
607 
608  /// Skip child object
609  void SkipObject(const CObjectTypeInfo& objectType);
610  /// Skip child object
611  void SkipObject(TTypeInfo typeInfo);
612 
613  /// Temporary reader
614  ///
615  /// Method instantiates the child object in the local temporary variable only,
616  /// the corresponding data member in the parent object is set to an appropriate null
617  /// representation for that data type.
618  /// An attempt to reference this child object after exiting the scope where it was
619  /// created generates an error.
620  void ReadSeparateObject(const CObjectInfo& object);
621 
622  // member
623  void ReadClassMember(const CObjectInfoMI& member);
624 
625  // variant
626  void ReadChoiceVariant(const CObjectInfoCV& object);
627 
628  /// Discard the object, which has been just read.
629  ///
630  /// Call this function inside hooks to discard the object,
631  /// which has been just read.
632  /// Such an object was created before the hook function was called,
633  /// and can be deleted only after the hook processing completes.
634  /// The option lets save memory when processing large amount of data.
635  /// Please keep in mind though, that the 'root' object constructed by
636  /// such read operation will be invalid.
637  void SetDiscardCurrObject(bool discard=true)
638  {m_DiscardCurrObject = discard;}
639  bool GetDiscardCurrObject(void) const
640  {return m_DiscardCurrObject;}
641 
642  /// Peek next data type name in XML stream
643  virtual string PeekNextTypeName(void);
644 //---------------------------------------------------------------------------
645 // Standard type readers
646  // bool
647  void ReadStd(bool& data);
648  void SkipStd(const bool &);
649 
650  // char
651  void ReadStd(char& data);
652  void SkipStd(const char& );
653 
654  // integer numbers
655  void ReadStd(signed char& data);
656  void ReadStd(unsigned char& data);
657  void SkipStd(const signed char& );
658  void SkipStd(const unsigned char& );
659  void ReadStd(short& data);
660  void ReadStd(unsigned short& data);
661  void SkipStd(const short& );
662  void SkipStd(const unsigned short& );
663  void ReadStd(int& data);
664  void ReadStd(unsigned& data);
665  void SkipStd(const int& );
666  void SkipStd(const unsigned& );
667 #ifndef NCBI_INT8_IS_LONG
668  void ReadStd(long& data);
669  void ReadStd(unsigned long& data);
670  void SkipStd(const long& );
671  void SkipStd(const unsigned long& );
672 #endif
673  void ReadStd(Int8& data);
675  void SkipStd(const Int8& );
676  void SkipStd(const Uint8& );
677 
678  // float numbers
679  void ReadStd(float& data);
680  void ReadStd(double& data);
681  void SkipStd(const float& );
682  void SkipStd(const double& );
683 #if SIZEOF_LONG_DOUBLE != 0
684  virtual void ReadStd(long double& data);
685  virtual void SkipStd(const long double& );
686 #endif
687 
688  // string
689  void ReadStd(string& data);
690  void SkipStd(const string& );
691 
692  // C string
693  void ReadStd(char* & data);
694  void ReadStd(const char* & data);
695  void SkipStd(char* const& );
696  void SkipStd(const char* const& );
697 
699  void SkipStd(const CBitString& data);
700 
701  // primitive readers
702  // bool
703  virtual bool ReadBool(void) = 0;
704  virtual void SkipBool(void) = 0;
705 
706  // char
707  virtual char ReadChar(void) = 0;
708  virtual void SkipChar(void) = 0;
709 
710  // integer numbers
711  virtual Int1 ReadInt1(void);
712  virtual Uint1 ReadUint1(void);
713  virtual Int2 ReadInt2(void);
714  virtual Uint2 ReadUint2(void);
715  virtual Int4 ReadInt4(void);
716  virtual Uint4 ReadUint4(void);
717  virtual Int8 ReadInt8(void) = 0;
718  virtual Uint8 ReadUint8(void) = 0;
719 
720  virtual void SkipInt1(void);
721  virtual void SkipUint1(void);
722  virtual void SkipInt2(void);
723  virtual void SkipUint2(void);
724  virtual void SkipInt4(void);
725  virtual void SkipUint4(void);
726  virtual void SkipInt8(void);
727  virtual void SkipUint8(void);
728 
729  virtual void SkipSNumber(void) = 0;
730  virtual void SkipUNumber(void) = 0;
731 
732  // float numbers
733  virtual float ReadFloat(void);
734  virtual double ReadDouble(void) = 0;
735  virtual void SkipFloat(void);
736  virtual void SkipDouble(void);
737 #if SIZEOF_LONG_DOUBLE != 0
738  virtual long double ReadLDouble(void);
739  virtual void SkipLDouble(void);
740 #endif
741  virtual void SkipFNumber(void) = 0;
742 
743  // string
744  virtual void ReadString(string& s,
746  virtual void ReadPackedString(string& s,
747  CPackString& pack_string,
750 
751  // StringStore
752  virtual void ReadStringStore(string& s);
753  virtual void SkipStringStore(void);
754 
755  // C string
756  virtual char* ReadCString(void);
757  virtual void SkipCString(void);
758 
759  // null
760  virtual void ReadNull(void) = 0;
761  virtual void SkipNull(void) = 0;
762 
763  // any content object
764  virtual void ReadAnyContentObject(CAnyContentObject& obj) = 0;
765  virtual void SkipAnyContentObject(void) = 0;
766  virtual void SkipAnyContentVariant(void);
767 
768  virtual void ReadBitString(CBitString& obj) = 0;
769  virtual void SkipBitString(void) = 0;
770  void ReadCompressedBitString(CBitString& data);
771 
772  // octet string
773  virtual void SkipByteBlock(void) = 0;
774 
775  // reads type info
776  virtual pair<TObjectPtr, TTypeInfo> ReadPointer(TTypeInfo declaredType);
781  eOtherPointer
782  };
783 
784  virtual void SkipPointer(TTypeInfo declaredType);
785 
786  template<class TKey, class TStorage> void ReadStd(CStrictId<TKey, TStorage>& data)
787  {
788  ReadStd(data.Set());
789  }
790 
791  template<class TKey, class TStorage> void SkipStd
793  {
794  SkipStd(data.Get());
795  }
796 
797 #ifdef NCBI_STRICT_GI
798  virtual void ReadGi(TGi& obj);
799  virtual void SkipGi(void);
800 #endif
801 
802 //---------------------------------------------------------------------------
803 // Internals
804 
805  // memory pool to use to create new objects when reading data
806  void SetMemoryPool(CObjectMemoryPool* memory_pool)
807  {
808  m_MemoryPool = memory_pool;
809  }
811  {
812  return m_MemoryPool;
813  }
814  // create and set new memory pool
815  void UseMemoryPool(void);
816 
817  // internal reader
818  void ReadExternalObject(TObjectPtr object, TTypeInfo typeInfo);
819  void SkipExternalObject(TTypeInfo typeInfo);
820 
821  CObjectInfo ReadObject(void);
822  virtual void EndOfRead(void);
823 
824  // try to read enum value name, "" if none
825  virtual TEnumValueType ReadEnum(const CEnumeratedTypeValues& values) = 0;
826 
827  void ResetLocalHooks(void);
828  bool DetectLoops(void) const;
829  void HandleEOF(CEofException&);
830 
831  void ThrowError1(const CDiagCompileInfo& diag_info,
832  TFailFlags fail, const char* message);
833  void ThrowError1(const CDiagCompileInfo& diag_info,
834  TFailFlags fail, const string& message);
835  // report unended block
836  void Unended(const string& msg);
837  // report unended object stack frame
838  virtual void UnendedFrame(void) override;
839  // report class member errors
840  void DuplicatedMember(const CMemberInfo* memberInfo);
841  bool ExpectedMember(const CMemberInfo* memberInfo);
842 
843  // check if m_Input has any more data to read
844  // (ANY data, including white spaces and comments)
845  bool HaveMoreData(void);
846 
847  enum EFlags {
848  fFlagNone = 0,
849  eFlagNone = fFlagNone,
850  fFlagAllowNonAsciiChars = 1 << 0,
851  eFlagAllowNonAsciiChars = fFlagAllowNonAsciiChars,
852  fFlagEnforcedStdXml = 1 << 1,
853  eFlagEnforcedStdXml = fFlagEnforcedStdXml
854  };
855  typedef int TFlags;
856  TFlags GetFlags(void) const;
859 
861  {
862  public:
864  ~ByteBlock(void);
865 
866  void End(void);
867 
868  CObjectIStream& GetStream(void) const;
869 
870  size_t Read(void* dst, size_t length, bool forceLength = false);
871 
872  bool KnownLength(void) const;
873  size_t GetExpectedLength(void) const;
874 
875  void SetLength(size_t length);
876  void EndOfBlock(void);
877 
878  private:
881  bool m_Ended;
882  size_t m_Length;
883 
884  friend class CObjectIStream;
885  };
887  {
888  public:
890  ~CharBlock(void);
891 
892  void End(void);
893 
894  CObjectIStream& GetStream(void) const;
895 
896  size_t Read(char* dst, size_t length, bool forceLength = false);
897 
898  bool KnownLength(void) const;
899  size_t GetExpectedLength(void) const;
900 
901  void SetLength(size_t length);
902  void EndOfBlock(void);
903 
904  private:
907  bool m_Ended;
908  size_t m_Length;
909 
910  friend class CObjectIStream;
911  };
912 
913 
914 #if HAVE_NCBI_C
915  // ASN.1 interface
916  class AsnIo
917  {
918  public:
919  AsnIo(CObjectIStream& in, const string& rootTypeName);
920  ~AsnIo(void);
921 
922  void End(void);
923 
924  CObjectIStream& GetStream(void) const;
925 
926  size_t Read(char* data, size_t length);
927 
928  operator asnio*(void);
929  asnio* operator->(void);
930  const string& GetRootTypeName(void) const;
931 
932  private:
934  bool m_Ended;
936  asnio* m_AsnIo;
937 
938  public:
939  size_t m_Count;
940  };
941  friend class AsnIo;
942 public:
943 #endif
944 
945 //---------------------------------------------------------------------------
946 // mid level I/O
947  // named type
948  MLIOVIR void ReadNamedType(TTypeInfo namedTypeInfo,
949  TTypeInfo typeInfo, TObjectPtr object);
950  MLIOVIR void SkipNamedType(TTypeInfo namedTypeInfo,
951  TTypeInfo typeInfo);
952 
953  // container
954  MLIOVIR void ReadContainer(const CContainerTypeInfo* containerType,
955  TObjectPtr containerPtr);
956  MLIOVIR void SkipContainer(const CContainerTypeInfo* containerType);
957 
958  // class
959  MLIOVIR void ReadClassSequential(const CClassTypeInfo* classType,
960  TObjectPtr classPtr);
961  MLIOVIR void ReadClassRandom(const CClassTypeInfo* classType,
962  TObjectPtr classPtr);
963  MLIOVIR void SkipClassSequential(const CClassTypeInfo* classType);
964  MLIOVIR void SkipClassRandom(const CClassTypeInfo* classType);
965 
966  // choice
967  MLIOVIR void ReadChoiceSimple(const CChoiceTypeInfo* choiceType,
968  TObjectPtr choicePtr);
969  MLIOVIR void SkipChoiceSimple(const CChoiceTypeInfo* choiceType);
970 
971  // alias
972  MLIOVIR void ReadAlias(const CAliasTypeInfo* aliasType,
973  TObjectPtr aliasPtr);
974  MLIOVIR void SkipAlias(const CAliasTypeInfo* aliasType);
975 
976 //---------------------------------------------------------------------------
977 // low level I/O
978  // named type (alias)
979  virtual void BeginNamedType(TTypeInfo namedTypeInfo);
980  virtual void EndNamedType(void);
981 
982  // container
983  virtual void BeginContainer(const CContainerTypeInfo* containerType) = 0;
984  virtual void EndContainer(void) = 0;
985  virtual bool BeginContainerElement(TTypeInfo elementType) = 0;
986  virtual void EndContainerElement(void);
987 
988  // class
989  virtual void BeginClass(const CClassTypeInfo* classInfo) = 0;
990  virtual void EndClass(void);
991 
992  virtual TMemberIndex BeginClassMember(const CClassTypeInfo* classType) = 0;
993  virtual TMemberIndex BeginClassMember(const CClassTypeInfo* classType,
994  TMemberIndex pos) = 0;
995  virtual void EndClassMember(void);
996  virtual void UndoClassMember(void) {}
997 
998  // choice
999  virtual void BeginChoice(const CChoiceTypeInfo* choiceType);
1000  virtual void EndChoice(void);
1001  virtual TMemberIndex BeginChoiceVariant(const CChoiceTypeInfo* choiceType) = 0;
1002  virtual void EndChoiceVariant(void);
1003 
1004  // byte block
1005  virtual void BeginBytes(ByteBlock& block) = 0;
1006  virtual size_t ReadBytes(ByteBlock& block, char* buffer, size_t count) = 0;
1007  virtual void EndBytes(const ByteBlock& block);
1008 
1009  // char block
1010  virtual void BeginChars(CharBlock& block) = 0;
1011  virtual size_t ReadChars(CharBlock& block, char* buffer, size_t count) = 0;
1012  virtual void EndChars(const CharBlock& block);
1013 
1014  virtual void StartDelayBuffer(void);
1015  virtual CRef<CByteSource> EndDelayBuffer(void);
1016  void EndDelayBuffer(CDelayBuffer& buffer,
1017  const CItemInfo* itemInfo, TObjectPtr objectPtr);
1018 
1019  TObjectPtr GetParentObjectPtr(TTypeInfo type,
1020  size_t max_depth = 1,
1021  size_t min_depth = 1) const;
1022 
1023 protected:
1025  CObjectIStream(CNcbiIstream& in, bool deleteIn = false);
1026  // reset state machine
1027  virtual void ResetState(void) override;
1028 
1029  typedef size_t TObjectIndex;
1030  // low level readers
1031  pair<TObjectPtr, TTypeInfo> ReadObjectInfo(void);
1032  virtual EPointerType ReadPointerType(void) = 0;
1033  virtual TObjectIndex ReadObjectPointer(void) = 0;
1034  virtual string ReadOtherPointer(void) = 0;
1035  virtual void ReadOtherPointerEnd(void);
1036 
1037  void RegisterObject(TTypeInfo typeInfo);
1038  void RegisterObject(TObjectPtr object, TTypeInfo typeInfo);
1039  const CReadObjectInfo& GetRegisteredObject(TObjectIndex index);
1040  virtual void x_SetPathHooks(bool set) override;
1041  bool x_HavePathHooks() const;
1042  EFixNonPrint x_GetFixCharsMethodDefault(void) const;
1043  EFixNonPrint x_FixCharsMethod(void) const;
1044  char x_FixCharsSubst(void) const {
1045  return m_NonPrintSubst;
1046  }
1047 
1053 
1054 private:
1055  static CObjectIStream* CreateObjectIStreamAsn(void);
1056  static CObjectIStream* CreateObjectIStreamAsnBinary(void);
1057  static CObjectIStream* CreateObjectIStreamXml(void);
1058  static CObjectIStream* CreateObjectIStreamJson(void);
1059 
1060  static CRef<CByteSource> GetSource(ESerialDataFormat format,
1061  const string& fileName,
1062  TSerialOpenFlags openFlags = 0);
1063  static CRef<CByteSource> GetSource(CNcbiIstream& inStream,
1064  bool deleteInStream = false);
1065 
1066  static ESerialVerifyData x_GetVerifyDataDefault(void);
1067  static ESerialSkipUnknown x_GetSkipUnknownDefault(void);
1068  static ESerialSkipUnknown x_GetSkipUnknownVariantsDefault(void);
1069 
1071  EFixNonPrint m_FixMethod; // method of fixing wrong (eg, non-printable) chars
1076 
1085 
1087 
1089  vector<TTypeInfo> m_ReqMonitorType;
1090 
1091 public:
1093  eReadAsNormal = 0,
1094  eReadAsDefault = 1,
1095  eReadAsNil = 2,
1096  eReadAsBigInt = 4
1097  };
1098 private:
1102 
1104  {
1105  m_SpecialCaseUsed = eReadAsNormal;
1106  m_MemberDefault = def;
1107  if (def) {
1108  m_SpecialCaseToExpect = m_SpecialCaseToExpect | (int)eReadAsDefault;
1109  }
1110  }
1112  {
1113  m_SpecialCaseUsed = eReadAsNormal;
1114  m_MemberDefault = nullptr;
1115  m_SpecialCaseToExpect = eReadAsNormal;
1116  }
1118  {
1119  m_SpecialCaseUsed = eReadAsNormal;
1120  m_SpecialCaseToExpect = m_SpecialCaseToExpect | (int)eReadAsNil;
1121  }
1123  {
1124  m_SpecialCaseUsed = eReadAsNormal;
1125  m_SpecialCaseToExpect = m_SpecialCaseToExpect & ~((int)eReadAsNil);
1126  }
1127 public:
1128  int ExpectSpecialCase(void) const
1129  {
1130  return m_SpecialCaseToExpect;
1131  }
1133  {
1134  return m_MemberDefault;
1135  }
1137  {
1138  m_SpecialCaseUsed = used;
1139  }
1141  {
1142  return m_SpecialCaseUsed;
1143  }
1144 
1145  // read hooks
1152 
1153  friend class CObjectOStream;
1154  friend class CObjectStreamCopier;
1155  friend class CMemberInfoFunctions;
1156  friend class CClassTypeInfo;
1157  friend class CAutoPointerTypeInfo;
1158 };
1159 
1160 inline
1161 bool GoodVisibleChar(char c);
1162 
1163 #define SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING 0
1164 #define SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_WRITING 0
1166 char ReplaceVisibleChar(char c, EFixNonPrint fix_method,
1167  const CObjectStack* io, const CTempString& str, char subst);
1168 
1169 
1170 /// Guard class for CObjectIStream::StartDelayBuffer/EndDelayBuffer
1171 ///
1172 /// CObjectIStream::StartDelayBuffer() should be followed by
1173 /// CObjectIStream::EndDelayBuffer() call. If it's not called we have a delay
1174 /// buffer leak. This class works as an guard (or auto pointer) to avoid call
1175 /// leaks.
1177 {
1178 public:
1179  /// Construct empty guard instance
1180  ///
1182  /// Construct instance on a given CObjectIStream object.
1183  /// Call istr.StartDelayBuffer()
1184  ///
1185  /// @param istr
1186  /// Guard protected instance
1188 
1190 
1191 
1192  /// Start deley buffer collection on a given CObjectIStream object.
1193  /// Call istr.StartDelayBuffer()
1194  ///
1195  /// @param istr
1196  /// Guard protected instance
1198 
1199  /// Redirect call to protected CObjectIStream
1200  /// After this call guarding is finished.
1202 
1203  /// Redirect call to protected CObjectIStream
1204  /// After this call guarding is finished.
1206  const CItemInfo* itemInfo,
1207  TObjectPtr objectPtr);
1208 
1209 private:
1212 private:
1214 };
1215 
1216 
1217 /* @} */
1218 
1219 
1220 #include <serial/impl/objistr.inl>
1221 
1223 
1224 #endif /* SERIAL___OBJISTR__HPP */
CNcbiIstream & ReadContainer(CNcbiIstream &is, TCont &cont)
Read a container from a stream.
Definition: cgi_serial.hpp:234
Serializable object that stores any combination of parsable data.
Definition: serialbase.hpp:264
CDelayBuffer.
Definition: delaybuf.hpp:58
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
Definition: ncbidiag.hpp:65
CObjectIStream –.
Definition: objistr.hpp:93
CObjectInfoCV –.
Definition: objectiter.hpp:588
CObjectInfoMI –.
Definition: objectiter.hpp:432
CObjectInfo –.
Definition: objectinfo.hpp:597
CObjectOStream –.
Definition: objostr.hpp:83
CObjectStreamCopier –.
Definition: objcopy.hpp:71
CObjectTypeInfo –.
Definition: objectinfo.hpp:94
Read hook for a choice variant (CHOICE)
Definition: objhook.hpp:117
Read hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:78
Read hook for a standalone object.
Definition: objhook.hpp:59
Skip hook for a choice variant (CHOICE)
Definition: objhook.hpp:239
Skip hook for data member of a containing object (eg, SEQUENCE)
Definition: objhook.hpp:223
Skip hook for a standalone object.
Definition: objhook.hpp:205
Guard class for CObjectIStream::StartDelayBuffer/EndDelayBuffer.
Definition: objistr.hpp:1177
Template class for strict ID types.
Definition: ncbimisc.hpp:893
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
Interface for testing cancellation request in a long lasting operation.
Definition: icanceled.hpp:51
Definition: set.hpp:45
Include a standard set of the NCBI C++ Toolkit most basic headers.
static uch flags
static const char * str(char *buf, int n)
Definition: stats.c:84
static char tmp[3200]
Definition: utf8.c:42
char data[12]
Definition: iconv.c:80
@ eNoOwnership
No ownership is assumed.
Definition: ncbi_types.h:135
ESerialSkipUnknown
Skip unknown members parameters.
Definition: serialdef.hpp:118
EFixNonPrint
How to process non-printing character in the ASN VisibleString.
Definition: serialdef.hpp:173
int TSerialOpenFlags
Definition: serialdef.hpp:135
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
ESerialVerifyData
Data verification parameters.
Definition: serialdef.hpp:107
CNcbiIstream & ReadObject(CNcbiIstream &str, TObjectPtr ptr, TTypeInfo info)
const void * TConstObjectPtr
Definition: serialdef.hpp:59
void Read(CObjectIStream &in, TObjectPtr object, const CTypeRef &type)
Definition: serial.cpp:60
EStringType
String type.
Definition: serialdef.hpp:185
ESerialDataFormat
Data file format.
Definition: serialdef.hpp:71
@ eFNP_Default
Definition: serialdef.hpp:181
@ eStringTypeVisible
VisibleString (in ASN.1 sense)
Definition: serialdef.hpp:186
CIStreamBuffer m_Input
Definition: objistr.hpp:1048
ESerialDataFormat GetDataFormat(void) const
Get data format.
vector< TTypeInfo > m_ReqMonitorType
Definition: objistr.hpp:1089
CRef< CByteSource > EndDelayBuffer(void)
Redirect call to protected CObjectIStream After this call guarding is finished.
virtual void ReadString(string &s, EStringType type=eStringTypeVisible)=0
virtual EPointerType ReadPointerType(void)=0
CStreamPathHook< CMemberInfo *, CSkipClassMemberHook * > m_PathSkipMemberHooks
Definition: objistr.hpp:1082
void ReadStd(long &data)
TFlags SetFlags(TFlags flags)
virtual bool ReadBool(void)=0
ESerialVerifyData GetVerifyData(void) const
Get input data verification parameter.
EFailFlags
Fail flags.
Definition: objistr.hpp:369
CObjectIStream & GetStream(void) const
char ReplaceVisibleChar(char c, EFixNonPrint fix_method, const CObjectStack *io, const CTempString &str, char subst)
Definition: objistr.cpp:1855
CObjectIStream(CNcbiIstream &in, bool deleteIn=false)
void SkipStd(const CBitString &data)
CStreamDelayBufferGuard(void)
Construct empty guard instance.
void FixNonPrintSubst(char subst)
Definition: objistr.hpp:361
void ReadStd(string &data)
virtual TMemberIndex BeginClassMember(const CClassTypeInfo *classType, TMemberIndex pos)=0
CLocalHookSet< CSkipObjectHook > m_ObjectSkipHookKey
Definition: objistr.hpp:1149
void SkipStd(const unsigned long &)
void SkipStd(const char *const &)
bool GoodVisibleChar(char c)
void SetMemberNillable()
Definition: objistr.hpp:1117
virtual void ReadNull(void)=0
void ReadStd(char *&data)
virtual void UndoClassMember(void)
Definition: objistr.hpp:996
void SetVerifyData(ESerialVerifyData verify)
Set up input data verification for this particular stream.
void ReadStd(bool &data)
virtual void EndContainer(void)=0
bool fail(void) const
Check if any of fail flags is set.
void SkipStd(const signed char &)
void SkipStd(const long &)
CStreamObjectPathHook< CSkipObjectHook * > m_PathSkipObjectHooks
Definition: objistr.hpp:1080
CObjectIStream * m_ObjectIStream
Definition: objistr.hpp:1213
CStreamDelayBufferGuard(const CStreamDelayBufferGuard &)
void ReadStd(float &data)
virtual void SkipByteBlock(void)=0
EFixNonPrint FixNonPrint(EFixNonPrint how)
Definition: objistr.hpp:355
virtual TMemberIndex BeginClassMember(const CClassTypeInfo *classType)=0
virtual size_t ReadChars(CharBlock &block, char *buffer, size_t count)=0
CStreamObjectPathHook< CReadObjectHook * > m_PathReadObjectHooks
Definition: objistr.hpp:1079
ESerialSkipUnknown GetSkipUnknownMembers(void)
Get skip unknown members parameter.
virtual string ReadOtherPointer(void)=0
void SetSpecialCaseUsed(ESpecialCaseRead used)
Definition: objistr.hpp:1136
virtual void SkipString(EStringType type=eStringTypeVisible)=0
virtual string GetStackTrace(void) const =0
CObjectIStream & m_Stream
Definition: objistr.hpp:879
void SkipStd(const CStrictId< TKey, TStorage > &data)
Definition: objistr.hpp:792
virtual void SkipFNumber(void)=0
CStreamPathHook< CVariantInfo *, CReadChoiceVariantHook * > m_PathReadVariantHooks
Definition: objistr.hpp:1083
void ReadStd(unsigned short &data)
ESpecialCaseRead m_SpecialCaseUsed
Definition: objistr.hpp:1101
virtual void BeginBytes(ByteBlock &block)=0
void SkipStd(const bool &)
TFlags GetFlags(void) const
virtual double ReadDouble(void)=0
void ReadStd(unsigned &data)
virtual void SkipBool(void)=0
int m_SpecialCaseToExpect
Definition: objistr.hpp:1100
bool CanSkipUnknownMembers(void)
Simple check if it's allowed to skip unknown members.
void SkipStd(const Uint8 &)
static CObjectIStream * Open(const string &fileName, ESerialDataFormat format)
Create serial object reader and attach it to a file stream.
virtual void x_SetPathHooks(bool set)=0
TTypeInfo m_MonitorType
Definition: objistr.hpp:1088
void ReadObject(TObjectPtr object, TTypeInfo typeInfo)
Read child object.
void ReadStd(signed char &data)
virtual TMemberIndex BeginChoiceVariant(const CChoiceTypeInfo *choiceType)=0
void SetSkipUnknownMembers(ESerialSkipUnknown skip)
Set up skipping unknown members for this particular stream.
virtual void SkipSNumber(void)=0
bool KnownLength(void) const
CObjectIStream & m_Stream
Definition: objistr.hpp:933
void SkipStd(const int &)
void SetLength(size_t length)
void SetMemberDefault(TConstObjectPtr def)
Definition: objistr.hpp:1103
CLocalHookSet< CReadObjectHook > m_ObjectHookKey
Definition: objistr.hpp:1146
virtual void BeginContainer(const CContainerTypeInfo *containerType)=0
void ReadStd(short &data)
virtual void SkipUNumber(void)=0
AutoPtr< CReadObjectList > m_Objects
Definition: objistr.hpp:1075
size_t GetExpectedLength(void) const
TFailFlags m_Fail
Definition: objistr.hpp:1077
TTypeInfo m_TypeAlias
Definition: objistr.hpp:1052
CLocalHookSet< CReadClassMemberHook > m_ClassMemberHookKey
Definition: objistr.hpp:1147
virtual void SkipNull(void)=0
void SetMemoryPool(CObjectMemoryPool *memory_pool)
Definition: objistr.hpp:806
void SkipStd(const double &)
bool KnownLength(void) const
virtual void BeginChars(CharBlock &block)=0
void ReadStd(unsigned char &data)
void SkipStd(const string &)
pair< TObjectPtr, TTypeInfo > ReadObjectInfo(void)
void ReadStd(char &data)
CStreamDelayBufferGuard & operator=(const CStreamDelayBufferGuard &)
virtual char ReadChar(void)=0
ESerialSkipUnknown m_SkipUnknown
Definition: objistr.hpp:1073
void UnsetMemberSpecialCase(void)
Definition: objistr.hpp:1111
ESerialSkipUnknown m_SkipUnknownVariants
Definition: objistr.hpp:1074
EDelayBufferParsing
DelayBuffer parsing policy.
Definition: objistr.hpp:518
CStreamPathHook< CMemberInfo *, CReadClassMemberHook * > m_PathReadMemberHooks
Definition: objistr.hpp:1081
void ReadStd(double &data)
virtual void ReadAnyContentObject(CAnyContentObject &obj)=0
TConstObjectPtr m_MemberDefault
Definition: objistr.hpp:1099
void SkipStd(const Int8 &)
void SkipStd(const float &)
virtual size_t ReadBytes(ByteBlock &block, char *buffer, size_t count)=0
void ReadStd(const char *&data)
TFlags ClearFlags(TFlags flags)
void EndDelayBuffer(CDelayBuffer &buffer, const CItemInfo *itemInfo, TObjectPtr objectPtr)
Redirect call to protected CObjectIStream After this call guarding is finished.
virtual void ReadBitString(CBitString &obj)=0
ESerialVerifyData m_VerifyData
Definition: objistr.hpp:1072
void ReadStd(CStrictId< TKey, TStorage > &data)
Definition: objistr.hpp:786
TFailFlags GetFailFlags(void) const
Get fail flags.
void ReadStd(unsigned long &data)
virtual void SkipBitString(void)=0
void ReadStd(Uint8 &data)
virtual TEnumValueType ReadEnum(const CEnumeratedTypeValues &values)=0
CObjectIStream & GetStream(void) const
TConstObjectPtr GetMemberDefault(void) const
Definition: objistr.hpp:1132
size_t TObjectIndex
Definition: objistr.hpp:1029
virtual bool BeginContainerElement(TTypeInfo elementType)=0
virtual void ResetState(void)
Definition: objstack.cpp:58
virtual Int8 ReadInt8(void)=0
virtual TObjectIndex ReadObjectPointer(void)=0
void SkipObject(TTypeInfo typeInfo)
Skip child object.
void StartDelayBuffer(CObjectIStream &istr)
Start deley buffer collection on a given CObjectIStream object.
int ExpectSpecialCase(void) const
Definition: objistr.hpp:1128
void SetSkipUnknownVariants(ESerialSkipUnknown skip)
Set up skipping unknown choice variants for this particular stream.
CStreamPathHook< CVariantInfo *, CSkipChoiceVariantHook * > m_PathSkipVariantHooks
Definition: objistr.hpp:1084
EFixNonPrint m_FixMethod
Definition: objistr.hpp:1071
void SkipStd(char *const &)
void SetLength(size_t length)
virtual void SkipAnyContentObject(void)=0
void ReadStd(CBitString &data)
ESerialSkipUnknown GetSkipUnknownVariants(void)
Get skip unknown choice variants parameter.
char m_NonPrintSubst
Definition: objistr.hpp:1070
bool GetDiscardCurrObject(void) const
Definition: objistr.hpp:639
void SetDiscardCurrObject(bool discard=true)
Discard the object, which has been just read.
Definition: objistr.hpp:637
ESerialDataFormat m_DataFormat
Definition: objistr.hpp:1050
virtual Uint8 ReadUint8(void)=0
bool CanSkipUnknownVariants(void)
Simple check if it's allowed to skip unknown variants.
CObjectIStream & m_Stream
Definition: objistr.hpp:905
bool m_DiscardCurrObject
Definition: objistr.hpp:1049
void SkipStd(const unsigned &)
CLocalHookSet< CSkipClassMemberHook > m_ClassMemberSkipHookKey
Definition: objistr.hpp:1150
CLocalHookSet< CSkipChoiceVariantHook > m_ChoiceVariantSkipHookKey
Definition: objistr.hpp:1151
void SkipStd(const short &)
bool DetectLoops(void) const
TFailFlags ClearFailFlags(TFailFlags flags)
Reset fail flags.
void ReadStd(int &data)
CRef< CObjectMemoryPool > m_MemoryPool
Definition: objistr.hpp:1086
virtual void BeginClass(const CClassTypeInfo *classInfo)=0
CObjectMemoryPool * GetMemoryPool(void)
Definition: objistr.hpp:810
char x_FixCharsSubst(void) const
Definition: objistr.hpp:1044
CStreamDelayBufferGuard(CObjectIStream &istr)
Construct instance on a given CObjectIStream object.
void ReadStd(Int8 &data)
void SkipStd(const unsigned char &)
CLocalHookSet< CReadChoiceVariantHook > m_ChoiceVariantHookKey
Definition: objistr.hpp:1148
TFlags m_Flags
Definition: objistr.hpp:1078
ESpecialCaseRead GetSpecialCaseUsed(void) const
Definition: objistr.hpp:1140
void SkipStd(const char &)
bool HaveMoreData(void)
size_t GetExpectedLength(void) const
void UnsetMemberNillable()
Definition: objistr.hpp:1122
virtual void UnendedFrame(void)
Definition: objstack.cpp:71
virtual string GetPosition(void) const =0
EDelayBufferParsing m_ParseDelayBuffers
Definition: objistr.hpp:1051
void SkipStd(const unsigned short &)
virtual void SkipChar(void)=0
@ 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
@ fReadError
An unknown error when reading the input file.
Definition: objistr.hpp:375
@ fIllegalCall
Illegal in a given context function call.
Definition: objistr.hpp:383
@ fNotImplemented
Method is not implemented.
Definition: objistr.hpp:389
@ fMissingValue
Mandatory value was missing in the input.
Definition: objistr.hpp:394
@ fNotOpen
No input file.
Definition: objistr.hpp:387
@ fInvalidData
Input data is incorrect (e.g. invalid enum)
Definition: objistr.hpp:381
@ fFail
Internal error, the real reason is unclear.
Definition: objistr.hpp:385
@ 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
@ fNoError
No error.
Definition: objistr.hpp:371
@ eDelayBufferPolicyNotSet
Parse only if local hook are present.
Definition: objistr.hpp:520
@ eDelayBufferPolicyAlwaysParse
Parse always.
Definition: objistr.hpp:522
uint8_t Uint1
1-byte (8-bit) unsigned integer
Definition: ncbitype.h:99
#define NCBI_DEPRECATED
int16_t Int2
2-byte (16-bit) signed integer
Definition: ncbitype.h:100
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
uint16_t Uint2
2-byte (16-bit) unsigned integer
Definition: ncbitype.h:101
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
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
Definition: ncbistre.hpp:146
IO_PREFIX::streampos CNcbiStreampos
Portable alias for streampos.
Definition: ncbistre.hpp:134
enum ENcbiOwnership EOwnership
Ownership relations between objects.
#define NCBI_XSERIAL_EXPORT
Definition: ncbi_export.h:1435
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
const struct ncbi::grid::netcache::search::fields::SIZE size
const CharType(& source)[N]
Definition: pointer.h:1149
#define verify(expr)
Definition: ncbi_assert.h:51
Memory pool for fast allocation of memory for localized set of CObjects, e.g.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Useful/utility classes and methods.
static Format format
Definition: njn_ioutil.cpp:53
std::istream & in(std::istream &in_, double &x_)
#define MLIOVIR
Definition: objstack.hpp:39
static pcre_uint8 * buffer
Definition: pcretest.c:1051
Definition: type.c:6
Modified on Sat Apr 20 12:16:34 2024 by modify_doxy.py rev. 669887