Reordered files in all libs - now all includes are in "libname/include" dir - logical, isn't it? This should break compilation however.

This commit is contained in:
pelya
2010-10-26 14:43:54 +03:00
parent fc58bc53c0
commit 6b9b163689
520 changed files with 41 additions and 43205 deletions

View File

@@ -0,0 +1,229 @@
/*
* 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: AttributeList.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ATTRIBUTELIST_HPP)
#define XERCESC_INCLUDE_GUARD_ATTRIBUTELIST_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Interface for an element's attribute specifications.
*
* The SAX parser implements this interface and passes an instance
* to the SAX application as the second argument of each startElement
* event.
*
* The instance provided will return valid results only during the
* scope of the startElement invocation (to save it for future
* use, the application must make a copy: the AttributeListImpl
* helper class provides a convenient constructor for doing so).
*
* An AttributeList includes only attributes that have been
* specified or defaulted: \#IMPLIED attributes will not be included.
*
* There are two ways for the SAX application to obtain information
* from the AttributeList. First, it can iterate through the entire
* list:
*
* <code>
* public void startElement (String name, AttributeList atts) {<br>
* &nbsp;for (XMLSize_t i = 0; i < atts.getLength(); i++) {<br>
* &nbsp;&nbsp;String name = atts.getName(i);<br>
* &nbsp;&nbsp;String type = atts.getType(i);<br>
* &nbsp;&nbsp;String value = atts.getValue(i);<br>
* &nbsp;&nbsp;[...]<br>
* &nbsp;}<br>
* }
* </code>
*
* (Note that the result of getLength() will be zero if there
* are no attributes.)
*
* As an alternative, the application can request the value or
* type of specific attributes:
*
* <code>
* public void startElement (String name, AttributeList atts) {<br>
* &nbsp;String identifier = atts.getValue("id");<br>
* &nbsp;String label = atts.getValue("label");<br>
* &nbsp;[...]<br>
* }
* </code>
*
* The AttributeListImpl helper class provides a convenience
* implementation for use by parser or application writers.
*
* @see DocumentHandler#startElement
* @see AttributeListImpl#AttributeListImpl
*/
class SAX_EXPORT AttributeList
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
/** Default constructor */
AttributeList()
{
}
/** Destructor */
virtual ~AttributeList()
{
}
//@}
/** @name The virtual attribute list interface */
//@{
/**
* Return the number of attributes in this list.
*
* The SAX parser may provide attributes in any
* arbitrary order, regardless of the order in which they were
* declared or specified. The number of attributes may be
* zero.
*
* @return The number of attributes in the list.
*/
virtual XMLSize_t getLength() const = 0;
/**
* Return the name of an attribute in this list (by position).
*
* The names must be unique: the SAX parser shall not include the
* same attribute twice. Attributes without values (those declared
* \#IMPLIED without a value specified in the start tag) will be
* omitted from the list.
*
* If the attribute name has a namespace prefix, the prefix
* will still be attached.
*
* @param index The index of the attribute in the list (starting at 0).
* @return The name of the indexed attribute, or null
* if the index is out of range.
* @see #getLength
*/
virtual const XMLCh* getName(const XMLSize_t index) const = 0;
/**
* Return the type of an attribute in the list (by position).
*
* The attribute type is one of the strings "CDATA", "ID",
* "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES",
* or "NOTATION" (always in upper case).
*
* If the parser has not read a declaration for the attribute,
* or if the parser does not report attribute types, then it must
* return the value "CDATA" as stated in the XML 1.0 Recommendation
* (clause 3.3.3, "Attribute-Value Normalization").
*
* For an enumerated attribute that is not a notation, the
* parser will report the type as "NMTOKEN".
*
* @param index The index of the attribute in the list (starting at 0).
* @return The attribute type as a string, or
* null if the index is out of range.
* @see #getLength
* @see #getType
*/
virtual const XMLCh* getType(const XMLSize_t index) const = 0;
/**
* Return the value of an attribute in the list (by position).
*
* If the attribute value is a list of tokens (IDREFS,
* ENTITIES, or NMTOKENS), the tokens will be concatenated
* into a single string separated by whitespace.
*
* @param index The index of the attribute in the list (starting at 0).
* @return The attribute value as a string, or
* null if the index is out of range.
* @see #getLength
* @see #getValue
*/
virtual const XMLCh* getValue(const XMLSize_t index) const = 0;
/**
* Return the type of an attribute in the list (by name).
*
* The return value is the same as the return value for
* getType(XMLSize_t).
*
* If the attribute name has a namespace prefix in the document,
* the application must include the prefix here.
*
* @param name The name of the attribute.
* @return The attribute type as a string, or null if no
* such attribute exists.
* @see #getType
*/
virtual const XMLCh* getType(const XMLCh* const name) const = 0;
/**
* Return the value of an attribute in the list (by name).
*
* The return value is the same as the return value for
* getValue(XMLSize_t).
*
* If the attribute name has a namespace prefix in the document,
* the application must include the prefix here.
*
* @param name The name of the attribute in the list.
* @return The attribute value as a string, or null if
* no such attribute exists.
* @see #getValue
*/
virtual const XMLCh* getValue(const XMLCh* const name) const = 0;
/**
* Return the value of an attribute in the list (by name).
*
* The return value is the same as the return value for
* getValue(XMLSize_t).
*
* If the attribute name has a namespace prefix in the document,
* the application must include the prefix here.
*
* @param name The name of the attribute in the list.
* @return The attribute value as a string, or null if
* no such attribute exists.
* @see #getValue
*/
virtual const XMLCh* getValue(const char* const name) const = 0;
//@}
private :
/* Constructors and operators */
/* Copy constructor */
AttributeList(const AttributeList&);
/* Assignment operator */
AttributeList& operator=(const AttributeList&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,159 @@
/*
* 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: DTDHandler.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DTDHANDLER_HPP)
#define XERCESC_INCLUDE_GUARD_DTDHANDLER_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Receive notification of basic DTD-related events.
*
* <p>If a SAX application needs information about notations and
* unparsed entities, then the application implements this
* interface and registers an instance with the SAX parser using
* the parser's setDTDHandler method. The parser uses the
* instance to report notation and unparsed entity declarations to
* the application.</p>
*
* <p>The SAX parser may report these events in any order, regardless
* of the order in which the notations and unparsed entities were
* declared; however, all DTD events must be reported after the
* document handler's startDocument event, and before the first
* startElement event.</p>
*
* <p>It is up to the application to store the information for
* future use (perhaps in a hash table or object tree).
* If the application encounters attributes of type "NOTATION",
* "ENTITY", or "ENTITIES", it can use the information that it
* obtained through this interface to find the entity and/or
* notation corresponding with the attribute value.</p>
*
* <p>The HandlerBase class provides a default implementation
* of this interface, which simply ignores the events.</p>
*
* @see Parser#setDTDHandler
* @see HandlerBase#HandlerBase
*/
class SAX_EXPORT DTDHandler
{
public:
/** @name Constructors and Destructor */
//@{
/** Default Constructor */
DTDHandler()
{
}
/** Destructor */
virtual ~DTDHandler()
{
}
//@}
/** @name The DTD handler interface */
//@{
/**
* Receive notification of a notation declaration event.
*
* <p>It is up to the application to record the notation for later
* reference, if necessary.</p>
*
* <p>If a system identifier is present, and it is a URL, the SAX
* parser must resolve it fully before passing it to the
* application.</p>
*
* @param name The notation name.
* @param publicId The notation's public identifier, or null if
* none was given.
* @param systemId The notation's system identifier, or null if
* none was given.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #unparsedEntityDecl
* @see AttributeList#AttributeList
*/
virtual void notationDecl
(
const XMLCh* const name
, const XMLCh* const publicId
, const XMLCh* const systemId
) = 0;
/**
* Receive notification of an unparsed entity declaration event.
*
* <p>Note that the notation name corresponds to a notation
* reported by the notationDecl() event. It is up to the
* application to record the entity for later reference, if
* necessary.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @param name The unparsed entity's name.
* @param publicId The entity's public identifier, or null if none
* was given.
* @param systemId The entity's system identifier (it must always
* have one).
* @param notationName The name of the associated notation.
* @see #notationDecl
* @see AttributeList#AttributeList
*/
virtual void unparsedEntityDecl
(
const XMLCh* const name
, const XMLCh* const publicId
, const XMLCh* const systemId
, const XMLCh* const notationName
) = 0;
/**
* Reset the DocType object on its reuse
*
* <p>This method helps in reseting the DTD object implementation
* defaults each time the DTD is begun.</p>
*
*/
virtual void resetDocType() = 0;
//@}
private :
/* Unimplemented constructors and operators */
/* Copy constructor */
DTDHandler(const DTDHandler&);
/* Assignment operator */
DTDHandler& operator=(const DTDHandler&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,283 @@
/*
* 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: DocumentHandler.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_DOCUMENTHANDLER_HPP)
#define XERCESC_INCLUDE_GUARD_DOCUMENTHANDLER_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class AttributeList;
class Locator;
/**
* Receive notification of general document events.
*
* <p>This is the main interface that most SAX applications
* implement: if the application needs to be informed of basic parsing
* events, it implements this interface and registers an instance with
* the SAX parser using the setDocumentHandler method. The parser
* uses the instance to report basic document-related events like
* the start and end of elements and character data.</p>
*
* <p>The order of events in this interface is very important, and
* mirrors the order of information in the document itself. For
* example, all of an element's content (character data, processing
* instructions, and/or subelements) will appear, in order, between
* the startElement event and the corresponding endElement event.</p>
*
* <p>Application writers who do not want to implement the entire
* interface while can derive a class from HandlerBase, which implements
* the default functionality; parser writers can instantiate
* HandlerBase to obtain a default handler. The application can find
* the location of any document event using the Locator interface
* supplied by the Parser through the setDocumentLocator method.</p>
*
* @see Parser#setDocumentHandler
* @see Locator#Locator
* @see HandlerBase#HandlerBase
*/
class SAX_EXPORT DocumentHandler
{
public:
/** @name Constructors and Destructor */
//@{
/** Default constructor */
DocumentHandler()
{
}
/** Destructor */
virtual ~DocumentHandler()
{
}
//@}
/** @name The virtual document handler interface */
//@{
/**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param chars The characters from the XML document.
* @param length The number of characters to read from the array.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #ignorableWhitespace
* @see Locator#Locator
*/
virtual void characters
(
const XMLCh* const chars
, const XMLSize_t length
) = 0;
/**
* Receive notification of the end of a document.
*
* <p>The SAX parser will invoke this method only once, and it will
* be the last method invoked during the parse. The parser shall
* not invoke this method until it has either abandoned parsing
* (because of an unrecoverable error) or reached the end of
* input.</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void endDocument () = 0;
/**
* Receive notification of the end of an element.
*
* <p>The SAX parser will invoke this method at the end of every
* element in the XML document; there will be a corresponding
* startElement() event for every endElement() event (even when the
* element is empty).</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached to the name.</p>
*
* @param name The element type name
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void endElement(const XMLCh* const name) = 0;
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>Validating Parsers must use this method to report each chunk
* of ignorable whitespace (see the W3C XML 1.0 recommendation,
* section 2.10): non-validating parsers may also use this method
* if they are capable of parsing and using content models.</p>
*
* <p>SAX parsers may return all contiguous whitespace in a single
* chunk, or they may split it into several chunks; however, all of
* the characters in any single event must come from the same
* external entity, so that the Locator provides useful
* information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* @param chars The characters from the XML document.
* @param length The number of characters to read from the array.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #characters
*/
virtual void ignorableWhitespace
(
const XMLCh* const chars
, const XMLSize_t length
) = 0;
/**
* Receive notification of a processing instruction.
*
* <p>The Parser will invoke this method once for each processing
* instruction found: note that processing instructions may occur
* before or after the main document element.</p>
*
* <p>A SAX parser should never report an XML declaration (XML 1.0,
* section 2.8) or a text declaration (XML 1.0, section 4.3.1)
* using this method.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none was supplied.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void processingInstruction
(
const XMLCh* const target
, const XMLCh* const data
) = 0;
/**
* Reset the Document object on its reuse
*
* <p>This method helps in reseting the document implementation
* defaults each time the document is begun.</p>
*
*/
virtual void resetDocument() = 0;
/**
* Receive an object for locating the origin of SAX document events.
*
* SAX parsers are strongly encouraged (though not absolutely
* required) to supply a locator: if it does so, it must supply
* the locator to the application by invoking this method before
* invoking any of the other methods in the DocumentHandler
* interface.
*
* The locator allows the application to determine the end
* position of any document-related event, even if the parser is
* not reporting an error. Typically, the application will
* use this information for reporting its own errors (such as
* character content that does not match an application's
* business rules). The information returned by the locator
* is probably not sufficient for use with a search engine.
*
* Note that the locator will return correct information only
* during the invocation of the events in this interface. The
* application should not attempt to use it at any other time.
*
* @param locator An object that can return the location of
* any SAX document event. The object is only
* 'on loan' to the client code and they are not
* to attempt to delete or modify it in any way!
*
* @see Locator#Locator
*/
virtual void setDocumentLocator(const Locator* const locator) = 0;
/**
* Receive notification of the beginning of a document.
*
* <p>The SAX parser will invoke this method only once, before any
* other methods in this interface or in DTDHandler (except for
* setDocumentLocator).</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
*/
virtual void startDocument() = 0;
/**
* Receive notification of the beginning of an element.
*
* <p>The Parser will invoke this method at the beginning of every
* element in the XML document; there will be a corresponding
* endElement() event for every startElement() event (even when the
* element is empty). All of the element's content will be
* reported, in order, before the corresponding endElement()
* event.</p>
*
* <p>If the element name has a namespace prefix, the prefix will
* still be attached. Note that the attribute list provided will
* contain only attributes with explicit values (specified or
* defaulted): \#IMPLIED attributes will be omitted.</p>
*
* @param name The element type name.
* @param attrs The attributes attached to the element, if any.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see #endElement
* @see AttributeList#AttributeList
*/
virtual void startElement
(
const XMLCh* const name
, AttributeList& attrs
) = 0;
//@}
private :
/* Unimplemented Constructors and operators */
/* Copy constructor */
DocumentHandler(const DocumentHandler&);
/** Assignment operator */
DocumentHandler& operator=(const DocumentHandler&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,165 @@
/*
* 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: EntityResolver.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ENTITYRESOLVER_HPP)
#define XERCESC_INCLUDE_GUARD_ENTITYRESOLVER_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class InputSource;
/**
* Basic interface for resolving entities.
*
* <p>If a SAX application needs to implement customized handling
* for external entities, it must implement this interface and
* register an instance with the SAX parser using the parser's
* setEntityResolver method.</p>
*
* <p>The parser will then allow the application to intercept any
* external entities (including the external DTD subset and external
* parameter entities, if any) before including them.</p>
*
* <p>Many SAX applications will not need to implement this interface,
* but it will be especially useful for applications that build
* XML documents from databases or other specialised input sources,
* or for applications that use URI types other than URLs.</p>
*
* <p>The following resolver would provide the application
* with a special character stream for the entity with the system
* identifier "http://www.myhost.com/today":</p>
*
*<code>
*\#include <xercesc/sax/EntityResolver.hpp><br>
*\#include <xercesc/sax/InputSource.hpp><br>
*<br>
*class MyResolver : public EntityResolver {<br>
* public:<br>&nbsp;
* InputSource resolveEntity (const XMLCh* const publicId, const XMLCh* const systemId);<br>&nbsp;&nbsp;
* <br>
* ...<br>&nbsp;&nbsp;
* };<br>&nbsp;
*<br>
*&nbsp;MyResolver::resolveEntity {<br>
*&nbsp;&nbsp;if (XMLString::compareString(systemId, "http://www.myhost.com/today")) {<br>
*&nbsp;&nbsp;&nbsp;MyReader* reader = new MyReader();<br>
*&nbsp;&nbsp;&nbsp;return new InputSource(reader);<br>
*&nbsp;&nbsp;} else {<br>
*&nbsp;&nbsp;&nbsp;return null;<br>
*&nbsp;&nbsp;}<br>
*&nbsp;}<br>
*<br>
*</code>
*
* <p>The application can also use this interface to redirect system
* identifiers to local URIs or to look up replacements in a catalog
* (possibly by using the public identifier).</p>
*
* <p>The HandlerBase class implements the default behaviour for
* this interface, which is simply always to return null (to request
* that the parser use the default system identifier).</p>
*
* @see Parser#setEntityResolver
* @see InputSource#InputSource
* @see HandlerBase#HandlerBase
*/
class SAX_EXPORT EntityResolver
{
public:
/** @name Constructors and Destructor */
//@{
/** Default Constructor */
EntityResolver()
{
}
/** Destructor */
virtual ~EntityResolver()
{
}
//@}
/** @name The EntityResolver interface */
//@{
/**
* Allow the application to resolve external entities.
*
* <p>The Parser will call this method before opening any external
* entity except the top-level document entity (including the
* external DTD subset, external entities referenced within the
* DTD, and external entities referenced within the document
* element): the application may request that the parser resolve
* the entity itself, that it use an alternative URI, or that it
* use an entirely different input source.</p>
*
* <p>Application writers can use this method to redirect external
* system identifiers to secure and/or local URIs, to look up
* public identifiers in a catalogue, or to read an entity from a
* database or other input source (including, for example, a dialog
* box).</p>
*
* <p>If the system identifier is a URL, the SAX parser must
* resolve it fully before reporting it to the application.</p>
*
* @param publicId The public identifier of the external entity
* being referenced, or null if none was supplied.
* @param systemId The system identifier of the external entity
* being referenced.
* @return An InputSource object describing the new input source,
* or null to request that the parser open a regular
* URI connection to the system identifier.
* The returned InputSource is owned by the parser which is
* responsible to clean up the memory.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception IOException An IO exception,
* possibly the result of creating a new InputStream
* or Reader for the InputSource.
* @see InputSource#InputSource
*/
virtual InputSource* resolveEntity
(
const XMLCh* const publicId
, const XMLCh* const systemId
) = 0;
//@}
private :
/* Unimplemented constructors and operators */
/* Copy constructor */
EntityResolver(const EntityResolver&);
/* Assignment operator */
EntityResolver& operator=(const EntityResolver&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,168 @@
/*
* 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: ErrorHandler.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_ERRORHANDLER_HPP)
#define XERCESC_INCLUDE_GUARD_ERRORHANDLER_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class SAXParseException;
/**
* Basic interface for SAX error handlers.
*
* <p>If a SAX application needs to implement customized error
* handling, it must implement this interface and then register an
* instance with the SAX parser using the parser's setErrorHandler
* method. The parser will then report all errors and warnings
* through this interface.</p>
*
* <p> The parser shall use this interface instead of throwing an
* exception: it is up to the application whether to throw an
* exception for different types of errors and warnings. Note,
* however, that there is no requirement that the parser continue to
* provide useful information after a call to fatalError (in other
* words, a SAX driver class could catch an exception and report a
* fatalError).</p>
*
* <p>The HandlerBase class provides a default implementation of this
* interface, ignoring warnings and recoverable errors and throwing a
* SAXParseException for fatal errors. An application may extend
* that class rather than implementing the complete interface
* itself.</p>
*
* @see Parser#setErrorHandler
* @see SAXParseException#SAXParseException
* @see HandlerBase#HandlerBase
*/
class SAX_EXPORT ErrorHandler
{
public:
/** @name Constructors and Destructor */
//@{
/** Default constructor */
ErrorHandler()
{
}
/** Destructor */
virtual ~ErrorHandler()
{
}
//@}
/** @name The error handler interface */
//@{
/**
* Receive notification of a warning.
*
* <p>SAX parsers will use this method to report conditions that
* are not errors or fatal errors as defined by the XML 1.0
* recommendation. The default behaviour is to take no action.</p>
*
* <p>The SAX parser must continue to provide normal parsing events
* after invoking this method: it should still be possible for the
* application to process the document through to the end.</p>
*
* @param exc The warning information encapsulated in a
* SAX parse exception.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see SAXParseException#SAXParseException
*/
virtual void warning(const SAXParseException& exc) = 0;
/**
* Receive notification of a recoverable error.
*
* <p>This corresponds to the definition of "error" in section 1.2
* of the W3C XML 1.0 Recommendation. For example, a validating
* parser would use this callback to report the violation of a
* validity constraint. The default behaviour is to take no
* action.</p>
*
* <p>The SAX parser must continue to provide normal parsing events
* after invoking this method: it should still be possible for the
* application to process the document through to the end. If the
* application cannot do so, then the parser should report a fatal
* error even if the XML 1.0 recommendation does not require it to
* do so.</p>
*
* @param exc The error information encapsulated in a
* SAX parse exception.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see SAXParseException#SAXParseException
*/
virtual void error(const SAXParseException& exc) = 0;
/**
* Receive notification of a non-recoverable error.
*
* <p>This corresponds to the definition of "fatal error" in
* section 1.2 of the W3C XML 1.0 Recommendation. For example, a
* parser would use this callback to report the violation of a
* well-formedness constraint.</p>
*
* <p>The application must assume that the document is unusable
* after the parser has invoked this method, and should continue
* (if at all) only for the sake of collecting addition error
* messages: in fact, SAX parsers are free to stop reporting any
* other events once this method has been invoked.</p>
*
* @param exc The error information encapsulated in a
* SAX parse exception.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see SAXParseException#SAXParseException
*/
virtual void fatalError(const SAXParseException& exc) = 0;
/**
* Reset the Error handler object on its reuse
*
* <p>This method helps in reseting the Error handler object
* implementation defaults each time the Error handler is begun.</p>
*
*/
virtual void resetErrors() = 0;
//@}
private :
/* Unimplemented constructors and operators */
/* Copy constructor */
ErrorHandler(const ErrorHandler&);
/* Assignment operator */
ErrorHandler& operator=(const ErrorHandler&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,466 @@
/*
* 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: HandlerBase.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_HANDLERBASE_HPP)
#define XERCESC_INCLUDE_GUARD_HANDLERBASE_HPP
#include <xercesc/sax/DocumentHandler.hpp>
#include <xercesc/sax/DTDHandler.hpp>
#include <xercesc/sax/EntityResolver.hpp>
#include <xercesc/sax/ErrorHandler.hpp>
#include <xercesc/sax/SAXParseException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class Locator;
class AttributeList;
/**
* Default base class for handlers.
*
* <p>This class implements the default behaviour for four SAX
* interfaces: EntityResolver, DTDHandler, DocumentHandler,
* and ErrorHandler.</p>
*
* <p>Application writers can extend this class when they need to
* implement only part of an interface; parser writers can
* instantiate this class to provide default handlers when the
* application has not supplied its own.</p>
*
* <p>Note that the use of this class is optional.</p>
*
* @see EntityResolver#EntityResolver
* @see DTDHandler#DTDHandler
* @see DocumentHandler#DocumentHandler
* @see ErrorHandler#ErrorHandler
*/
class SAX_EXPORT HandlerBase :
public EntityResolver, public DTDHandler, public DocumentHandler
, public ErrorHandler
{
public:
/** @name Default handlers for the DocumentHandler interface */
//@{
/**
* Receive notification of character data inside an element.
*
* <p>By default, do nothing. Application writers may override this
* method to take specific actions for each chunk of character data
* (such as adding the data to a node or buffer, or printing it to
* a file).</p>
*
* @param chars The characters.
* @param length The number of characters to use from the
* character array.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#characters
*/
virtual void characters
(
const XMLCh* const chars
, const XMLSize_t length
);
/**
* Receive notification of the end of the document.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the beginning
* of a document (such as finalising a tree or closing an output
* file).</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#endDocument
*/
virtual void endDocument();
/**
* Receive notification of the end of an element.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the end of
* each element (such as finalising a tree node or writing
* output to a file).</p>
*
* @param name The element type name.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#endElement
*/
virtual void endElement(const XMLCh* const name);
/**
* Receive notification of ignorable whitespace in element content.
*
* <p>By default, do nothing. Application writers may override this
* method to take specific actions for each chunk of ignorable
* whitespace (such as adding data to a node or buffer, or printing
* it to a file).</p>
*
* @param chars The whitespace characters.
* @param length The number of characters to use from the
* character array.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#ignorableWhitespace
*/
virtual void ignorableWhitespace
(
const XMLCh* const chars
, const XMLSize_t length
);
/**
* Receive notification of a processing instruction.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions for each
* processing instruction, such as setting status variables or
* invoking other methods.</p>
*
* @param target The processing instruction target.
* @param data The processing instruction data, or null if
* none is supplied.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#processingInstruction
*/
virtual void processingInstruction
(
const XMLCh* const target
, const XMLCh* const data
);
/**
* Reset the Document object on its reuse
*
* @see DocumentHandler#resetDocument
*/
virtual void resetDocument();
//@}
/** @name Default implementation of DocumentHandler interface */
//@{
/**
* Receive a Locator object for document events.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass if they wish to store the locator for use
* with other document events.</p>
*
* @param locator A locator for all SAX document events.
* @see DocumentHandler#setDocumentLocator
* @see Locator
*/
virtual void setDocumentLocator(const Locator* const locator);
/**
* Receive notification of the beginning of the document.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the beginning
* of a document (such as allocating the root node of a tree or
* creating an output file).</p>
*
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#startDocument
*/
virtual void startDocument();
/**
* Receive notification of the start of an element.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to take specific actions at the start of
* each element (such as allocating a new tree node or writing
* output to a file).</p>
*
* @param name The element type name.
* @param attributes The specified or defaulted attributes.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see DocumentHandler#startElement
*/
virtual void startElement
(
const XMLCh* const name
, AttributeList& attributes
);
//@}
/** @name Default implementation of the EntityResolver interface. */
//@{
/**
* Resolve an external entity.
*
* <p>Always return null, so that the parser will use the system
* identifier provided in the XML document. This method implements
* the SAX default behaviour: application writers can override it
* in a subclass to do special translations such as catalog lookups
* or URI redirection.</p>
*
* @param publicId The public identifier, or null if none is
* available.
* @param systemId The system identifier provided in the XML
* document.
* @return The new input source, or null to require the
* default behaviour.
* The returned InputSource is owned by the parser which is
* responsible to clean up the memory.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see EntityResolver#resolveEntity
*/
virtual InputSource* resolveEntity
(
const XMLCh* const publicId
, const XMLCh* const systemId
);
//@}
/** @name Default implementation of the ErrorHandler interface */
//@{
/**
* Receive notification of a recoverable parser error.
*
* <p>The default implementation does nothing. Application writers
* may override this method in a subclass to take specific actions
* for each error, such as inserting the message in a log file or
* printing it to the console.</p>
*
* @param exc The warning information encoded as an exception.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see ErrorHandler#warning
* @see SAXParseException#SAXParseException
*/
virtual void error(const SAXParseException& exc);
/**
* Report a fatal XML parsing error.
*
* <p>The default implementation throws a SAXParseException.
* Application writers may override this method in a subclass if
* they need to take specific actions for each fatal error (such as
* collecting all of the errors into a single report): in any case,
* the application must stop all regular processing when this
* method is invoked, since the document is no longer reliable, and
* the parser may no longer report parsing events.</p>
*
* @param exc The error information encoded as an exception.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see ErrorHandler#fatalError
* @see SAXParseException#SAXParseException
*/
virtual void fatalError(const SAXParseException& exc);
/**
* Receive notification of a parser warning.
*
* <p>The default implementation does nothing. Application writers
* may override this method in a subclass to take specific actions
* for each warning, such as inserting the message in a log file or
* printing it to the console.</p>
*
* @param exc The warning information encoded as an exception.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @see ErrorHandler#warning
* @see SAXParseException#SAXParseException
*/
virtual void warning(const SAXParseException& exc);
/**
* Reset the Error handler object on its reuse
*
* @see ErrorHandler#resetErrors
*/
virtual void resetErrors();
//@}
/** @name Default implementation of DTDHandler interface. */
//@{
/**
* Receive notification of a notation declaration.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass if they wish to keep track of the notations
* declared in a document.</p>
*
* @param name The notation name.
* @param publicId The notation public identifier, or null if not
* available.
* @param systemId The notation system identifier.
* @see DTDHandler#notationDecl
*/
virtual void notationDecl
(
const XMLCh* const name
, const XMLCh* const publicId
, const XMLCh* const systemId
);
/**
* Reset the DTD object on its reuse
*
* @see DTDHandler#resetDocType
*/
virtual void resetDocType();
/**
* Receive notification of an unparsed entity declaration.
*
* <p>By default, do nothing. Application writers may override this
* method in a subclass to keep track of the unparsed entities
* declared in a document.</p>
*
* @param name The entity name.
* @param publicId The entity public identifier, or null if not
* available.
* @param systemId The entity system identifier.
* @param notationName The name of the associated notation.
* @see DTDHandler#unparsedEntityDecl
*/
virtual void unparsedEntityDecl
(
const XMLCh* const name
, const XMLCh* const publicId
, const XMLCh* const systemId
, const XMLCh* const notationName
);
//@}
HandlerBase() {};
virtual ~HandlerBase() {};
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
HandlerBase(const HandlerBase&);
HandlerBase& operator=(const HandlerBase&);
};
// ---------------------------------------------------------------------------
// HandlerBase: Inline default implementations
// ---------------------------------------------------------------------------
inline void HandlerBase::characters(const XMLCh* const
, const XMLSize_t)
{
}
inline void HandlerBase::endDocument()
{
}
inline void HandlerBase::endElement(const XMLCh* const)
{
}
inline void HandlerBase::error(const SAXParseException&)
{
}
inline void HandlerBase::fatalError(const SAXParseException& exc)
{
throw exc;
}
inline void
HandlerBase::ignorableWhitespace( const XMLCh* const
, const XMLSize_t)
{
}
inline void HandlerBase::notationDecl( const XMLCh* const
, const XMLCh* const
, const XMLCh* const)
{
}
inline void
HandlerBase::processingInstruction( const XMLCh* const
, const XMLCh* const)
{
}
inline void HandlerBase::resetErrors()
{
}
inline void HandlerBase::resetDocument()
{
}
inline void HandlerBase::resetDocType()
{
}
inline InputSource*
HandlerBase::resolveEntity( const XMLCh* const
, const XMLCh* const)
{
return 0;
}
inline void
HandlerBase::unparsedEntityDecl(const XMLCh* const
, const XMLCh* const
, const XMLCh* const
, const XMLCh* const)
{
}
inline void HandlerBase::setDocumentLocator(const Locator* const)
{
}
inline void HandlerBase::startDocument()
{
}
inline void
HandlerBase::startElement( const XMLCh* const
, AttributeList&)
{
}
inline void HandlerBase::warning(const SAXParseException&)
{
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,337 @@
/*
* 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: InputSource.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_INPUTSOURCE_HPP)
#define XERCESC_INCLUDE_GUARD_INPUTSOURCE_HPP
#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class BinInputStream;
/**
* A single input source for an XML entity.
*
* <p>This class encapsulates information about an input source in a
* single object, which may include a public identifier or a system
* identifier</p>
*
* <p>There are two places that the application will deliver this input
* source to the parser: as the argument to the Parser::parse method, or as
* the return value of the EntityResolver::resolveEntity method.</p>
*
* <p>InputSource is never used directly, but is the base class for a number
* of derived classes for particular types of input sources. Derivatives are
* provided (in the framework/ directory) for URL input sources, memory buffer
* input sources, and so on.</p>
*
* <p>When it is time to parse the input described by an input source, it
* will be asked to create a binary stream for that source. That stream will
* be used to input the data of the source. The derived class provides the
* implementation of the makeStream() method, and provides a type of stream
* of the correct type for the input source it represents.
*
* <p>An InputSource object belongs to the application: the parser never
* modifies them in any way. They are always passed by const reference so
* the parser will make a copy of any input sources that it must keep
* around beyond the call.</p>
*
* @see Parser#parse
* @see EntityResolver#resolveEntity
*/
class SAX_EXPORT InputSource : public XMemory
{
public:
// -----------------------------------------------------------------------
// All constructors are hidden, just the destructor is available
// -----------------------------------------------------------------------
/** @name Destructor */
//@{
/**
* Destructor
*
*/
virtual ~InputSource();
//@}
// -----------------------------------------------------------------------
/** @name Virtual input source interface */
//@{
/**
* Makes the byte stream for this input source.
*
* <p>The derived class must create and return a binary input stream of an
* appropriate type for its kind of data source. The returned stream must
* be dynamically allocated and becomes the parser's property.
* </p>
*
* @see BinInputStream
*/
virtual BinInputStream* makeStream() const = 0;
//@}
// -----------------------------------------------------------------------
/** @name Getter methods */
//@{
/**
* An input source can be set to force the parser to assume a particular
* encoding for the data that input source represents, via the setEncoding()
* method. This method returns name of the encoding that is to be forced.
* If the encoding has never been forced, it returns a null pointer.
*
* @return The forced encoding, or null if none was supplied.
* @see #setEncoding
*/
virtual const XMLCh* getEncoding() const;
/**
* Get the public identifier for this input source.
*
* @return The public identifier, or null if none was supplied.
* @see #setPublicId
*/
virtual const XMLCh* getPublicId() const;
/**
* Get the system identifier for this input source.
*
* <p>If the system ID is a URL, it will be fully resolved.</p>
*
* @return The system identifier.
* @see #setSystemId
*/
virtual const XMLCh* getSystemId() const;
/**
* Get the flag that indicates if the parser should issue fatal error if this input source
* is not found.
*
* @return True if the parser should issue fatal error if this input source is not found.
* False if the parser issue warning message instead.
* @see #setIssueFatalErrorIfNotFound
*/
virtual bool getIssueFatalErrorIfNotFound() const;
MemoryManager* getMemoryManager() const;
//@}
// -----------------------------------------------------------------------
/** @name Setter methods */
//@{
/**
* Set the encoding which will be required for use with the XML text read
* via a stream opened by this input source.
*
* <p>This is usually not set, allowing the encoding to be sensed in the
* usual XML way. However, in some cases, the encoding in the file is known
* to be incorrect because of intermediate transcoding, for instance
* encapsulation within a MIME document.
*
* @param encodingStr The name of the encoding to force.
*/
virtual void setEncoding(const XMLCh* const encodingStr);
/**
* Set the public identifier for this input source.
*
* <p>The public identifier is always optional: if the application writer
* includes one, it will be provided as part of the location information.</p>
*
* @param publicId The public identifier as a string.
* @see Locator#getPublicId
* @see SAXParseException#getPublicId
* @see #getPublicId
*/
virtual void setPublicId(const XMLCh* const publicId);
/**
* Set the system identifier for this input source.
*
* <p>Set the system identifier for this input source.
*
* </p>The system id is always required. The public id may be used to map
* to another system id, but the system id must always be present as a fall
* back.
*
* <p>If the system ID is a URL, it must be fully resolved.</p>
*
* @param systemId The system identifier as a string.
* @see #getSystemId
* @see Locator#getSystemId
* @see SAXParseException#getSystemId
*/
virtual void setSystemId(const XMLCh* const systemId);
/**
* Indicates if the parser should issue fatal error if this input source
* is not found. If set to false, the parser issue warning message instead.
*
* @param flag True if the parser should issue fatal error if this input source is not found.
* If set to false, the parser issue warning message instead. (Default: true)
*
* @see #getIssueFatalErrorIfNotFound
*/
virtual void setIssueFatalErrorIfNotFound(const bool flag);
//@}
protected :
// -----------------------------------------------------------------------
// Hidden constructors
// -----------------------------------------------------------------------
/** @name Constructors and Destructor */
//@{
/** Default constructor */
InputSource(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Constructor with a system identifier as XMLCh type.
* @param systemId The system identifier (URI).
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
InputSource(const XMLCh* const systemId,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Constructor with a system and public identifiers
* @param systemId The system identifier (URI).
* @param publicId The public identifier as in the entity definition.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
InputSource
(
const XMLCh* const systemId
, const XMLCh* const publicId
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/** Constructor witha system identifier as string
* @param systemId The system identifier (URI).
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
InputSource(const char* const systemId,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/** Constructor witha system and public identifiers. Both as string
* @param systemId The system identifier (URI).
* @param publicId The public identifier as in the entity definition.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
InputSource
(
const char* const systemId
, const char* const publicId
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
//@}
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
InputSource(const InputSource&);
InputSource& operator=(const InputSource&);
// -----------------------------------------------------------------------
// Private data members
//
// fEncoding
// This is the encoding to use. Usually this is null, which means
// to use the information found in the file itself. But, if set,
// this encoding will be used without question.
//
// fPublicId
// This is the optional public id for the input source. It can be
// null if none is desired.
//
// fSystemId
// This is the system id for the input source. This is what is
// actually used to open the source.
//
// fFatalErrorIfNotFound
// -----------------------------------------------------------------------
MemoryManager* const fMemoryManager;
XMLCh* fEncoding;
XMLCh* fPublicId;
XMLCh* fSystemId;
bool fFatalErrorIfNotFound;
};
// ---------------------------------------------------------------------------
// InputSource: Getter methods
// ---------------------------------------------------------------------------
inline const XMLCh* InputSource::getEncoding() const
{
return fEncoding;
}
inline const XMLCh* InputSource::getPublicId() const
{
return fPublicId;
}
inline const XMLCh* InputSource::getSystemId() const
{
return fSystemId;
}
inline bool InputSource::getIssueFatalErrorIfNotFound() const
{
return fFatalErrorIfNotFound;
}
inline MemoryManager* InputSource::getMemoryManager() const
{
return fMemoryManager;
}
// ---------------------------------------------------------------------------
// InputSource: Setter methods
// ---------------------------------------------------------------------------
inline void InputSource::setIssueFatalErrorIfNotFound(const bool flag)
{
fFatalErrorIfNotFound = flag;
}
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,125 @@
/*
* 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: Locator.hpp 672273 2008-06-27 13:57:00Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_LOCATOR_HPP)
#define XERCESC_INCLUDE_GUARD_LOCATOR_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
/**
* Interface for associating a SAX event with a document location.
*
* <p>If a SAX parser provides location information to the SAX
* application, it does so by implementing this interface and then
* passing an instance to the application using the document
* handler's setDocumentLocator method. The application can use the
* object to obtain the location of any other document handler event
* in the XML source document.</p>
*
* <p>Note that the results returned by the object will be valid only
* during the scope of each document handler method: the application
* will receive unpredictable results if it attempts to use the
* locator at any other time.</p>
*
* <p>SAX parsers are not required to supply a locator, but they are
* very strong encouraged to do so. If the parser supplies a
* locator, it must do so before reporting any other document events.
* If no locator has been set by the time the application receives
* the startDocument event, the application should assume that a
* locator is not available.</p>
*
* @see DocumentHandler#setDocumentLocator
*/
class SAX_EXPORT Locator
{
public:
/** @name Constructors and Destructor */
//@{
/** Default constructor */
Locator()
{
}
/** Destructor */
virtual ~Locator()
{
}
//@}
/** @name The locator interface */
//@{
/**
* Return the public identifier for the current document event.
* <p>This will be the public identifier
* @return A string containing the public identifier, or
* null if none is available.
* @see #getSystemId
*/
virtual const XMLCh* getPublicId() const = 0;
/**
* Return the system identifier for the current document event.
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before passing it to the application.</p>
*
* @return A string containing the system identifier, or null
* if none is available.
* @see #getPublicId
*/
virtual const XMLCh* getSystemId() const = 0;
/**
* Return the line number where the current document event ends.
* Note that this is the line position of the first character
* after the text associated with the document event.
* @return The line number, or 0 if none is available.
* @see #getColumnNumber
*/
virtual XMLFileLoc getLineNumber() const = 0;
/**
* Return the column number where the current document event ends.
* Note that this is the column number of the first
* character after the text associated with the document
* event. The first column in a line is position 1.
* @return The column number, or 0 if none is available.
* @see #getLineNumber
*/
virtual XMLFileLoc getColumnNumber() const = 0;
//@}
private :
/* Copy constructor */
Locator(const Locator&);
/* Assignment operator */
Locator& operator=(const Locator&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,245 @@
/*
* 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: Parser.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#if !defined(XERCESC_INCLUDE_GUARD_PARSER_HPP)
#define XERCESC_INCLUDE_GUARD_PARSER_HPP
#include <xercesc/util/XercesDefs.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class DTDHandler;
class EntityResolver;
class DocumentHandler;
class ErrorHandler;
class InputSource;
/**
* Basic interface for SAX (Simple API for XML) parsers.
*
* All SAX parsers must implement this basic interface: it allows
* applications to register handlers for different types of events
* and to initiate a parse from a URI, or a character stream.
*
* All SAX parsers must also implement a zero-argument constructor
* (though other constructors are also allowed).
*
* SAX parsers are reusable but not re-entrant: the application
* may reuse a parser object (possibly with a different input source)
* once the first parse has completed successfully, but it may not
* invoke the parse() methods recursively within a parse.
*
* @see EntityResolver#EntityResolver
* @see DTDHandler#DTDHandler
* @see DocumentHandler#DocumentHandler
* @see ErrorHandler#ErrorHandler
* @see HandlerBase#HandlerBase
* @see InputSource#InputSource
*/
#include <xercesc/util/XercesDefs.hpp>
class SAX_EXPORT Parser
{
public:
/** @name Constructors and Destructor */
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
//@{
/** The default constructor */
Parser()
{
}
/** The destructor */
virtual ~Parser()
{
}
//@}
//-----------------------------------------------------------------------
// The parser interface
//-----------------------------------------------------------------------
/** @name The parser interfaces */
//@{
/**
* Allow an application to register a custom entity resolver.
*
* If the application does not register an entity resolver, the
* SAX parser will resolve system identifiers and open connections
* to entities itself (this is the default behaviour implemented in
* HandlerBase).
*
* Applications may register a new or different entity resolver
* in the middle of a parse, and the SAX parser must begin using
* the new resolver immediately.
*
* @param resolver The object for resolving entities.
* @see EntityResolver#EntityResolver
* @see HandlerBase#HandlerBase
*/
virtual void setEntityResolver(EntityResolver* const resolver) = 0;
/**
* Allow an application to register a DTD event handler.
*
* If the application does not register a DTD handler, all DTD
* events reported by the SAX parser will be silently ignored (this
* is the default behaviour implemented by HandlerBase).
*
* Applications may register a new or different handler in the middle
* of a parse, and the SAX parser must begin using the new handler
* immediately.
*
* @param handler The DTD handler.
* @see DTDHandler#DTDHandler
* @see HandlerBase#HandlerBase
*/
virtual void setDTDHandler(DTDHandler* const handler) = 0;
/**
* Allow an application to register a document event handler.
*
* If the application does not register a document handler, all
* document events reported by the SAX parser will be silently
* ignored (this is the default behaviour implemented by
* HandlerBase).
*
* Applications may register a new or different handler in the
* middle of a parse, and the SAX parser must begin using the new
* handler immediately.
*
* @param handler The document handler.
* @see DocumentHandler#DocumentHandler
* @see HandlerBase#HandlerBase
*/
virtual void setDocumentHandler(DocumentHandler* const handler) = 0;
/**
* Allow an application to register an error event handler.
*
* If the application does not register an error event handler,
* all error events reported by the SAX parser will be silently
* ignored, except for fatalError, which will throw a SAXException
* (this is the default behaviour implemented by HandlerBase).
*
* Applications may register a new or different handler in the
* middle of a parse, and the SAX parser must begin using the new
* handler immediately.
*
* @param handler The error handler.
* @see ErrorHandler#ErrorHandler
* @see SAXException#SAXException
* @see HandlerBase#HandlerBase
*/
virtual void setErrorHandler(ErrorHandler* const handler) = 0;
/**
* Parse an XML document.
*
* The application can use this method to instruct the SAX parser
* to begin parsing an XML document from any valid input
* source (a character stream, a byte stream, or a URI).
*
* Applications may not invoke this method while a parse is in
* progress (they should create a new Parser instead for each
* additional XML document). Once a parse is complete, an
* application may reuse the same Parser object, possibly with a
* different input source.
*
* @param source The input source for the top-level of the
* XML document.
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception XMLException An exception from the parser or client
* handler code.
* @see InputSource#InputSource
* @see #setEntityResolver
* @see #setDTDHandler
* @see #setDocumentHandler
* @see #setErrorHandler
*/
virtual void parse
(
const InputSource& source
) = 0;
/**
* Parse an XML document from a system identifier (URI).
*
* This method is a shortcut for the common case of reading a
* document from a system identifier. It is the exact equivalent
* of the following:
*
* parse(new URLInputSource(systemId));
*
* If the system identifier is a URL, it must be fully resolved
* by the application before it is passed to the parser.
*
* @param systemId The system identifier (URI).
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception XMLException An exception from the parser or client
* handler code.
* @see #parse(const InputSource&)
*/
virtual void parse
(
const XMLCh* const systemId
) = 0;
/**
* Parse an XML document from a system identifier (URI).
*
* This method is a shortcut for the common case of reading a
* document from a system identifier. It is the exact equivalent
* of the following:
*
* parse(new URLInputSource(systemId));
*
* If the system identifier is a URL, it must be fully resolved
* by the application before it is passed to the parser.
*
* @param systemId The system identifier (URI).
* @exception SAXException Any SAX exception, possibly
* wrapping another exception.
* @exception XMLException An exception from the parser or client
* handler code.
* @see #parse(const InputSource&)
*/
virtual void parse
(
const char* const systemId
) = 0;
//@}
private :
/* The copy constructor, you cannot call this directly */
Parser(const Parser&);
/* The assignment operator, you cannot call this directly */
Parser& operator=(const Parser&);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,230 @@
/*
* 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: SAXException.hpp 527149 2007-04-10 14:56:39Z amassari $
*/
#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
/**
* Encapsulate a general SAX error or warning.
*
* <p>This class can contain basic error or warning information from
* either the XML SAX parser or the application: a parser writer or
* application writer can subclass it to provide additional
* functionality. SAX handlers may throw this exception or
* any exception subclassed from it.</p>
*
* <p>If the application needs to pass through other types of
* exceptions, it must wrap those exceptions in a SAXException
* or an exception derived from a SAXException.</p>
*
* <p>If the parser or application needs to include information
* about a specific location in an XML document, it should use the
* SAXParseException subclass.</p>
*
* @see SAXParseException#SAXParseException
*/
class SAX_EXPORT SAXException : public XMemory
{
public:
/** @name Constructors and Destructor */
//@{
/** Default constructor
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
SAXException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
fMsg(XMLString::replicate(XMLUni::fgZeroLenString, manager))
, fMemoryManager(manager)
{
}
/**
* Create a new SAXException.
*
* @param msg The error or warning message.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
SAXException(const XMLCh* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
fMsg(XMLString::replicate(msg, manager))
, fMemoryManager(manager)
{
}
/**
* Create a new SAXException.
*
* @param msg The error or warning message.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
SAXException(const char* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
fMsg(XMLString::transcode(msg, manager))
, fMemoryManager(manager)
{
}
/**
* Copy constructor
*
* @param toCopy The exception to be copy constructed
*/
SAXException(const SAXException& toCopy) :
XMemory(toCopy)
, fMsg(XMLString::replicate(toCopy.fMsg, toCopy.fMemoryManager))
, fMemoryManager(toCopy.fMemoryManager)
{
}
/** Destructor */
virtual ~SAXException()
{
fMemoryManager->deallocate(fMsg);//delete [] fMsg;
}
//@}
/** @name Public Operators */
//@{
/**
* Assignment operator
*
* @param toCopy The object to be copied
*/
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;
}
//@}
/** @name Getter Methods */
//@{
/**
* Get the contents of the message
*
*/
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);
/**
* Create a new SAXException.
*
* @param msg The error or warning message.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
SAXNotSupportedException(const XMLCh* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/**
* Create a new SAXException.
*
* @param msg The error or warning message.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
SAXNotSupportedException(const char* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/**
* Copy constructor
*
* @param toCopy The exception to be copy constructed
*/
SAXNotSupportedException(const SAXException& toCopy);
};
class SAX_EXPORT SAXNotRecognizedException : public SAXException
{
public:
SAXNotRecognizedException(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/**
* Create a new SAXException.
*
* @param msg The error or warning message.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
SAXNotRecognizedException(const XMLCh* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/**
* Create a new SAXException.
*
* @param msg The error or warning message.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
*/
SAXNotRecognizedException(const char* const msg,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/**
* Copy constructor
*
* @param toCopy The exception to be copy constructed
*/
SAXNotRecognizedException(const SAXException& toCopy);
};
XERCES_CPP_NAMESPACE_END
#endif

View File

@@ -0,0 +1,185 @@
/*
* 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: SAXParseException.hpp 932887 2010-04-11 13:04:59Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_SAXPARSEEXCEPTION_HPP)
#define XERCESC_INCLUDE_GUARD_SAXPARSEEXCEPTION_HPP
#include <xercesc/sax/SAXException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class Locator;
/**
* Encapsulate an XML parse error or warning.
*
* <p>This exception will include information for locating the error
* in the original XML document. Note that although the application
* will receive a SAXParseException as the argument to the handlers
* in the ErrorHandler interface, the application is not actually
* required to throw the exception; instead, it can simply read the
* information in it and take a different action.</p>
*
* <p>Since this exception is a subclass of SAXException, it
* inherits the ability to wrap another exception.</p>
*
* @see SAXException#SAXException
* @see Locator#Locator
* @see ErrorHandler#ErrorHandler
*/
class SAX_EXPORT SAXParseException : public SAXException
{
public:
/** @name Constructors and Destructor */
//@{
/**
* Create a new SAXParseException from a message and a Locator.
*
* <p>This constructor is especially useful when an application is
* creating its own exception from within a DocumentHandler
* callback.</p>
*
* @param message The error or warning message.
* @param locator The locator object for the error or warning.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
* @see Locator#Locator
* @see Parser#setLocale
*/
SAXParseException(const XMLCh* const message, const Locator& locator,
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
/**
* Create a new SAXParseException.
*
* <p>This constructor is most useful for parser writers.</p>
*
* <p>If the system identifier is a URL, the parser must resolve it
* fully before creating the exception.</p>
*
* @param message The error or warning message.
* @param publicId The public identifier of the entity that generated
* the error or warning.
* @param systemId The system identifier of the entity that generated
* the error or warning.
* @param lineNumber The line number of the end of the text that
* caused the error or warning.
* @param columnNumber The column number of the end of the text that
* caused the error or warning.
* @param manager Pointer to the memory manager to be used to
* allocate objects.
* @see Parser#setLocale
*/
SAXParseException
(
const XMLCh* const message
, const XMLCh* const publicId
, const XMLCh* const systemId
, const XMLFileLoc lineNumber
, const XMLFileLoc columnNumber
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
/**
* Copy constructor
*
* @param toCopy The object to be copied
*/
SAXParseException(const SAXParseException& toCopy);
/**
* Destructor
*/
~SAXParseException();
//@}
/** @name Assignment operator */
//@{
/**
* Assignment operator
*
* @param toAssign The object to be copied through assignment
*
*/
SAXParseException& operator=(const SAXParseException& toAssign);
//@}
/** @name Getter methods */
//@{
/**
* The column number of the end of the text where the exception occurred.
*
* <p>The first column in a line is position 1.</p>
*
* @return An integer representing the column number, or 0
* if none is available.
* @see Locator#getColumnNumber
*/
XMLFileLoc getColumnNumber() const;
/**
* The line number of the end of the text where the exception occurred.
*
* @return An integer representing the line number, or 0
* if none is available.
* @see Locator#getLineNumber
*/
XMLFileLoc getLineNumber() const;
/**
* Get the public identifier of the entity where the exception occurred.
*
* @return A string containing the public identifier, or null
* if none is available.
* @see Locator#getPublicId
*/
const XMLCh* getPublicId() const;
/**
* Get the system identifier of the entity where the exception occurred.
*
* <p>If the system identifier is a URL, it will be resolved
* fully.</p>
*
* @return A string containing the system identifier, or null
* if none is available.
* @see Locator#getSystemId
*/
const XMLCh* getSystemId() const;
//@}
private:
/* Data Members */
/* The column in the source text where the error occured. */
XMLFileLoc fColumnNumber;
/* The line in the source text where the error occured. */
XMLFileLoc fLineNumber;
/* The public id of the file where the error occured. */
XMLCh* fPublicId;
/* The system id of the file where the error occured. */
XMLCh* fSystemId;
};
XERCES_CPP_NAMESPACE_END
#endif