Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

DWFXMLSerializer.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (c) 1996-2005 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 
00019 #ifndef _DWFTK_DWFXMLSERIALIZER_H
00020 #define _DWFTK_DWFXMLSERIALIZER_H
00021 
00022 
00027 
00028 #ifndef DWFTK_READ_ONLY
00029 
00030 
00031 
00032 
00033 #include "dwfcore/STL.h"
00034 #include "dwfcore/UUID.h"
00035 #include "dwfcore/BufferOutputStream.h"
00036 #include "dwfcore/XMLEncodingOutputStream.h"
00037 #include "dwfcore/UTF8EncodingOutputStream.h"
00038 using namespace DWFCore;
00039 
00040 #include "dwf/Toolkit.h"
00041 #include "dwf/package/XML.h"
00042 
00043 
00044 namespace DWFToolkit
00045 {
00046 
00054 class DWFXMLSerializer : public DWFToolkitMemory
00055 {
00056 
00057 public:
00058 
00062     typedef enum
00063     {
00064         eElementOpen = 0x0100
00065 
00066     } teFlags;
00067 
00068 public:
00069 
00077     _DWFTK_API
00078     DWFXMLSerializer( DWFUUID& rUUID )
00079         throw();
00080 
00086     _DWFTK_API
00087     virtual ~DWFXMLSerializer()
00088         throw();
00089 
00098     _DWFTK_API
00099     void attach( DWFOutputStream& rStream )
00100         throw( DWFException );
00101 
00107     _DWFTK_API
00108     void detach()
00109         throw( DWFException );
00110 
00125     _DWFTK_API
00126     const DWFString& nextUUID( bool bSquash )
00127         throw();
00128 
00136     _DWFTK_API
00137     void startElement( const DWFString& zName, const DWFString& zNamespace = L"" )
00138         throw( DWFException );
00139 
00148     _DWFTK_API
00149     void addAttribute( const DWFString& zName, const DWFString& zValue, const DWFString& zNamespace = L"" )
00150         throw( DWFException );
00151 
00158     _DWFTK_API
00159     void addCData( const DWFString& zCData )
00160         throw( DWFException );
00161         
00167     _DWFTK_API
00168     void endElement()
00169         throw( DWFException );
00170 
00171 private:
00172 
00173     class _XMLOutputStream : public DWFBufferOutputStream
00174     {
00175     public:
00176 
00177         _XMLOutputStream( DWFOutputStream& rOutputStream )
00178             throw();
00179 
00180         virtual ~_XMLOutputStream()
00181             throw();
00182 
00183         //
00184         // use this method for publishing the xml data
00185         // it will be encoded correctly
00186         //
00187         size_t writeXML( const void*   pBuffer,
00188                          size_t        nBytesToWrite )
00189             throw( DWFException );
00190 
00191         //
00192         // stream interface - called back into for
00193         // writing to buffer
00194         //
00195         size_t write( const void*   pBuffer,
00196                       size_t        nBytesToWrite )
00197             throw( DWFException );
00198 
00199         //
00200         // toggles XML encoding - certain characters "<", ">", etc
00201         // shouldn't be XML encoded as they are written to the stream
00202         //
00203         void encode( bool bXML = true )
00204         {
00205             _bXML = bXML;
00206         }
00207 
00208     private:
00209 
00210         bool                        _bXML;
00211         DWFXMLEncodingOutputStream  _oXMLStream;
00212         DWFUTF8EncodingOutputStream _oUTF8Stream;
00213     };
00214 
00215 private:
00216 
00217     DWFUUID&            _rUUID;
00218     _XMLOutputStream*   _pStream;
00219 
00220     bool                _bLastElementOpen;
00221     const DWFString*    _pLastElement;
00222     vector<DWFString>   _oDepthChart;
00223 
00224 private:
00225 
00226     //
00227     // Unimplemented methods
00228     //
00229 
00230     DWFXMLSerializer( const DWFXMLSerializer& );
00231     DWFXMLSerializer& operator=( const DWFXMLSerializer& );
00232 };
00233 
00234 }
00235 
00236 
00237 #endif
00238 #endif
00239 

Generated on Tue May 17 12:38:50 2005 for Autodesk DWF Toolkit by  doxygen 1.4.1