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 101054 2023-10-23 14:30:08Z gouriano $
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);
674  void ReadStd(Uint8& 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 
698  void ReadStd(CBitString& data);
699  void SkipStd(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(CStrictId<TKey, TStorage>& data)
792  {
793  SkipStd(data.Set());
794  }
795 
796 #ifdef NCBI_STRICT_GI
797  virtual void ReadGi(TGi& obj);
798  virtual void SkipGi(void);
799 #endif
800 
801 //---------------------------------------------------------------------------
802 // Internals
803 
804  // memory pool to use to create new objects when reading data
805  void SetMemoryPool(CObjectMemoryPool* memory_pool)
806  {
807  m_MemoryPool = memory_pool;
808  }
810  {
811  return m_MemoryPool;
812  }
813  // create and set new memory pool
814  void UseMemoryPool(void);
815 
816  // internal reader
817  void ReadExternalObject(TObjectPtr object, TTypeInfo typeInfo);
818  void SkipExternalObject(TTypeInfo typeInfo);
819 
820  CObjectInfo ReadObject(void);
821  virtual void EndOfRead(void);
822 
823  // try to read enum value name, "" if none
824  virtual TEnumValueType ReadEnum(const CEnumeratedTypeValues& values) = 0;
825 
826  void ResetLocalHooks(void);
827  bool DetectLoops(void) const;
828  void HandleEOF(CEofException&);
829 
830  void ThrowError1(const CDiagCompileInfo& diag_info,
831  TFailFlags fail, const char* message);
832  void ThrowError1(const CDiagCompileInfo& diag_info,
833  TFailFlags fail, const string& message);
834  // report unended block
835  void Unended(const string& msg);
836  // report unended object stack frame
837  virtual void UnendedFrame(void) override;
838  // report class member errors
839  void DuplicatedMember(const CMemberInfo* memberInfo);
840  bool ExpectedMember(const CMemberInfo* memberInfo);
841 
842  // check if m_Input has any more data to read
843  // (ANY data, including white spaces and comments)
844  bool HaveMoreData(void);
845 
846  enum EFlags {
847  fFlagNone = 0,
848  eFlagNone = fFlagNone,
849  fFlagAllowNonAsciiChars = 1 << 0,
850  eFlagAllowNonAsciiChars = fFlagAllowNonAsciiChars,
851  fFlagEnforcedStdXml = 1 << 1,
852  eFlagEnforcedStdXml = fFlagEnforcedStdXml
853  };
854  typedef int TFlags;
855  TFlags GetFlags(void) const;
858 
860  {
861  public:
863  ~ByteBlock(void);
864 
865  void End(void);
866 
867  CObjectIStream& GetStream(void) const;
868 
869  size_t Read(void* dst, size_t length, bool forceLength = false);
870 
871  bool KnownLength(void) const;
872  size_t GetExpectedLength(void) const;
873 
874  void SetLength(size_t length);
875  void EndOfBlock(void);
876 
877  private:
880  bool m_Ended;
881  size_t m_Length;
882 
883  friend class CObjectIStream;
884  };
886  {
887  public:
889  ~CharBlock(void);
890 
891  void End(void);
892 
893  CObjectIStream& GetStream(void) const;
894 
895  size_t Read(char* dst, size_t length, bool forceLength = false);
896 
897  bool KnownLength(void) const;
898  size_t GetExpectedLength(void) const;
899 
900  void SetLength(size_t length);
901  void EndOfBlock(void);
902 
903  private:
906  bool m_Ended;
907  size_t m_Length;
908 
909  friend class CObjectIStream;
910  };
911 
912 
913 #if HAVE_NCBI_C
914  // ASN.1 interface
915  class AsnIo
916  {
917  public:
918  AsnIo(CObjectIStream& in, const string& rootTypeName);
919  ~AsnIo(void);
920 
921  void End(void);
922 
923  CObjectIStream& GetStream(void) const;
924 
925  size_t Read(char* data, size_t length);
926 
927  operator asnio*(void);
928  asnio* operator->(void);
929  const string& GetRootTypeName(void) const;
930 
931  private:
933  bool m_Ended;
935  asnio* m_AsnIo;
936 
937  public:
938  size_t m_Count;
939  };
940  friend class AsnIo;
941 public:
942 #endif
943 
944 //---------------------------------------------------------------------------
945 // mid level I/O
946  // named type
947  MLIOVIR void ReadNamedType(TTypeInfo namedTypeInfo,
948  TTypeInfo typeInfo, TObjectPtr object);
949  MLIOVIR void SkipNamedType(TTypeInfo namedTypeInfo,
950  TTypeInfo typeInfo);
951 
952  // container
953  MLIOVIR void ReadContainer(const CContainerTypeInfo* containerType,
954  TObjectPtr containerPtr);
955  MLIOVIR void SkipContainer(const CContainerTypeInfo* containerType);
956 
957  // class
958  MLIOVIR void ReadClassSequential(const CClassTypeInfo* classType,
959  TObjectPtr classPtr);
960  MLIOVIR void ReadClassRandom(const CClassTypeInfo* classType,
961  TObjectPtr classPtr);
962  MLIOVIR void SkipClassSequential(const CClassTypeInfo* classType);
963  MLIOVIR void SkipClassRandom(const CClassTypeInfo* classType);
964 
965  // choice
966  MLIOVIR void ReadChoiceSimple(const CChoiceTypeInfo* choiceType,
967  TObjectPtr choicePtr);
968  MLIOVIR void SkipChoiceSimple(const CChoiceTypeInfo* choiceType);
969 
970  // alias
971  MLIOVIR void ReadAlias(const CAliasTypeInfo* aliasType,
972  TObjectPtr aliasPtr);
973  MLIOVIR void SkipAlias(const CAliasTypeInfo* aliasType);
974 
975 //---------------------------------------------------------------------------
976 // low level I/O
977  // named type (alias)
978  virtual void BeginNamedType(TTypeInfo namedTypeInfo);
979  virtual void EndNamedType(void);
980 
981  // container
982  virtual void BeginContainer(const CContainerTypeInfo* containerType) = 0;
983  virtual void EndContainer(void) = 0;
984  virtual bool BeginContainerElement(TTypeInfo elementType) = 0;
985  virtual void EndContainerElement(void);
986 
987  // class
988  virtual void BeginClass(const CClassTypeInfo* classInfo) = 0;
989  virtual void EndClass(void);
990 
991  virtual TMemberIndex BeginClassMember(const CClassTypeInfo* classType) = 0;
992  virtual TMemberIndex BeginClassMember(const CClassTypeInfo* classType,
993  TMemberIndex pos) = 0;
994  virtual void EndClassMember(void);
995  virtual void UndoClassMember(void) {}
996 
997  // choice
998  virtual void BeginChoice(const CChoiceTypeInfo* choiceType);
999  virtual void EndChoice(void);
1000  virtual TMemberIndex BeginChoiceVariant(const CChoiceTypeInfo* choiceType) = 0;
1001  virtual void EndChoiceVariant(void);
1002 
1003  // byte block
1004  virtual void BeginBytes(ByteBlock& block) = 0;
1005  virtual size_t ReadBytes(ByteBlock& block, char* buffer, size_t count) = 0;
1006  virtual void EndBytes(const ByteBlock& block);
1007 
1008  // char block
1009  virtual void BeginChars(CharBlock& block) = 0;
1010  virtual size_t ReadChars(CharBlock& block, char* buffer, size_t count) = 0;
1011  virtual void EndChars(const CharBlock& block);
1012 
1013  virtual void StartDelayBuffer(void);
1014  virtual CRef<CByteSource> EndDelayBuffer(void);
1015  void EndDelayBuffer(CDelayBuffer& buffer,
1016  const CItemInfo* itemInfo, TObjectPtr objectPtr);
1017 
1018  TObjectPtr GetParentObjectPtr(TTypeInfo type,
1019  size_t max_depth = 1,
1020  size_t min_depth = 1) const;
1021 
1022 protected:
1024  CObjectIStream(CNcbiIstream& in, bool deleteIn = false);
1025  // reset state machine
1026  virtual void ResetState(void) override;
1027 
1028  typedef size_t TObjectIndex;
1029  // low level readers
1030  pair<TObjectPtr, TTypeInfo> ReadObjectInfo(void);
1031  virtual EPointerType ReadPointerType(void) = 0;
1032  virtual TObjectIndex ReadObjectPointer(void) = 0;
1033  virtual string ReadOtherPointer(void) = 0;
1034  virtual void ReadOtherPointerEnd(void);
1035 
1036  void RegisterObject(TTypeInfo typeInfo);
1037  void RegisterObject(TObjectPtr object, TTypeInfo typeInfo);
1038  const CReadObjectInfo& GetRegisteredObject(TObjectIndex index);
1039  virtual void x_SetPathHooks(bool set) override;
1040  bool x_HavePathHooks() const;
1041  EFixNonPrint x_GetFixCharsMethodDefault(void) const;
1042  EFixNonPrint x_FixCharsMethod(void) const;
1043  char x_FixCharsSubst(void) const {
1044  return m_NonPrintSubst;
1045  }
1046 
1052 
1053 private:
1054  static CObjectIStream* CreateObjectIStreamAsn(void);
1055  static CObjectIStream* CreateObjectIStreamAsnBinary(void);
1056  static CObjectIStream* CreateObjectIStreamXml(void);
1057  static CObjectIStream* CreateObjectIStreamJson(void);
1058 
1059  static CRef<CByteSource> GetSource(ESerialDataFormat format,
1060  const string& fileName,
1061  TSerialOpenFlags openFlags = 0);
1062  static CRef<CByteSource> GetSource(CNcbiIstream& inStream,
1063  bool deleteInStream = false);
1064 
1065  static ESerialVerifyData x_GetVerifyDataDefault(void);
1066  static ESerialSkipUnknown x_GetSkipUnknownDefault(void);
1067  static ESerialSkipUnknown x_GetSkipUnknownVariantsDefault(void);
1068 
1070  EFixNonPrint m_FixMethod; // method of fixing wrong (eg, non-printable) chars
1075 
1084 
1086 
1088  vector<TTypeInfo> m_ReqMonitorType;
1089 
1090 public:
1092  eReadAsNormal = 0,
1093  eReadAsDefault = 1,
1094  eReadAsNil = 2,
1095  eReadAsBigInt = 4
1096  };
1097 private:
1101 
1103  {
1104  m_SpecialCaseUsed = eReadAsNormal;
1105  m_MemberDefault = def;
1106  if (def) {
1107  m_SpecialCaseToExpect = m_SpecialCaseToExpect | (int)eReadAsDefault;
1108  }
1109  }
1111  {
1112  m_SpecialCaseUsed = eReadAsNormal;
1113  m_MemberDefault = nullptr;
1114  m_SpecialCaseToExpect = eReadAsNormal;
1115  }
1117  {
1118  m_SpecialCaseUsed = eReadAsNormal;
1119  m_SpecialCaseToExpect = m_SpecialCaseToExpect | (int)eReadAsNil;
1120  }
1122  {
1123  m_SpecialCaseUsed = eReadAsNormal;
1124  m_SpecialCaseToExpect = m_SpecialCaseToExpect & ~((int)eReadAsNil);
1125  }
1126 public:
1127  int ExpectSpecialCase(void) const
1128  {
1129  return m_SpecialCaseToExpect;
1130  }
1132  {
1133  return m_MemberDefault;
1134  }
1136  {
1137  m_SpecialCaseUsed = used;
1138  }
1140  {
1141  return m_SpecialCaseUsed;
1142  }
1143 
1144  // read hooks
1151 
1152  friend class CObjectOStream;
1153  friend class CObjectStreamCopier;
1154  friend class CMemberInfoFunctions;
1155  friend class CClassTypeInfo;
1156  friend class CAutoPointerTypeInfo;
1157 };
1158 
1159 inline
1160 bool GoodVisibleChar(char c);
1161 
1162 #define SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING 0
1163 #define SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_WRITING 0
1165 char ReplaceVisibleChar(char c, EFixNonPrint fix_method,
1166  const CObjectStack* io, const CTempString& str, char subst);
1167 
1168 
1169 /// Guard class for CObjectIStream::StartDelayBuffer/EndDelayBuffer
1170 ///
1171 /// CObjectIStream::StartDelayBuffer() should be followed by
1172 /// CObjectIStream::EndDelayBuffer() call. If it's not called we have a delay
1173 /// buffer leak. This class works as an guard (or auto pointer) to avoid call
1174 /// leaks.
1176 {
1177 public:
1178  /// Construct empty guard instance
1179  ///
1181  /// Construct instance on a given CObjectIStream object.
1182  /// Call istr.StartDelayBuffer()
1183  ///
1184  /// @param istr
1185  /// Guard protected instance
1187 
1189 
1190 
1191  /// Start deley buffer collection on a given CObjectIStream object.
1192  /// Call istr.StartDelayBuffer()
1193  ///
1194  /// @param istr
1195  /// Guard protected instance
1197 
1198  /// Redirect call to protected CObjectIStream
1199  /// After this call guarding is finished.
1201 
1202  /// Redirect call to protected CObjectIStream
1203  /// After this call guarding is finished.
1205  const CItemInfo* itemInfo,
1206  TObjectPtr objectPtr);
1207 
1208 private:
1211 private:
1213 };
1214 
1215 
1216 /* @} */
1217 
1218 
1219 #include <serial/impl/objistr.inl>
1220 
1222 
1223 #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:1176
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
void Set(TId id)
Definition: ncbimisc.hpp:922
@ 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:1047
ESerialDataFormat GetDataFormat(void) const
Get data format.
vector< TTypeInfo > m_ReqMonitorType
Definition: objistr.hpp:1088
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:1081
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(CStrictId< TKey, TStorage > &data)
Definition: objistr.hpp:791
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:1148
void SkipStd(const unsigned long &)
void SkipStd(const char *const &)
bool GoodVisibleChar(char c)
void SetMemberNillable()
Definition: objistr.hpp:1116
virtual void ReadNull(void)=0
void ReadStd(char *&data)
virtual void UndoClassMember(void)
Definition: objistr.hpp:995
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:1079
CObjectIStream * m_ObjectIStream
Definition: objistr.hpp:1212
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:1078
ESerialSkipUnknown GetSkipUnknownMembers(void)
Get skip unknown members parameter.
virtual string ReadOtherPointer(void)=0
void SetSpecialCaseUsed(ESpecialCaseRead used)
Definition: objistr.hpp:1135
virtual void SkipString(EStringType type=eStringTypeVisible)=0
virtual string GetStackTrace(void) const =0
CObjectIStream & m_Stream
Definition: objistr.hpp:878
virtual void SkipFNumber(void)=0
CStreamPathHook< CVariantInfo *, CReadChoiceVariantHook * > m_PathReadVariantHooks
Definition: objistr.hpp:1082
void ReadStd(unsigned short &data)
ESpecialCaseRead m_SpecialCaseUsed
Definition: objistr.hpp:1100
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:1099
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:1087
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:932
void SkipStd(const int &)
void SetLength(size_t length)
void SetMemberDefault(TConstObjectPtr def)
Definition: objistr.hpp:1102
CLocalHookSet< CReadObjectHook > m_ObjectHookKey
Definition: objistr.hpp:1145
virtual void BeginContainer(const CContainerTypeInfo *containerType)=0
void ReadStd(short &data)
virtual void SkipUNumber(void)=0
AutoPtr< CReadObjectList > m_Objects
Definition: objistr.hpp:1074
size_t GetExpectedLength(void) const
TFailFlags m_Fail
Definition: objistr.hpp:1076
TTypeInfo m_TypeAlias
Definition: objistr.hpp:1051
CLocalHookSet< CReadClassMemberHook > m_ClassMemberHookKey
Definition: objistr.hpp:1146
virtual void SkipNull(void)=0
void SetMemoryPool(CObjectMemoryPool *memory_pool)
Definition: objistr.hpp:805
void SkipStd(const double &)
bool KnownLength(void) const
virtual void BeginChars(CharBlock &block)=0
void SkipStd(CBitString &data)
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:1072
void UnsetMemberSpecialCase(void)
Definition: objistr.hpp:1110
ESerialSkipUnknown m_SkipUnknownVariants
Definition: objistr.hpp:1073
EDelayBufferParsing
DelayBuffer parsing policy.
Definition: objistr.hpp:518
CStreamPathHook< CMemberInfo *, CReadClassMemberHook * > m_PathReadMemberHooks
Definition: objistr.hpp:1080
void ReadStd(double &data)
virtual void ReadAnyContentObject(CAnyContentObject &obj)=0
TConstObjectPtr m_MemberDefault
Definition: objistr.hpp:1098
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:1071
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:1131
size_t TObjectIndex
Definition: objistr.hpp:1028
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:1127
void SetSkipUnknownVariants(ESerialSkipUnknown skip)
Set up skipping unknown choice variants for this particular stream.
CStreamPathHook< CVariantInfo *, CSkipChoiceVariantHook * > m_PathSkipVariantHooks
Definition: objistr.hpp:1083
EFixNonPrint m_FixMethod
Definition: objistr.hpp:1070
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:1069
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:1049
virtual Uint8 ReadUint8(void)=0
bool CanSkipUnknownVariants(void)
Simple check if it's allowed to skip unknown variants.
CObjectIStream & m_Stream
Definition: objistr.hpp:904
bool m_DiscardCurrObject
Definition: objistr.hpp:1048
void SkipStd(const unsigned &)
CLocalHookSet< CSkipClassMemberHook > m_ClassMemberSkipHookKey
Definition: objistr.hpp:1149
CLocalHookSet< CSkipChoiceVariantHook > m_ChoiceVariantSkipHookKey
Definition: objistr.hpp:1150
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:1085
virtual void BeginClass(const CClassTypeInfo *classInfo)=0
CObjectMemoryPool * GetMemoryPool(void)
Definition: objistr.hpp:809
char x_FixCharsSubst(void) const
Definition: objistr.hpp:1043
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:1147
TFlags m_Flags
Definition: objistr.hpp:1077
ESpecialCaseRead GetSpecialCaseUsed(void) const
Definition: objistr.hpp:1139
void SkipStd(const char &)
bool HaveMoreData(void)
size_t GetExpectedLength(void) const
void UnsetMemberNillable()
Definition: objistr.hpp:1121
virtual void UnendedFrame(void)
Definition: objstack.cpp:71
virtual string GetPosition(void) const =0
EDelayBufferParsing m_ParseDelayBuffers
Definition: objistr.hpp:1050
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 char tmp[2048]
Definition: utf8.c:42
static pcre_uint8 * buffer
Definition: pcretest.c:1051
static const char * str(char *buf, int n)
Definition: stats.c:84
Definition: type.c:6
Modified on Tue Nov 28 02:21:41 2023 by modify_doxy.py rev. 669887