⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objostrxml.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* * =========================================================================== * PRODUCTION $Log: objostrxml.cpp,v $ * PRODUCTION Revision 1000.5  2004/06/01 19:41:18  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.73 * PRODUCTION * =========================================================================== *//*  $Id: objostrxml.cpp,v 1000.5 2004/06/01 19:41:18 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 object output stream** ---------------------------------------------------------------------------* $Log: objostrxml.cpp,v $* Revision 1000.5  2004/06/01 19:41:18  gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.73** Revision 1.73  2004/05/19 17:26:19  gouriano* Corrected serialization of containers when the code was generated by DTD** Revision 1.72  2004/05/17 21:03:03  gorelenk* Added include of PCH ncbi_pch.hpp** Revision 1.71  2004/05/04 17:04:43  gouriano* Check double for being finite** Revision 1.70  2004/01/29 20:43:04  gouriano* Corrected writing of AnyContent objects in case it has attributes* with previously undefined namespaces, or tags with empty content** Revision 1.69  2004/01/22 20:48:38  gouriano* corrected writing of namespace prefixes** Revision 1.68  2004/01/08 17:42:00  gouriano* Added encoding Windows-1252.* Made it possible to omit document type declaration** Revision 1.67  2003/11/26 19:59:41  vasilche* GetPosition() and GetDataFormat() methods now are implemented* in parent classes CObjectIStream and CObjectOStream to avoid* pure virtual method call in destructors.** Revision 1.66  2003/11/21 16:16:48  vasilche* More efficient writing of hex numbers.** Revision 1.65  2003/10/31 17:39:40  grichenk* Allow empty containers** Revision 1.64  2003/09/25 19:44:08  gouriano* Corrected serialization of AnyContent object's attributes** Revision 1.63  2003/09/22 20:55:23  gouriano* Corrected writing of AnyContent objects in case of no schema reference** Revision 1.62  2003/09/16 14:48:36  gouriano* Enhanced AnyContent objects to support XML namespaces and attribute info items.** Revision 1.61  2003/08/25 15:59:09  gouriano* added possibility to use namespaces in XML i/o streams** Revision 1.60  2003/08/13 18:23:54  gouriano* corrected XML schema namespace name** Revision 1.59  2003/08/13 15:47:45  gouriano* implemented serialization of AnyContent objects** Revision 1.58  2003/07/02 13:01:29  gouriano* added ability to read/write XML files with reference to schema** Revision 1.57  2003/06/30 15:39:48  gouriano* added encoding (utf-8 or iso-8859-1)** Revision 1.56  2003/06/24 20:57:36  gouriano* corrected code generation and serialization of non-empty unnamed containers (XML)** Revision 1.55  2003/05/22 20:10:02  gouriano* added UTF8 strings** Revision 1.54  2003/05/16 18:02:18  gouriano* revised exception error messages** Revision 1.53  2003/04/29 18:30:37  gouriano* object data member initialization verification** Revision 1.52  2003/03/26 16:14:23  vasilche* Removed TAB symbols. Some formatting.** Revision 1.51  2003/02/07 16:09:22  gouriano* correction of GetContainerElementTypeFamily for the case of copying objects** Revision 1.50  2003/02/05 17:08:00  gouriano* added possibility to read/write objects generated from an ASN.1 spec as "standard" XML - without scope prefixes** Revision 1.49  2003/02/04 17:06:25  gouriano* added check for NaN in WriteDouble** Revision 1.48  2003/01/22 21:03:16  gouriano* remove trailing zeros when writing a float value** Revision 1.47  2003/01/22 20:53:09  gouriano* more control on how a float value is to be written** Revision 1.46  2003/01/21 19:32:26  gouriano* corrected reading containers of primitive types** Revision 1.45  2003/01/10 17:48:41  gouriano* added check for empty container** Revision 1.44  2003/01/10 16:54:10  gouriano* fixed a bug with optional class members** Revision 1.43  2002/12/26 21:35:45  gouriano* corrected handling choice's XML attributes** Revision 1.42  2002/12/26 19:32:34  gouriano* changed XML I/O streams to properly handle object copying** Revision 1.41  2002/12/17 19:04:32  gouriano* corrected reading/writing of character references** Revision 1.40  2002/12/12 21:08:07  gouriano* implemented handling of complex XML containers** Revision 1.39  2002/11/26 22:10:31  gouriano* added unnamed lists of sequences (choices) as container elements** Revision 1.38  2002/11/20 21:22:51  gouriano* corrected processing of unnamed sequences as choice variants** Revision 1.37  2002/11/19 19:48:51  gouriano* added support of XML attributes of choice variants** Revision 1.36  2002/11/14 21:00:18  gouriano* added support of XML attribute lists** Revision 1.35  2002/10/25 14:49:27  vasilche* NCBI C Toolkit compatibility code extracted to libxcser library.* Serial streams flags names were renamed to fXxx.** Names of flags** Revision 1.34  2002/10/18 14:27:09  gouriano* added possibility to enable/disable/set public identifier** Revision 1.33  2002/10/15 13:47:59  gouriano* modified to handle "standard" (generated from DTD) XML i/o** Revision 1.32  2002/10/08 18:59:38  grichenk* Check for null pointers in containers (assert in debug mode,* warning in release).** Revision 1.31  2002/09/25 19:37:36  gouriano* added the possibility of having no tag prefix in XML I/O streams** Revision 1.30  2002/03/07 22:02:02  grichenk* Added "Separator" modifier for CObjectOStream** Revision 1.29  2001/11/09 19:07:58  grichenk* Fixed DTDFilePrefix functions** Revision 1.28  2001/10/17 20:41:26  grichenk* Added CObjectOStream::CharBlock class** Revision 1.27  2001/10/17 18:18:30  grichenk* Added CObjectOStreamXml::xxxFilePrefix() and* CObjectOStreamXml::xxxFileName()** Revision 1.26  2001/05/17 15:07:08  lavr* Typos corrected** Revision 1.25  2001/04/25 20:41:53  vakatov* <limits.h>, <float.h>  --->  <corelib/ncbi_limits.h>** Revision 1.24  2001/04/13 14:57:15  kholodov* Added: SetDTDFileName function to set DTD module name in XML header** Revision 1.23  2000/12/26 22:24:14  vasilche* Fixed errors of compilation on Mac.** Revision 1.22  2000/12/15 15:38:45  vasilche* Added support of Int8 and long double.* Enum values now have type Int4 instead of long.** Revision 1.21  2000/12/04 19:02:41  beloslyu* changes for FreeBSD** Revision 1.20  2000/11/07 17:25:41  vasilche* Fixed encoding of XML:*     removed unnecessary apostrophes in OCTET STRING*     removed unnecessary content in NULL* Added module names to CTypeInfo and CEnumeratedTypeValues** Revision 1.19  2000/10/20 15:51:43  vasilche* Fixed data error processing.* Added interface for constructing container objects directly into output stream.* object.hpp, object.inl and object.cpp were split to* objectinfo.*, objecttype.*, objectiter.* and objectio.*.** Revision 1.18  2000/10/17 18:45:35  vasilche* Added possibility to turn off object cross reference detection in* CObjectIStream and CObjectOStream.** Revision 1.17  2000/10/13 20:22:56  vasilche* Fixed warnings on 64 bit compilers.* Fixed missing typename in templates.** Revision 1.16  2000/10/13 16:28:40  vasilche* Reduced header dependency.* Avoid use of templates with virtual methods.* Reduced amount of different maps used.* All this lead to smaller compiled code size (libraries and programs).** Revision 1.15  2000/10/05 15:52:51  vasilche* Avoid using snprintf because it's missing on osf1_gcc** Revision 1.14  2000/10/05 13:17:17  vasilche* Added missing #include <stdio.h>** Revision 1.13  2000/10/04 19:19:00  vasilche* Fixed processing floating point data.** Revision 1.12  2000/10/03 17:22:45  vasilche* Reduced header dependency.* Reduced size of debug libraries on WorkShop by 3 times.* Fixed tag allocation for parent classes.* Fixed CObject allocation/deallocation in streams.* Moved instantiation of several templates in separate source file.** Revision 1.11  2000/09/29 16:18:24  vasilche* Fixed binary format encoding/decoding on 64 bit compulers.* Implemented CWeakMap<> for automatic cleaning map entries.* Added cleaning local hooks via CWeakMap<>.* Renamed ReadTypeName -> ReadFileHeader, ENoTypeName -> ENoFileHeader.* Added some user interface methods to CObjectIStream, CObjectOStream and* CObjectStreamCopier.** Revision 1.10  2000/09/26 17:38:22  vasilche* Fixed incomplete choiceptr implementation.* Removed temporary comments.** Revision 1.9  2000/09/18 20:00:25  vasilche* Separated CVariantInfo and CMemberInfo.* Implemented copy hooks.* All hooks now are stored in CTypeInfo/CMemberInfo/CVariantInfo.* Most type specific functions now are implemented via function pointers instead of virtual functions.** Revision 1.8  2000/09/01 13:16:20  vasilche* Implemented class/container/choice iterators.* Implemented CObjectStreamCopier for copying data without loading into memory.** Revision 1.7  2000/08/15 19:44:50  vasilche* Added Read/Write hooks:* CReadObjectHook/CWriteObjectHook for objects of specified type.* CReadClassMemberHook/CWriteClassMemberHook for specified members.* CReadChoiceVariantHook/CWriteChoiceVariant for specified choice variants.* CReadContainerElementHook/CWriteContainerElementsHook for containers.** Revision 1.6  2000/07/03 18:42:46  vasilche* Added interface to typeinfo via CObjectInfo and CConstObjectInfo.* Reduced header dependency.** Revision 1.5  2000/06/16 19:24:22  vasilche* Updated MSVC project.* Fixed error on MSVC with static const class member.** Revision 1.4  2000/06/16 16:31:22  vasilche* Changed implementation of choices and classes info to allow use of the same classes in generated and user written classes.** Revision 1.3  2000/06/07 19:46:00  vasilche* Some code cleaning.* Macros renaming in more clear way.* BEGIN_NAMED_*_INFO, ADD_*_MEMBER, ADD_NAMED_*_MEMBER.** Revision 1.2  2000/06/01 19:07:05  vasilche* Added parsing of XML data.** Revision 1.1  2000/05/24 20:08:49  vasilche* Implemented XML dump.** ===========================================================================*/#include <ncbi_pch.hpp>#include <corelib/ncbistd.hpp>#include <corelib/ncbi_limits.h>#include <serial/objostrxml.hpp>#include <serial/objistr.hpp>#include <serial/objcopy.hpp>#include <serial/memberid.hpp>#include <serial/memberlist.hpp>#include <serial/enumvalues.hpp>#include <serial/objhook.hpp>#include <serial/classinfo.hpp>#include <serial/choice.hpp>#include <serial/continfo.hpp>#include <serial/delaybuf.hpp>#include <serial/ptrinfo.hpp>#include <stdio.h>#include <math.h>BEGIN_NCBI_SCOPECObjectOStream* CObjectOStream::OpenObjectOStreamXml(CNcbiOstream& out,                                                     bool deleteOut){    return new CObjectOStreamXml(out, deleteOut);}string CObjectOStreamXml::sm_DefaultDTDFilePrefix = "";string CObjectOStreamXml::sm_DefaultSchemaNamespace = "http://www.ncbi.nlm.nih.gov";CObjectOStreamXml::CObjectOStreamXml(CNcbiOstream& out, bool deleteOut)    : CObjectOStream(eSerial_Xml, out, deleteOut),      m_LastTagAction(eTagClose), m_EndTag(true),      m_UseDefaultDTDFilePrefix( true),      m_UsePublicId( true),      m_Attlist( false), m_StdXml( false), m_EnforcedStdXml( false),      m_RealFmt( eRealScientificFormat ), m_Encoding( eEncoding_Unknown ),      m_UseSchemaRef( false ), m_UseSchemaLoc( true ), m_UseDTDRef( true ){    m_Output.SetBackLimit(1);}CObjectOStreamXml::~CObjectOStreamXml(void){}void CObjectOStreamXml::SetEncoding(EEncoding enc){    m_Encoding = enc;}CObjectOStreamXml::EEncoding CObjectOStreamXml::GetEncoding(void) const{    return m_Encoding;}void CObjectOStreamXml::SetReferenceSchema(bool use_schema){    m_UseSchemaRef = use_schema;}bool CObjectOStreamXml::GetReferenceSchema(void) const{    return m_UseSchemaRef;}void CObjectOStreamXml::SetReferenceDTD(bool use_dtd){    m_UseDTDRef = use_dtd;}bool CObjectOStreamXml::GetReferenceDTD(void) const{    return m_UseDTDRef;}void CObjectOStreamXml::SetUseSchemaLocation(bool use_loc){    m_UseSchemaLoc = use_loc;}bool CObjectOStreamXml::GetUseSchemaLocation(void) const{    return m_UseSchemaLoc;}CObjectOStreamXml::ERealValueFormat    CObjectOStreamXml::GetRealValueFormat(void) const{    return m_RealFmt;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -