FDO API Reference Feature Data Objects

Serializable.h

Go to the documentation of this file.
00001 #ifndef FDO_XML_SERIALIZABLE_H
00002 #define FDO_XML_SERIALIZABLE_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 /// FdoXmlSerializable provides the ability to serialize an FDO object 
00026 /// to an XML Document. Serialization support can be added to any class by basing
00027 /// it on FdoXmlSerializable and implementing the _writeXml callback.
00028 class FdoXmlSerializable 
00029 {
00030 public:
00031 
00032     /// \brief
00033     /// Writes this object to a file. A complete XML document,
00034     /// containing this object, is written.
00035     /// 
00036     /// \param fileName 
00037     /// Input the file name.
00038     /// \param flags 
00039     /// Input controls the writing of the elements to the document.
00040     /// If NULL then the default flags are used (see FdoXmlFlags::Create())
00041     /// 
00042     FDO_API virtual void WriteXml(
00043         FdoString* fileName, 
00044         FdoXmlFlags* flags = NULL
00045     );
00046 
00047     /// \brief
00048     /// Writes to an XML writer. This object is appended to the XML document
00049     /// being written. Unlike the other WriteXml() functions it is not necessarily 
00050     /// the only object in its document.
00051     /// 
00052     /// \param xmlWriter 
00053     /// Input the XML writer. When this function completes, the
00054     /// XML writer's current position will be just after this object.
00055     /// \param flags 
00056     /// Input controls the writing of the elements to the writer.
00057     /// If NULL then the default flags are used (see FdoXmlFlags::Create())
00058     /// 
00059     FDO_API virtual void WriteXml(
00060         FdoXmlWriter* xmlWriter, 
00061         FdoXmlFlags* flags = NULL
00062     );
00063 
00064     /// \brief
00065     /// Writes to a text writer. A complete XML document,
00066     /// containing this object, is written.
00067     /// 
00068     /// \param textWriter 
00069     /// Input the text writer.When this function completes, the
00070     /// text writer's current position will be just after this object.
00071     /// \param flags 
00072     /// Input controls the writing of the elements to the writer.
00073     /// If NULL then the default flags are used (see FdoXmlFlags::Create())
00074     /// 
00075     FDO_API virtual void WriteXml(
00076         FdoIoTextWriter* textWriter, 
00077         FdoXmlFlags* flags = NULL
00078     );
00079 
00080     /// \brief
00081     /// Writes to a stream. A complete XML document,
00082     /// containing this object, is written.
00083     /// 
00084     /// \param stream 
00085     /// Input the stream. When this function completes, the
00086     /// stream's current position will be just after this object.
00087     /// \param flags 
00088     /// Input controls the writing of the elements to the stream.
00089     /// If NULL then the default flags are used (see FdoXmlFlags::Create())
00090     /// 
00091     FDO_API virtual void WriteXml(
00092         FdoIoStream* stream, 
00093         FdoXmlFlags* flags = NULL
00094     );
00095 
00096     /// \brief
00097     /// Gets the stylesheet for converting the XML document from 
00098     /// internal to external format. When classes derived from FdoXmlSerializable
00099     /// define an internal format, they must override this function to return a
00100     /// stylesheet that does the conversion.
00101     /// 
00102     /// \return
00103     /// Returns NULL by default (no internal format defined)
00104     /// 
00105     FDO_API virtual FdoXmlReader* GetFromInternalStylesheet();
00106 
00107 protected:
00108     /// \brief
00109     /// Callback for writing to XML. Derived classes must implement this function
00110     /// to serialize the class into XML element(s). The class must be written as one 
00111     /// XML element (with 0 or more sub-elements).
00112     /// 
00113     /// \param xmlWriter 
00114     /// Input serialize to this XML writer. FdoXmlWriter provides
00115     /// functions for writing elements and attributes.
00116     /// \param flags 
00117     /// Input the XML flags that were passed to FdoXmlSerializable::WriteXml()
00118     /// 
00119     FDO_API virtual void _writeXml(
00120         FdoXmlWriter* xmlWriter, 
00121         const FdoXmlFlags* flags
00122     ) = 0;
00123 
00124 };
00125 
00126 #endif
00127 
00128 

Comments or suggestions? Send us feedback.