FDO API Reference | Feature Data Objects |
00001 #ifndef FDO_XML_DESERIALIZABLE_H 00002 #define FDO_XML_DESERIALIZABLE_H 00003 00004 // 00005 // Copyright (C) 2004-2006 Autodesk, Inc. 00006 // 00007 // This library is free software; you can redistribute it and/or 00008 // modify it under the terms of version 2.1 of the GNU Lesser 00009 // General Public License as published by the Free Software Foundation. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 // 00020 00021 #include <FdoStd.h> 00022 #include <Fdo/Xml/Flags.h> 00023 00024 /// \brief 00025 /// FdoXmlDeserializable provides the ability to deserialize an FDO object 00026 /// from an XML Document. Deserialization support can be added to any class by basing 00027 /// it on FdoXmlDeserializable and implementing the FdoXmlSaxHander callbacks. 00028 class FdoXmlDeserializable : public FdoXmlSaxHandler 00029 { 00030 public: 00031 00032 /// \brief 00033 /// Reads from an XML document in a file. 00034 /// 00035 /// \param fileName 00036 /// Input the file name. Must consist of an XML document. 00037 /// \param flags 00038 /// Input controls the reading of the elements from the document. 00039 /// If NULL then the default flags are used (see FdoXmlFlags::Create()) 00040 /// 00041 FDO_API virtual void ReadXml( 00042 FdoString* fileName, 00043 FdoXmlFlags* flags = NULL 00044 ); 00045 00046 /// \brief 00047 /// Reads an XML document from an XML reader. 00048 /// 00049 /// \param reader 00050 /// Input the XML reader. 00051 /// \param flags 00052 /// Input controls the reading of the elements from the document. 00053 /// If NULL then the default flags are used (see FdoXmlFlags::Create()) 00054 /// 00055 FDO_API virtual void ReadXml( 00056 FdoXmlReader* xmlReader, 00057 FdoXmlFlags* flags = NULL 00058 ); 00059 00060 /// \brief 00061 /// Reads an XML document from a text reader. 00062 /// 00063 /// \param reader 00064 /// Input the text reader. Must be positioned at the 00065 /// start of an XML document. 00066 /// \param flags 00067 /// Input controls the reading of the elements from the document. 00068 /// If NULL then the default flags are used (see FdoXmlFlags::Create()) 00069 /// 00070 FDO_API virtual void ReadXml( 00071 FdoIoTextReader* textReader, 00072 FdoXmlFlags* flags = NULL 00073 ); 00074 00075 /// \brief 00076 /// Reads an XML document from a stream. 00077 /// 00078 /// \param reader 00079 /// Input the stream. Must be positioned at the 00080 /// start of an XML document. 00081 /// \param flags 00082 /// Input controls the reading of the elements from the document. 00083 /// If NULL then the default flags are used (see FdoXmlFlags::Create()) 00084 /// 00085 FDO_API virtual void ReadXml( 00086 FdoIoStream* stream, 00087 FdoXmlFlags* flags = NULL 00088 ); 00089 00090 /// \brief 00091 /// Gets the XML Flags that were passed to the ReadXml() 00092 /// function that is currently being executed. This function would 00093 /// typically be called by the FdoXmlSaxHandler callbacks. 00094 /// 00095 /// \return 00096 /// Returns the XML Flags 00097 /// 00098 FDO_API virtual FdoXmlFlags* GetDeserializationFlags(); 00099 00100 /// \brief 00101 /// Gets the current XML Reader. This function would 00102 /// typically be called by the FdoXmlSaxHandler callbacks when 00103 /// ReadXml() is being invoked. When ReadXml() reads from a file, stream, 00104 /// or text reader, a wrapping XML reader is automatically created. 00105 /// 00106 /// \return 00107 /// Returns the XML reader 00108 /// 00109 FDO_API virtual FdoXmlReader* GetXmlReader(); 00110 00111 /// \brief 00112 /// Gets the stylesheet for converting the XML document from 00113 /// external to internal format. When classes derived from FdoXmlDeserializable 00114 /// define an internal format, they must override this function to return a 00115 /// stylesheet that does the conversion. 00116 /// 00117 /// \return 00118 /// Returns NULL by default (no internal format defined) 00119 /// 00120 FDO_API virtual FdoXmlReader* GetFromExternalStylesheet(); 00121 00122 /// \brief 00123 /// Gets the SAX context to pass to the FdoXmlSaxHandler callbacks. 00124 /// Classes derived from FdoXmlDeserializable can override this function to 00125 /// specify a SAX context with class-specific information. 00126 /// 00127 /// \return 00128 /// Returns NULL by default, the default FdoXmlSaxContext is used. 00129 /// The default provides basic error handling functionality. 00130 /// 00131 FDO_API virtual FdoXmlSaxContext* GetSaxContext(); 00132 00133 protected: 00134 FDO_API FdoXmlDeserializable(); 00135 FDO_API virtual ~FdoXmlDeserializable(); 00136 00137 private: 00138 /// current XML flags 00139 FdoXmlFlagsP mFlags; 00140 /// current XML reader 00141 FdoXmlReaderP mInternalReader; 00142 00143 }; 00144 00145 #endif 00146 00147
Comments or suggestions? Send us feedback. |