1 #ifndef SERIAL___OBJISTR__HPP
2 #define SERIAL___OBJISTR__HPP
120 bool deleteInStream);
149 const string& fileName,
255 void OpenFromBuffer(
const char*
buffer,
size_t size);
358 m_FixMethod = how ==
eFNP_Default ? x_GetFixCharsMethodDefault() : how;
362 m_NonPrintSubst = subst;
401 fNullValue = 1 << 11, eNullValue= fNullValue
435 bool InGoodState(
void);
442 virtual bool EndOfData(
void);
448 void SetCanceledCallback(
const ICanceled* callback);
502 virtual void Location(
string&,
size_t&)
const;
506 void SetPathReadObjectHook(
const string& path,
CReadObjectHook* hook);
507 void SetPathSkipObjectHook(
const string& path,
CSkipObjectHook* hook);
515 void ResetMonitorType(
void);
524 eDelayBufferPolicyNeverParse
526 void SetDelayBufferParsingPolicy(EDelayBufferParsing policy);
527 EDelayBufferParsing GetDelayBufferParsingPolicy(
void)
const;
528 bool ShouldParseDelayBuffer(
void)
const;
549 size_t max_length = 16,
550 size_t max_bytes = 1024*1024);
575 virtual string ReadFileHeader(
void);
620 void ReadSeparateObject(
const CObjectInfo&
object);
638 {m_DiscardCurrObject = discard;}
640 {
return m_DiscardCurrObject;}
643 virtual string PeekNextTypeName(
void);
667 #ifndef NCBI_INT8_IS_LONG
683 #if SIZEOF_LONG_DOUBLE != 0
684 virtual void ReadStd(
long double&
data);
685 virtual void SkipStd(
const long double& );
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);
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);
733 virtual float ReadFloat(
void);
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);
746 virtual void ReadPackedString(
string& s,
752 virtual void ReadStringStore(
string& s);
753 virtual void SkipStringStore(
void);
756 virtual char* ReadCString(
void);
757 virtual void SkipCString(
void);
766 virtual void SkipAnyContentVariant(
void);
776 virtual pair<TObjectPtr, TTypeInfo> ReadPointer(
TTypeInfo declaredType);
784 virtual void SkipPointer(
TTypeInfo declaredType);
791 template<
class TKey,
class TStorage>
void SkipStd
797 #ifdef NCBI_STRICT_GI
798 virtual void ReadGi(
TGi& obj);
799 virtual void SkipGi(
void);
808 m_MemoryPool = memory_pool;
815 void UseMemoryPool(
void);
819 void SkipExternalObject(
TTypeInfo typeInfo);
822 virtual void EndOfRead(
void);
827 void ResetLocalHooks(
void);
836 void Unended(
const string&
msg);
840 void DuplicatedMember(
const CMemberInfo* memberInfo);
841 bool ExpectedMember(
const CMemberInfo* memberInfo);
849 eFlagNone = fFlagNone,
850 fFlagAllowNonAsciiChars = 1 << 0,
851 eFlagAllowNonAsciiChars = fFlagAllowNonAsciiChars,
852 fFlagEnforcedStdXml = 1 << 1,
853 eFlagEnforcedStdXml = fFlagEnforcedStdXml
870 size_t Read(
void* dst,
size_t length,
bool forceLength =
false);
896 size_t Read(
char* dst,
size_t length,
bool forceLength =
false);
926 size_t Read(
char*
data,
size_t length);
928 operator asnio*(void);
929 asnio* operator->(
void);
930 const string& GetRootTypeName(
void)
const;
979 virtual void BeginNamedType(
TTypeInfo namedTypeInfo);
980 virtual void EndNamedType(
void);
986 virtual void EndContainerElement(
void);
990 virtual void EndClass(
void);
995 virtual void EndClassMember(
void);
1000 virtual void EndChoice(
void);
1002 virtual void EndChoiceVariant(
void);
1007 virtual void EndBytes(
const ByteBlock& block);
1012 virtual void EndChars(
const CharBlock& block);
1014 virtual void StartDelayBuffer(
void);
1020 size_t max_depth = 1,
1021 size_t min_depth = 1)
const;
1035 virtual void ReadOtherPointerEnd(
void);
1037 void RegisterObject(
TTypeInfo typeInfo);
1041 bool x_HavePathHooks()
const;
1045 return m_NonPrintSubst;
1061 const string& fileName,
1064 bool deleteInStream =
false);
1105 m_SpecialCaseUsed = eReadAsNormal;
1106 m_MemberDefault = def;
1108 m_SpecialCaseToExpect = m_SpecialCaseToExpect | (
int)eReadAsDefault;
1113 m_SpecialCaseUsed = eReadAsNormal;
1114 m_MemberDefault =
nullptr;
1115 m_SpecialCaseToExpect = eReadAsNormal;
1119 m_SpecialCaseUsed = eReadAsNormal;
1120 m_SpecialCaseToExpect = m_SpecialCaseToExpect | (
int)eReadAsNil;
1124 m_SpecialCaseUsed = eReadAsNormal;
1125 m_SpecialCaseToExpect = m_SpecialCaseToExpect & ~((
int)eReadAsNil);
1130 return m_SpecialCaseToExpect;
1134 return m_MemberDefault;
1138 m_SpecialCaseUsed = used;
1142 return m_SpecialCaseUsed;
1163 #define SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_READING 0
1164 #define SERIAL_ALLOW_UTF8_IN_VISIBLESTRING_ON_WRITING 0
CNcbiIstream & ReadContainer(CNcbiIstream &is, TCont &cont)
Read a container from a stream.
Serializable object that stores any combination of parsable data.
Incapsulate compile time information such as __FILE__, __LINE__, NCBI_MODULE, current function.
Read hook for a choice variant (CHOICE)
Read hook for data member of a containing object (eg, SEQUENCE)
Read hook for a standalone object.
Skip hook for a choice variant (CHOICE)
Skip hook for data member of a containing object (eg, SEQUENCE)
Skip hook for a standalone object.
Guard class for CObjectIStream::StartDelayBuffer/EndDelayBuffer.
Template class for strict ID types.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Interface for testing cancellation request in a long lasting operation.
Include a standard set of the NCBI C++ Toolkit most basic headers.
static const char * str(char *buf, int n)
@ eNoOwnership
No ownership is assumed.
ESerialSkipUnknown
Skip unknown members parameters.
EFixNonPrint
How to process non-printing character in the ASN VisibleString.
size_t TMemberIndex
Type used for indexing class members and choice variants.
ESerialVerifyData
Data verification parameters.
CNcbiIstream & ReadObject(CNcbiIstream &str, TObjectPtr ptr, TTypeInfo info)
const void * TConstObjectPtr
void Read(CObjectIStream &in, TObjectPtr object, const CTypeRef &type)
ESerialDataFormat
Data file format.
@ eStringTypeVisible
VisibleString (in ASN.1 sense)
ESerialDataFormat GetDataFormat(void) const
Get data format.
vector< TTypeInfo > m_ReqMonitorType
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
TFlags SetFlags(TFlags flags)
virtual bool ReadBool(void)=0
ESerialVerifyData GetVerifyData(void) const
Get input data verification parameter.
CObjectIStream & GetStream(void) const
char ReplaceVisibleChar(char c, EFixNonPrint fix_method, const CObjectStack *io, const CTempString &str, char subst)
CObjectIStream(CNcbiIstream &in, bool deleteIn=false)
void SkipStd(const CBitString &data)
CStreamDelayBufferGuard(void)
Construct empty guard instance.
void FixNonPrintSubst(char subst)
void ReadStd(string &data)
virtual TMemberIndex BeginClassMember(const CClassTypeInfo *classType, TMemberIndex pos)=0
CLocalHookSet< CSkipObjectHook > m_ObjectSkipHookKey
void SkipStd(const unsigned long &)
void SkipStd(const char *const &)
bool GoodVisibleChar(char c)
virtual void ReadNull(void)=0
void ReadStd(char *&data)
virtual void UndoClassMember(void)
void SetVerifyData(ESerialVerifyData verify)
Set up input data verification for this particular stream.
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
CObjectIStream * m_ObjectIStream
CStreamDelayBufferGuard(const CStreamDelayBufferGuard &)
void ReadStd(float &data)
virtual void SkipByteBlock(void)=0
EFixNonPrint FixNonPrint(EFixNonPrint how)
virtual TMemberIndex BeginClassMember(const CClassTypeInfo *classType)=0
virtual size_t ReadChars(CharBlock &block, char *buffer, size_t count)=0
CStreamObjectPathHook< CReadObjectHook * > m_PathReadObjectHooks
ESerialSkipUnknown GetSkipUnknownMembers(void)
Get skip unknown members parameter.
virtual string ReadOtherPointer(void)=0
void SetSpecialCaseUsed(ESpecialCaseRead used)
virtual void SkipString(EStringType type=eStringTypeVisible)=0
virtual string GetStackTrace(void) const =0
CObjectIStream & m_Stream
void SkipStd(const CStrictId< TKey, TStorage > &data)
virtual void SkipFNumber(void)=0
CStreamPathHook< CVariantInfo *, CReadChoiceVariantHook * > m_PathReadVariantHooks
void ReadStd(unsigned short &data)
ESpecialCaseRead m_SpecialCaseUsed
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
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
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
void SkipStd(const int &)
void SetLength(size_t length)
void SetMemberDefault(TConstObjectPtr def)
CLocalHookSet< CReadObjectHook > m_ObjectHookKey
virtual void BeginContainer(const CContainerTypeInfo *containerType)=0
void ReadStd(short &data)
virtual void SkipUNumber(void)=0
AutoPtr< CReadObjectList > m_Objects
size_t GetExpectedLength(void) const
CLocalHookSet< CReadClassMemberHook > m_ClassMemberHookKey
virtual void SkipNull(void)=0
void SetMemoryPool(CObjectMemoryPool *memory_pool)
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)
CStreamDelayBufferGuard & operator=(const CStreamDelayBufferGuard &)
virtual char ReadChar(void)=0
ESerialSkipUnknown m_SkipUnknown
void UnsetMemberSpecialCase(void)
ESerialSkipUnknown m_SkipUnknownVariants
EDelayBufferParsing
DelayBuffer parsing policy.
CStreamPathHook< CMemberInfo *, CReadClassMemberHook * > m_PathReadMemberHooks
void ReadStd(double &data)
virtual void ReadAnyContentObject(CAnyContentObject &obj)=0
TConstObjectPtr m_MemberDefault
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
void ReadStd(CStrictId< TKey, TStorage > &data)
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
virtual bool BeginContainerElement(TTypeInfo elementType)=0
virtual void ResetState(void)
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
void SetSkipUnknownVariants(ESerialSkipUnknown skip)
Set up skipping unknown choice variants for this particular stream.
CStreamPathHook< CVariantInfo *, CSkipChoiceVariantHook * > m_PathSkipVariantHooks
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.
bool GetDiscardCurrObject(void) const
void SetDiscardCurrObject(bool discard=true)
Discard the object, which has been just read.
ESerialDataFormat m_DataFormat
virtual Uint8 ReadUint8(void)=0
bool CanSkipUnknownVariants(void)
Simple check if it's allowed to skip unknown variants.
CObjectIStream & m_Stream
void SkipStd(const unsigned &)
CLocalHookSet< CSkipClassMemberHook > m_ClassMemberSkipHookKey
CLocalHookSet< CSkipChoiceVariantHook > m_ChoiceVariantSkipHookKey
void SkipStd(const short &)
~CStreamDelayBufferGuard(void)
bool DetectLoops(void) const
TFailFlags ClearFailFlags(TFailFlags flags)
Reset fail flags.
CRef< CObjectMemoryPool > m_MemoryPool
virtual void BeginClass(const CClassTypeInfo *classInfo)=0
CObjectMemoryPool * GetMemoryPool(void)
char x_FixCharsSubst(void) const
CStreamDelayBufferGuard(CObjectIStream &istr)
Construct instance on a given CObjectIStream object.
void SkipStd(const unsigned char &)
CLocalHookSet< CReadChoiceVariantHook > m_ChoiceVariantHookKey
ESpecialCaseRead GetSpecialCaseUsed(void) const
void SkipStd(const char &)
size_t GetExpectedLength(void) const
void UnsetMemberNillable()
virtual void UnendedFrame(void)
virtual string GetPosition(void) const =0
EDelayBufferParsing m_ParseDelayBuffers
void SkipStd(const unsigned short &)
virtual void SkipChar(void)=0
@ fEOF
End of file in the middle of reading an object.
@ fOverflow
Data read is beyond the allowed limits.
@ fReadError
An unknown error when reading the input file.
@ fIllegalCall
Illegal in a given context function call.
@ fNotImplemented
Method is not implemented.
@ fMissingValue
Mandatory value was missing in the input.
@ fInvalidData
Input data is incorrect (e.g. invalid enum)
@ fFail
Internal error, the real reason is unclear.
@ fUnknownValue
Unknown value was present in the input.
@ fFormatError
Input file formatting does not conform with specification.
@ eDelayBufferPolicyNotSet
Parse only if local hook are present.
@ eDelayBufferPolicyAlwaysParse
Parse always.
uint8_t Uint1
1-byte (8-bit) unsigned integer
int16_t Int2
2-byte (16-bit) signed integer
int32_t Int4
4-byte (32-bit) signed integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
uint16_t Uint2
2-byte (16-bit) unsigned integer
int64_t Int8
8-byte (64-bit) signed integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
int8_t Int1
1-byte (8-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
IO_PREFIX::streampos CNcbiStreampos
Portable alias for streampos.
enum ENcbiOwnership EOwnership
Ownership relations between objects.
#define NCBI_XSERIAL_EXPORT
unsigned int
A callback function used to compare two keys in a database.
const struct ncbi::grid::netcache::search::fields::SIZE size
const CharType(& source)[N]
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.
std::istream & in(std::istream &in_, double &x_)
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)