mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-15 22:57:12 +02:00
Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
This commit is contained in:
120
vendor/POCO/XML/include/Poco/SAX/Attributes.h
vendored
Normal file
120
vendor/POCO/XML/include/Poco/SAX/Attributes.h
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
//
|
||||
// Attributes.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX2 Attributes Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_Attributes_INCLUDED
|
||||
#define SAX_Attributes_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API Attributes
|
||||
/// Interface for a list of XML attributes.
|
||||
/// This interface allows access to a list of attributes in three different ways:
|
||||
/// 1.by attribute index;
|
||||
/// 2.by Namespace-qualified name; or
|
||||
/// 3.by qualified (prefixed) name.
|
||||
///
|
||||
/// The list will not contain attributes that were declared #IMPLIED but not
|
||||
/// specified in the start tag. It will also not contain
|
||||
/// attributes used as Namespace declarations (xmlns*) unless the
|
||||
/// http://xml.org/sax/features/namespace-prefixes
|
||||
/// feature is set to true (it is false by default).
|
||||
///
|
||||
/// If the namespace-prefixes feature (see above) is false, access by
|
||||
/// qualified name may not be available; if the
|
||||
/// http://xml.org/sax/features/namespaces feature is false, access by
|
||||
/// Namespace-qualified names may not be available.
|
||||
/// This interface replaces the now-deprecated SAX1 AttributeList interface,
|
||||
/// which does not contain Namespace support. In
|
||||
/// addition to Namespace support, it adds the getIndex methods (below).
|
||||
/// The order of attributes in the list is unspecified, and will vary from
|
||||
/// implementation to implementation.
|
||||
{
|
||||
public:
|
||||
virtual int getIndex(const XMLString& name) const = 0;
|
||||
/// Look up the index of an attribute by a qualified name.
|
||||
|
||||
virtual int getIndex(const XMLString& namespaceURI, const XMLString& localName) const = 0;
|
||||
/// Look up the index of an attribute by a namspace name.
|
||||
|
||||
virtual int getLength() const = 0;
|
||||
/// Return the number of attributes in the list.
|
||||
///
|
||||
/// Once you know the number of attributes, you can iterate through the list.
|
||||
|
||||
virtual const XMLString& getLocalName(int i) const = 0;
|
||||
/// Look up a local attribute name by index.
|
||||
|
||||
virtual const XMLString& getQName(int i) const = 0;
|
||||
/// Look up a qualified attribute name by index.
|
||||
|
||||
virtual const XMLString& getType(int i) const = 0;
|
||||
/// Look up an attribute type by index.
|
||||
///
|
||||
/// 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".
|
||||
|
||||
virtual const XMLString& getType(const XMLString& qname) const = 0;
|
||||
/// Look up an attribute type by a qualified name.
|
||||
///
|
||||
/// See getType(int) for a description of the possible types.
|
||||
|
||||
virtual const XMLString& getType(const XMLString& namespaceURI, const XMLString& localName) const = 0;
|
||||
/// Look up an attribute type by a namespace name.
|
||||
///
|
||||
/// See getType(int) for a description of the possible types.
|
||||
|
||||
virtual const XMLString& getValue(int i) const = 0;
|
||||
/// Look up an attribute value by index.
|
||||
///
|
||||
/// If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens
|
||||
/// will be concatenated into a single string with each token separated by a single space.
|
||||
|
||||
virtual const XMLString& getValue(const XMLString& qname) const = 0;
|
||||
/// Look up an attribute value by a qualified name.
|
||||
///
|
||||
/// See getValue(int) for a description of the possible values.
|
||||
|
||||
virtual const XMLString& getValue(const XMLString& uri, const XMLString& localName) const = 0;
|
||||
/// Look up an attribute value by a namespace name.
|
||||
///
|
||||
/// See getValue(int) for a description of the possible values.
|
||||
|
||||
virtual const XMLString& getURI(int i) const = 0;
|
||||
/// Look up a namespace URI by index.
|
||||
|
||||
protected:
|
||||
virtual ~Attributes();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_Attributes_INCLUDED
|
307
vendor/POCO/XML/include/Poco/SAX/AttributesImpl.h
vendored
Normal file
307
vendor/POCO/XML/include/Poco/SAX/AttributesImpl.h
vendored
Normal file
@ -0,0 +1,307 @@
|
||||
//
|
||||
// AttributesImpl.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// Implementation of the SAX2 Attributes Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_AttributesImpl_INCLUDED
|
||||
#define SAX_AttributesImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/SAX/Attributes.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API AttributesImpl: public Attributes
|
||||
/// This class provides a default implementation of the SAX2 Attributes interface,
|
||||
/// with the addition of manipulators so that the list can be modified or reused.
|
||||
///
|
||||
/// There are two typical uses of this class:
|
||||
/// 1. to take a persistent snapshot of an Attributes object in a startElement event; or
|
||||
/// 2. to construct or modify an Attributes object in a SAX2 driver or filter.
|
||||
{
|
||||
public:
|
||||
struct Attribute
|
||||
{
|
||||
XMLString localName;
|
||||
XMLString namespaceURI;
|
||||
XMLString qname;
|
||||
XMLString value;
|
||||
XMLString type;
|
||||
bool specified;
|
||||
};
|
||||
using AttributeVec = std::vector<Attribute>;
|
||||
using iterator = AttributeVec::const_iterator;
|
||||
|
||||
AttributesImpl();
|
||||
/// Creates the AttributesImpl.
|
||||
|
||||
AttributesImpl(const Attributes& attributes);
|
||||
/// Creates the AttributesImpl by copying another one.
|
||||
|
||||
AttributesImpl(const AttributesImpl& attributes);
|
||||
/// Creates the AttributesImpl by copying another one.
|
||||
|
||||
AttributesImpl(AttributesImpl&& attributes) noexcept;
|
||||
/// Creates the AttributesImpl by copying another one.
|
||||
|
||||
~AttributesImpl();
|
||||
/// Destroys the AttributesImpl.
|
||||
|
||||
AttributesImpl& operator = (const AttributesImpl& attributes);
|
||||
/// Assignment operator.
|
||||
|
||||
AttributesImpl& operator = (AttributesImpl&& attributes) noexcept;
|
||||
/// Assignment operator.
|
||||
|
||||
int getIndex(const XMLString& name) const;
|
||||
int getIndex(const XMLString& namespaceURI, const XMLString& localName) const;
|
||||
int getLength() const;
|
||||
const XMLString& getLocalName(int i) const;
|
||||
const XMLString& getQName(int i) const;
|
||||
const XMLString& getType(int i) const;
|
||||
const XMLString& getType(const XMLString& qname) const;
|
||||
const XMLString& getType(const XMLString& namespaceURI, const XMLString& localName) const;
|
||||
const XMLString& getValue(int i) const;
|
||||
const XMLString& getValue(const XMLString& qname) const;
|
||||
const XMLString& getValue(const XMLString& namespaceURI, const XMLString& localName) const;
|
||||
const XMLString& getURI(int i) const;
|
||||
|
||||
bool isSpecified(int i) const;
|
||||
/// Returns true unless the attribute value was provided by DTD defaulting.
|
||||
/// Extension from Attributes2 interface.
|
||||
|
||||
bool isSpecified(const XMLString& qname) const;
|
||||
/// Returns true unless the attribute value was provided by DTD defaulting.
|
||||
/// Extension from Attributes2 interface.
|
||||
|
||||
bool isSpecified(const XMLString& namespaceURI, const XMLString& localName) const;
|
||||
/// Returns true unless the attribute value was provided by DTD defaulting.
|
||||
/// Extension from Attributes2 interface.
|
||||
|
||||
void setValue(int i, const XMLString& value);
|
||||
/// Sets the value of an attribute.
|
||||
|
||||
void setValue(const XMLString& qname, const XMLString& value);
|
||||
/// Sets the value of an attribute.
|
||||
|
||||
void setValue(const XMLString& namespaceURI, const XMLString& localName, const XMLString& value);
|
||||
/// Sets the value of an attribute.
|
||||
|
||||
void setAttributes(const Attributes& attributes);
|
||||
/// Copies the attributes from another Attributes object.
|
||||
|
||||
void setAttribute(int i, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value);
|
||||
/// Sets an attribute.
|
||||
|
||||
void addAttribute(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value);
|
||||
/// Adds an attribute to the end of the list.
|
||||
|
||||
void addAttribute(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value, bool specified);
|
||||
/// Adds an attribute to the end of the list.
|
||||
|
||||
void addAttribute(const XMLChar* namespaceURI, const XMLChar* localName, const XMLChar* qname, const XMLChar* type, const XMLChar* value, bool specified);
|
||||
/// Adds an attribute to the end of the list.
|
||||
|
||||
Attribute& addAttribute();
|
||||
/// Add an (empty) attribute to the end of the list.
|
||||
/// For internal use only.
|
||||
/// The returned Attribute element must be filled by the caller.
|
||||
|
||||
void removeAttribute(int i);
|
||||
/// Removes an attribute.
|
||||
|
||||
void removeAttribute(const XMLString& qname);
|
||||
/// Removes an attribute.
|
||||
|
||||
void removeAttribute(const XMLString& namespaceURI, const XMLString& localName);
|
||||
/// Removes an attribute.
|
||||
|
||||
void clear();
|
||||
/// Removes all attributes.
|
||||
|
||||
void reserve(std::size_t capacity);
|
||||
/// Reserves capacity in the internal vector.
|
||||
|
||||
void setLocalName(int i, const XMLString& localName);
|
||||
/// Sets the local name of an attribute.
|
||||
|
||||
void setQName(int i, const XMLString& qname);
|
||||
/// Sets the qualified name of an attribute.
|
||||
|
||||
void setType(int i, const XMLString& type);
|
||||
/// Sets the type of an attribute.
|
||||
|
||||
void setURI(int i, const XMLString& namespaceURI);
|
||||
/// Sets the namespace URI of an attribute.
|
||||
|
||||
iterator begin() const;
|
||||
/// Iterator support.
|
||||
|
||||
iterator end() const;
|
||||
/// Iterator support.
|
||||
|
||||
protected:
|
||||
Attribute* find(const XMLString& qname) const;
|
||||
Attribute* find(const XMLString& namespaceURI, const XMLString& localName) const;
|
||||
|
||||
struct EmptyAttribute: Attribute
|
||||
{
|
||||
EmptyAttribute();
|
||||
};
|
||||
|
||||
private:
|
||||
AttributeVec _attributes;
|
||||
static EmptyAttribute _empty;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline AttributesImpl::iterator AttributesImpl::begin() const
|
||||
{
|
||||
return _attributes.begin();
|
||||
}
|
||||
|
||||
|
||||
inline AttributesImpl::iterator AttributesImpl::end() const
|
||||
{
|
||||
return _attributes.end();
|
||||
}
|
||||
|
||||
|
||||
inline AttributesImpl::Attribute& AttributesImpl::addAttribute()
|
||||
{
|
||||
_attributes.push_back(_empty);
|
||||
return _attributes.back();
|
||||
}
|
||||
|
||||
|
||||
inline int AttributesImpl::getLength() const
|
||||
{
|
||||
return (int) _attributes.size();
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& AttributesImpl::getLocalName(int i) const
|
||||
{
|
||||
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
|
||||
return _attributes[i].localName;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& AttributesImpl::getQName(int i) const
|
||||
{
|
||||
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
|
||||
return _attributes[i].qname;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& AttributesImpl::getType(int i) const
|
||||
{
|
||||
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
|
||||
return _attributes[i].type;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& AttributesImpl::getType(const XMLString& qname) const
|
||||
{
|
||||
Attribute* pAttr = find(qname);
|
||||
if (pAttr)
|
||||
return pAttr->type;
|
||||
else
|
||||
return _empty.type;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& AttributesImpl::getType(const XMLString& namespaceURI, const XMLString& localName) const
|
||||
{
|
||||
Attribute* pAttr = find(namespaceURI, localName);
|
||||
if (pAttr)
|
||||
return pAttr->type;
|
||||
else
|
||||
return _empty.type;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& AttributesImpl::getValue(int i) const
|
||||
{
|
||||
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
|
||||
return _attributes[i].value;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& AttributesImpl::getValue(const XMLString& qname) const
|
||||
{
|
||||
Attribute* pAttr = find(qname);
|
||||
if (pAttr)
|
||||
return pAttr->value;
|
||||
else
|
||||
return _empty.value;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& AttributesImpl::getValue(const XMLString& namespaceURI, const XMLString& localName) const
|
||||
{
|
||||
Attribute* pAttr = find(namespaceURI, localName);
|
||||
if (pAttr)
|
||||
return pAttr->value;
|
||||
else
|
||||
return _empty.value;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& AttributesImpl::getURI(int i) const
|
||||
{
|
||||
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
|
||||
return _attributes[i].namespaceURI;
|
||||
}
|
||||
|
||||
|
||||
inline bool AttributesImpl::isSpecified(int i) const
|
||||
{
|
||||
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
|
||||
return _attributes[i].specified;
|
||||
}
|
||||
|
||||
|
||||
inline bool AttributesImpl::isSpecified(const XMLString& qname) const
|
||||
{
|
||||
Attribute* pAttr = find(qname);
|
||||
if (pAttr)
|
||||
return pAttr->specified;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
inline bool AttributesImpl::isSpecified(const XMLString& namespaceURI, const XMLString& localName) const
|
||||
{
|
||||
Attribute* pAttr = find(namespaceURI, localName);
|
||||
if (pAttr)
|
||||
return pAttr->specified;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_AttributesImpl_INCLUDED
|
240
vendor/POCO/XML/include/Poco/SAX/ContentHandler.h
vendored
Normal file
240
vendor/POCO/XML/include/Poco/SAX/ContentHandler.h
vendored
Normal file
@ -0,0 +1,240 @@
|
||||
//
|
||||
// ContentHandler.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX2 ContentHandler Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_ContentHandler_INCLUDED
|
||||
#define SAX_ContentHandler_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class Locator;
|
||||
class Attributes;
|
||||
|
||||
|
||||
class XML_API ContentHandler
|
||||
/// Receive notification of the logical content of a document.
|
||||
///
|
||||
/// 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 setContentHandler
|
||||
/// method. The parser uses the instance to report basic document-related events
|
||||
/// like the start and end of elements and character data.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// This interface is similar to the now-deprecated SAX 1.0 DocumentHandler
|
||||
/// interface, but it adds support for Namespaces and for reporting skipped
|
||||
/// entities (in non-validating XML processors).
|
||||
/// Receive notification of the logical content of a document.
|
||||
{
|
||||
public:
|
||||
virtual void setDocumentLocator(const Locator* loc) = 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
|
||||
/// ContentHandler 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
|
||||
/// SAX event callbacks after startDocument returns and before endDocument is
|
||||
/// called. The application should not attempt to use it at any other time.
|
||||
|
||||
virtual void startDocument() = 0;
|
||||
/// Receive notification of the beginning of a document.
|
||||
///
|
||||
/// The SAX parser calls this function one time before calling all other
|
||||
/// functions of this class (except SetDocumentLocator).
|
||||
|
||||
virtual void endDocument() = 0;
|
||||
/// Receive notification of the end of a document.
|
||||
///
|
||||
/// 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.
|
||||
|
||||
virtual void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList) = 0;
|
||||
/// Receive notification of the beginning of an element.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// This event allows up to three name components for each element:
|
||||
/// 1. the Namespace URI;
|
||||
/// 2. the local name; and
|
||||
/// 3. the qualified (prefixed) name.
|
||||
///
|
||||
/// Any or all of these may be provided, depending on the values of the http://xml.org/sax/features/namespaces
|
||||
/// and the http://xml.org/sax/features/namespace-prefixes properties:
|
||||
/// * the Namespace URI and local name are required when the namespaces
|
||||
/// property is true (the default), and are optional when the namespaces property
|
||||
/// is false (if one is specified, both must be);
|
||||
/// * the qualified name is required when the namespace-prefixes property
|
||||
/// is true, and is optional when the namespace-prefixes property is false (the
|
||||
/// default).
|
||||
///
|
||||
/// Note that the attribute list provided will contain only attributes with
|
||||
/// explicit values (specified or defaulted): #IMPLIED attributes will be omitted.
|
||||
/// The attribute list will contain attributes used for Namespace declarations
|
||||
/// (xmlns* attributes) only if the http://xml.org/sax/features/namespace-prefixes
|
||||
/// property is true (it is false by default, and support for a true value is
|
||||
/// optional).
|
||||
///
|
||||
/// Like characters(), attribute values may have characters that need more than
|
||||
/// one char value.
|
||||
|
||||
virtual void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname) = 0;
|
||||
/// Receive notification of the end of an element.
|
||||
///
|
||||
/// 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).
|
||||
///
|
||||
/// For information on the names, see startElement.
|
||||
|
||||
virtual void characters(const XMLChar ch[], int start, int length) = 0;
|
||||
/// Receive notification of character data.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// The application must not attempt to read from the array outside of the specified
|
||||
/// range.
|
||||
///
|
||||
/// Individual characters may consist of more than one XMLChar value. There
|
||||
/// are three important cases where this happens, because characters can't be
|
||||
/// represented in just sixteen bits. In one case, characters are represented
|
||||
/// in a Surrogate Pair, using two special Unicode values. Such characters are
|
||||
/// in the so-called "Astral Planes", with a code point above U+FFFF. A second
|
||||
/// case involves composite characters, such as a base character combining with
|
||||
/// one or more accent characters. And most important, if XMLChar is a plain
|
||||
/// char, characters are encoded in UTF-8.
|
||||
///
|
||||
/// Your code should not assume that algorithms using char-at-a-time idioms
|
||||
/// will be working in character units; in some cases they will split characters.
|
||||
/// This is relevant wherever XML permits arbitrary characters, such as attribute
|
||||
/// values, processing instruction data, and comments as well as in data reported
|
||||
/// from this method. It's also generally relevant whenever C++ code manipulates
|
||||
/// internationalized text; the issue isn't unique to XML.
|
||||
///
|
||||
/// Note that some parsers will report whitespace in element content using the
|
||||
/// ignorableWhitespace method rather than this one (validating parsers must
|
||||
/// do so).
|
||||
|
||||
virtual void ignorableWhitespace(const XMLChar ch[], int start, int length) = 0;
|
||||
/// Receive notification of ignorable whitespace in element content.
|
||||
///
|
||||
/// Validating Parsers must use this method to report each chunk of whitespace
|
||||
/// in element content (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.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// The application must not attempt to read from the array outside of the specified
|
||||
/// range.
|
||||
|
||||
virtual void processingInstruction(const XMLString& target, const XMLString& data) = 0;
|
||||
/// Receive notification of a processing instruction.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// A SAX parser must 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.
|
||||
///
|
||||
/// Like characters(), processing instruction data may have characters that
|
||||
/// need more than one char value.
|
||||
|
||||
virtual void startPrefixMapping(const XMLString& prefix, const XMLString& uri) = 0;
|
||||
/// Begin the scope of a prefix-URI Namespace mapping.
|
||||
///
|
||||
/// The information from this event is not necessary for normal Namespace processing:
|
||||
/// the SAX XML reader will automatically replace prefixes for element and attribute
|
||||
/// names when the http://xml.org/sax/features/namespaces feature is true (the
|
||||
/// default).
|
||||
///
|
||||
/// There are cases, however, when applications need to use prefixes in character
|
||||
/// data or in attribute values, where they cannot safely be expanded automatically;
|
||||
/// the start/endPrefixMapping event supplies the information to the application
|
||||
/// to expand prefixes in those contexts itself, if necessary.
|
||||
///
|
||||
/// Note that start/endPrefixMapping events are not guaranteed to be properly
|
||||
/// nested relative to each other: all startPrefixMapping events will occur
|
||||
/// immediately before the corresponding startElement event, and all endPrefixMapping
|
||||
/// events will occur immediately after the corresponding endElement event,
|
||||
/// but their order is not otherwise guaranteed.
|
||||
///
|
||||
/// There should never be start/endPrefixMapping events for the "xml" prefix,
|
||||
/// since it is predeclared and immutable.
|
||||
|
||||
virtual void endPrefixMapping(const XMLString& prefix) = 0;
|
||||
/// End the scope of a prefix-URI mapping.
|
||||
///
|
||||
/// See startPrefixMapping for details. These events will always occur immediately
|
||||
/// after the corresponding endElement event, but the order of endPrefixMapping
|
||||
/// events is not otherwise guaranteed.
|
||||
|
||||
virtual void skippedEntity(const XMLString& name) = 0;
|
||||
/// Receive notification of a skipped entity. This is not called for entity
|
||||
/// references within markup constructs such as element start tags or markup
|
||||
/// declarations. (The XML recommendation requires reporting skipped external
|
||||
/// entities. SAX also reports internal entity expansion/non-expansion, except
|
||||
/// within markup constructs.)
|
||||
///
|
||||
/// The Parser will invoke this method each time the entity is skipped. Non-validating
|
||||
/// processors may skip entities if they have not seen the declarations (because,
|
||||
/// for example, the entity was declared in an external DTD subset). All processors
|
||||
/// may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities
|
||||
/// and the http://xml.org/sax/features/external-parameter-entities properties.
|
||||
|
||||
protected:
|
||||
virtual ~ContentHandler();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_ContentHandler_INCLUDED
|
86
vendor/POCO/XML/include/Poco/SAX/DTDHandler.h
vendored
Normal file
86
vendor/POCO/XML/include/Poco/SAX/DTDHandler.h
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
//
|
||||
// DTDHandler.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX DTDHandler Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_DTDHandler_INCLUDED
|
||||
#define SAX_DTDHandler_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API DTDHandler
|
||||
/// 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.
|
||||
///
|
||||
/// Note that this interface includes only those DTD events that the XML recommendation
|
||||
/// requires processors to report: notation and unparsed entity declarations.
|
||||
///
|
||||
/// 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. (If the LexicalHandler is used, these events must also be reported before the endDTD event.)
|
||||
///
|
||||
/// 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.
|
||||
{
|
||||
public:
|
||||
virtual void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId) = 0;
|
||||
/// Receive notification of a notation declaration event.
|
||||
///
|
||||
/// It is up to the application to record the notation for later reference,
|
||||
/// if necessary; notations may appear as attribute values and in unparsed
|
||||
/// entity declarations, and are sometime used with processing instruction
|
||||
/// target names.
|
||||
///
|
||||
/// At least one of publicId and systemId must be non-null. If a system identifier
|
||||
/// is present, and it is a URL, the SAX parser must resolve it fully before passing
|
||||
/// it to the application through this event.
|
||||
///
|
||||
/// There is no guarantee that the notation declaration will be reported before any
|
||||
/// unparsed entities that use it.
|
||||
///
|
||||
/// Note that publicId and systemId maybe null, therefore we pass a pointer rather than a reference.
|
||||
|
||||
virtual void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName) = 0;
|
||||
/// Receive notification of an unparsed entity declaration event.
|
||||
///
|
||||
/// 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; unparsed entities may appear as attribute values.
|
||||
///
|
||||
/// If the system identifier is a URL, the parser must resolve it fully before
|
||||
/// passing it to the application.
|
||||
///
|
||||
/// Note that publicId maybe null, therefore we pass a pointer rather than a reference.
|
||||
|
||||
protected:
|
||||
virtual ~DTDHandler();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_DTDHandler_INCLUDED
|
91
vendor/POCO/XML/include/Poco/SAX/DeclHandler.h
vendored
Normal file
91
vendor/POCO/XML/include/Poco/SAX/DeclHandler.h
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
//
|
||||
// DeclHandler.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX2-ext DeclHandler Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_DeclHandler_INCLUDED
|
||||
#define SAX_DeclHandler_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API DeclHandler
|
||||
/// This is an optional extension handler for SAX2 to provide information
|
||||
/// about DTD declarations in an XML document. XML
|
||||
/// readers are not required to support this handler, and this handler is
|
||||
/// not included in the core SAX2 distribution.
|
||||
///
|
||||
/// Note that data-related DTD declarations (unparsed entities and notations)
|
||||
/// are already reported through the DTDHandler interface.
|
||||
/// If you are using the declaration handler together with a lexical handler,
|
||||
/// all of the events will occur between the startDTD and the endDTD events.
|
||||
/// To set the DeclHandler for an XML reader, use the setProperty method
|
||||
/// with the propertyId "http://xml.org/sax/properties/declaration-handler".
|
||||
/// If the reader does not support declaration events, it will throw a
|
||||
/// SAXNotRecognizedException or a SAXNotSupportedException when you attempt to
|
||||
/// register the handler.
|
||||
{
|
||||
public:
|
||||
virtual void attributeDecl(const XMLString& eName, const XMLString& aName, const XMLString* valueDefault, const XMLString* value) = 0;
|
||||
/// Report an attribute type declaration.
|
||||
///
|
||||
/// Only the effective (first) declaration for an attribute will be reported.
|
||||
/// The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS",
|
||||
/// "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", a parenthesized token group
|
||||
/// with the separator "|" and all whitespace removed, or the word "NOTATION"
|
||||
/// followed by a space followed by a parenthesized token group with all whitespace
|
||||
/// removed.
|
||||
///
|
||||
/// The value will be the value as reported to applications, appropriately normalized
|
||||
/// and with entity and character references expanded.
|
||||
|
||||
virtual void elementDecl(const XMLString& name, const XMLString& model) = 0;
|
||||
/// Report an element type declaration.
|
||||
///
|
||||
/// The content model will consist of the string "EMPTY", the string "ANY", or a
|
||||
/// parenthesised group, optionally followed by an occurrence indicator. The model
|
||||
/// will be normalized so that all parameter entities are fully resolved and all
|
||||
/// whitespace is removed,and will include the enclosing parentheses. Other
|
||||
/// normalization (such as removing redundant parentheses or simplifying occurrence
|
||||
/// indicators) is at the discretion of the parser.
|
||||
|
||||
virtual void externalEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId) = 0;
|
||||
/// Report an external entity declaration.
|
||||
///
|
||||
/// Only the effective (first) declaration for each entity will be reported.
|
||||
///
|
||||
/// If the system identifier is a URL, the parser must resolve it fully before
|
||||
/// passing it to the application.
|
||||
|
||||
virtual void internalEntityDecl(const XMLString& name, const XMLString& value) = 0;
|
||||
/// Report an internal entity declaration.
|
||||
///
|
||||
/// Only the effective (first) declaration for each entity will be reported. All
|
||||
/// parameter entities in the value will be expanded, but general entities will not.
|
||||
|
||||
protected:
|
||||
virtual ~DeclHandler();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_DeclHandler_INCLUDED
|
83
vendor/POCO/XML/include/Poco/SAX/DefaultHandler.h
vendored
Normal file
83
vendor/POCO/XML/include/Poco/SAX/DefaultHandler.h
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
//
|
||||
// DefaultHandler.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX-2 DefaultHandler class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_DefaultHandler_INCLUDED
|
||||
#define SAX_DefaultHandler_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/SAX/EntityResolver.h"
|
||||
#include "Poco/SAX/DTDHandler.h"
|
||||
#include "Poco/SAX/ContentHandler.h"
|
||||
#include "Poco/SAX/ErrorHandler.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API DefaultHandler: public EntityResolver, public DTDHandler, public ContentHandler, public ErrorHandler
|
||||
/// Default base class for SAX2 event handlers.
|
||||
/// This class is available as a convenience base class for SAX2 applications:
|
||||
/// it provides default implementations for all of the
|
||||
/// callbacks in the four core SAX2 handler classes:
|
||||
/// * EntityResolver
|
||||
/// * DTDHandler
|
||||
/// * ContentHandler
|
||||
/// * ErrorHandler
|
||||
/// 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.
|
||||
{
|
||||
public:
|
||||
DefaultHandler();
|
||||
/// Creates the DefaultHandler.
|
||||
|
||||
~DefaultHandler();
|
||||
/// Destroys the DefaultHandler.
|
||||
|
||||
// EntityResolver
|
||||
InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId);
|
||||
void releaseInputSource(InputSource* pSource);
|
||||
|
||||
// DTDHandler
|
||||
void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId);
|
||||
void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName);
|
||||
|
||||
// ContentHandler
|
||||
void setDocumentLocator(const Locator* loc);
|
||||
void startDocument();
|
||||
void endDocument();
|
||||
void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attributes);
|
||||
void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname);
|
||||
void characters(const XMLChar ch[], int start, int length);
|
||||
void ignorableWhitespace(const XMLChar ch[], int start, int length);
|
||||
void processingInstruction(const XMLString& target, const XMLString& data);
|
||||
void startPrefixMapping(const XMLString& prefix, const XMLString& uri);
|
||||
void endPrefixMapping(const XMLString& prefix);
|
||||
void skippedEntity(const XMLString& name);
|
||||
|
||||
// ErrorHandler
|
||||
void warning(const SAXException& exc);
|
||||
void error(const SAXException& exc);
|
||||
void fatalError(const SAXException& exc);
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_DefaultHandler_INCLUDED
|
86
vendor/POCO/XML/include/Poco/SAX/EntityResolver.h
vendored
Normal file
86
vendor/POCO/XML/include/Poco/SAX/EntityResolver.h
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
//
|
||||
// EntityResolver.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX EntityResolver Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_EntityResolver_INCLUDED
|
||||
#define SAX_EntityResolver_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class InputSource;
|
||||
|
||||
|
||||
class XML_API EntityResolver
|
||||
/// If a SAX application needs to implement customized handling for external entities,
|
||||
/// it must implement this interface and register an instance with the SAX driver using
|
||||
/// the setEntityResolver method.
|
||||
///
|
||||
/// The XML reader will then allow the application to intercept any external entities
|
||||
/// (including the external DTD subset and external parameter entities, if any) before
|
||||
/// including them.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// 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).
|
||||
{
|
||||
public:
|
||||
virtual InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId) = 0;
|
||||
/// Allow the application to resolve external entities.
|
||||
///
|
||||
/// The parser will call this method before opening any external entity except the
|
||||
/// top-level document entity. Such entities include the external DTD subset and
|
||||
/// external parameter entities referenced within the DTD (in either case, only
|
||||
/// if the parser reads external parameter entities), and external general entities
|
||||
/// referenced within the document element (if the parser reads external general entities).
|
||||
/// The application may request that the parser locate the entity itself, that it use an
|
||||
/// alternative URI, or that it use data provided by the application (as a character or
|
||||
/// byte input stream).
|
||||
///
|
||||
/// 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).
|
||||
/// Neither XML nor SAX specifies a preferred policy for using public or system IDs to resolve
|
||||
/// resources. However, SAX specifies how to interpret any InputSource returned by this method,
|
||||
/// and that if none is returned, then the system ID will be dereferenced as a URL.
|
||||
///
|
||||
/// If the system identifier is a URL, the SAX parser must resolve it fully before reporting it to
|
||||
/// the application.
|
||||
///
|
||||
/// Note that publicId maybe null, therefore we pass a pointer rather than a reference.
|
||||
|
||||
virtual void releaseInputSource(InputSource* pSource) = 0;
|
||||
/// This is a non-standard extension to SAX!
|
||||
/// Called by the parser when the input source returned by ResolveEntity is
|
||||
/// no longer needed. Should free any resources used by the input source.
|
||||
|
||||
protected:
|
||||
virtual ~EntityResolver();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_EntityResolver_INCLUDED
|
78
vendor/POCO/XML/include/Poco/SAX/EntityResolverImpl.h
vendored
Normal file
78
vendor/POCO/XML/include/Poco/SAX/EntityResolverImpl.h
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
//
|
||||
// EntityResolverImpl.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// An implementation of EntityResolver.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_EntityResolverImpl_INCLUDED
|
||||
#define SAX_EntityResolverImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#include "Poco/SAX/EntityResolver.h"
|
||||
#include "Poco/URIStreamOpener.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API EntityResolverImpl: public EntityResolver
|
||||
/// A default implementation of the EntityResolver interface.
|
||||
///
|
||||
/// The system ID is first interpreted as an URI and the
|
||||
/// URIStreamOpener is used to create and open an istream
|
||||
/// for an InputSource.
|
||||
///
|
||||
/// If the system ID is not a valid URI, it is
|
||||
/// interpreted as a filesystem path and a Poco::FileInputStream
|
||||
/// is opened for it.
|
||||
{
|
||||
public:
|
||||
EntityResolverImpl();
|
||||
/// Creates an EntityResolverImpl that uses the default
|
||||
/// URIStreamOpener.
|
||||
|
||||
EntityResolverImpl(const Poco::URIStreamOpener& opener);
|
||||
/// Creates an EntityResolverImpl that uses the given
|
||||
/// URIStreamOpener.
|
||||
|
||||
~EntityResolverImpl();
|
||||
/// Destroys the EntityResolverImpl.
|
||||
|
||||
InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId);
|
||||
/// Tries to use the URIStreamOpener to create and open an istream
|
||||
/// for the given systemId, which is interpreted as an URI.
|
||||
///
|
||||
/// If the systemId is not a valid URI, it is interpreted as
|
||||
/// a local filesystem path and a Poco::FileInputStream is opened for it.
|
||||
|
||||
void releaseInputSource(InputSource* pSource);
|
||||
/// Deletes the InputSource's stream.
|
||||
|
||||
protected:
|
||||
std::istream* resolveSystemId(const XMLString& systemId);
|
||||
|
||||
private:
|
||||
EntityResolverImpl(const EntityResolverImpl&);
|
||||
EntityResolverImpl& operator = (const EntityResolverImpl&);
|
||||
|
||||
const Poco::URIStreamOpener& _opener;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_EntityResolverImpl_INCLUDED
|
92
vendor/POCO/XML/include/Poco/SAX/ErrorHandler.h
vendored
Normal file
92
vendor/POCO/XML/include/Poco/SAX/ErrorHandler.h
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
//
|
||||
// ErrorHandler.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX ErrorHandler Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_ErrorHandler_INCLUDED
|
||||
#define SAX_ErrorHandler_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class SAXException;
|
||||
|
||||
|
||||
class XML_API ErrorHandler
|
||||
/// If a SAX application needs to implement customized error handling, it must
|
||||
/// implement this interface and then register an instance with the XML reader
|
||||
/// using the setErrorHandler method. The parser will then report all errors and
|
||||
/// warnings through this interface.
|
||||
///
|
||||
/// WARNING: If an application does not register an ErrorHandler, XML parsing errors
|
||||
/// will go unreported, except that SAXParseExceptions will be thrown for fatal errors.
|
||||
/// In order to detect validity errors, an ErrorHandler that does something with error()
|
||||
/// calls must be registered.
|
||||
///
|
||||
/// For XML processing errors, a SAX driver must use this interface in preference to
|
||||
/// throwing an exception: it is up to the application to decide whether to throw an
|
||||
/// exception for different types of errors and warnings. Note, however, that there is no
|
||||
/// requirement that the parser continue to report additional errors after a call to
|
||||
/// fatalError. In other words, a SAX driver class may throw an exception after reporting
|
||||
/// any fatalError. Also parsers may throw appropriate exceptions for non-XML errors. For
|
||||
/// example, XMLReader::parse() would throw an IOException for errors accessing entities or
|
||||
/// the document.
|
||||
{
|
||||
public:
|
||||
virtual void warning(const SAXException& exc) = 0;
|
||||
/// Receive notification of a warning.
|
||||
///
|
||||
/// SAX parsers will use this method to report conditions that are not errors or fatal
|
||||
/// errors as defined by the XML recommendation. The default behaviour is to take no action.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// Filters may use this method to report other, non-XML warnings as well.
|
||||
|
||||
virtual void error(const SAXException& exc) = 0;
|
||||
/// Receive notification of a recoverable error.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// 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 recommendation does not require it to do so.
|
||||
///
|
||||
/// Filters may use this method to report other, non-XML errors as well.
|
||||
|
||||
virtual void fatalError(const SAXException& exc) = 0;
|
||||
/// Receive notification of a non-recoverable error.
|
||||
/// 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
|
||||
/// additional error messages: in fact, SAX parsers are free to stop reporting any other
|
||||
/// events once this method has been invoked.
|
||||
|
||||
protected:
|
||||
virtual ~ErrorHandler();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_ErrorHandler_INCLUDED
|
169
vendor/POCO/XML/include/Poco/SAX/InputSource.h
vendored
Normal file
169
vendor/POCO/XML/include/Poco/SAX/InputSource.h
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
//
|
||||
// InputSource.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX InputSource - A single input source for an XML entity.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_InputSource_INCLUDED
|
||||
#define SAX_InputSource_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#include "Poco/XML/XMLStream.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API InputSource
|
||||
/// This class allows a SAX application to encapsulate information about an input
|
||||
/// source in a single object, which may include a public identifier, a system
|
||||
/// identifier, a byte stream (possibly with a specified encoding), and/or a character
|
||||
/// stream.
|
||||
///
|
||||
/// There are two places that the application can deliver an input source to the
|
||||
/// parser: as the argument to the Parser.parse method, or as the return value of the
|
||||
/// EntityResolver::resolveEntity() method.
|
||||
///
|
||||
/// The SAX parser will use the InputSource object to determine how to read XML input.
|
||||
/// If there is a character stream available, the parser will read that stream directly,
|
||||
/// disregarding any text encoding declaration found in that stream. If there is no character
|
||||
/// stream, but there is a byte stream, the parser will use that byte stream, using the
|
||||
/// encoding specified in the InputSource or else (if no encoding is specified) autodetecting
|
||||
/// the character encoding using an algorithm such as the one in the XML specification.
|
||||
/// If neither a character stream nor a byte stream is available, the parser will attempt
|
||||
/// to open a URI connection to the resource identified by the system identifier.
|
||||
///
|
||||
/// An InputSource object belongs to the application: the SAX parser shall never modify it in
|
||||
/// any way (it may modify a copy if necessary). However, standard processing of both byte and
|
||||
/// character streams is to close them on as part of end-of-parse cleanup, so applications should
|
||||
/// not attempt to re-use such streams after they have been handed to a parser.
|
||||
{
|
||||
public:
|
||||
InputSource();
|
||||
/// Zero-argument default constructor.
|
||||
|
||||
InputSource(const XMLString& systemId);
|
||||
/// Creates a new input source with a system identifier.
|
||||
/// Applications may use setPublicId to include a public identifier as well,
|
||||
/// or setEncoding to specify the character encoding, if known.
|
||||
///
|
||||
/// If the system identifier is a URL, it must be fully resolved (it may not
|
||||
/// be a relative URL).
|
||||
|
||||
InputSource(XMLByteInputStream& istr);
|
||||
/// Creates a new input source with a byte stream.
|
||||
///
|
||||
/// Application writers should use setSystemId() to provide a base for resolving
|
||||
/// relative URIs, may use setPublicId to include a public identifier, and may use
|
||||
/// setEncoding to specify the object's character encoding.
|
||||
|
||||
~InputSource();
|
||||
/// Destroys the InputSource.
|
||||
|
||||
void setPublicId(const XMLString& publicId);
|
||||
/// Set the public identifier for this input source.
|
||||
///
|
||||
/// The public identifier is always optional: if the application writer includes one,
|
||||
/// it will be provided as part of the location information.
|
||||
|
||||
void setSystemId(const XMLString& systemId);
|
||||
/// Set the system identifier for this input source.
|
||||
///
|
||||
/// The system identifier is optional if there is a byte stream or a character stream,
|
||||
/// but it is still useful to provide one, since the application can use it to resolve
|
||||
/// relative URIs and can include it in error messages and warnings (the parser will
|
||||
/// attempt to open a connection to the URI only if there is no byte stream or character
|
||||
/// stream specified).
|
||||
///
|
||||
/// If the application knows the character encoding of the object pointed to by the system
|
||||
/// identifier, it can register the encoding using the setEncoding method.
|
||||
///
|
||||
/// If the system identifier is a URL, it must be fully resolved (it may not be a relative URL).
|
||||
|
||||
const XMLString& getPublicId() const;
|
||||
/// Get the public identifier for this input source.
|
||||
|
||||
const XMLString& getSystemId() const;
|
||||
/// Get the system identifier for this input source.
|
||||
|
||||
void setByteStream(XMLByteInputStream& istr);
|
||||
/// Set the byte stream for this input source.
|
||||
/// The SAX parser will ignore this if there is also a character stream specified, but it
|
||||
/// will use a byte stream in preference to opening a URI connection itself.
|
||||
|
||||
XMLByteInputStream* getByteStream() const;
|
||||
/// Get the byte stream for this input source.
|
||||
|
||||
void setCharacterStream(XMLCharInputStream& istr);
|
||||
/// Set the character stream for this input source.
|
||||
|
||||
XMLCharInputStream* getCharacterStream() const;
|
||||
/// Get the character stream for this input source.
|
||||
|
||||
void setEncoding(const XMLString& encoding);
|
||||
/// Set the character encoding, if known.
|
||||
/// The encoding must be a string acceptable for an XML encoding declaration
|
||||
/// (see section 4.3.3 of the XML 1.0 recommendation).
|
||||
|
||||
const XMLString& getEncoding() const;
|
||||
/// Get the character encoding for a byte stream or URI.
|
||||
|
||||
private:
|
||||
XMLString _publicId;
|
||||
XMLString _systemId;
|
||||
XMLString _encoding;
|
||||
XMLByteInputStream* _bistr;
|
||||
XMLCharInputStream* _cistr;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const XMLString& InputSource::getPublicId() const
|
||||
{
|
||||
return _publicId;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& InputSource::getSystemId() const
|
||||
{
|
||||
return _systemId;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& InputSource::getEncoding() const
|
||||
{
|
||||
return _encoding;
|
||||
}
|
||||
|
||||
|
||||
inline XMLByteInputStream* InputSource::getByteStream() const
|
||||
{
|
||||
return _bistr;
|
||||
}
|
||||
|
||||
|
||||
inline XMLCharInputStream* InputSource::getCharacterStream() const
|
||||
{
|
||||
return _cistr;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_InputSource_INCLUDED
|
125
vendor/POCO/XML/include/Poco/SAX/LexicalHandler.h
vendored
Normal file
125
vendor/POCO/XML/include/Poco/SAX/LexicalHandler.h
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
//
|
||||
// LexicalHandler.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX2-ext LexicalHandler Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_LexicalHandler_INCLUDED
|
||||
#define SAX_LexicalHandler_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API LexicalHandler
|
||||
/// This is an optional extension handler for SAX2 to provide lexical information
|
||||
/// about an XML document, such as comments and CDATA section boundaries.
|
||||
/// XML readers are not required to recognize this handler, and it is not part of
|
||||
/// core-only SAX2 distributions.
|
||||
///
|
||||
/// The events in the lexical handler apply to the entire document, not just to the
|
||||
/// document element, and all lexical handler events must appear between the content
|
||||
/// handler's startDocument and endDocument events.
|
||||
///
|
||||
/// To set the LexicalHandler for an XML reader, use the setProperty method with the
|
||||
/// property name http://xml.org/sax/properties/lexical-handler and an object implementing
|
||||
/// this interface (or null) as the value. If the reader does not report lexical events,
|
||||
/// it will throw a SAXNotRecognizedException when you attempt to register the handler.
|
||||
{
|
||||
public:
|
||||
virtual void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId) = 0;
|
||||
/// Report the start of DTD declarations, if any.
|
||||
///
|
||||
/// This method is intended to report the beginning of the DOCTYPE declaration;
|
||||
/// if the document has no DOCTYPE declaration, this method will not be invoked.
|
||||
///
|
||||
/// All declarations reported through DTDHandler or DeclHandler events must appear
|
||||
/// between the startDTD and endDTD events. Declarations are assumed to belong to
|
||||
/// the internal DTD subset unless they appear between startEntity and endEntity
|
||||
/// events. Comments and processing instructions from the DTD should also be reported
|
||||
/// between the startDTD and endDTD events, in their original order of (logical) occurrence;
|
||||
/// they are not required to appear in their correct locations relative to DTDHandler or
|
||||
/// DeclHandler events, however.
|
||||
///
|
||||
/// Note that the start/endDTD events will appear within the start/endDocument events from
|
||||
/// ContentHandler and before the first startElement event.
|
||||
|
||||
virtual void endDTD() = 0;
|
||||
/// Report the end of DTD declarations.
|
||||
///
|
||||
/// This method is intended to report the end of the DOCTYPE declaration; if the document
|
||||
/// has no DOCTYPE declaration, this method will not be invoked.
|
||||
|
||||
virtual void startEntity(const XMLString& name) = 0;
|
||||
/// Report the beginning of some internal and external XML entities.
|
||||
///
|
||||
/// The reporting of parameter entities (including the external DTD subset) is optional,
|
||||
/// and SAX2 drivers that report LexicalHandler events may not implement it; you can use the
|
||||
/// http://xml.org/sax/features/lexical-handler/parameter-entities feature to query or control
|
||||
/// the reporting of parameter entities.
|
||||
///
|
||||
/// General entities are reported with their regular names, parameter entities have '%'
|
||||
/// prepended to their names, and the external DTD subset has the pseudo-entity name "[dtd]".
|
||||
///
|
||||
/// When a SAX2 driver is providing these events, all other events must be properly nested
|
||||
/// within start/end entity events. There is no additional requirement that events from
|
||||
/// DeclHandler or DTDHandler be properly ordered.
|
||||
///
|
||||
/// Note that skipped entities will be reported through the skippedEntity event, which is part of
|
||||
/// the ContentHandler interface.
|
||||
///
|
||||
/// Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under
|
||||
/// any circumstances:
|
||||
///
|
||||
/// * general entities within attribute values
|
||||
/// * parameter entities within declarations
|
||||
///
|
||||
/// These will be silently expanded, with no indication of where the original entity boundaries were.
|
||||
///
|
||||
/// Note also that the boundaries of character references (which are not really entities anyway) are not reported.
|
||||
///
|
||||
/// All start/endEntity events must be properly nested.
|
||||
|
||||
virtual void endEntity(const XMLString& name) = 0;
|
||||
/// Report the end of an entity.
|
||||
|
||||
virtual void startCDATA() = 0;
|
||||
/// Report the start of a CDATA section.
|
||||
///
|
||||
/// The contents of the CDATA section will be reported through the regular characters event;
|
||||
/// this event is intended only to report the boundary.
|
||||
|
||||
virtual void endCDATA() = 0;
|
||||
/// Report the end of a CDATA section.
|
||||
|
||||
virtual void comment(const XMLChar ch[], int start, int length) = 0;
|
||||
/// Report an XML comment anywhere in the document.
|
||||
///
|
||||
/// This callback will be used for comments inside or outside the document element,
|
||||
/// including comments in the external DTD subset (if read). Comments in the DTD must
|
||||
/// be properly nested inside start/endDTD and start/endEntity events (if used).
|
||||
|
||||
protected:
|
||||
virtual ~LexicalHandler();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_LexicalHandler_INCLUDED
|
103
vendor/POCO/XML/include/Poco/SAX/Locator.h
vendored
Normal file
103
vendor/POCO/XML/include/Poco/SAX/Locator.h
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
//
|
||||
// Locator.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX Locator Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_Locator_INCLUDED
|
||||
#define SAX_Locator_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API Locator
|
||||
/// Interface for associating a SAX event with a document location.
|
||||
///
|
||||
/// 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
|
||||
/// content handler's setDocumentLocator method. The application can use the object to obtain
|
||||
/// the location of any other SAX event in the XML source document.
|
||||
///
|
||||
/// Note that the results returned by the object will be valid only during the scope of each
|
||||
/// callback method: the application will receive unpredictable results if it attempts to use
|
||||
/// the locator at any other time, or after parsing completes.
|
||||
///
|
||||
/// SAX parsers are not required to supply a locator, but they are very strongly 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.
|
||||
{
|
||||
public:
|
||||
virtual XMLString getPublicId() const = 0;
|
||||
/// Return the public identifier for the current document event.
|
||||
///
|
||||
/// The return value is the public identifier of the document entity or of the external
|
||||
/// parsed entity in which the markup triggering the event appears.
|
||||
|
||||
virtual XMLString getSystemId() const = 0;
|
||||
/// Return the system identifier for the current document event.
|
||||
///
|
||||
/// The return value is the system identifier of the document entity or of the external
|
||||
/// parsed entity in which the markup triggering the event appears.
|
||||
///
|
||||
/// If the system identifier is a URL, the parser must resolve it fully before passing
|
||||
/// it to the application. For example, a file name must always be provided as a
|
||||
/// file:... URL, and other kinds of relative URI are also resolved against their bases.
|
||||
|
||||
virtual int getLineNumber() const = 0;
|
||||
/// Return the line number where the current document event ends.
|
||||
/// Lines are delimited by line ends, which are defined in the XML specification.
|
||||
///
|
||||
/// Warning: The return value from the method is intended only as an approximation for
|
||||
/// the sake of diagnostics; it is not intended to provide sufficient information to
|
||||
/// edit the character content of the original XML document. In some cases, these "line"
|
||||
/// numbers match what would be displayed as columns, and in others they may not match the
|
||||
/// source text due to internal entity expansion.
|
||||
///
|
||||
/// The return value is an approximation of the line number in the document entity or external
|
||||
/// parsed entity where the markup triggering the event appears.
|
||||
///
|
||||
/// If possible, the SAX driver should provide the line position of the first character after
|
||||
/// the text associated with the document event. The first line is line 1.
|
||||
|
||||
virtual int getColumnNumber() const = 0;
|
||||
/// Return the column number where the current document event ends.
|
||||
/// This is one-based number of characters since the last line end.
|
||||
///
|
||||
/// Warning: The return value from the method is intended only as an approximation
|
||||
/// for the sake of diagnostics; it is not intended to provide sufficient information
|
||||
/// to edit the character content of the original XML document. For example, when lines
|
||||
/// contain combining character sequences, wide characters, surrogate pairs, or bi-directional
|
||||
/// text, the value may not correspond to the column in a text editor's display.
|
||||
///
|
||||
/// The return value is an approximation of the column number in the document entity or external
|
||||
/// parsed entity where the markup triggering the event appears.
|
||||
///
|
||||
/// If possible, the SAX driver should provide the line position of the first character after
|
||||
/// the text associated with the document event. The first column in each line is column 1.
|
||||
|
||||
protected:
|
||||
virtual ~Locator();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_Locator_INCLUDED
|
88
vendor/POCO/XML/include/Poco/SAX/LocatorImpl.h
vendored
Normal file
88
vendor/POCO/XML/include/Poco/SAX/LocatorImpl.h
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
//
|
||||
// LocatorImpl.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// An implementation of the SAX Locator interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_LocatorImpl_INCLUDED
|
||||
#define SAX_LocatorImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/SAX/Locator.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API LocatorImpl: public Locator
|
||||
/// Provide an optional convenience implementation of Locator.
|
||||
{
|
||||
public:
|
||||
LocatorImpl();
|
||||
/// Zero-argument constructor.
|
||||
///
|
||||
/// This will not normally be useful, since the main purpose of this class is
|
||||
/// to make a snapshot of an existing Locator.
|
||||
|
||||
LocatorImpl(const Locator& loc);
|
||||
/// Copy constructor.
|
||||
///
|
||||
/// Create a persistent copy of the current state of a locator. When the original
|
||||
/// locator changes, this copy will still keep the original values (and it can be
|
||||
/// used outside the scope of DocumentHandler methods).
|
||||
|
||||
~LocatorImpl();
|
||||
/// Destroys the Locator.
|
||||
|
||||
LocatorImpl& operator = (const Locator& loc);
|
||||
/// Assignment operator.
|
||||
|
||||
XMLString getPublicId() const;
|
||||
/// Return the saved public identifier.
|
||||
|
||||
XMLString getSystemId() const;
|
||||
/// Return the saved system identifier.
|
||||
|
||||
int getLineNumber() const;
|
||||
/// Return the saved line number (1-based).
|
||||
|
||||
int getColumnNumber() const;
|
||||
/// Return the saved column number (1-based).
|
||||
|
||||
void setPublicId(const XMLString& publicId);
|
||||
/// Set the public identifier for this locator.
|
||||
|
||||
void setSystemId(const XMLString& systemId);
|
||||
/// Set the system identifier for this locator.
|
||||
|
||||
void setLineNumber(int lineNumber);
|
||||
/// Set the line number for this locator (1-based).
|
||||
|
||||
void setColumnNumber(int columnNumber);
|
||||
/// Set the column number for this locator (1-based).
|
||||
|
||||
private:
|
||||
XMLString _publicId;
|
||||
XMLString _systemId;
|
||||
int _lineNumber;
|
||||
int _columnNumber;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_LocatorImpl_INCLUDED
|
195
vendor/POCO/XML/include/Poco/SAX/NamespaceSupport.h
vendored
Normal file
195
vendor/POCO/XML/include/Poco/SAX/NamespaceSupport.h
vendored
Normal file
@ -0,0 +1,195 @@
|
||||
//
|
||||
// NamespaceSupport.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// Namespace support for SAX2.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_NamespaceSupport_INCLUDED
|
||||
#define SAX_NamespaceSupport_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API NamespaceSupport
|
||||
/// Encapsulate Namespace logic for use by SAX drivers.
|
||||
/// This class encapsulates the logic of Namespace processing:
|
||||
/// it tracks the declarations currently in force for each context and
|
||||
/// automatically processes qualified XML 1.0 names into their Namespace
|
||||
/// parts; it can also be used in reverse for generating
|
||||
/// XML 1.0 from Namespaces.
|
||||
/// Namespace support objects are reusable, but the reset method
|
||||
/// must be invoked between each session.
|
||||
{
|
||||
public:
|
||||
using PrefixSet = std::set<XMLString>;
|
||||
|
||||
NamespaceSupport();
|
||||
/// Creates a NamespaceSupport object.
|
||||
|
||||
~NamespaceSupport();
|
||||
/// Destroys a NamespaceSupport object.
|
||||
|
||||
bool declarePrefix(const XMLString& prefix, const XMLString& namespaceURI);
|
||||
/// Declare a Namespace prefix. All prefixes must be declared before they are
|
||||
/// referenced. For example, a SAX driver (parser) would scan an element's attributes
|
||||
/// in two passes: first for namespace declarations, then a second pass using
|
||||
/// processName() to interpret prefixes against (potentially redefined) prefixes.
|
||||
///
|
||||
/// This method declares a prefix in the current Namespace context; the prefix
|
||||
/// will remain in force until this context is popped, unless it is shadowed
|
||||
/// in a descendant context.
|
||||
///
|
||||
/// To declare the default element Namespace, use the empty string as the prefix.
|
||||
///
|
||||
/// Note that you must not declare a prefix after you've pushed and popped another
|
||||
/// Namespace context, or treated the declarations phase as complete by processing
|
||||
/// a prefixed name.
|
||||
///
|
||||
/// Returns true if the prefix was legal, false otherwise.
|
||||
|
||||
bool undeclarePrefix(const XMLString& prefix);
|
||||
/// Remove the given namespace prefix.
|
||||
|
||||
void getDeclaredPrefixes(PrefixSet& prefixes) const;
|
||||
/// Return an enumeration of all prefixes declared in this context.
|
||||
///
|
||||
/// The empty (default) prefix will be included in this enumeration; note that
|
||||
/// this behaviour differs from that of getPrefix() and getPrefixes().
|
||||
|
||||
const XMLString& getPrefix(const XMLString& namespaceURI) const;
|
||||
/// Return one of the prefixes mapped to a Namespace URI.
|
||||
///
|
||||
/// If more than one prefix is currently mapped to the same URI, this method
|
||||
/// will make an arbitrary selection; if you want all of the prefixes, use the
|
||||
/// getPrefixes() method instead.
|
||||
|
||||
bool isMapped(const XMLString& namespaceURI) const;
|
||||
/// Returns true if the given namespaceURI has been mapped to a prefix,
|
||||
/// false otherwise.
|
||||
|
||||
void getPrefixes(PrefixSet& prefixes) const;
|
||||
/// Return an enumeration of all prefixes whose declarations are active in the
|
||||
/// current context. This includes declarations from parent contexts that have
|
||||
/// not been overridden.
|
||||
///
|
||||
/// Note: if there is a default prefix, it will not be returned in this enumeration;
|
||||
/// check for the default prefix using the getURI with an argument of "".
|
||||
|
||||
void getPrefixes(const XMLString& namespaceURI, PrefixSet& prefixes) const;
|
||||
/// Return an enumeration of all prefixes for a given URI whose declarations
|
||||
/// are active in the current context. This includes declarations from parent
|
||||
/// contexts that have not been overridden.
|
||||
///
|
||||
/// This method returns prefixes mapped to a specific Namespace URI. The xml:
|
||||
/// prefix will be included. If you want only one prefix that's mapped to the
|
||||
/// Namespace URI, and you don't care which one you get, use the getPrefix() method
|
||||
/// instead.
|
||||
///
|
||||
/// Note: the empty (default) prefix is never included in this enumeration;
|
||||
/// to check for the presence of a default Namespace, use the getURI() method
|
||||
/// with an argument of "".
|
||||
|
||||
const XMLString& getURI(const XMLString& prefix) const;
|
||||
/// Look up a prefix and get the currently-mapped Namespace URI.
|
||||
///
|
||||
/// This method looks up the prefix in the current context. Use the empty string
|
||||
/// ("") for the default Namespace.
|
||||
|
||||
void pushContext();
|
||||
/// Start a new Namespace context. The new context will automatically inherit
|
||||
/// the declarations of its parent context, but it will also keep track of which
|
||||
/// declarations were made within this context.
|
||||
///
|
||||
/// Event callback code should start a new context once per element. This means
|
||||
/// being ready to call this in either of two places. For elements that don't
|
||||
/// include namespace declarations, the ContentHandler::startElement() callback
|
||||
/// is the right place. For elements with such a declaration, it'd done in the
|
||||
/// first ContentHandler::startPrefixMapping() callback. A boolean flag can be
|
||||
/// used to track whether a context has been started yet. When either of those
|
||||
/// methods is called, it checks the flag to see if a new context needs to be
|
||||
/// started. If so, it starts the context and sets the flag. After
|
||||
/// ContentHandler::startElement() does that, it always clears the flag.
|
||||
///
|
||||
/// Normally, SAX drivers would push a new context at the beginning of each
|
||||
/// XML element. Then they perform a first pass over the attributes to process
|
||||
/// all namespace declarations, making ContentHandler::startPrefixMapping() callbacks.
|
||||
/// Then a second pass is made, to determine the namespace-qualified names for
|
||||
/// all attributes and for the element name. Finally all the information for
|
||||
/// the ContentHandler::startElement() callback is available, so it can then
|
||||
/// be made.
|
||||
///
|
||||
/// The Namespace support object always starts with a base context already in
|
||||
/// force: in this context, only the "xml" prefix is declared.
|
||||
|
||||
void popContext();
|
||||
/// Revert to the previous Namespace context.
|
||||
///
|
||||
/// Normally, you should pop the context at the end of each XML element. After
|
||||
/// popping the context, all Namespace prefix mappings that were previously
|
||||
/// in force are restored.
|
||||
///
|
||||
/// You must not attempt to declare additional Namespace prefixes after popping
|
||||
/// a context, unless you push another context first.
|
||||
|
||||
bool processName(const XMLString& qname, XMLString& namespaceURI, XMLString& localName, bool isAttribute) const;
|
||||
/// Process a raw XML 1.0 name.
|
||||
/// This method processes a raw XML 1.0 name in the current context
|
||||
/// by removing the prefix and looking it up among the
|
||||
/// prefixes currently declared. The result will be returned in
|
||||
/// namespaceURI and localName.
|
||||
/// If the raw name has a prefix that has not been declared, then the return
|
||||
/// value will be false, otherwise true.
|
||||
///
|
||||
/// Note that attribute names are processed differently than element names:
|
||||
/// an unprefixed element name will receive the
|
||||
/// default Namespace (if any), while an unprefixed attribute name will not.
|
||||
|
||||
void reset();
|
||||
/// Reset this Namespace support object for reuse.
|
||||
///
|
||||
/// It is necessary to invoke this method before reusing the Namespace support
|
||||
/// object for a new session. If namespace declaration URIs are to be supported,
|
||||
/// that flag must also be set to a non-default value.
|
||||
/// Reset this Namespace support object for reuse.
|
||||
|
||||
static const XMLString XML_NAMESPACE;
|
||||
static const XMLString XML_NAMESPACE_PREFIX;
|
||||
static const XMLString XMLNS_NAMESPACE;
|
||||
static const XMLString XMLNS_NAMESPACE_PREFIX;
|
||||
|
||||
private:
|
||||
NamespaceSupport(const NamespaceSupport&);
|
||||
NamespaceSupport& operator = (const NamespaceSupport&);
|
||||
|
||||
typedef std::map<XMLString, XMLString> Context;
|
||||
typedef std::vector<Context> ContextVec;
|
||||
|
||||
ContextVec _contexts;
|
||||
|
||||
static const XMLString EMPTY_STRING;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_NamespaceSupport_INCLUDED
|
176
vendor/POCO/XML/include/Poco/SAX/SAXException.h
vendored
Normal file
176
vendor/POCO/XML/include/Poco/SAX/SAXException.h
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
//
|
||||
// SAXException.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX exception classes.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_SAXException_INCLUDED
|
||||
#define SAX_SAXException_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLException.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
POCO_DECLARE_EXCEPTION(XML_API, SAXException, XMLException)
|
||||
/// The base class for all SAX-related exceptions like SAXParseException,
|
||||
/// SAXNotRecognizedException or SAXNotSupportedException.
|
||||
///
|
||||
/// This class can contain basic error or warning information from either the XML 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.
|
||||
///
|
||||
/// 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.
|
||||
///
|
||||
/// If the parser or application needs to include information about a specific location in an XML
|
||||
/// document, it should use the SAXParseException subclass.
|
||||
|
||||
|
||||
POCO_DECLARE_EXCEPTION(XML_API, SAXNotRecognizedException, SAXException)
|
||||
/// Exception class for an unrecognized identifier.
|
||||
///
|
||||
/// An XMLReader will throw this exception when it finds an unrecognized feature or property
|
||||
/// identifier; SAX applications and extensions may use this class for other, similar purposes.
|
||||
|
||||
|
||||
POCO_DECLARE_EXCEPTION(XML_API, SAXNotSupportedException, SAXException)
|
||||
/// Exception class for an unsupported operation.
|
||||
///
|
||||
/// An XMLReader will throw this exception when it recognizes a feature or property identifier,
|
||||
/// but cannot perform the requested operation (setting a state or value). Other SAX2 applications
|
||||
/// and extensions may use this class for similar purposes.
|
||||
|
||||
|
||||
class Locator;
|
||||
|
||||
|
||||
class XML_API SAXParseException: public SAXException
|
||||
/// Encapsulate an XML parse error or warning.
|
||||
///
|
||||
/// This exception may include information for locating the error in the original XML document,
|
||||
/// as if it came from a Locator object. 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.
|
||||
///
|
||||
/// Since this exception is a subclass of SAXException, it inherits the ability to wrap another exception.
|
||||
{
|
||||
public:
|
||||
SAXParseException(const std::string& msg, const Locator& loc);
|
||||
/// Create a new SAXParseException from a message and a Locator.
|
||||
|
||||
SAXParseException(const std::string& msg, const Locator& loc, const Poco::Exception& exc);
|
||||
/// Wrap an existing exception in a SAXParseException.
|
||||
|
||||
SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber);
|
||||
/// Create a new SAXParseException with an embedded exception.
|
||||
///
|
||||
/// This constructor is most useful for parser writers.
|
||||
/// All parameters except the message are as if they were provided by a Locator.
|
||||
/// For example, if the system identifier is a URL (including relative filename),
|
||||
/// the caller must resolve it fully before creating the exception.
|
||||
|
||||
SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber, const Poco::Exception& exc);
|
||||
/// Create a new SAXParseException.
|
||||
///
|
||||
/// This constructor is most useful for parser writers.
|
||||
/// All parameters except the message are as if they were provided by a Locator.
|
||||
/// For example, if the system identifier is a URL (including relative filename),
|
||||
/// the caller must resolve it fully before creating the exception.
|
||||
|
||||
SAXParseException(const SAXParseException& exc);
|
||||
/// Creates a new SAXParseException from another one.
|
||||
|
||||
~SAXParseException() noexcept;
|
||||
/// Destroy the exception.
|
||||
|
||||
SAXParseException& operator = (const SAXParseException& exc);
|
||||
/// Assignment operator.
|
||||
|
||||
const char* name() const noexcept;
|
||||
/// Returns a static string describing the exception.
|
||||
|
||||
const char* className() const noexcept;
|
||||
/// Returns the name of the exception class.
|
||||
|
||||
Poco::Exception* clone() const;
|
||||
/// Creates an exact copy of the exception.
|
||||
|
||||
void rethrow() const;
|
||||
/// (Re)Throws the exception.
|
||||
|
||||
const XMLString& getPublicId() const;
|
||||
/// Get the public identifier of the entity where the exception occurred.
|
||||
|
||||
const XMLString& getSystemId() const;
|
||||
/// Get the system identifier of the entity where the exception occurred.
|
||||
|
||||
int getLineNumber() const;
|
||||
/// The line number of the end of the text where the exception occurred.
|
||||
/// The first line is line 1.
|
||||
|
||||
int getColumnNumber() const;
|
||||
/// The column number of the end of the text where the exception occurred.
|
||||
/// The first column in a line is position 1.
|
||||
|
||||
protected:
|
||||
static std::string buildMessage(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber);
|
||||
|
||||
private:
|
||||
SAXParseException();
|
||||
|
||||
XMLString _publicId;
|
||||
XMLString _systemId;
|
||||
int _lineNumber;
|
||||
int _columnNumber;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline const XMLString& SAXParseException::getPublicId() const
|
||||
{
|
||||
return _publicId;
|
||||
}
|
||||
|
||||
|
||||
inline const XMLString& SAXParseException::getSystemId() const
|
||||
{
|
||||
return _systemId;
|
||||
}
|
||||
|
||||
|
||||
inline int SAXParseException::getLineNumber() const
|
||||
{
|
||||
return _lineNumber;
|
||||
}
|
||||
|
||||
|
||||
inline int SAXParseException::getColumnNumber() const
|
||||
{
|
||||
return _columnNumber;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_SAXException_INCLUDED
|
103
vendor/POCO/XML/include/Poco/SAX/SAXParser.h
vendored
Normal file
103
vendor/POCO/XML/include/Poco/SAX/SAXParser.h
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
//
|
||||
// SAXParser.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// Implementation of the XMLReader interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_SAXParser_INCLUDED
|
||||
#define SAX_SAXParser_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/SAX/XMLReader.h"
|
||||
#include "Poco/XML/ParserEngine.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API SAXParser: public XMLReader
|
||||
/// This class provides a SAX2 (Simple API for XML) interface to expat,
|
||||
/// the XML parser toolkit.
|
||||
/// The following SAX2 features and properties are supported:
|
||||
/// * http://xml.org/sax/features/external-general-entities
|
||||
/// * http://xml.org/sax/features/external-parameter-entities
|
||||
/// * http://xml.org/sax/features/namespaces
|
||||
/// * http://xml.org/sax/features/namespace-prefixes
|
||||
/// * http://xml.org/sax/properties/lexical-handler
|
||||
/// * http://xml.org/sax/properties/declaration-handler
|
||||
///
|
||||
/// The following proprietary extensions are supported:
|
||||
/// * http://www.appinf.com/features/enable-partial-reads --
|
||||
/// see ParserEngine::setEnablePartialReads()
|
||||
{
|
||||
public:
|
||||
SAXParser();
|
||||
/// Creates an SAXParser.
|
||||
|
||||
SAXParser(const XMLString& encoding);
|
||||
/// Creates an SAXParser with the given encoding.
|
||||
|
||||
~SAXParser();
|
||||
/// Destroys the SAXParser.
|
||||
|
||||
void setEncoding(const XMLString& encoding);
|
||||
/// Sets the encoding used by the parser if no
|
||||
/// encoding is specified in the XML document.
|
||||
|
||||
const XMLString& getEncoding() const;
|
||||
/// Returns the name of the encoding used by
|
||||
/// the parser if no encoding is specified in
|
||||
/// the XML document.
|
||||
|
||||
void addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding);
|
||||
/// Adds an encoding to the parser. Does not take ownership of the pointer!
|
||||
|
||||
/// XMLReader
|
||||
void setEntityResolver(EntityResolver* pResolver);
|
||||
EntityResolver* getEntityResolver() const;
|
||||
void setDTDHandler(DTDHandler* pDTDHandler);
|
||||
DTDHandler* getDTDHandler() const;
|
||||
void setContentHandler(ContentHandler* pContentHandler);
|
||||
ContentHandler* getContentHandler() const;
|
||||
void setErrorHandler(ErrorHandler* pErrorHandler);
|
||||
ErrorHandler* getErrorHandler() const;
|
||||
void setFeature(const XMLString& featureId, bool state);
|
||||
bool getFeature(const XMLString& featureId) const;
|
||||
void setProperty(const XMLString& propertyId, const XMLString& value);
|
||||
void setProperty(const XMLString& propertyId, void* value);
|
||||
void* getProperty(const XMLString& propertyId) const;
|
||||
void parse(InputSource* pSource);
|
||||
void parse(const XMLString& systemId);
|
||||
void parseMemoryNP(const char* xml, std::size_t size);
|
||||
|
||||
/// Extensions
|
||||
void parseString(const std::string& xml);
|
||||
|
||||
static const XMLString FEATURE_PARTIAL_READS;
|
||||
|
||||
protected:
|
||||
void setupParse();
|
||||
|
||||
private:
|
||||
ParserEngine _engine;
|
||||
bool _namespaces;
|
||||
bool _namespacePrefixes;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_SAXParser_INCLUDED
|
81
vendor/POCO/XML/include/Poco/SAX/WhitespaceFilter.h
vendored
Normal file
81
vendor/POCO/XML/include/Poco/SAX/WhitespaceFilter.h
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
//
|
||||
// WhitespaceFilter.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: WhitespaceFilter
|
||||
//
|
||||
// Definition of the WhitespaceFilter class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_WhitespaceFilter_INCLUDED
|
||||
#define SAX_WhitespaceFilter_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/SAX/XMLFilterImpl.h"
|
||||
#include "Poco/SAX/LexicalHandler.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API WhitespaceFilter: public XMLFilterImpl, public LexicalHandler
|
||||
/// This implementation of the SAX2 XMLFilter interface
|
||||
/// filters all whitespace-only character data element
|
||||
/// content.
|
||||
{
|
||||
public:
|
||||
WhitespaceFilter();
|
||||
/// Creates the WhitespaceFilter, with no parent.
|
||||
|
||||
WhitespaceFilter(XMLReader* pReader);
|
||||
/// Creates the WhitespaceFilter with the specified parent.
|
||||
|
||||
~WhitespaceFilter();
|
||||
/// Destroys the WhitespaceFilter.
|
||||
|
||||
// XMLReader
|
||||
void setProperty(const XMLString& propertyId, const XMLString& value);
|
||||
void setProperty(const XMLString& propertyId, void* value);
|
||||
void* getProperty(const XMLString& propertyId) const;
|
||||
|
||||
// ContentHandler
|
||||
void startDocument();
|
||||
void endDocument();
|
||||
void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList);
|
||||
void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname);
|
||||
void characters(const XMLChar ch[], int start, int length);
|
||||
void ignorableWhitespace(const XMLChar ch[], int start, int length);
|
||||
void processingInstruction(const XMLString& target, const XMLString& data);
|
||||
|
||||
// LexicalHandler
|
||||
void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId);
|
||||
void endDTD();
|
||||
void startEntity(const XMLString& name);
|
||||
void endEntity(const XMLString& name);
|
||||
void startCDATA();
|
||||
void endCDATA();
|
||||
void comment(const XMLChar ch[], int start, int length);
|
||||
|
||||
protected:
|
||||
void setupParse();
|
||||
|
||||
private:
|
||||
LexicalHandler* _pLexicalHandler;
|
||||
XMLString _data;
|
||||
bool _filter;
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_WhitespaceFilter_INCLUDED
|
61
vendor/POCO/XML/include/Poco/SAX/XMLFilter.h
vendored
Normal file
61
vendor/POCO/XML/include/Poco/SAX/XMLFilter.h
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
//
|
||||
// XMLFilter.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAXFilters
|
||||
//
|
||||
// SAX2 XMLFilter Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_XMLFilter_INCLUDED
|
||||
#define SAX_XMLFilter_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/SAX/XMLReader.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API XMLFilter: public XMLReader
|
||||
/// Interface for an XML filter.
|
||||
///
|
||||
/// An XML filter is like an XML reader, except that it obtains its events from another XML reader
|
||||
/// rather than a primary source like an XML document or database. Filters can modify a stream of
|
||||
/// events as they pass on to the final application.
|
||||
///
|
||||
/// The XMLFilterImpl helper class provides a convenient base for creating SAX2 filters, by passing on
|
||||
/// all EntityResolver, DTDHandler, ContentHandler and ErrorHandler events automatically.
|
||||
{
|
||||
public:
|
||||
virtual XMLReader* getParent() const = 0;
|
||||
/// Set the parent reader.
|
||||
///
|
||||
/// This method allows the application to link the filter to a parent reader (which may be another
|
||||
/// filter). The argument may not be null.
|
||||
|
||||
virtual void setParent(XMLReader* pParent) = 0;
|
||||
/// Get the parent reader.
|
||||
///
|
||||
/// This method allows the application to query the parent reader (which may be another filter).
|
||||
/// It is generally a bad idea to perform any operations on the parent reader directly: they should
|
||||
/// all pass through this filter.
|
||||
|
||||
protected:
|
||||
virtual ~XMLFilter();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_XMLFilter_INCLUDED
|
132
vendor/POCO/XML/include/Poco/SAX/XMLFilterImpl.h
vendored
Normal file
132
vendor/POCO/XML/include/Poco/SAX/XMLFilterImpl.h
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
//
|
||||
// XMLFilterImpl.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAXFilters
|
||||
//
|
||||
// SAX2 XMLFilterImpl class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_XMLFilterImpl_INCLUDED
|
||||
#define SAX_XMLFilterImpl_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/SAX/XMLFilter.h"
|
||||
#include "Poco/SAX/EntityResolver.h"
|
||||
#include "Poco/SAX/DTDHandler.h"
|
||||
#include "Poco/SAX/ContentHandler.h"
|
||||
#include "Poco/SAX/ErrorHandler.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class XML_API XMLFilterImpl: public XMLFilter, public EntityResolver, public DTDHandler, public ContentHandler, public ErrorHandler
|
||||
/// Base class for deriving an XML filter.
|
||||
///
|
||||
/// This class is designed to sit between an XMLReader and the client application's event
|
||||
/// handlers. By default, it does nothing but pass requests up to the reader and events on to
|
||||
/// the handlers unmodified, but subclasses can override specific methods to modify the event
|
||||
/// stream or the configuration requests as they pass through.
|
||||
{
|
||||
public:
|
||||
XMLFilterImpl();
|
||||
/// Construct an empty XML filter, with no parent.
|
||||
///
|
||||
/// This filter will have no parent: you must assign a parent before you start a parse or do any
|
||||
/// configuration with setFeature or setProperty, unless you use this as a pure event consumer rather
|
||||
/// than as an XMLReader.
|
||||
|
||||
XMLFilterImpl(XMLReader* pParent);
|
||||
/// Construct an XML filter with the specified parent.
|
||||
|
||||
~XMLFilterImpl();
|
||||
/// Destroys the XMLFilterImpl.
|
||||
|
||||
// XMLFilter
|
||||
XMLReader* getParent() const;
|
||||
void setParent(XMLReader* pParent);
|
||||
|
||||
// XMLReader
|
||||
void setEntityResolver(EntityResolver* pResolver);
|
||||
EntityResolver* getEntityResolver() const;
|
||||
void setDTDHandler(DTDHandler* pDTDHandler);
|
||||
DTDHandler* getDTDHandler() const;
|
||||
void setContentHandler(ContentHandler* pContentHandler);
|
||||
ContentHandler* getContentHandler() const;
|
||||
void setErrorHandler(ErrorHandler* pErrorHandler);
|
||||
ErrorHandler* getErrorHandler() const;
|
||||
void setFeature(const XMLString& featureId, bool state);
|
||||
bool getFeature(const XMLString& featureId) const;
|
||||
void setProperty(const XMLString& propertyId, const XMLString& value);
|
||||
void setProperty(const XMLString& propertyId, void* value);
|
||||
void* getProperty(const XMLString& propertyId) const;
|
||||
void parse(InputSource* pSource);
|
||||
void parse(const XMLString& systemId);
|
||||
void parseMemoryNP(const char* xml, std::size_t size);
|
||||
|
||||
// EntityResolver
|
||||
InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId);
|
||||
void releaseInputSource(InputSource* pSource);
|
||||
|
||||
// DTDHandler
|
||||
void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId);
|
||||
void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName);
|
||||
|
||||
// ContentHandler
|
||||
void setDocumentLocator(const Locator* loc);
|
||||
void startDocument();
|
||||
void endDocument();
|
||||
void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList);
|
||||
void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname);
|
||||
void characters(const XMLChar ch[], int start, int length);
|
||||
void ignorableWhitespace(const XMLChar ch[], int start, int length);
|
||||
void processingInstruction(const XMLString& target, const XMLString& data);
|
||||
void startPrefixMapping(const XMLString& prefix, const XMLString& uri);
|
||||
void endPrefixMapping(const XMLString& prefix);
|
||||
void skippedEntity(const XMLString& prefix);
|
||||
void warning(const SAXException& e);
|
||||
void error(const SAXException& e);
|
||||
void fatalError(const SAXException& e);
|
||||
|
||||
protected:
|
||||
XMLReader* parent() const;
|
||||
/// Return a pointer to the parent reader.
|
||||
/// Subclasses can use this method instead of
|
||||
/// getParent() for better performance - this method
|
||||
/// is non-virtual and implemented as inline.
|
||||
|
||||
virtual void setupParse();
|
||||
/// Setup the event handlers in the parent reader.
|
||||
|
||||
private:
|
||||
XMLReader* _pParent;
|
||||
EntityResolver* _pEntityResolver;
|
||||
DTDHandler* _pDTDHandler;
|
||||
ContentHandler* _pContentHandler;
|
||||
ErrorHandler* _pErrorHandler;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// inlines
|
||||
//
|
||||
inline XMLReader* XMLFilterImpl::parent() const
|
||||
{
|
||||
return _pParent;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_XMLFilterImpl_INCLUDED
|
205
vendor/POCO/XML/include/Poco/SAX/XMLReader.h
vendored
Normal file
205
vendor/POCO/XML/include/Poco/SAX/XMLReader.h
vendored
Normal file
@ -0,0 +1,205 @@
|
||||
//
|
||||
// XMLReader.h
|
||||
//
|
||||
// Library: XML
|
||||
// Package: SAX
|
||||
// Module: SAX
|
||||
//
|
||||
// SAX2 XMLReader Interface.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#ifndef SAX_XMLReader_INCLUDED
|
||||
#define SAX_XMLReader_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/XML/XML.h"
|
||||
#include "Poco/XML/XMLString.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace XML {
|
||||
|
||||
|
||||
class EntityResolver;
|
||||
class DTDHandler;
|
||||
class ContentHandler;
|
||||
class ErrorHandler;
|
||||
class InputSource;
|
||||
class LexicalHandler;
|
||||
class NamespaceHandler;
|
||||
|
||||
|
||||
class XML_API XMLReader
|
||||
/// Interface for reading an XML document using callbacks.
|
||||
/// XMLReader is the interface that an XML parser's SAX2 driver must
|
||||
/// implement. This interface allows an application to set and
|
||||
/// query features and properties in the parser, to register event handlers
|
||||
/// for document processing, and to initiate a document parse.
|
||||
/// All SAX interfaces are assumed to be synchronous: the parse methods must not
|
||||
/// return until parsing is complete, and readers
|
||||
/// must wait for an event-handler callback to return before reporting the next event.
|
||||
{
|
||||
public:
|
||||
virtual void setEntityResolver(EntityResolver* pResolver) = 0;
|
||||
/// Allow an application to register an entity resolver.
|
||||
///
|
||||
/// If the application does not register an entity resolver, the
|
||||
/// XMLReader will perform its own default resolution.
|
||||
///
|
||||
/// Applications may register a new or different resolver in the middle of a
|
||||
/// parse, and the SAX parser must begin using the new resolver immediately.
|
||||
|
||||
virtual EntityResolver* getEntityResolver() const = 0;
|
||||
/// Return the current entity resolver.
|
||||
|
||||
virtual void setDTDHandler(DTDHandler* pDTDHandler) = 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.
|
||||
///
|
||||
/// 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.
|
||||
|
||||
virtual DTDHandler* getDTDHandler() const = 0;
|
||||
/// Return the current DTD handler.
|
||||
|
||||
virtual void setContentHandler(ContentHandler* pContentHandler) = 0;
|
||||
/// Allow an application to register a content event handler.
|
||||
///
|
||||
/// If the application does not register a content handler, all content events
|
||||
/// reported by the SAX parser will be silently ignored.
|
||||
///
|
||||
/// 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.
|
||||
|
||||
virtual ContentHandler* getContentHandler() const = 0;
|
||||
/// Return the current content handler.
|
||||
|
||||
virtual void setErrorHandler(ErrorHandler* pErrorHandler) = 0;
|
||||
/// Allow an application to register an error event handler.
|
||||
///
|
||||
/// If the application does not register an error handler, all error events reported by
|
||||
/// the SAX parser will be silently ignored; however, normal processing may not continue.
|
||||
/// It is highly recommended that all SAX applications implement an error handler to avoid
|
||||
/// unexpected bugs.
|
||||
///
|
||||
/// 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.
|
||||
|
||||
virtual ErrorHandler* getErrorHandler() const = 0;
|
||||
/// Return the current error handler.
|
||||
|
||||
virtual void setFeature(const XMLString& featureId, bool state) = 0;
|
||||
/// Set the state of a feature.
|
||||
///
|
||||
/// The feature name is any fully-qualified URI. It is possible for an XMLReader to
|
||||
/// expose a feature value but to be unable to change the current value. Some feature
|
||||
/// values may be immutable or mutable only in specific contexts, such as before, during,
|
||||
/// or after a parse.
|
||||
///
|
||||
/// All XMLReaders are required to support setting http://xml.org/sax/features/namespaces
|
||||
/// to true and http://xml.org/sax/features/namespace-prefixes to false.
|
||||
|
||||
virtual bool getFeature(const XMLString& featureId) const = 0;
|
||||
/// Look up the value of a feature.
|
||||
///
|
||||
/// The feature name is any fully-qualified URI. It is possible for an XMLReader
|
||||
/// to recognize a feature name but temporarily be unable to return its value.
|
||||
/// Some feature values may be available only in specific contexts, such as before,
|
||||
/// during, or after a parse. Also, some feature values may not be programmatically
|
||||
/// accessible. (In the case of an adapter for SAX1 Parser, there is no
|
||||
/// implementation-independent way to expose whether the underlying parser is performing
|
||||
/// validation, expanding external entities, and so forth.)
|
||||
///
|
||||
/// All XMLReaders are required to recognize the
|
||||
/// http://xml.org/sax/features/namespaces and the
|
||||
/// http://xml.org/sax/features/namespace-prefixes feature names.
|
||||
/// Implementors are free (and encouraged) to invent their own features,
|
||||
/// using names built on their own URIs.
|
||||
|
||||
virtual void setProperty(const XMLString& propertyId, const XMLString& value) = 0;
|
||||
/// Set the value of a property.
|
||||
///
|
||||
/// The property name is any fully-qualified URI. It is possible for an XMLReader
|
||||
/// to recognize a property name but to be unable to change the current value.
|
||||
/// Some property values may be immutable or mutable only in specific contexts,
|
||||
/// such as before, during, or after a parse.
|
||||
///
|
||||
/// XMLReaders are not required to recognize setting any specific property names, though a
|
||||
/// core set is defined by SAX2.
|
||||
///
|
||||
/// This method is also the standard mechanism for setting extended handlers.
|
||||
|
||||
virtual void setProperty(const XMLString& propertyId, void* value) = 0;
|
||||
/// Set the value of a property.
|
||||
/// See also setProperty(const XMLString&, const XMLString&).
|
||||
|
||||
virtual void* getProperty(const XMLString& propertyId) const = 0;
|
||||
/// Look up the value of a property.
|
||||
/// String values are returned as XMLChar*
|
||||
/// The property name is any fully-qualified URI. It is possible for an XMLReader to
|
||||
/// recognize a property name but temporarily be unable to return its value. Some property
|
||||
/// values may be available only in specific contexts, such as before, during, or after a parse.
|
||||
///
|
||||
/// XMLReaders are not required to recognize any specific property names, though an initial
|
||||
/// core set is documented for SAX2.
|
||||
///
|
||||
/// Implementors are free (and encouraged) to invent their own properties, using names
|
||||
/// built on their own URIs.
|
||||
|
||||
virtual void parse(InputSource* pSource) = 0;
|
||||
/// Parse an XML document.
|
||||
///
|
||||
/// The application can use this method to instruct the XML reader 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 XMLReader instead for each nested XML document). Once a parse is complete, an
|
||||
/// application may reuse the same XMLReader object, possibly with a different input source.
|
||||
/// Configuration of the XMLReader object (such as handler bindings and values established for
|
||||
/// feature flags and properties) is unchanged by completion of a parse, unless the definition of that
|
||||
/// aspect of the configuration explicitly specifies other behavior. (For example, feature flags or
|
||||
/// properties exposing characteristics of the document being parsed.)
|
||||
///
|
||||
/// During the parse, the XMLReader will provide information about the XML document through the registered
|
||||
/// event handlers.
|
||||
///
|
||||
/// This method is synchronous: it will not return until parsing has ended. If a client application
|
||||
/// wants to terminate parsing early, it should throw an exception.
|
||||
|
||||
virtual void parse(const XMLString& systemId) = 0;
|
||||
/// Parse an XML document from a system identifier.
|
||||
/// See also parse(InputSource*).
|
||||
|
||||
virtual void parseMemoryNP(const char* xml, std::size_t size) = 0;
|
||||
/// Parse an XML document from memory.
|
||||
/// See also parse(InputSource*).
|
||||
|
||||
// SAX Features
|
||||
static const XMLString FEATURE_VALIDATION;
|
||||
static const XMLString FEATURE_NAMESPACES;
|
||||
static const XMLString FEATURE_NAMESPACE_PREFIXES;
|
||||
static const XMLString FEATURE_EXTERNAL_GENERAL_ENTITIES;
|
||||
static const XMLString FEATURE_EXTERNAL_PARAMETER_ENTITIES;
|
||||
static const XMLString FEATURE_STRING_INTERNING;
|
||||
|
||||
// SAX Properties
|
||||
static const XMLString PROPERTY_DECLARATION_HANDLER;
|
||||
static const XMLString PROPERTY_LEXICAL_HANDLER;
|
||||
|
||||
protected:
|
||||
virtual ~XMLReader();
|
||||
};
|
||||
|
||||
|
||||
} } // namespace Poco::XML
|
||||
|
||||
|
||||
#endif // SAX_XMLReader_INCLUDED
|
Reference in New Issue
Block a user