FDO API Reference Feature Data Objects

SaxContext.h

Go to the documentation of this file.
00001 #ifndef FDO_XML_SAXCONTEXT_H
00002 #define FDO_XML_SAXCONTEXT_H
00003 // 
00004 
00005 //
00006 // Copyright (C) 2004-2006  Autodesk, Inc.
00007 // 
00008 // This library is free software; you can redistribute it and/or
00009 // modify it under the terms of version 2.1 of the GNU Lesser
00010 // General Public License as published by the Free Software Foundation.
00011 // 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 // Lesser General Public License for more details.
00016 // 
00017 // You should have received a copy of the GNU Lesser General Public
00018 // License along with this library; if not, write to the Free Software
00019 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 //
00021 
00022 #include <FdoCommon.h>
00023 
00024 class FdoXmlReader;
00025 
00026 /// \brief
00027 /// FdoXmlSaxContext provides contextual information to the 
00028 /// FdoMathUtility callback implementations when an XML document parse
00029 /// is in progress. This class provides very rudimentary functionality such as
00030 /// error reporting and access to the FdoXmlReader doing the parse. Applications
00031 /// can pass extra information by sub-classing from this class.
00032 class FdoXmlSaxContext : public FdoDisposable
00033 {
00034 public:
00035     /// \brief
00036     /// Constructs the default Sax Context
00037     /// 
00038     /// \param reader 
00039     /// Input the FdoXmlReader that is parsing the XML document.
00040     /// 
00041     /// \return
00042     /// Returns FdoXmlSaxContext
00043     /// 
00044     FDO_API_COMMON static FdoXmlSaxContext* Create(FdoXmlReader* reader);
00045 
00046     /// \brief
00047     /// Gets the FdoXmlReader that is parsing the XML document.
00048     /// 
00049     /// \return
00050     /// Returns FdoXmlReader
00051     /// 
00052     FDO_API_COMMON FdoXmlReader* GetReader();
00053 
00054     /// \brief
00055     /// Adds an error to the error list.
00056     /// 
00057     /// \param ex 
00058     /// Input the error to add. 
00059     /// \warning 
00060     /// If this error has a 
00061     /// cause, it will be overridden when thrown (see ThrowErrors()).
00062     /// 
00063     FDO_API_COMMON void AddError( FdoException* ex );
00064 
00065     /// \brief
00066     /// Throws all errors in the error list.
00067     /// The errors are thrown as a chain. The first error is one thrown. The
00068     /// second error is set to be the cause of the first error, the third
00069     /// the cause of the second and so on.
00070     /// 
00071     FDO_API_COMMON void ThrowErrors();
00072 
00073 protected:
00074     /// Default constructor to keep g++ from complaining.
00075     FDO_API_COMMON FdoXmlSaxContext();
00076     FDO_API_COMMON FdoXmlSaxContext(FdoXmlReader* reader);
00077     FDO_API_COMMON virtual ~FdoXmlSaxContext();
00078 
00079 private:
00080     /// Error Collection definition
00081     class Errors : public FdoCollection<FdoException,FdoException>
00082     {
00083     protected:
00084         virtual void Dispose();
00085 
00086         Errors() {}
00087 
00088     public:
00089         static Errors* Create()
00090         {
00091             return new  Errors();
00092         }
00093     };
00094 
00095     /// Error collection
00096     FdoPtr<Errors> mErrors;
00097 
00098     /// Current XML Reader.
00099     FdoXmlReader*  mpReader;
00100 };
00101 
00102 /// \brief
00103 /// FdoXmlSaxContextP is a FdoPtr on FdoXmlSaxContext, provided for convenience.
00104 typedef FdoPtr<FdoXmlSaxContext> FdoXmlSaxContextP;
00105 
00106 #endif
00107 
00108 

Comments or suggestions? Send us feedback.