XML.h

00001 //
00002 //  Copyright (c) 2003-2006 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,
00008 //  AS TO THE CORRECTNESS OF THIS CODE OR ANY DERIVATIVE
00009 //  WORKS WHICH INCORPORATE IT.
00010 //
00011 //  AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS
00012 //  AND EXPLICITLY DISCLAIMS ANY LIABILITY, INCLUDING
00013 //  CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00014 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00015 //
00016 //  Use, duplication, or disclosure by the U.S. Government is subject to
00017 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00018 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00019 //  Data and Computer Software), as applicable.
00020 //
00021 #ifndef _DWFCORE_XML_H
00022 #define _DWFCORE_XML_H
00023 
00024 #include "dwfcore/BufferInputStream.h"
00025 #include "dwfcore/String.h"
00026 #include "dwfcore/STL.h"
00027 #include "dwfcore/DWFXMLSerializer.h"
00028 
00029 namespace DWFCore
00030 {
00031 
00044 class DWFXMLCallback
00045 {
00046 
00047 public:
00048 
00054     _DWFCORE_API
00055     virtual ~DWFXMLCallback()
00056         throw()
00057     {
00058         if (_pFilter && _bOwnFilter)
00059         {
00060             DWFCORE_FREE_OBJECT( _pFilter );
00061         }
00062     }
00063 
00087     _DWFCORE_API
00088     virtual void notifyStartElement( const char*    zName,
00089                                      const char**   ppAttributeList )
00090         throw() = 0;
00091 
00099     _DWFCORE_API
00100     virtual void notifyEndElement( const char*      zName )
00101         throw() = 0;
00102 
00113     _DWFCORE_API
00114     virtual void notifyStartNamespace( const char*  zPrefix,
00115                                        const char*  zURI )
00116         throw() = 0;
00117 
00127     _DWFCORE_API
00128     virtual void notifyEndNamespace( const char*    zPrefix )
00129         throw() = 0;
00130 
00146     _DWFCORE_API
00147     virtual void notifyCharacterData( const char*   zCData, 
00148                                       int           nLength ) 
00149         throw() = 0;
00150 
00168     _DWFCORE_API
00169     void setStreamFilter( DWFBufferInputStream*     pFilter,
00170                           bool                      bOwnFilter )
00171         throw()
00172     {
00173         if (_pFilter && _bOwnFilter)
00174         {
00175             DWFCORE_FREE_OBJECT( _pFilter );
00176         }
00177 
00178         _pFilter = pFilter;
00179         _bOwnFilter = bOwnFilter;
00180     }
00181 
00188     _DWFCORE_API
00189     DWFBufferInputStream* getStreamFilter() const
00190         throw()
00191     {
00192         return _pFilter;
00193     }
00194 
00195 protected:
00196 
00202     _DWFCORE_API
00203     DWFXMLCallback()
00204         throw()
00205         : _nElementDepth( 0 )
00206         , _nNamespaceDepth( 0 )
00207         , _pFilter( NULL )
00208         , _bOwnFilter( false )
00209     {;}
00210 
00211 protected:
00212 
00213     unsigned int _nElementDepth;
00214     unsigned int _nNamespaceDepth;
00215 
00216 private:
00217 
00218     DWFBufferInputStream*   _pFilter;
00219     bool                    _bOwnFilter;
00220 };
00221 
00222 
00229 class DWFXMLBuildable
00230 {
00231 
00232 public:
00233 
00238     typedef struct tUnresolved
00239     {
00244         unsigned int    nType;
00248         DWFString       zValue;
00249 
00250         tUnresolved( unsigned int nUnresolveType, const DWFString& zUnresolvedValue )
00251             : nType( nUnresolveType )
00252             , zValue( zUnresolvedValue )
00253         {;}
00254     } tUnresolved;
00255 
00259     typedef std::vector<tUnresolved>  tUnresolvedList;
00260 
00261 public:
00262 
00268     _DWFCORE_API
00269     virtual ~DWFXMLBuildable()
00270         throw()
00271     {;}
00272 
00295     _DWFCORE_API
00296     virtual void parseAttributeList( const char** ppAttributeList )
00297         throw( DWFException ) = 0;
00298 
00309     _DWFCORE_API
00310     virtual void parseAttributeList( const char** ppAttributeList, 
00311                                      tUnresolvedList& rUnresolvedList )
00312         throw( DWFException );
00313 
00314 protected:
00315 
00321     _DWFCORE_API
00322     DWFXMLBuildable()
00323         throw()
00324     {;}
00325 };
00326 
00327 
00334 class DWFXMLNamespaceBase
00335 {
00336 
00337 public:
00338 
00344     _DWFCORE_API
00345     DWFXMLNamespaceBase()
00346         throw()
00347     {;}
00348 
00358     _DWFCORE_API
00359     DWFXMLNamespaceBase( const DWFString& zNamespace, const DWFString& zXMLNS )
00360         throw( DWFException );
00361 
00367     _DWFCORE_API
00368     virtual ~DWFXMLNamespaceBase()
00369         throw()
00370     {;}
00371 
00375     _DWFCORE_API
00376     virtual const DWFString& prefix() const
00377         throw()
00378     {
00379         return _zPrefix;
00380     }
00381 
00385     _DWFCORE_API
00386     virtual const DWFString& xmlns() const
00387         throw()
00388     {
00389         return _zXMLNS;
00390     }
00391 
00392 protected:
00393 
00394     DWFString _zPrefix;
00395     DWFString _zXMLNS;
00396 
00397 };
00398 
00399 
00406 class DWFXMLSerializableBase
00407 {
00408 
00409 public:
00410 
00416     _DWFCORE_API
00417     virtual ~DWFXMLSerializableBase()
00418         throw()
00419     {;}
00420 
00428     _DWFCORE_API
00429     virtual void serializeXML( DWFXMLSerializer& rSerializer, unsigned int nFlags )
00430         throw( DWFException ) = 0;
00431 
00439     _DWFCORE_API
00440     virtual DWFString namespaceXML( unsigned int nFlags ) const
00441         throw() = 0;
00442 
00451     _DWFCORE_API
00452     virtual void setDefaultNamespace( const DWFString& zDefaultNamespace )
00453         throw( DWFException )
00454     {
00455         _zDefaultNamespace.assign( zDefaultNamespace );
00456     }
00457 
00475     _DWFCORE_API
00476     virtual const DWFXMLNamespaceBase& addNamespace( const DWFString& /*zNamespace*/, 
00477                                                      const DWFString& /*zXMLNS*/ )
00478         throw( DWFException )
00479     {
00480         _DWFCORE_THROW( DWFNotImplementedException, /*NOXLATE*/L"This serializable entity does not support additional namespaces." );
00481     }
00482 
00483 protected:
00484 
00493     _DWFCORE_API
00494     DWFXMLSerializableBase( const DWFString& zDefaultNamespace = /*NOXLATE*/L"" )
00495         throw();
00496 
00497 protected:
00498 
00499     DWFString   _zDefaultNamespace;
00500 };
00501 
00502 }
00503 
00504 #endif
00505 

Generated on Tue Jan 6 22:39:29 2009 for Autodesk DWF Core Library by  doxygen 1.4.5