SAXException.hpp
Go to the documentation of this file.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id$
*/
#if !defined(XERCESC_INCLUDE_GUARD_SAXEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_SAXEXCEPTION_HPP
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/XMLUni.hpp>
#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class SAX_EXPORT SAXException : public XMemory
{
public:
SAXException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
fMsg(XMLString::replicate(XMLUni::fgZeroLenString, manager))
, fMemoryManager(manager)
{
}
SAXException(const XMLCh* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
fMsg(XMLString::replicate(msg, manager))
, fMemoryManager(manager)
{
}
SAXException(const char* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
fMsg(XMLString::transcode(msg, manager))
, fMemoryManager(manager)
{
}
SAXException(const SAXException& toCopy) :
XMemory(toCopy)
, fMsg(XMLString::replicate(toCopy.fMsg, toCopy.fMemoryManager))
, fMemoryManager(toCopy.fMemoryManager)
{
}
virtual ~SAXException()
{
fMemoryManager->deallocate(fMsg);//delete [] fMsg;
}
SAXException& operator=(const SAXException& toCopy)
{
if (this == &toCopy)
return *this;
fMemoryManager->deallocate(fMsg);//delete [] fMsg;
fMsg = XMLString::replicate(toCopy.fMsg, toCopy.fMemoryManager);
fMemoryManager = toCopy.fMemoryManager;
return *this;
}
virtual const XMLCh* getMessage() const
{
return fMsg;
}
protected :
// -----------------------------------------------------------------------
// Protected data members
//
// fMsg
// This is the text of the error that is being thrown.
// -----------------------------------------------------------------------
XMLCh* fMsg;
MemoryManager* fMemoryManager;
};
class SAX_EXPORT SAXNotSupportedException : public SAXException
{
public:
SAXNotSupportedException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
SAXNotSupportedException(const XMLCh* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
SAXNotSupportedException(const char* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
SAXNotSupportedException(const SAXException& toCopy);
};
class SAX_EXPORT SAXNotRecognizedException : public SAXException
{
public:
SAXNotRecognizedException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
SAXNotRecognizedException(const XMLCh* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
SAXNotRecognizedException(const char* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
SAXNotRecognizedException(const SAXException& toCopy);
};
XERCES_CPP_NAMESPACE_END
#endif
SAXException::fMemoryManager
MemoryManager * fMemoryManager
Definition: SAXException.hpp:158
SAXException
Encapsulate a general SAX error or warning.
Definition: SAXException.hpp:51
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:40
SAXException::SAXException
SAXException(const SAXException &toCopy)
Copy constructor.
Definition: SAXException.hpp:102
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XMLUni.hpp
SAXException::operator=
SAXException & operator=(const SAXException &toCopy)
Assignment operator.
Definition: SAXException.hpp:125
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XMLString::replicate
static char * replicate(const char *const toRep, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Replicates a string NOTE: The returned buffer is allocated with the MemoryManager.
SAXException::fMsg
XMLCh * fMsg
Definition: SAXException.hpp:157
SAXNotSupportedException
Definition: SAXException.hpp:161
SAXException::~SAXException
virtual ~SAXException()
Destructor.
Definition: SAXException.hpp:110
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
SAXNotRecognizedException
Definition: SAXException.hpp:195
XMLString.hpp
SAXException::getMessage
virtual const XMLCh * getMessage() const
Get the contents of the message.
Definition: SAXException.hpp:143
SAX_EXPORT
#define SAX_EXPORT
Definition: XercesDefs.hpp:164
SAXException::SAXException
SAXException(const XMLCh *const msg, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Create a new SAXException.
Definition: SAXException.hpp:74
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:39
XMLString
Class for representing native character strings and handling common string operations.
Definition: XMLString.hpp:45
SAXException::SAXException
SAXException(const char *const msg, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Create a new SAXException.
Definition: SAXException.hpp:89
XMLUni
Definition: XMLUni.hpp:44
SAXException::SAXException
SAXException(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Default constructor.
Definition: SAXException.hpp:60
XMemory.hpp