Main Page   Class Hierarchy   Compound List   File List   Compound Members  

XMLInternalErrorHandler.hpp

00001 
00002 /*
00003  * The Apache Software License, Version 1.1
00004  *
00005  * Copyright (c) 2001 The Apache Software Foundation.  All rights
00006  * reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  *
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in
00017  *    the documentation and/or other materials provided with the
00018  *    distribution.
00019  *
00020  * 3. The end-user documentation included with the redistribution,
00021  *    if any, must include the following acknowledgment:
00022  *       "This product includes software developed by the
00023  *        Apache Software Foundation (http://www.apache.org/)."
00024  *    Alternately, this acknowledgment may appear in the software itself,
00025  *    if and wherever such third-party acknowledgments normally appear.
00026  *
00027  * 4. The names "Xerces" and "Apache Software Foundation" must
00028  *    not be used to endorse or promote products derived from this
00029  *    software without prior written permission. For written
00030  *    permission, please contact apache\@apache.org.
00031  *
00032  * 5. Products derived from this software may not be called "Apache",
00033  *    nor may "Apache" appear in their name, without prior written
00034  *    permission of the Apache Software Foundation.
00035  *
00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00039  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00040  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00041  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00042  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00043  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00045  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00046  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00047  * SUCH DAMAGE.
00048  * ====================================================================
00049  *
00050  * This software consists of voluntary contributions made by many
00051  * individuals on behalf of the Apache Software Foundation, and was
00052  * originally based on software copyright (c) 1999, International
00053  * Business Machines, Inc., http://www.ibm.com .  For more information
00054  * on the Apache Software Foundation, please see
00055  * <http://www.apache.org/>.
00056  */
00057 
00058 /*
00059  * $Log: XMLInternalErrorHandler.hpp,v $
00060  * Revision 1.1  2002/05/11 20:18:58  bhavani
00061  * CR#CR062582# adding xercesc 1.7 file
00062  *
00063  * Revision 1.1.1.1  2002/02/01 22:21:58  peiyongz
00064  * sane_include
00065  *
00066  * Revision 1.1  2001/07/26 17:04:10  tng
00067  * Schema: Process should stop after fatal error, and user throws need to be rethrown.
00068  *
00069  */
00070 
00071 #include <xercesc/util/XercesDefs.hpp>
00072 #include <xercesc/sax/ErrorHandler.hpp>
00073 
00074 class XMLInternalErrorHandler : public ErrorHandler
00075 {
00076 public:
00077     // -----------------------------------------------------------------------
00078     //  Constructors and Destructor
00079     // -----------------------------------------------------------------------
00080     XMLInternalErrorHandler(ErrorHandler* userHandler = 0) :
00081        fSawWarning(false),
00082        fSawError(false),
00083        fSawFatal(false),
00084        fUserErrorHandler(userHandler)
00085     {
00086     }
00087 
00088     ~XMLInternalErrorHandler()
00089     {
00090     }
00091 
00092     // -----------------------------------------------------------------------
00093     //  Implementation of the error handler interface
00094     // -----------------------------------------------------------------------
00095     void warning(const SAXParseException& toCatch);
00096     void error(const SAXParseException& toCatch);
00097     void fatalError(const SAXParseException& toCatch);
00098     void resetErrors();
00099 
00100     // -----------------------------------------------------------------------
00101     //  Getter methods
00102     // -----------------------------------------------------------------------
00103     bool getSawWarning() const;
00104     bool getSawError() const;
00105     bool getSawFatal() const;
00106 
00107     // -----------------------------------------------------------------------
00108     //  Private data members
00109     //
00110     //  fSawWarning
00111     //      This is set if we get any warning, and is queryable via a getter
00112     //      method.
00113     //
00114     //  fSawError
00115     //      This is set if we get any errors, and is queryable via a getter
00116     //      method.
00117     //
00118     //  fSawFatal
00119     //      This is set if we get any fatal, and is queryable via a getter
00120     //      method.
00121     //
00122     //  fUserErrorHandler
00123     //      This is the error handler from user
00124     // -----------------------------------------------------------------------
00125     bool    fSawWarning;
00126     bool    fSawError;
00127     bool    fSawFatal;
00128     ErrorHandler* fUserErrorHandler;
00129 };
00130 
00131 inline bool XMLInternalErrorHandler::getSawWarning() const
00132 {
00133     return fSawWarning;
00134 }
00135 
00136 inline bool XMLInternalErrorHandler::getSawError() const
00137 {
00138     return fSawError;
00139 }
00140 
00141 inline bool XMLInternalErrorHandler::getSawFatal() const
00142 {
00143     return fSawFatal;
00144 }
00145 
00146 inline void XMLInternalErrorHandler::warning(const SAXParseException& toCatch)
00147 {
00148     fSawWarning = true;
00149     if (fUserErrorHandler)
00150         fUserErrorHandler->warning(toCatch);
00151 }
00152 
00153 inline void XMLInternalErrorHandler::error(const SAXParseException& toCatch)
00154 {
00155     fSawError = true;
00156     if (fUserErrorHandler)
00157         fUserErrorHandler->error(toCatch);
00158 }
00159 
00160 inline void XMLInternalErrorHandler::fatalError(const SAXParseException& toCatch)
00161 {
00162     fSawFatal = true;
00163     if (fUserErrorHandler)
00164         fUserErrorHandler->fatalError(toCatch);
00165 }
00166 
00167 inline void XMLInternalErrorHandler::resetErrors()
00168 {
00169     fSawWarning = false;
00170     fSawError = false;
00171     fSawFatal = false;
00172 }

Generated on Tue Nov 19 09:36:35 2002 by doxygen1.3-rc1