📄 objostrxml.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: objostrxml.hpp,v $ * PRODUCTION Revision 1000.2 2004/04/12 17:15:24 gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.38 * PRODUCTION * =========================================================================== */#ifndef OBJOSTRXML__HPP#define OBJOSTRXML__HPP/* $Id: objostrxml.hpp,v 1000.2 2004/04/12 17:15:24 gouriano Exp $* ===========================================================================** PUBLIC DOMAIN NOTICE* National Center for Biotechnology Information** This software/database is a "United States Government Work" under the* terms of the United States Copyright Act. It was written as part of* the author's official duties as a United States Government employee and* thus cannot be copyrighted. This software/database is freely available* to the public for use. The National Library of Medicine and the U.S.* Government have not placed any restriction on its use or reproduction.** Although all reasonable efforts have been taken to ensure the accuracy* and reliability of the software and data, the NLM and the U.S.* Government do not and cannot warrant the performance or results that* may be obtained by using this software or data. The NLM and the U.S.* Government disclaim all warranties, express or implied, including* warranties of performance, merchantability or fitness for any particular* purpose.** Please cite the author in any work or product based on this material.** ===========================================================================** Author: Eugene Vasilchenko** File Description:* XML objects output stream*/#include <corelib/ncbistd.hpp>#include <serial/objostr.hpp>#include <stack>/** @addtogroup ObjStreamSupport * * @{ */BEGIN_NCBI_SCOPEclass NCBI_XSERIAL_EXPORT CObjectOStreamXml : public CObjectOStream{public: CObjectOStreamXml(CNcbiOstream& out, bool deleteOut); virtual ~CObjectOStreamXml(void); virtual string GetPosition(void) const; enum EEncoding { eEncoding_Unknown, eEncoding_UTF8, eEncoding_ISO8859_1, eEncoding_Windows_1252 }; void SetEncoding(EEncoding enc); EEncoding GetEncoding(void) const; void SetReferenceSchema(bool use_schema = true); bool GetReferenceSchema(void) const; void SetReferenceDTD(bool use_dtd = true); bool GetReferenceDTD(void) const; void SetUseSchemaLocation(bool use_loc = true); bool GetUseSchemaLocation(void) const; static void SetDefaultSchemaNamespace(const string& schema_ns); static string GetDefaultSchemaNamespace(void); virtual void WriteFileHeader(TTypeInfo type); // DTD file name and prefix. The final module name is built as // DTDFilePrefix + DTDFileName. // If "DTDFilePrefix" has never been set for this stream, then // the global "DefaultDTDFilePrefix" will be used. // If it has been set to any value (including empty string), then // that value will be used. void SetDTDFilePrefix(const string& prefix); string GetDTDFilePrefix(void) const; // Default (global) DTD file prefix. static void SetDefaultDTDFilePrefix(const string& prefix); static string GetDefaultDTDFilePrefix(void); // If "DTDFileName" is not set or set to empty string for this stream, // then type name will be used as the file name. void SetDTDFileName(const string& filename); string GetDTDFileName(void) const; // Enable/disable DTD public identifier. // If disabled (it is ENABLED by default), only system identifier // will be written in the output XML stream void EnableDTDPublicId(void); void DisableDTDPublicId(void); // DTD public identifier. If set to non-empty string, the stream will // write this in the output XML file. Otherwise the "default" public id // will be generated void SetDTDPublicId(const string& publicId); string GetDTDPublicId(void) const; enum ERealValueFormat { eRealFixedFormat, eRealScientificFormat }; ERealValueFormat GetRealValueFormat(void) const; void SetRealValueFormat(ERealValueFormat fmt); void SetEnforcedStdXml(bool set = true); bool GetEnforcedStdXml(void) {return m_EnforcedStdXml;}protected: virtual void WriteBool(bool data); virtual void WriteChar(char data); virtual void WriteInt4(Int4 data); virtual void WriteUint4(Uint4 data); virtual void WriteInt8(Int8 data); virtual void WriteUint8(Uint8 data); virtual void WriteFloat(float data); virtual void WriteDouble(double data); void WriteDouble2(double data, size_t digits); virtual void WriteCString(const char* str); virtual void WriteString(const string& s, EStringType type = eStringTypeVisible); virtual void WriteStringStore(const string& s); virtual void CopyString(CObjectIStream& in); virtual void CopyStringStore(CObjectIStream& in); virtual void WriteNullPointer(void); virtual void WriteObjectReference(TObjectIndex index); virtual void WriteOtherBegin(TTypeInfo typeInfo); virtual void WriteOtherEnd(TTypeInfo typeInfo); virtual void WriteOther(TConstObjectPtr object, TTypeInfo typeInfo); void WriteId(const string& str); void WriteNull(void); virtual void WriteAnyContentObject(const CAnyContentObject& obj); virtual void CopyAnyContentObject(CObjectIStream& in); void WriteEscapedChar(char c); virtual void WriteEnum(const CEnumeratedTypeValues& values, TEnumValueType value); virtual void CopyEnum(const CEnumeratedTypeValues& values, CObjectIStream& in); void WriteEnum(const CEnumeratedTypeValues& values, TEnumValueType value, const string& valueName);#ifdef VIRTUAL_MID_LEVEL_IO virtual void WriteNamedType(TTypeInfo namedTypeInfo, TTypeInfo typeInfo, TConstObjectPtr object); virtual void CopyNamedType(TTypeInfo namedTypeInfo, TTypeInfo typeInfo, CObjectStreamCopier& copier); virtual void WriteContainer(const CContainerTypeInfo* containerType, TConstObjectPtr containerPtr); void WriteContainerContents(const CContainerTypeInfo* containerType, TConstObjectPtr containerPtr); virtual void WriteClass(const CClassTypeInfo* objectType, TConstObjectPtr objectPtr); virtual void WriteClassMember(const CMemberId& memberId, TTypeInfo memberType, TConstObjectPtr memberPtr); virtual bool WriteClassMember(const CMemberId& memberId, const CDelayBuffer& buffer); virtual void WriteChoice(const CChoiceTypeInfo* choiceType, TConstObjectPtr choicePtr); void WriteChoiceContents(const CChoiceTypeInfo* choiceType, TConstObjectPtr choicePtr);/* // COPY virtual void CopyNamedType(TTypeInfo namedTypeInfo, TTypeInfo typeInfo, CObjectStreamCopier& copier); virtual void CopyContainer(const CContainerTypeInfo* containerType, CObjectStreamCopier& copier); virtual void CopyClassRandom(const CClassTypeInfo* objectType, CObjectStreamCopier& copier); virtual void CopyClassSequential(const CClassTypeInfo* objectType, CObjectStreamCopier& copier); virtual void CopyChoice(const CChoiceTypeInfo* choiceType, CObjectStreamCopier& copier);*/#endif // low level I/O virtual void BeginNamedType(TTypeInfo namedTypeInfo); virtual void EndNamedType(void); virtual void BeginContainer(const CContainerTypeInfo* containerType); virtual void EndContainer(void); virtual void BeginContainerElement(TTypeInfo elementType); virtual void EndContainerElement(void); void BeginArrayElement(TTypeInfo elementType); void EndArrayElement(void); void CheckStdXml(const CClassTypeInfoBase* classType); ETypeFamily GetRealTypeFamily(TTypeInfo typeInfo); ETypeFamily GetContainerElementTypeFamily(TTypeInfo typeInfo); virtual void BeginClass(const CClassTypeInfo* classInfo); virtual void EndClass(void); virtual void BeginClassMember(const CMemberId& id); void BeginClassMember(TTypeInfo memberType, const CMemberId& id); virtual void EndClassMember(void); virtual void BeginChoice(const CChoiceTypeInfo* choiceType); virtual void EndChoice(void); virtual void BeginChoiceVariant(const CChoiceTypeInfo* choiceType, const CMemberId& id); virtual void EndChoiceVariant(void); virtual void WriteBytes(const ByteBlock& block, const char* bytes, size_t length); virtual void WriteChars(const CharBlock& block, const char* chars, size_t length);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -