1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-08-10 18:07:10 +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:
Sandu Liviu Catalin
2021-01-30 08:51:39 +02:00
parent e0e34b4030
commit 4a6bfc086c
6219 changed files with 1209835 additions and 454916 deletions

View File

@@ -0,0 +1,573 @@
//
// AbstractContainerNode.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/AbstractContainerNode.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/Element.h"
#include "Poco/DOM/Attr.h"
#include "Poco/DOM/DOMException.h"
#include "Poco/DOM/ElementsByTagNameList.h"
#include "Poco/DOM/AutoPtr.h"
#include "Poco/NumberParser.h"
#include "Poco/UnicodeConverter.h"
namespace Poco {
namespace XML {
const XMLString AbstractContainerNode::WILDCARD(toXMLString("*"));
AbstractContainerNode::AbstractContainerNode(Document* pOwnerDocument):
AbstractNode(pOwnerDocument),
_pFirstChild(0)
{
}
AbstractContainerNode::AbstractContainerNode(Document* pOwnerDocument, const AbstractContainerNode& node):
AbstractNode(pOwnerDocument, node),
_pFirstChild(0)
{
}
AbstractContainerNode::~AbstractContainerNode()
{
AbstractNode* pChild = static_cast<AbstractNode*>(_pFirstChild);
while (pChild)
{
AbstractNode* pDelNode = pChild;
pChild = pChild->_pNext;
pDelNode->_pNext = 0;
pDelNode->_pParent = 0;
pDelNode->release();
}
}
Node* AbstractContainerNode::firstChild() const
{
return _pFirstChild;
}
Node* AbstractContainerNode::lastChild() const
{
AbstractNode* pChild = _pFirstChild;
if (pChild)
{
while (pChild->_pNext) pChild = pChild->_pNext;
return pChild;
}
return 0;
}
Node* AbstractContainerNode::insertBefore(Node* newChild, Node* refChild)
{
poco_check_ptr (newChild);
if (static_cast<AbstractNode*>(newChild)->_pOwner != _pOwner && static_cast<AbstractNode*>(newChild)->_pOwner != this)
throw DOMException(DOMException::WRONG_DOCUMENT_ERR);
if (refChild && static_cast<AbstractNode*>(refChild)->_pParent != this)
throw DOMException(DOMException::NOT_FOUND_ERR);
if (newChild == refChild)
return newChild;
if (this == newChild)
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
AbstractNode* pFirst = 0;
AbstractNode* pLast = 0;
if (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
{
AbstractContainerNode* pFrag = static_cast<AbstractContainerNode*>(newChild);
pFirst = pFrag->_pFirstChild;
pLast = pFirst;
if (pFirst)
{
while (pLast->_pNext)
{
pLast->_pParent = this;
pLast = pLast->_pNext;
}
pLast->_pParent = this;
}
pFrag->_pFirstChild = 0;
}
else
{
newChild->duplicate();
AbstractContainerNode* pParent = static_cast<AbstractNode*>(newChild)->_pParent;
if (pParent) pParent->removeChild(newChild);
pFirst = static_cast<AbstractNode*>(newChild);
pLast = pFirst;
pFirst->_pParent = this;
}
if (_pFirstChild && pFirst)
{
AbstractNode* pCur = _pFirstChild;
if (pCur == refChild)
{
pLast->_pNext = _pFirstChild;
_pFirstChild = pFirst;
}
else
{
while (pCur && pCur->_pNext != refChild) pCur = pCur->_pNext;
if (pCur)
{
pLast->_pNext = pCur->_pNext;
pCur->_pNext = pFirst;
}
else throw DOMException(DOMException::NOT_FOUND_ERR);
}
}
else _pFirstChild = pFirst;
if (events())
{
while (pFirst && pFirst != pLast->_pNext)
{
pFirst->dispatchNodeInserted();
pFirst->dispatchNodeInsertedIntoDocument();
pFirst = pFirst->_pNext;
}
dispatchSubtreeModified();
}
return newChild;
}
Node* AbstractContainerNode::replaceChild(Node* newChild, Node* oldChild)
{
poco_check_ptr (newChild);
poco_check_ptr (oldChild);
if (static_cast<AbstractNode*>(newChild)->_pOwner != _pOwner && static_cast<AbstractNode*>(newChild)->_pOwner != this)
throw DOMException(DOMException::WRONG_DOCUMENT_ERR);
if (static_cast<AbstractNode*>(oldChild)->_pParent != this)
throw DOMException(DOMException::NOT_FOUND_ERR);
if (newChild == oldChild)
return newChild;
if (this == newChild)
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
bool doEvents = events();
if (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
{
insertBefore(newChild, oldChild);
removeChild(oldChild);
}
else
{
AbstractContainerNode* pParent = static_cast<AbstractNode*>(newChild)->_pParent;
if (pParent) pParent->removeChild(newChild);
if (oldChild == _pFirstChild)
{
if (doEvents)
{
_pFirstChild->dispatchNodeRemoved();
_pFirstChild->dispatchNodeRemovedFromDocument();
}
static_cast<AbstractNode*>(newChild)->_pNext = static_cast<AbstractNode*>(oldChild)->_pNext;
static_cast<AbstractNode*>(newChild)->_pParent = this;
_pFirstChild->_pNext = 0;
_pFirstChild->_pParent = 0;
_pFirstChild = static_cast<AbstractNode*>(newChild);
if (doEvents)
{
static_cast<AbstractNode*>(newChild)->dispatchNodeInserted();
static_cast<AbstractNode*>(newChild)->dispatchNodeInsertedIntoDocument();
}
}
else
{
AbstractNode* pCur = _pFirstChild;
while (pCur && pCur->_pNext != oldChild) pCur = pCur->_pNext;
if (pCur)
{
poco_assert_dbg (pCur->_pNext == oldChild);
if (doEvents)
{
static_cast<AbstractNode*>(oldChild)->dispatchNodeRemoved();
static_cast<AbstractNode*>(oldChild)->dispatchNodeRemovedFromDocument();
}
static_cast<AbstractNode*>(newChild)->_pNext = static_cast<AbstractNode*>(oldChild)->_pNext;
static_cast<AbstractNode*>(newChild)->_pParent = this;
static_cast<AbstractNode*>(oldChild)->_pNext = 0;
static_cast<AbstractNode*>(oldChild)->_pParent = 0;
pCur->_pNext = static_cast<AbstractNode*>(newChild);
if (doEvents)
{
static_cast<AbstractNode*>(newChild)->dispatchNodeInserted();
static_cast<AbstractNode*>(newChild)->dispatchNodeInsertedIntoDocument();
}
}
else throw DOMException(DOMException::NOT_FOUND_ERR);
}
newChild->duplicate();
oldChild->autoRelease();
}
if (doEvents) dispatchSubtreeModified();
return oldChild;
}
Node* AbstractContainerNode::removeChild(Node* oldChild)
{
poco_check_ptr (oldChild);
bool doEvents = events();
if (oldChild == _pFirstChild)
{
if (doEvents)
{
static_cast<AbstractNode*>(oldChild)->dispatchNodeRemoved();
static_cast<AbstractNode*>(oldChild)->dispatchNodeRemovedFromDocument();
}
_pFirstChild = _pFirstChild->_pNext;
static_cast<AbstractNode*>(oldChild)->_pNext = 0;
static_cast<AbstractNode*>(oldChild)->_pParent = 0;
}
else
{
AbstractNode* pCur = _pFirstChild;
while (pCur && pCur->_pNext != oldChild) pCur = pCur->_pNext;
if (pCur)
{
if (doEvents)
{
static_cast<AbstractNode*>(oldChild)->dispatchNodeRemoved();
static_cast<AbstractNode*>(oldChild)->dispatchNodeRemovedFromDocument();
}
pCur->_pNext = pCur->_pNext->_pNext;
static_cast<AbstractNode*>(oldChild)->_pNext = 0;
static_cast<AbstractNode*>(oldChild)->_pParent = 0;
}
else throw DOMException(DOMException::NOT_FOUND_ERR);
}
oldChild->autoRelease();
if (doEvents) dispatchSubtreeModified();
return oldChild;
}
Node* AbstractContainerNode::appendChild(Node* newChild)
{
return insertBefore(newChild, 0);
}
void AbstractContainerNode::dispatchNodeRemovedFromDocument()
{
AbstractNode::dispatchNodeRemovedFromDocument();
Node* pChild = firstChild();
while (pChild)
{
static_cast<AbstractNode*>(pChild)->dispatchNodeRemovedFromDocument();
pChild = pChild->nextSibling();
}
}
void AbstractContainerNode::dispatchNodeInsertedIntoDocument()
{
AbstractNode::dispatchNodeInsertedIntoDocument();
Node* pChild = firstChild();
while (pChild)
{
static_cast<AbstractNode*>(pChild)->dispatchNodeInsertedIntoDocument();
pChild = pChild->nextSibling();
}
}
bool AbstractContainerNode::hasChildNodes() const
{
return _pFirstChild != 0;
}
bool AbstractContainerNode::hasAttributes() const
{
return false;
}
Node* AbstractContainerNode::getNodeByPath(const XMLString& path) const
{
XMLString::const_iterator it = path.begin();
if (it != path.end() && *it == '/')
{
++it;
if (it != path.end() && *it == '/')
{
++it;
XMLString name;
while (it != path.end() && *it != '/' && *it != '@' && *it != '[') name += *it++;
if (it != path.end() && *it == '/') ++it;
if (name.empty()) name = WILDCARD;
AutoPtr<ElementsByTagNameList> pList = new ElementsByTagNameList(this, name);
unsigned long length = pList->length();
for (unsigned long i = 0; i < length; i++)
{
XMLString::const_iterator beg = it;
const Node* pNode = findNode(beg, path.end(), pList->item(i), 0);
if (pNode) return const_cast<Node*>(pNode);
}
return 0;
}
}
return const_cast<Node*>(findNode(it, path.end(), this, 0));
}
Node* AbstractContainerNode::getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const
{
XMLString::const_iterator it = path.begin();
if (it != path.end() && *it == '/')
{
++it;
if (it != path.end() && *it == '/')
{
++it;
XMLString name;
while (it != path.end() && *it != '/' && *it != '@' && *it != '[') name += *it++;
if (it != path.end() && *it == '/') ++it;
XMLString namespaceURI;
XMLString localName;
bool nameOK = true;
if (name.empty())
{
namespaceURI = WILDCARD;
localName = WILDCARD;
}
else
{
nameOK = nsMap.processName(name, namespaceURI, localName, false);
}
if (nameOK)
{
AutoPtr<ElementsByTagNameListNS> pList = new ElementsByTagNameListNS(this, namespaceURI, localName);
unsigned long length = pList->length();
for (unsigned long i = 0; i < length; i++)
{
XMLString::const_iterator beg = it;
const Node* pNode = findNode(beg, path.end(), pList->item(i), &nsMap);
if (pNode) return const_cast<Node*>(pNode);
}
}
return 0;
}
}
return const_cast<Node*>(findNode(it, path.end(), this, &nsMap));
}
const Node* AbstractContainerNode::findNode(XMLString::const_iterator& it, const XMLString::const_iterator& end, const Node* pNode, const NSMap* pNSMap)
{
if (pNode && it != end)
{
if (*it == '[')
{
++it;
if (it != end && *it == '@')
{
++it;
XMLString attr;
while (it != end && *it != ']' && *it != '=') attr += *it++;
if (it != end && *it == '=')
{
++it;
XMLString value;
if (it != end && *it == '\'')
{
++it;
while (it != end && *it != '\'') value += *it++;
if (it != end) ++it;
}
else
{
while (it != end && *it != ']') value += *it++;
}
if (it != end) ++it;
return findNode(it, end, findElement(attr, value, pNode, pNSMap), pNSMap);
}
else
{
if (it != end) ++it;
return findAttribute(attr, pNode, pNSMap);
}
}
else
{
XMLString index;
while (it != end && *it != ']') index += *it++;
if (it != end) ++it;
#ifdef XML_UNICODE_WCHAR_T
std::string idx;
Poco::UnicodeConverter::convert(index, idx);
int i = Poco::NumberParser::parse(idx);
#else
int i = Poco::NumberParser::parse(index);
#endif
return findNode(it, end, findElement(i, pNode, pNSMap), pNSMap);
}
}
else
{
while (it != end && *it == '/') ++it;
XMLString key;
while (it != end && *it != '/' && *it != '[') key += *it++;
XMLString::const_iterator itStart(it);
const Node* pFound = 0;
const Node* pElem = findElement(key, pNode->firstChild(), pNSMap);
while (!pFound && pElem)
{
pFound = findNode(it, end, pElem, pNSMap);
if (!pFound) pElem = findElement(key, pElem->nextSibling(), pNSMap);
it = itStart;
}
return pFound;
}
}
else return pNode;
}
const Node* AbstractContainerNode::findElement(const XMLString& name, const Node* pNode, const NSMap* pNSMap)
{
while (pNode)
{
if (pNode->nodeType() == Node::ELEMENT_NODE && namesAreEqual(pNode, name, pNSMap))
return pNode;
pNode = pNode->nextSibling();
}
return 0;
}
const Node* AbstractContainerNode::findElement(int index, const Node* pNode, const NSMap* pNSMap)
{
const Node* pRefNode = pNode;
if (index > 0)
{
pNode = pNode->nextSibling();
while (pNode)
{
if (namesAreEqual(pNode, pRefNode, pNSMap))
{
if (--index == 0) break;
}
pNode = pNode->nextSibling();
}
}
return pNode;
}
const Node* AbstractContainerNode::findElement(const XMLString& attr, const XMLString& value, const Node* pNode, const NSMap* pNSMap)
{
const Node* pRefNode = pNode;
const Element* pElem = dynamic_cast<const Element*>(pNode);
if (!(pElem && pElem->hasAttributeValue(attr, value, pNSMap)))
{
pNode = pNode->nextSibling();
while (pNode)
{
if (namesAreEqual(pNode, pRefNode, pNSMap))
{
pElem = dynamic_cast<const Element*>(pNode);
if (pElem && pElem->hasAttributeValue(attr, value, pNSMap)) break;
}
pNode = pNode->nextSibling();
}
}
return pNode;
}
const Attr* AbstractContainerNode::findAttribute(const XMLString& name, const Node* pNode, const NSMap* pNSMap)
{
const Attr* pResult(0);
const Element* pElem = dynamic_cast<const Element*>(pNode);
if (pElem)
{
if (pNSMap)
{
XMLString namespaceURI;
XMLString localName;
if (pNSMap->processName(name, namespaceURI, localName, true))
{
pResult = pElem->getAttributeNodeNS(namespaceURI, localName);
}
}
else
{
pResult = pElem->getAttributeNode(name);
}
}
return pResult;
}
bool AbstractContainerNode::hasAttributeValue(const XMLString& name, const XMLString& value, const NSMap* pNSMap) const
{
const Attr* pAttr = findAttribute(name, this, pNSMap);
return pAttr && pAttr->getValue() == value;
}
bool AbstractContainerNode::namesAreEqual(const Node* pNode1, const Node* pNode2, const NSMap* pNSMap)
{
if (pNSMap)
{
return pNode1->localName() == pNode2->localName() && pNode1->namespaceURI() == pNode2->namespaceURI();
}
else
{
return pNode1->nodeName() == pNode2->nodeName();
}
}
bool AbstractContainerNode::namesAreEqual(const Node* pNode, const XMLString& name, const NSMap* pNSMap)
{
if (pNSMap)
{
XMLString namespaceURI;
XMLString localName;
if (name == WILDCARD)
{
return true;
}
else if (pNSMap->processName(name, namespaceURI, localName, false))
{
return (pNode->namespaceURI() == namespaceURI || namespaceURI == WILDCARD) && (pNode->localName() == localName || localName == WILDCARD);
}
else return false;
}
else
{
return pNode->nodeName() == name || name == WILDCARD;
}
}
} } // namespace Poco::XML

367
vendor/POCO/XML/src/AbstractNode.cpp vendored Normal file
View File

@@ -0,0 +1,367 @@
//
// AbstractNode.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/AbstractNode.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/ChildNodesList.h"
#include "Poco/DOM/EventDispatcher.h"
#include "Poco/DOM/DOMException.h"
#include "Poco/DOM/EventException.h"
#include "Poco/DOM/DOMImplementation.h"
#include "Poco/DOM/Attr.h"
#include "Poco/XML/Name.h"
#include "Poco/DOM/AutoPtr.h"
namespace Poco {
namespace XML {
const XMLString AbstractNode::NODE_NAME = toXMLString("#node");
const XMLString AbstractNode::EMPTY_STRING;
AbstractNode::AbstractNode(Document* pOwnerDocument):
_pParent(0),
_pNext(0),
_pOwner(pOwnerDocument),
_pEventDispatcher(0)
{
}
AbstractNode::AbstractNode(Document* pOwnerDocument, const AbstractNode& node):
_pParent(0),
_pNext(0),
_pOwner(pOwnerDocument),
_pEventDispatcher(0)
{
}
AbstractNode::~AbstractNode()
{
delete _pEventDispatcher;
if (_pNext) _pNext->release();
}
void AbstractNode::autoRelease()
{
_pOwner->autoReleasePool().add(this);
}
const XMLString& AbstractNode::nodeName() const
{
return NODE_NAME;
}
const XMLString& AbstractNode::getNodeValue() const
{
return EMPTY_STRING;
}
void AbstractNode::setNodeValue(const XMLString& value)
{
throw DOMException(DOMException::NO_DATA_ALLOWED_ERR);
}
Node* AbstractNode::parentNode() const
{
return _pParent;
}
NodeList* AbstractNode::childNodes() const
{
return new ChildNodesList(this);
}
Node* AbstractNode::firstChild() const
{
return 0;
}
Node* AbstractNode::lastChild() const
{
return 0;
}
Node* AbstractNode::previousSibling() const
{
if (_pParent)
{
AbstractNode* pSibling = _pParent->_pFirstChild;
while (pSibling)
{
if (pSibling->_pNext == this) return pSibling;
pSibling = pSibling->_pNext;
}
}
return 0;
}
Node* AbstractNode::nextSibling() const
{
return _pNext;
}
NamedNodeMap* AbstractNode::attributes() const
{
return 0;
}
Document* AbstractNode::ownerDocument() const
{
return _pOwner;
}
Node* AbstractNode::insertBefore(Node* newChild, Node* refChild)
{
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
}
Node* AbstractNode::replaceChild(Node* newChild, Node* oldChild)
{
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
}
Node* AbstractNode::removeChild(Node* oldChild)
{
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);
}
Node* AbstractNode::appendChild(Node* newChild)
{
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
}
bool AbstractNode::hasChildNodes() const
{
return false;
}
Node* AbstractNode::cloneNode(bool deep) const
{
return copyNode(deep, _pOwner);
}
void AbstractNode::normalize()
{
}
bool AbstractNode::isSupported(const XMLString& feature, const XMLString& version) const
{
return DOMImplementation::instance().hasFeature(feature, version);
}
const XMLString& AbstractNode::namespaceURI() const
{
return EMPTY_STRING;
}
XMLString AbstractNode::prefix() const
{
return EMPTY_STRING;
}
const XMLString& AbstractNode::localName() const
{
return EMPTY_STRING;
}
bool AbstractNode::hasAttributes() const
{
return false;
}
XMLString AbstractNode::innerText() const
{
return EMPTY_STRING;
}
Node* AbstractNode::getNodeByPath(const XMLString& path) const
{
return 0;
}
Node* AbstractNode::getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const
{
return 0;
}
void AbstractNode::addEventListener(const XMLString& type, EventListener* listener, bool useCapture)
{
if (_pEventDispatcher)
_pEventDispatcher->removeEventListener(type, listener, useCapture);
else
_pEventDispatcher = new EventDispatcher;
_pEventDispatcher->addEventListener(type, listener, useCapture);
}
void AbstractNode::removeEventListener(const XMLString& type, EventListener* listener, bool useCapture)
{
if (_pEventDispatcher)
_pEventDispatcher->removeEventListener(type, listener, useCapture);
}
bool AbstractNode::dispatchEvent(Event* evt)
{
if (eventsSuspended()) return true;
if (evt->type().empty()) throw EventException(EventException::UNSPECIFIED_EVENT_TYPE_ERR);
evt->setTarget(this);
evt->setCurrentPhase(Event::CAPTURING_PHASE);
if (_pParent) _pParent->captureEvent(evt);
if (_pEventDispatcher && !evt->isStopped())
{
evt->setCurrentPhase(Event::AT_TARGET);
evt->setCurrentTarget(this);
_pEventDispatcher->dispatchEvent(evt);
}
if (!evt->isStopped() && evt->bubbles() && _pParent)
{
evt->setCurrentPhase(Event::BUBBLING_PHASE);
_pParent->bubbleEvent(evt);
}
return evt->isCanceled();
}
void AbstractNode::captureEvent(Event* evt)
{
if (_pParent)
_pParent->captureEvent(evt);
if (_pEventDispatcher && !evt->isStopped())
{
evt->setCurrentTarget(this);
_pEventDispatcher->captureEvent(evt);
}
}
void AbstractNode::bubbleEvent(Event* evt)
{
evt->setCurrentTarget(this);
if (_pEventDispatcher)
{
_pEventDispatcher->bubbleEvent(evt);
}
if (_pParent && !evt->isStopped())
_pParent->bubbleEvent(evt);
}
void AbstractNode::dispatchSubtreeModified()
{
AutoPtr<MutationEvent> pEvent = new MutationEvent(_pOwner, MutationEvent::DOMSubtreeModified, this, true, false, 0);
dispatchEvent(pEvent.get());
}
void AbstractNode::dispatchNodeInserted()
{
AutoPtr<MutationEvent> pEvent = new MutationEvent(_pOwner, MutationEvent::DOMNodeInserted, this, true, false, parentNode());
dispatchEvent(pEvent.get());
}
void AbstractNode::dispatchNodeRemoved()
{
AutoPtr<MutationEvent> pEvent = new MutationEvent(_pOwner, MutationEvent::DOMNodeRemoved, this, true, false, parentNode());
dispatchEvent(pEvent.get());
}
void AbstractNode::dispatchNodeRemovedFromDocument()
{
AutoPtr<MutationEvent> pEvent = new MutationEvent(_pOwner, MutationEvent::DOMNodeRemovedFromDocument, this, false, false, 0);
dispatchEvent(pEvent.get());
}
void AbstractNode::dispatchNodeInsertedIntoDocument()
{
AutoPtr<MutationEvent> pEvent = new MutationEvent(_pOwner, MutationEvent::DOMNodeInsertedIntoDocument, this, false, false, 0);
dispatchEvent(pEvent.get());
}
void AbstractNode::dispatchAttrModified(Attr* pAttr, MutationEvent::AttrChangeType changeType, const XMLString& prevValue, const XMLString& newValue)
{
AutoPtr<MutationEvent> pEvent = new MutationEvent(_pOwner, MutationEvent::DOMAttrModified, this, true, false, pAttr, prevValue, newValue, pAttr->name(), changeType);
dispatchEvent(pEvent.get());
}
void AbstractNode::dispatchCharacterDataModified(const XMLString& prevValue, const XMLString& newValue)
{
AutoPtr<MutationEvent> pEvent = new MutationEvent(_pOwner, MutationEvent::DOMCharacterDataModified, this, true, false, 0, prevValue, newValue, EMPTY_STRING, MutationEvent::MODIFICATION);
dispatchEvent(pEvent.get());
}
bool AbstractNode::events() const
{
return _pOwner->events();
}
bool AbstractNode::eventsSuspended() const
{
return _pOwner->eventsSuspended();
}
void AbstractNode::setOwnerDocument(Document* pOwnerDocument)
{
_pOwner = pOwnerDocument;
}
} } // namespace Poco::XML

133
vendor/POCO/XML/src/Attr.cpp vendored Normal file
View File

@@ -0,0 +1,133 @@
//
// Attr.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/Attr.h"
#include "Poco/DOM/Document.h"
#include "Poco/XML/NamePool.h"
namespace Poco {
namespace XML {
Attr::Attr(Document* pOwnerDocument, Element* pOwnerElement, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& value, bool specified):
AbstractNode(pOwnerDocument),
_name(pOwnerDocument->namePool().insert(qname, namespaceURI, localName)),
_value(value),
_specified(specified)
{
}
Attr::Attr(Document* pOwnerDocument, const Attr& attr):
AbstractNode(pOwnerDocument, attr),
_name(pOwnerDocument->namePool().insert(attr._name)),
_value(attr._value),
_specified(attr._specified)
{
}
Attr::~Attr()
{
}
void Attr::setValue(const XMLString& value)
{
XMLString oldValue = _value;
_value = value;
_specified = true;
if (_pParent && !_pOwner->eventsSuspended())
_pParent->dispatchAttrModified(this, MutationEvent::MODIFICATION, oldValue, value);
}
Node* Attr::parentNode() const
{
return 0;
}
Node* Attr::previousSibling() const
{
if (_pParent)
{
Attr* pSibling = static_cast<Element*>(_pParent)->_pFirstAttr;
while (pSibling)
{
if (pSibling->_pNext == const_cast<Attr*>(this)) return pSibling;
pSibling = static_cast<Attr*>(pSibling->_pNext);
}
return pSibling;
}
return 0;
}
const XMLString& Attr::nodeName() const
{
return _name.qname();
}
const XMLString& Attr::getNodeValue() const
{
return _value;
}
void Attr::setNodeValue(const XMLString& value)
{
setValue(value);
}
unsigned short Attr::nodeType() const
{
return ATTRIBUTE_NODE;
}
const XMLString& Attr::namespaceURI() const
{
return _name.namespaceURI();
}
XMLString Attr::prefix() const
{
return _name.prefix();
}
const XMLString& Attr::localName() const
{
return _name.localName();
}
XMLString Attr::innerText() const
{
return nodeValue();
}
Node* Attr::copyNode(bool deep, Document* pOwnerDocument) const
{
return new Attr(pOwnerDocument, *this);
}
} } // namespace Poco::XML

123
vendor/POCO/XML/src/AttrMap.cpp vendored Normal file
View File

@@ -0,0 +1,123 @@
//
// AttrMap.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/AttrMap.h"
#include "Poco/DOM/Attr.h"
#include "Poco/DOM/Element.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/DOMException.h"
namespace Poco {
namespace XML {
AttrMap::AttrMap(Element* pElement):
_pElement(pElement)
{
poco_check_ptr (pElement);
_pElement->duplicate();
}
AttrMap::~AttrMap()
{
_pElement->release();
}
Node* AttrMap::getNamedItem(const XMLString& name) const
{
return _pElement->getAttributeNode(name);
}
Node* AttrMap::setNamedItem(Node* arg)
{
poco_check_ptr (arg);
if (arg->nodeType() != Node::ATTRIBUTE_NODE)
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
return _pElement->setAttributeNode(static_cast<Attr*>(arg));
}
Node* AttrMap::removeNamedItem(const XMLString& name)
{
Attr* pAttr = _pElement->getAttributeNode(name);
if (pAttr)
return _pElement->removeAttributeNode(pAttr);
else
return 0;
}
Node* AttrMap::item(unsigned long index) const
{
AbstractNode* pAttr = _pElement->_pFirstAttr;
while (index-- > 0 && pAttr) pAttr = static_cast<AbstractNode*>(pAttr->nextSibling());
return pAttr;
}
unsigned long AttrMap::length() const
{
unsigned long result = 0;
AbstractNode* pAttr = _pElement->_pFirstAttr;
while (pAttr)
{
pAttr = static_cast<AbstractNode*>(pAttr->nextSibling());
++result;
}
return result;
}
Node* AttrMap::getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const
{
return _pElement->getAttributeNodeNS(namespaceURI, localName);
}
Node* AttrMap::setNamedItemNS(Node* arg)
{
poco_check_ptr (arg);
if (arg->nodeType() != Node::ATTRIBUTE_NODE)
throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
return _pElement->setAttributeNodeNS(static_cast<Attr*>(arg));
}
Node* AttrMap::removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName)
{
Attr* pAttr = _pElement->getAttributeNodeNS(namespaceURI, localName);
if (pAttr)
return _pElement->removeAttributeNode(pAttr);
else
return 0;
}
void AttrMap::autoRelease()
{
_pElement->ownerDocument()->autoReleasePool().add(this);
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/Attributes.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// Attributes.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/Attributes.h"
namespace Poco {
namespace XML {
Attributes::~Attributes()
{
}
} } // namespace Poco::XML

299
vendor/POCO/XML/src/AttributesImpl.cpp vendored Normal file
View File

@@ -0,0 +1,299 @@
//
// AttributesImpl.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/AttributesImpl.h"
namespace Poco {
namespace XML {
AttributesImpl::EmptyAttribute::EmptyAttribute()
{
specified = false;
type = XML_LIT("CDATA");
}
AttributesImpl::EmptyAttribute AttributesImpl::_empty;
AttributesImpl::AttributesImpl()
{
}
AttributesImpl::AttributesImpl(const Attributes& attributes)
{
setAttributes(attributes);
}
AttributesImpl::AttributesImpl(const AttributesImpl& attributes):
_attributes(attributes._attributes)
{
}
AttributesImpl::AttributesImpl(AttributesImpl&& attributes) noexcept:
_attributes(std::move(attributes._attributes))
{
}
AttributesImpl::~AttributesImpl()
{
}
AttributesImpl& AttributesImpl::operator = (const AttributesImpl& attributes)
{
if (&attributes != this)
{
_attributes = attributes._attributes;
}
return *this;
}
AttributesImpl& AttributesImpl::operator = (AttributesImpl&& attributes) noexcept
{
_attributes = std::move(attributes._attributes);
return *this;
}
int AttributesImpl::getIndex(const XMLString& qname) const
{
int i = 0;
AttributeVec::const_iterator it;
for (it = _attributes.begin(); it != _attributes.end(); ++it)
{
if (it->qname == qname) return i;
++i;
}
return -1;
}
int AttributesImpl::getIndex(const XMLString& namespaceURI, const XMLString& localName) const
{
int i = 0;
AttributeVec::const_iterator it;
for (it = _attributes.begin(); it != _attributes.end(); ++it)
{
if (it->namespaceURI == namespaceURI && it->localName == localName) return i;
++i;
}
return -1;
}
void AttributesImpl::setValue(int i, const XMLString& value)
{
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
_attributes[i].value = value;
_attributes[i].specified = true;
}
void AttributesImpl::setValue(const XMLString& qname, const XMLString& value)
{
Attribute* pAttr = find(qname);
if (pAttr)
{
pAttr->value = value;
pAttr->specified = true;
}
}
void AttributesImpl::setValue(const XMLString& namespaceURI, const XMLString& localName, const XMLString& value)
{
Attribute* pAttr = find(namespaceURI, localName);
if (pAttr)
{
pAttr->value = value;
pAttr->specified = true;
}
}
void AttributesImpl::setAttributes(const Attributes& attributes)
{
if (&attributes != this)
{
int count = attributes.getLength();
_attributes.clear();
_attributes.reserve(count);
for (int i = 0; i < count; i++)
{
addAttribute(attributes.getURI(i), attributes.getLocalName(i), attributes.getQName(i), attributes.getType(i), attributes.getValue(i));
}
}
}
void AttributesImpl::setAttribute(int i, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value)
{
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
_attributes[i].namespaceURI = namespaceURI;
_attributes[i].localName = localName;
_attributes[i].qname = qname;
_attributes[i].type = type;
_attributes[i].value = value;
_attributes[i].specified = true;
}
void AttributesImpl::addAttribute(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value)
{
AttributeVec::iterator it = _attributes.insert(_attributes.end(), Attribute());
it->namespaceURI = namespaceURI;
it->localName = localName;
it->qname = qname;
it->value = value;
it->type = type;
it->specified = true;
}
void AttributesImpl::addAttribute(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value, bool specified)
{
AttributeVec::iterator it = _attributes.insert(_attributes.end(), Attribute());
it->namespaceURI = namespaceURI;
it->localName = localName;
it->qname = qname;
it->value = value;
it->type = type;
it->specified = specified;
}
void AttributesImpl::addAttribute(const XMLChar* namespaceURI, const XMLChar* localName, const XMLChar* qname, const XMLChar* type, const XMLChar* value, bool specified)
{
AttributeVec::iterator it = _attributes.insert(_attributes.end(), Attribute());
it->namespaceURI = namespaceURI;
it->localName = localName;
it->qname = qname;
it->value = value;
it->type = type;
it->specified = specified;
}
void AttributesImpl::removeAttribute(int i)
{
int cur = 0;
for (AttributeVec::iterator it = _attributes.begin(); it != _attributes.end(); ++it, ++cur)
{
if (cur == i)
{
_attributes.erase(it);
break;
}
}
}
void AttributesImpl::removeAttribute(const XMLString& qname)
{
for (AttributeVec::iterator it = _attributes.begin(); it != _attributes.end(); ++it)
{
if (it->qname == qname)
{
_attributes.erase(it);
break;
}
}
}
void AttributesImpl::removeAttribute(const XMLString& namespaceURI, const XMLString& localName)
{
for (AttributeVec::iterator it = _attributes.begin(); it != _attributes.end(); ++it)
{
if (it->namespaceURI == namespaceURI && it->localName == localName)
{
_attributes.erase(it);
break;
}
}
}
void AttributesImpl::clear()
{
_attributes.clear();
}
void AttributesImpl::reserve(std::size_t capacity)
{
_attributes.reserve(capacity);
}
void AttributesImpl::setLocalName(int i, const XMLString& localName)
{
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
_attributes[i].localName = localName;
}
void AttributesImpl::setQName(int i, const XMLString& qname)
{
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
_attributes[i].qname = qname;
}
void AttributesImpl::setType(int i, const XMLString& type)
{
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
_attributes[i].type = type;
}
void AttributesImpl::setURI(int i, const XMLString& namespaceURI)
{
poco_assert (0 <= i && i < static_cast<int>(_attributes.size()));
_attributes[i].namespaceURI = namespaceURI;
}
AttributesImpl::Attribute* AttributesImpl::find(const XMLString& qname) const
{
for (AttributeVec::const_iterator it = _attributes.begin(); it != _attributes.end(); ++it)
{
if (it->qname == qname)
return const_cast<Attribute*>(&(*it));
}
return 0;
}
AttributesImpl::Attribute* AttributesImpl::find(const XMLString& namespaceURI, const XMLString& localName) const
{
for (AttributeVec::const_iterator it = _attributes.begin(); it != _attributes.end(); ++it)
{
if (it->namespaceURI == namespaceURI && it->localName == localName)
return const_cast<Attribute*>(&(*it));
}
return 0;
}
} } // namespace Poco::XML

74
vendor/POCO/XML/src/CDATASection.cpp vendored Normal file
View File

@@ -0,0 +1,74 @@
//
// CDATASection.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/CDATASection.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/DOMException.h"
namespace Poco {
namespace XML {
const XMLString CDATASection::NODE_NAME = toXMLString("#cdata-section");
CDATASection::CDATASection(Document* pOwnerDocument, const XMLString& data):
Text(pOwnerDocument, data)
{
}
CDATASection::CDATASection(Document* pOwnerDocument, const CDATASection& sec):
Text(pOwnerDocument, sec)
{
}
CDATASection::~CDATASection()
{
}
Text* CDATASection::splitText(unsigned long offset)
{
Node* pParent = parentNode();
if (!pParent) throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
int n = length() - offset;
Text* pNew = ownerDocument()->createCDATASection(substringData(offset, n));
deleteData(offset, n);
pParent->insertBefore(pNew, nextSibling())->release();
return pNew;
}
const XMLString& CDATASection::nodeName() const
{
return NODE_NAME;
}
unsigned short CDATASection::nodeType() const
{
return Node::CDATA_SECTION_NODE;
}
Node* CDATASection::copyNode(bool deep, Document* pOwnerDocument) const
{
return new CDATASection(pOwnerDocument, *this);
}
} } // namespace Poco::XML

152
vendor/POCO/XML/src/CharacterData.cpp vendored Normal file
View File

@@ -0,0 +1,152 @@
//
// CharacterData.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/CharacterData.h"
#include "Poco/DOM/DOMException.h"
#include "Poco/String.h"
namespace Poco {
namespace XML {
CharacterData::CharacterData(Document* pOwnerDocument, const XMLString& data):
AbstractNode(pOwnerDocument),
_data(data)
{
}
CharacterData::CharacterData(Document* pOwnerDocument, const CharacterData& data):
AbstractNode(pOwnerDocument, data),
_data(data._data)
{
}
CharacterData::~CharacterData()
{
}
void CharacterData::setData(const XMLString& data)
{
if (events())
{
XMLString oldData = _data;
_data = data;
dispatchCharacterDataModified(oldData, _data);
}
else
{
_data = data;
}
}
XMLString CharacterData::substringData(unsigned long offset, unsigned long count) const
{
if (offset >= _data.length())
throw DOMException(DOMException::INDEX_SIZE_ERR);
return _data.substr(offset, count);
}
void CharacterData::appendData(const XMLString& arg)
{
if (events())
{
XMLString oldData = _data;
_data.append(arg);
dispatchCharacterDataModified(oldData, _data);
}
else
{
_data.append(arg);
}
}
void CharacterData::insertData(unsigned long offset, const XMLString& arg)
{
if (offset > _data.length())
throw DOMException(DOMException::INDEX_SIZE_ERR);
if (events())
{
XMLString oldData = _data;
_data.insert(offset, arg);
dispatchCharacterDataModified(oldData, _data);
}
else
{
_data.insert(offset, arg);
}
}
void CharacterData::deleteData(unsigned long offset, unsigned long count)
{
if (offset >= _data.length())
throw DOMException(DOMException::INDEX_SIZE_ERR);
if (events())
{
XMLString oldData = _data;
_data.replace(offset, count, EMPTY_STRING);
dispatchCharacterDataModified(oldData, _data);
}
else
_data.replace(offset, count, EMPTY_STRING);
}
void CharacterData::replaceData(unsigned long offset, unsigned long count, const XMLString& arg)
{
if (offset >= _data.length())
throw DOMException(DOMException::INDEX_SIZE_ERR);
if (events())
{
XMLString oldData = _data;
_data.replace(offset, count, arg);
dispatchCharacterDataModified(oldData, _data);
}
else
{
_data.replace(offset, count, arg);
}
}
const XMLString& CharacterData::getNodeValue() const
{
return _data;
}
void CharacterData::setNodeValue(const XMLString& value)
{
setData(value);
}
XMLString CharacterData::trimmedData() const
{
return Poco::trim(_data);
}
} } // namespace Poco::XML

70
vendor/POCO/XML/src/ChildNodesList.cpp vendored Normal file
View File

@@ -0,0 +1,70 @@
//
// ChildNodesList.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/ChildNodesList.h"
#include "Poco/DOM/Node.h"
#include "Poco/DOM/Document.h"
namespace Poco {
namespace XML {
ChildNodesList::ChildNodesList(const Node* pParent):
_pParent(pParent)
{
poco_check_ptr (pParent);
_pParent->duplicate();
}
ChildNodesList::~ChildNodesList()
{
_pParent->release();
}
Node* ChildNodesList::item(unsigned long index) const
{
unsigned long n = 0;
Node* pCur = _pParent->firstChild();
while (pCur && n++ < index)
{
pCur = pCur->nextSibling();
}
return pCur;
}
unsigned long ChildNodesList::length() const
{
unsigned long n = 0;
Node* pCur = _pParent->firstChild();
while (pCur)
{
++n;
pCur = pCur->nextSibling();
}
return n;
}
void ChildNodesList::autoRelease()
{
_pParent->ownerDocument()->autoReleasePool().add(this);
}
} } // namespace Poco::XML

60
vendor/POCO/XML/src/Comment.cpp vendored Normal file
View File

@@ -0,0 +1,60 @@
//
// Comment.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/Comment.h"
namespace Poco {
namespace XML {
const XMLString Comment::NODE_NAME = toXMLString("#comment");
Comment::Comment(Document* pOwnerDocument, const XMLString& data):
CharacterData(pOwnerDocument, data)
{
}
Comment::Comment(Document* pOwnerDocument, const Comment& comment):
CharacterData(pOwnerDocument, comment)
{
}
Comment::~Comment()
{
}
const XMLString& Comment::nodeName() const
{
return NODE_NAME;
}
unsigned short Comment::nodeType() const
{
return Node::COMMENT_NODE;
}
Node* Comment::copyNode(bool deep, Document* pOwnerDocument) const
{
return new Comment(pOwnerDocument, *this);
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/ContentHandler.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// ContentHandler.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/ContentHandler.h"
namespace Poco {
namespace XML {
ContentHandler::~ContentHandler()
{
}
} } // namespace Poco::XML

312
vendor/POCO/XML/src/DOMBuilder.cpp vendored Normal file
View File

@@ -0,0 +1,312 @@
//
// DOMBuilder.cpp
//
// Library: XML
// Package: DOM
// Module: DOMBuilder
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DOMBuilder.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/DocumentType.h"
#include "Poco/DOM/CharacterData.h"
#include "Poco/DOM/Text.h"
#include "Poco/DOM/Comment.h"
#include "Poco/DOM/CDATASection.h"
#include "Poco/DOM/Element.h"
#include "Poco/DOM/Attr.h"
#include "Poco/DOM/Entity.h"
#include "Poco/DOM/EntityReference.h"
#include "Poco/DOM/Notation.h"
#include "Poco/DOM/ProcessingInstruction.h"
#include "Poco/DOM/AutoPtr.h"
#include "Poco/SAX/XMLReader.h"
#include "Poco/SAX/AttributesImpl.h"
namespace Poco {
namespace XML {
const XMLString DOMBuilder::EMPTY_STRING;
DOMBuilder::DOMBuilder(XMLReader& xmlReader, NamePool* pNamePool):
_xmlReader(xmlReader),
_pNamePool(pNamePool),
_pDocument(0),
_pParent(0),
_pPrevious(0),
_inCDATA(false),
_namespaces(true)
{
_xmlReader.setContentHandler(this);
_xmlReader.setDTDHandler(this);
_xmlReader.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER, static_cast<LexicalHandler*>(this));
if (_pNamePool) _pNamePool->duplicate();
}
DOMBuilder::~DOMBuilder()
{
if (_pNamePool) _pNamePool->release();
}
Document* DOMBuilder::parse(const XMLString& uri)
{
setupParse();
_pDocument->suspendEvents();
try
{
_xmlReader.parse(uri);
}
catch (...)
{
_pDocument->release();
_pDocument = 0;
_pParent = 0;
_pPrevious = 0;
throw;
}
_pDocument->resumeEvents();
_pDocument->collectGarbage();
return _pDocument;
}
Document* DOMBuilder::parse(InputSource* pInputSource)
{
setupParse();
_pDocument->suspendEvents();
try
{
_xmlReader.parse(pInputSource);
}
catch (...)
{
_pDocument->release();
_pDocument = 0;
_pParent = 0;
_pPrevious = 0;
throw;
}
_pDocument->resumeEvents();
_pDocument->collectGarbage();
return _pDocument;
}
Document* DOMBuilder::parseMemoryNP(const char* xml, std::size_t size)
{
setupParse();
_pDocument->suspendEvents();
try
{
_xmlReader.parseMemoryNP(xml, size);
}
catch (...)
{
_pDocument->release();
_pDocument = 0;
_pParent = 0;
_pPrevious = 0;
throw;
}
_pDocument->resumeEvents();
_pDocument->collectGarbage();
return _pDocument;
}
void DOMBuilder::setupParse()
{
_pDocument = new Document(_pNamePool);
_pParent = _pDocument;
_pPrevious = 0;
_inCDATA = false;
_namespaces = _xmlReader.getFeature(XMLReader::FEATURE_NAMESPACES);
}
inline void DOMBuilder::appendNode(AbstractNode* pNode)
{
if (_pPrevious && _pPrevious != _pParent)
{
_pPrevious->_pNext = pNode;
pNode->_pParent = _pParent;
pNode->duplicate();
}
else _pParent->appendChild(pNode);
_pPrevious = pNode;
}
void DOMBuilder::notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId)
{
DocumentType* pDoctype = _pDocument->getDoctype();
if (pDoctype)
{
AutoPtr<Notation> pNotation = _pDocument->createNotation(name, (publicId ? *publicId : EMPTY_STRING), (systemId ? *systemId : EMPTY_STRING));
pDoctype->appendChild(pNotation);
}
}
void DOMBuilder::unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName)
{
DocumentType* pDoctype = _pDocument->getDoctype();
if (pDoctype)
{
AutoPtr<Entity> pEntity = _pDocument->createEntity(name, publicId ? *publicId : EMPTY_STRING, systemId, notationName);
pDoctype->appendChild(pEntity);
}
}
void DOMBuilder::setDocumentLocator(const Locator* loc)
{
}
void DOMBuilder::startDocument()
{
}
void DOMBuilder::endDocument()
{
}
void DOMBuilder::startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attributes)
{
AutoPtr<Element> pElem = _namespaces ? _pDocument->createElementNS(uri, qname.empty() ? localName : qname) : _pDocument->createElement(qname);
const AttributesImpl& attrs = dynamic_cast<const AttributesImpl&>(attributes);
Attr* pPrevAttr = 0;
for (const auto& attr: attrs)
{
AutoPtr<Attr> pAttr = new Attr(_pDocument, 0, attr.namespaceURI, attr.localName, attr.qname, attr.value, attr.specified);
pPrevAttr = pElem->addAttributeNodeNP(pPrevAttr, pAttr);
}
appendNode(pElem);
_pParent = pElem;
}
void DOMBuilder::endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname)
{
_pPrevious = _pParent;
_pParent = static_cast<AbstractContainerNode*>(_pParent->parentNode());
}
void DOMBuilder::characters(const XMLChar ch[], int start, int length)
{
if (_inCDATA)
{
if (_pPrevious && _pPrevious->nodeType() == Node::CDATA_SECTION_NODE)
{
static_cast<CDATASection*>(_pPrevious)->appendData(XMLString(ch + start, length));
}
else
{
AutoPtr<CDATASection> pCDATA = _pDocument->createCDATASection(XMLString(ch + start, length));
appendNode(pCDATA);
}
}
else
{
if (_pPrevious && _pPrevious->nodeType() == Node::TEXT_NODE)
{
static_cast<Text*>(_pPrevious)->appendData(XMLString(ch + start, length));
}
else
{
AutoPtr<Text> pText = _pDocument->createTextNode(XMLString(ch + start, length));
appendNode(pText);
}
}
}
void DOMBuilder::ignorableWhitespace(const XMLChar ch[], int start, int length)
{
characters(ch, start, length);
}
void DOMBuilder::processingInstruction(const XMLString& target, const XMLString& data)
{
AutoPtr<ProcessingInstruction> pPI = _pDocument->createProcessingInstruction(target, data);
appendNode(pPI);
}
void DOMBuilder::startPrefixMapping(const XMLString& prefix, const XMLString& uri)
{
}
void DOMBuilder::endPrefixMapping(const XMLString& prefix)
{
}
void DOMBuilder::skippedEntity(const XMLString& name)
{
AutoPtr<EntityReference> pER = _pDocument->createEntityReference(name);
appendNode(pER);
}
void DOMBuilder::startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId)
{
AutoPtr<DocumentType> pDoctype = new DocumentType(_pDocument, name, publicId, systemId);
_pDocument->setDoctype(pDoctype);
}
void DOMBuilder::endDTD()
{
}
void DOMBuilder::startEntity(const XMLString& name)
{
}
void DOMBuilder::endEntity(const XMLString& name)
{
}
void DOMBuilder::startCDATA()
{
_inCDATA = true;
}
void DOMBuilder::endCDATA()
{
_inCDATA = false;
}
void DOMBuilder::comment(const XMLChar ch[], int start, int length)
{
AutoPtr<Comment> pComment = _pDocument->createComment(XMLString(ch + start, length));
appendNode(pComment);
}
} } // namespace Poco::XML

107
vendor/POCO/XML/src/DOMException.cpp vendored Normal file
View File

@@ -0,0 +1,107 @@
//
// DOMException.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DOMException.h"
#include <typeinfo>
namespace Poco {
namespace XML {
const std::string DOMException::MESSAGES[_NUMBER_OF_MESSAGES] =
{
"Invalid DOM exception code",
"Index or size is negative or greater than allowed value",
"The specified range of text does not fit into a DOMString",
"A node is inserted somewhere it doesn't belong",
"A node is used in a different document than the one that created it",
"An invalid character is specified",
"Data is specified for a node which does not support data",
"An attempt is made to modify an object where modifications are not allowed",
"An attempt was made to reference a node in a context where it does not exist",
"The implementation does not support the type of object requested",
"An attempt is made to add an attribute that is already in use elsewhere",
"A parameter or an operation is not supported by the underlying object",
"An invalid or illegal string is specified",
"An attempt is made to modify the type of the underlying object",
"An attempt is made to create or change an object in a way which is incorrect with regard to namespaces",
"An attempt is made to use an object that is not, or is no longer, usable"
};
DOMException::DOMException(unsigned short code):
XMLException(message(code)),
_code(code)
{
}
DOMException::DOMException(const DOMException& exc):
XMLException(exc),
_code(exc._code)
{
}
DOMException::~DOMException() noexcept
{
}
DOMException& DOMException::operator = (const DOMException& exc)
{
if (&exc != this)
{
XMLException::operator = (exc);
_code = exc._code;
}
return *this;
}
const char* DOMException::name() const noexcept
{
return "DOMException";
}
const char* DOMException::className() const noexcept
{
return typeid(*this).name();
}
Poco::Exception* DOMException::clone() const
{
return new DOMException(*this);
}
void DOMException::rethrow() const
{
throw *this;
}
const std::string& DOMException::message(unsigned short code)
{
if (code >= 1 && code < _NUMBER_OF_MESSAGES)
return MESSAGES[code];
else
return MESSAGES[0];
}
} } // namespace Poco::XML

View File

@@ -0,0 +1,86 @@
//
// DOMImplementation.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DOMImplementation.h"
#include "Poco/DOM/DocumentType.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/Element.h"
#include "Poco/String.h"
#include "Poco/SingletonHolder.h"
namespace Poco {
namespace XML {
const XMLString DOMImplementation::FEATURE_XML = toXMLString("xml");
const XMLString DOMImplementation::FEATURE_CORE = toXMLString("core");
const XMLString DOMImplementation::FEATURE_EVENTS = toXMLString("events");
const XMLString DOMImplementation::FEATURE_MUTATIONEVENTS = toXMLString("mutationevents");
const XMLString DOMImplementation::FEATURE_TRAVERSAL = toXMLString("traversal");
const XMLString DOMImplementation::VERSION_1_0 = toXMLString("1.0");
const XMLString DOMImplementation::VERSION_2_0 = toXMLString("2.0");
DOMImplementation::DOMImplementation()
{
}
DOMImplementation::~DOMImplementation()
{
}
bool DOMImplementation::hasFeature(const XMLString& feature, const XMLString& version) const
{
XMLString lcFeature = Poco::toLower(feature);
return (lcFeature == FEATURE_XML && version == VERSION_1_0) ||
(lcFeature == FEATURE_CORE && version == VERSION_2_0) ||
(lcFeature == FEATURE_EVENTS && version == VERSION_2_0) ||
(lcFeature == FEATURE_MUTATIONEVENTS && version == VERSION_2_0) ||
(lcFeature == FEATURE_TRAVERSAL && version == VERSION_2_0);
}
DocumentType* DOMImplementation::createDocumentType(const XMLString& name, const XMLString& publicId, const XMLString& systemId) const
{
return new DocumentType(0, name, publicId, systemId);
}
Document* DOMImplementation::createDocument(const XMLString& namespaceURI, const XMLString& qualifiedName, DocumentType* doctype) const
{
Document* pDoc = new Document(doctype);
if (namespaceURI.empty())
pDoc->appendChild(pDoc->createElement(qualifiedName))->release();
else
pDoc->appendChild(pDoc->createElementNS(namespaceURI, qualifiedName))->release();
return pDoc;
}
namespace
{
static Poco::SingletonHolder<DOMImplementation> sh;
}
const DOMImplementation& DOMImplementation::instance()
{
return *sh.get();
}
} } // namespace Poco::XML

32
vendor/POCO/XML/src/DOMObject.cpp vendored Normal file
View File

@@ -0,0 +1,32 @@
//
// DOMObject.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DOMObject.h"
namespace Poco {
namespace XML {
DOMObject::DOMObject(): _rc(1)
{
}
DOMObject::~DOMObject()
{
}
} } // namespace Poco::XML

157
vendor/POCO/XML/src/DOMParser.cpp vendored Normal file
View File

@@ -0,0 +1,157 @@
//
// DOMParser.cpp
//
// Library: XML
// Package: DOM
// Module: DOMParser
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DOMParser.h"
#include "Poco/DOM/DOMBuilder.h"
#include "Poco/SAX/WhitespaceFilter.h"
#include "Poco/SAX/InputSource.h"
#include "Poco/XML/NamePool.h"
#include <sstream>
namespace Poco {
namespace XML {
const XMLString DOMParser::FEATURE_FILTER_WHITESPACE = toXMLString("http://www.appinf.com/features/no-whitespace-in-element-content");
DOMParser::DOMParser(NamePool* pNamePool):
_pNamePool(pNamePool),
_filterWhitespace(false)
{
if (_pNamePool) _pNamePool->duplicate();
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
}
DOMParser::DOMParser(unsigned long namePoolSize):
_pNamePool(new NamePool(namePoolSize)),
_filterWhitespace(false)
{
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
_saxParser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
}
DOMParser::~DOMParser()
{
if (_pNamePool) _pNamePool->release();
}
void DOMParser::setEncoding(const XMLString& encoding)
{
_saxParser.setEncoding(encoding);
}
const XMLString& DOMParser::getEncoding() const
{
return _saxParser.getEncoding();
}
void DOMParser::addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding)
{
_saxParser.addEncoding(name, pEncoding);
}
void DOMParser::setFeature(const XMLString& name, bool state)
{
if (name == FEATURE_FILTER_WHITESPACE)
_filterWhitespace = state;
else
_saxParser.setFeature(name, state);
}
bool DOMParser::getFeature(const XMLString& name) const
{
if (name == FEATURE_FILTER_WHITESPACE)
return _filterWhitespace;
else
return _saxParser.getFeature(name);
}
Document* DOMParser::parse(const XMLString& uri)
{
if (_filterWhitespace)
{
WhitespaceFilter filter(&_saxParser);
DOMBuilder builder(filter, _pNamePool);
return builder.parse(uri);
}
else
{
DOMBuilder builder(_saxParser, _pNamePool);
return builder.parse(uri);
}
}
Document* DOMParser::parse(InputSource* pInputSource)
{
if (_filterWhitespace)
{
WhitespaceFilter filter(&_saxParser);
DOMBuilder builder(filter, _pNamePool);
return builder.parse(pInputSource);
}
else
{
DOMBuilder builder(_saxParser, _pNamePool);
return builder.parse(pInputSource);
}
}
Document* DOMParser::parseString(const std::string& xml)
{
return parseMemory(xml.data(), xml.size());
}
Document* DOMParser::parseMemory(const char* xml, std::size_t size)
{
if (_filterWhitespace)
{
WhitespaceFilter filter(&_saxParser);
DOMBuilder builder(filter, _pNamePool);
return builder.parseMemoryNP(xml, size);
}
else
{
DOMBuilder builder(_saxParser, _pNamePool);
return builder.parseMemoryNP(xml, size);
}
}
EntityResolver* DOMParser::getEntityResolver() const
{
return _saxParser.getEntityResolver();
}
void DOMParser::setEntityResolver(EntityResolver* pEntityResolver)
{
_saxParser.setEntityResolver(pEntityResolver);
}
} } // namespace Poco::XML

323
vendor/POCO/XML/src/DOMSerializer.cpp vendored Normal file
View File

@@ -0,0 +1,323 @@
//
// DOMSerializer.cpp
//
// Library: XML
// Package: DOM
// Module: DOMSerializer
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DOMSerializer.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/DocumentType.h"
#include "Poco/DOM/DocumentFragment.h"
#include "Poco/DOM/Element.h"
#include "Poco/DOM/Attr.h"
#include "Poco/DOM/Text.h"
#include "Poco/DOM/CDATASection.h"
#include "Poco/DOM/Comment.h"
#include "Poco/DOM/ProcessingInstruction.h"
#include "Poco/DOM/Entity.h"
#include "Poco/DOM/Notation.h"
#include "Poco/DOM/NamedNodeMap.h"
#include "Poco/DOM/AutoPtr.h"
#include "Poco/SAX/EntityResolver.h"
#include "Poco/SAX/DTDHandler.h"
#include "Poco/SAX/ContentHandler.h"
#include "Poco/SAX/LexicalHandler.h"
#include "Poco/SAX/AttributesImpl.h"
#include "Poco/SAX/ErrorHandler.h"
#include "Poco/SAX/SAXException.h"
namespace Poco {
namespace XML {
const XMLString DOMSerializer::CDATA = toXMLString("CDATA");
DOMSerializer::DOMSerializer():
_pEntityResolver(0),
_pDTDHandler(0),
_pContentHandler(0),
_pErrorHandler(0),
_pDeclHandler(0),
_pLexicalHandler(0)
{
}
DOMSerializer::~DOMSerializer()
{
}
void DOMSerializer::setEntityResolver(EntityResolver* pEntityResolver)
{
_pEntityResolver = pEntityResolver;
}
EntityResolver* DOMSerializer::getEntityResolver() const
{
return _pEntityResolver;
}
void DOMSerializer::setDTDHandler(DTDHandler* pDTDHandler)
{
_pDTDHandler = pDTDHandler;
}
DTDHandler* DOMSerializer::getDTDHandler() const
{
return _pDTDHandler;
}
void DOMSerializer::setContentHandler(ContentHandler* pContentHandler)
{
_pContentHandler = pContentHandler;
}
ContentHandler* DOMSerializer::getContentHandler() const
{
return _pContentHandler;
}
void DOMSerializer::setErrorHandler(ErrorHandler* pErrorHandler)
{
_pErrorHandler = pErrorHandler;
}
ErrorHandler* DOMSerializer::getErrorHandler() const
{
return _pErrorHandler;
}
void DOMSerializer::setFeature(const XMLString& featureId, bool state)
{
if (featureId == XMLReader::FEATURE_NAMESPACES)
throw SAXNotSupportedException(fromXMLString(XMLReader::FEATURE_NAMESPACES));
else if (featureId == XMLReader::FEATURE_NAMESPACE_PREFIXES)
throw SAXNotSupportedException(fromXMLString(XMLReader::FEATURE_NAMESPACE_PREFIXES));
else
throw SAXNotRecognizedException(fromXMLString(featureId));
}
bool DOMSerializer::getFeature(const XMLString& featureId) const
{
if (featureId == XMLReader::FEATURE_NAMESPACES)
throw SAXNotSupportedException(fromXMLString(XMLReader::FEATURE_NAMESPACES));
else if (featureId == XMLReader::FEATURE_NAMESPACE_PREFIXES)
throw SAXNotSupportedException(fromXMLString(XMLReader::FEATURE_NAMESPACE_PREFIXES));
else
throw SAXNotRecognizedException(fromXMLString(featureId));
}
void DOMSerializer::setProperty(const XMLString& propertyId, const XMLString& value)
{
if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER || propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
throw SAXNotSupportedException(std::string("property does not take a string value: ") + fromXMLString(propertyId));
else
throw SAXNotRecognizedException(fromXMLString(propertyId));
}
void DOMSerializer::setProperty(const XMLString& propertyId, void* value)
{
if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER)
_pDeclHandler = reinterpret_cast<DeclHandler*>(value);
else if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
_pLexicalHandler = reinterpret_cast<LexicalHandler*>(value);
else throw SAXNotRecognizedException(fromXMLString(propertyId));
}
void* DOMSerializer::getProperty(const XMLString& propertyId) const
{
if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER)
return _pDeclHandler;
else if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
return _pLexicalHandler;
else throw SAXNotSupportedException(fromXMLString(propertyId));
}
void DOMSerializer::serialize(const Node* pNode)
{
poco_check_ptr (pNode);
handleNode(pNode);
}
void DOMSerializer::parse(InputSource* pSource)
{
throw XMLException("The DOMSerializer cannot parse an InputSource");
}
void DOMSerializer::parse(const XMLString& systemId)
{
throw XMLException("The DOMSerializer cannot parse from a system identifier");
}
void DOMSerializer::parseMemoryNP(const char* xml, std::size_t size)
{
throw XMLException("The DOMSerializer cannot parse from memory");
}
void DOMSerializer::iterate(const Node* pNode) const
{
while (pNode)
{
handleNode(pNode);
pNode = pNode->nextSibling();
}
}
void DOMSerializer::handleNode(const Node* pNode) const
{
switch (pNode->nodeType())
{
case Node::ELEMENT_NODE:
handleElement(static_cast<const Element*>(pNode));
break;
case Node::TEXT_NODE:
handleCharacterData(static_cast<const Text*>(pNode));
break;
case Node::CDATA_SECTION_NODE:
handleCDATASection(static_cast<const CDATASection*>(pNode));
break;
case Node::ENTITY_NODE:
handleEntity(static_cast<const Entity*>(pNode));
break;
case Node::PROCESSING_INSTRUCTION_NODE:
handlePI(static_cast<const ProcessingInstruction*>(pNode));
break;
case Node::COMMENT_NODE:
handleComment(static_cast<const Comment*>(pNode));
break;
case Node::DOCUMENT_NODE:
handleDocument(static_cast<const Document*>(pNode));
break;
case Node::DOCUMENT_TYPE_NODE:
handleDocumentType(static_cast<const DocumentType*>(pNode));
break;
case Node::DOCUMENT_FRAGMENT_NODE:
handleFragment(static_cast<const DocumentFragment*>(pNode));
break;
case Node::NOTATION_NODE:
handleNotation(static_cast<const Notation*>(pNode));
break;
}
}
void DOMSerializer::handleElement(const Element* pElement) const
{
if (_pContentHandler)
{
AutoPtr<NamedNodeMap> pAttrs = pElement->attributes();
AttributesImpl saxAttrs;
for (unsigned long i = 0; i < pAttrs->length(); ++i)
{
Attr* pAttr = static_cast<Attr*>(pAttrs->item(i));
saxAttrs.addAttribute(pAttr->namespaceURI(), pAttr->localName(), pAttr->nodeName(), CDATA, pAttr->value(), pAttr->specified());
}
_pContentHandler->startElement(pElement->namespaceURI(), pElement->localName(), pElement->tagName(), saxAttrs);
}
iterate(pElement->firstChild());
if (_pContentHandler)
_pContentHandler->endElement(pElement->namespaceURI(), pElement->localName(), pElement->tagName());
}
void DOMSerializer::handleCharacterData(const Text* pText) const
{
if (_pContentHandler)
{
const XMLString& data = pText->data();
_pContentHandler->characters(data.c_str(), 0, (int) data.length());
}
}
void DOMSerializer::handleComment(const Comment* pComment) const
{
if (_pLexicalHandler)
{
const XMLString& data = pComment->data();
_pLexicalHandler->comment(data.c_str(), 0, (int) data.length());
}
}
void DOMSerializer::handlePI(const ProcessingInstruction* pPI) const
{
if (_pContentHandler) _pContentHandler->processingInstruction(pPI->target(), pPI->data());
}
void DOMSerializer::handleCDATASection(const CDATASection* pCDATA) const
{
if (_pLexicalHandler) _pLexicalHandler->startCDATA();
handleCharacterData(pCDATA);
if (_pLexicalHandler) _pLexicalHandler->endCDATA();
}
void DOMSerializer::handleDocument(const Document* pDocument) const
{
if (_pContentHandler) _pContentHandler->startDocument();
const DocumentType* pDoctype = pDocument->doctype();
if (pDoctype) handleDocumentType(pDoctype);
iterate(pDocument->firstChild());
if (_pContentHandler) _pContentHandler->endDocument();
}
void DOMSerializer::handleDocumentType(const DocumentType* pDocumentType) const
{
if (_pLexicalHandler) _pLexicalHandler->startDTD(pDocumentType->name(), pDocumentType->publicId(), pDocumentType->systemId());
iterate(pDocumentType->firstChild());
if (_pLexicalHandler) _pLexicalHandler->endDTD();
}
void DOMSerializer::handleFragment(const DocumentFragment* pFragment) const
{
iterate(pFragment->firstChild());
}
void DOMSerializer::handleNotation(const Notation* pNotation) const
{
if (_pDTDHandler) _pDTDHandler->notationDecl(pNotation->nodeName(), &pNotation->publicId(), &pNotation->systemId());
}
void DOMSerializer::handleEntity(const Entity* pEntity) const
{
if (_pDTDHandler) _pDTDHandler->unparsedEntityDecl(pEntity->nodeName(), &pEntity->publicId(), pEntity->systemId(), pEntity->notationName());
}
} } // namespace Poco::XML

102
vendor/POCO/XML/src/DOMWriter.cpp vendored Normal file
View File

@@ -0,0 +1,102 @@
//
// DOMWriter.cpp
//
// Library: XML
// Package: DOM
// Module: DOMWriter
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DOMWriter.h"
#include "Poco/XML/XMLWriter.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/DocumentFragment.h"
#include "Poco/DOM/DocumentType.h"
#include "Poco/DOM/DOMException.h"
#include "Poco/DOM/DOMSerializer.h"
#include "Poco/SAX/LexicalHandler.h"
#include "Poco/XML/XMLException.h"
#include "Poco/Path.h"
#include "Poco/FileStream.h"
namespace Poco {
namespace XML {
DOMWriter::DOMWriter():
_pTextEncoding(0),
_options(0),
_indent("\t")
{
}
DOMWriter::~DOMWriter()
{
}
void DOMWriter::setEncoding(const std::string& encodingName, Poco::TextEncoding& textEncoding)
{
_encodingName = encodingName;
_pTextEncoding = &textEncoding;
}
void DOMWriter::setOptions(int options)
{
_options = options;
}
void DOMWriter::setNewLine(const std::string& newLine)
{
_newLine = newLine;
}
void DOMWriter::setIndent(const std::string& indent)
{
_indent = indent;
}
void DOMWriter::writeNode(XMLByteOutputStream& ostr, const Node* pNode)
{
poco_check_ptr (pNode);
bool isFragment = pNode->nodeType() != Node::DOCUMENT_NODE;
XMLWriter writer(ostr, _options, _encodingName, _pTextEncoding);
writer.setNewLine(_newLine);
writer.setIndent(_indent);
DOMSerializer serializer;
serializer.setContentHandler(&writer);
serializer.setDTDHandler(&writer);
serializer.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER, static_cast<LexicalHandler*>(&writer));
if (isFragment) writer.startFragment();
serializer.serialize(pNode);
if (isFragment) writer.endFragment();
}
void DOMWriter::writeNode(const std::string& systemId, const Node* pNode)
{
Poco::FileOutputStream ostr(systemId);
if (ostr.good())
writeNode(ostr, pNode);
else
throw Poco::CreateFileException(systemId);
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/DTDHandler.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// DTDHandler.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/DTDHandler.h"
namespace Poco {
namespace XML {
DTDHandler::~DTDHandler()
{
}
} } // namespace Poco::XML

117
vendor/POCO/XML/src/DTDMap.cpp vendored Normal file
View File

@@ -0,0 +1,117 @@
//
// DTDMap.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DTDMap.h"
#include "Poco/DOM/DocumentType.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/DOMException.h"
namespace Poco {
namespace XML {
DTDMap::DTDMap(const DocumentType* pDocumentType, unsigned short type):
_pDocumentType(pDocumentType),
_type(type)
{
poco_check_ptr (pDocumentType->ownerDocument());
}
DTDMap::~DTDMap()
{
}
Node* DTDMap::getNamedItem(const XMLString& name) const
{
Node* pCur = _pDocumentType->firstChild();
while (pCur)
{
if (pCur->nodeType() == _type && pCur->nodeName() == name)
return pCur;
pCur = pCur->nextSibling();
}
return pCur;
}
Node* DTDMap::setNamedItem(Node* arg)
{
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);
}
Node* DTDMap::removeNamedItem(const XMLString& name)
{
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);
}
Node* DTDMap::item(unsigned long index) const
{
unsigned long n = 0;
Node* pCur = _pDocumentType->firstChild();
while (pCur)
{
if (pCur->nodeType() == _type)
{
if (n == index) return pCur;
++n;
}
pCur = pCur->nextSibling();
}
return pCur;
}
unsigned long DTDMap::length() const
{
unsigned long n = 0;
Node* pCur = _pDocumentType->firstChild();
while (pCur)
{
if (pCur->nodeType() == _type) ++n;
pCur = pCur->nextSibling();
}
return n;
}
Node* DTDMap::getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const
{
return 0;
}
Node* DTDMap::setNamedItemNS(Node* arg)
{
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);
}
Node* DTDMap::removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName)
{
throw DOMException(DOMException::NO_MODIFICATION_ALLOWED_ERR);
}
void DTDMap::autoRelease()
{
_pDocumentType->ownerDocument()->autoReleasePool().add(this);
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/DeclHandler.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// DeclHandler.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/DeclHandler.h"
namespace Poco {
namespace XML {
DeclHandler::~DeclHandler()
{
}
} } // namespace Poco::XML

123
vendor/POCO/XML/src/DefaultHandler.cpp vendored Normal file
View File

@@ -0,0 +1,123 @@
//
// DefaultHandler.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/DefaultHandler.h"
namespace Poco {
namespace XML {
DefaultHandler::DefaultHandler()
{
}
DefaultHandler::~DefaultHandler()
{
}
InputSource* DefaultHandler::resolveEntity(const XMLString* publicId, const XMLString& systemId)
{
return 0;
}
void DefaultHandler::releaseInputSource(InputSource* pSource)
{
}
void DefaultHandler::notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId)
{
}
void DefaultHandler::unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName)
{
}
void DefaultHandler::setDocumentLocator(const Locator* loc)
{
}
void DefaultHandler::startDocument()
{
}
void DefaultHandler::endDocument()
{
}
void DefaultHandler::startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attributes)
{
}
void DefaultHandler::endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname)
{
}
void DefaultHandler::characters(const XMLChar ch[], int start, int length)
{
}
void DefaultHandler::ignorableWhitespace(const XMLChar ch[], int start, int length)
{
}
void DefaultHandler::processingInstruction(const XMLString& target, const XMLString& data)
{
}
void DefaultHandler::startPrefixMapping(const XMLString& prefix, const XMLString& uri)
{
}
void DefaultHandler::endPrefixMapping(const XMLString& prefix)
{
}
void DefaultHandler::skippedEntity(const XMLString& name)
{
}
void DefaultHandler::warning(const SAXException& exc)
{
}
void DefaultHandler::error(const SAXException& exc)
{
}
void DefaultHandler::fatalError(const SAXException& exc)
{
}
} } // namespace Poco::XML

326
vendor/POCO/XML/src/Document.cpp vendored Normal file
View File

@@ -0,0 +1,326 @@
//
// Document.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/Document.h"
#include "Poco/DOM/DocumentType.h"
#include "Poco/DOM/DOMImplementation.h"
#include "Poco/DOM/Element.h"
#include "Poco/DOM/Attr.h"
#include "Poco/DOM/DocumentFragment.h"
#include "Poco/DOM/Text.h"
#include "Poco/DOM/Comment.h"
#include "Poco/DOM/CDATASection.h"
#include "Poco/DOM/ProcessingInstruction.h"
#include "Poco/DOM/EntityReference.h"
#include "Poco/DOM/DOMException.h"
#include "Poco/DOM/ElementsByTagNameList.h"
#include "Poco/DOM/Entity.h"
#include "Poco/DOM/Notation.h"
#include "Poco/XML/Name.h"
#include "Poco/XML/NamePool.h"
namespace Poco {
namespace XML {
const XMLString Document::NODE_NAME = toXMLString("#document");
Document::Document(NamePool* pNamePool):
AbstractContainerNode(0),
_pDocumentType(0),
_eventSuspendLevel(0)
{
if (pNamePool)
{
_pNamePool = pNamePool;
_pNamePool->duplicate();
}
else
{
_pNamePool = new NamePool;
}
}
Document::Document(unsigned long namePoolSize):
AbstractContainerNode(0),
_pDocumentType(0),
_pNamePool(new NamePool(namePoolSize)),
_eventSuspendLevel(0)
{
}
Document::Document(DocumentType* pDocumentType, NamePool* pNamePool):
AbstractContainerNode(0),
_pDocumentType(pDocumentType),
_eventSuspendLevel(0)
{
if (pNamePool)
{
_pNamePool = pNamePool;
_pNamePool->duplicate();
}
else
{
_pNamePool = new NamePool;
}
if (_pDocumentType)
{
_pDocumentType->duplicate();
_pDocumentType->setOwnerDocument(this);
}
}
Document::Document(DocumentType* pDocumentType, unsigned long namePoolSize):
AbstractContainerNode(0),
_pDocumentType(pDocumentType),
_pNamePool(new NamePool(namePoolSize)),
_eventSuspendLevel(0)
{
if (_pDocumentType)
{
_pDocumentType->duplicate();
_pDocumentType->setOwnerDocument(this);
}
}
Document::~Document()
{
if (_pDocumentType) _pDocumentType->release();
_pNamePool->release();
}
bool Document::dispatchEvent(Event* evt)
{
return _eventSuspendLevel > 0 || AbstractContainerNode::dispatchEvent(evt);
}
void Document::collectGarbage()
{
_autoReleasePool.release();
}
void Document::suspendEvents()
{
++_eventSuspendLevel;
}
void Document::resumeEvents()
{
poco_assert_dbg (_eventSuspendLevel > 0);
--_eventSuspendLevel;
}
const DOMImplementation& Document::implementation() const
{
return DOMImplementation::instance();
}
Element* Document::documentElement() const
{
// Skip non-element nodes before the document element
Node* pCur = firstChild();
while (pCur)
{
if (dynamic_cast<Element*>(pCur))
return static_cast<Element*>(pCur);
pCur = pCur->nextSibling();
}
return 0;
}
Element* Document::createElement(const XMLString& tagName) const
{
return new Element(const_cast<Document*>(this), EMPTY_STRING, EMPTY_STRING, tagName);
}
DocumentFragment* Document::createDocumentFragment() const
{
return new DocumentFragment(const_cast<Document*>(this));
}
Text* Document::createTextNode(const XMLString& data) const
{
return new Text(const_cast<Document*>(this), data);
}
Comment* Document::createComment(const XMLString& data) const
{
return new Comment(const_cast<Document*>(this), data);
}
CDATASection* Document::createCDATASection(const XMLString& data) const
{
return new CDATASection(const_cast<Document*>(this), data);
}
ProcessingInstruction* Document::createProcessingInstruction(const XMLString& target, const XMLString& data) const
{
return new ProcessingInstruction(const_cast<Document*>(this), target, data);
}
Attr* Document::createAttribute(const XMLString& name) const
{
return new Attr(const_cast<Document*>(this), 0, EMPTY_STRING, EMPTY_STRING, name, EMPTY_STRING);
}
EntityReference* Document::createEntityReference(const XMLString& name) const
{
return new EntityReference(const_cast<Document*>(this), name);
}
NodeList* Document::getElementsByTagName(const XMLString& name) const
{
return new ElementsByTagNameList(const_cast<Document*>(this), name);
}
const XMLString& Document::nodeName() const
{
return NODE_NAME;
}
unsigned short Document::nodeType() const
{
return Node::DOCUMENT_NODE;
}
Node* Document::importNode(Node* importedNode, bool deep)
{
return static_cast<AbstractNode*>(importedNode)->copyNode(deep, this);
}
Element* Document::createElementNS(const XMLString& namespaceURI, const XMLString& qualifiedName) const
{
return new Element(const_cast<Document*>(this), namespaceURI, Name::localName(qualifiedName), qualifiedName);
}
Attr* Document::createAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName) const
{
return new Attr(const_cast<Document*>(this), 0, namespaceURI, Name::localName(qualifiedName), qualifiedName, EMPTY_STRING);
}
NodeList* Document::getElementsByTagNameNS(const XMLString& namespaceURI, const XMLString& localName) const
{
return new ElementsByTagNameListNS(const_cast<Document*>(this), namespaceURI, localName);
}
Element* Document::getElementById(const XMLString& elementId) const
{
return 0;
}
Event* Document::createEvent(const XMLString& eventType) const
{
if (eventType == MutationEvent::DOMSubtreeModified ||
eventType == MutationEvent::DOMNodeInserted ||
eventType == MutationEvent::DOMNodeRemoved ||
eventType == MutationEvent::DOMNodeRemovedFromDocument ||
eventType == MutationEvent::DOMNodeInsertedIntoDocument ||
eventType == MutationEvent::DOMAttrModified ||
eventType == MutationEvent::DOMCharacterDataModified)
{
return new MutationEvent(const_cast<Document*>(this), eventType);
}
throw DOMException(DOMException::NOT_SUPPORTED_ERR);
}
Node* Document::copyNode(bool deep, Document* pOwnerDocument) const
{
throw DOMException(DOMException::NOT_SUPPORTED_ERR);
}
void Document::setDoctype(DocumentType* pDoctype)
{
if (_pDocumentType) _pDocumentType->release();
_pDocumentType = pDoctype;
if (_pDocumentType)
{
_pDocumentType->duplicate();
_pDocumentType->setOwnerDocument(this);
}
}
bool Document::eventsSuspended() const
{
return _eventSuspendLevel > 0;
}
bool Document::events() const
{
return _eventSuspendLevel == 0;
}
Entity* Document::createEntity(const XMLString& name, const XMLString& publicId, const XMLString& systemId, const XMLString& notationName) const
{
return new Entity(const_cast<Document*>(this), name, publicId, systemId, notationName);
}
Notation* Document::createNotation(const XMLString& name, const XMLString& publicId, const XMLString& systemId) const
{
return new Notation(const_cast<Document*>(this), name, publicId, systemId);
}
Element* Document::getElementById(const XMLString& elementId, const XMLString& idAttribute) const
{
Element* pElem = documentElement();
if (pElem) pElem = pElem->getElementById(elementId, idAttribute);
return pElem;
}
Element* Document::getElementByIdNS(const XMLString& elementId, const XMLString& idAttributeURI, const XMLString& idAttributeLocalName) const
{
Element* pElem = documentElement();
if (pElem) pElem = pElem->getElementByIdNS(elementId, idAttributeURI, idAttributeLocalName);
return pElem;
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/DocumentEvent.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// DocumentEvent.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DocumentEvent.h"
namespace Poco {
namespace XML {
DocumentEvent::~DocumentEvent()
{
}
} } // namespace Poco::XML

View File

@@ -0,0 +1,70 @@
//
// DocumentFragment.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DocumentFragment.h"
namespace Poco {
namespace XML {
const XMLString DocumentFragment::NODE_NAME = toXMLString("#document-fragment");
DocumentFragment::DocumentFragment(Document* pOwnerDocument):
AbstractContainerNode(pOwnerDocument)
{
}
DocumentFragment::DocumentFragment( Document* pOwnerDocument, const DocumentFragment& fragment):
AbstractContainerNode(pOwnerDocument, fragment)
{
}
DocumentFragment::~DocumentFragment()
{
}
const XMLString& DocumentFragment::nodeName() const
{
return NODE_NAME;
}
unsigned short DocumentFragment::nodeType() const
{
return Node::DOCUMENT_FRAGMENT_NODE;
}
Node* DocumentFragment::copyNode(bool deep, Document* pOwnerDocument) const
{
DocumentFragment* pClone = new DocumentFragment(pOwnerDocument, *this);
if (deep)
{
Node* pCur = firstChild();
while (pCur)
{
pClone->appendChild(static_cast<AbstractNode*>(pCur)->copyNode(deep, pOwnerDocument))->release();
pCur = pCur->nextSibling();
}
}
return pClone;
}
} } // namespace Poco::XML

84
vendor/POCO/XML/src/DocumentType.cpp vendored Normal file
View File

@@ -0,0 +1,84 @@
//
// DocumentType.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/DocumentType.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/DTDMap.h"
#include "Poco/DOM/DOMException.h"
namespace Poco {
namespace XML {
DocumentType::DocumentType(Document* pOwner, const XMLString& name, const XMLString& publicId, const XMLString& systemId):
AbstractContainerNode(pOwner),
_name(name),
_publicId(publicId),
_systemId(systemId)
{
}
DocumentType::DocumentType(Document* pOwner, const DocumentType& doctype):
AbstractContainerNode(pOwner, doctype),
_name(doctype._name),
_publicId(doctype._publicId),
_systemId(doctype._systemId)
{
}
DocumentType::~DocumentType()
{
}
NamedNodeMap* DocumentType::entities() const
{
return new DTDMap(this, Node::ENTITY_NODE);
}
NamedNodeMap* DocumentType::notations() const
{
return new DTDMap(this, Node::NOTATION_NODE);
}
const XMLString& DocumentType::nodeName() const
{
return _name;
}
unsigned short DocumentType::nodeType() const
{
return Node::DOCUMENT_TYPE_NODE;
}
const XMLString& DocumentType::internalSubset() const
{
return EMPTY_STRING;
}
Node* DocumentType::copyNode(bool deep, Document* pOwnerDocument) const
{
return new DocumentType(pOwnerDocument, *this);
}
} } // namespace Poco::XML

444
vendor/POCO/XML/src/Element.cpp vendored Normal file
View File

@@ -0,0 +1,444 @@
//
// Element.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/Element.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/Attr.h"
#include "Poco/DOM/DOMException.h"
#include "Poco/DOM/ElementsByTagNameList.h"
#include "Poco/DOM/Text.h"
#include "Poco/DOM/AttrMap.h"
namespace Poco {
namespace XML {
Element::Element(Document* pOwnerDocument, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname):
AbstractContainerNode(pOwnerDocument),
_name(pOwnerDocument->namePool().insert(qname, namespaceURI, localName)),
_pFirstAttr(0)
{
}
Element::Element(Document* pOwnerDocument, const Element& element):
AbstractContainerNode(pOwnerDocument, element),
_name(pOwnerDocument->namePool().insert(element._name)),
_pFirstAttr(0)
{
Attr* pAttr = element._pFirstAttr;
while (pAttr)
{
Attr* pClonedAttr = static_cast<Attr*>(pAttr->copyNode(false, pOwnerDocument));
setAttributeNode(pClonedAttr);
pClonedAttr->release();
pAttr = static_cast<Attr*>(pAttr->_pNext);
}
}
Element::~Element()
{
if (_pFirstAttr) _pFirstAttr->release();
}
const XMLString& Element::getAttribute(const XMLString& name) const
{
Attr* pAttr = getAttributeNode(name);
if (pAttr)
return pAttr->getValue();
else
return EMPTY_STRING;
}
void Element::setAttribute(const XMLString& name, const XMLString& value)
{
Attr* pAttr = getAttributeNode(name);
if (pAttr)
{
pAttr->setValue(value);
}
else
{
pAttr = ownerDocument()->createAttribute(name);
pAttr->setValue(value);
setAttributeNode(pAttr);
pAttr->release();
}
}
void Element::removeAttribute(const XMLString& name)
{
Attr* pAttr = getAttributeNode(name);
if (pAttr) removeAttributeNode(pAttr);
}
Attr* Element::getAttributeNode(const XMLString& name) const
{
Attr* pAttr = _pFirstAttr;
while (pAttr && pAttr->_name.qname() != name) pAttr = static_cast<Attr*>(pAttr->_pNext);
return pAttr;
}
Attr* Element::setAttributeNode(Attr* newAttr)
{
poco_check_ptr (newAttr);
if (newAttr->ownerDocument() != ownerDocument())
throw DOMException(DOMException::WRONG_DOCUMENT_ERR);
if (newAttr->ownerElement())
throw DOMException(DOMException::INUSE_ATTRIBUTE_ERR);
Attr* oldAttr = getAttributeNode(newAttr->name());
if (oldAttr) removeAttributeNode(oldAttr);
Attr* pCur = _pFirstAttr;
if (pCur)
{
while (pCur->_pNext) pCur = static_cast<Attr*>(pCur->_pNext);
pCur->_pNext = newAttr;
}
else _pFirstAttr = newAttr;
newAttr->duplicate();
newAttr->_pParent = this;
if (_pOwner->events())
dispatchAttrModified(newAttr, MutationEvent::ADDITION, EMPTY_STRING, newAttr->getValue());
return oldAttr;
}
Attr* Element::removeAttributeNode(Attr* oldAttr)
{
poco_check_ptr (oldAttr);
if (_pOwner->events())
dispatchAttrModified(oldAttr, MutationEvent::REMOVAL, oldAttr->getValue(), EMPTY_STRING);
if (oldAttr != _pFirstAttr)
{
Attr* pCur = _pFirstAttr;
while (pCur->_pNext != oldAttr) pCur = static_cast<Attr*>(pCur->_pNext);
if (pCur)
{
pCur->_pNext = static_cast<Attr*>(pCur->_pNext->_pNext);
}
else throw DOMException(DOMException::NOT_FOUND_ERR);
}
else _pFirstAttr = static_cast<Attr*>(_pFirstAttr->_pNext);
oldAttr->_pNext = 0;
oldAttr->_pParent = 0;
oldAttr->autoRelease();
return oldAttr;
}
Attr* Element::addAttributeNodeNP(Attr* oldAttr, Attr* newAttr)
{
newAttr->_pParent = this;
if (oldAttr)
{
oldAttr->_pNext = newAttr;
}
else if (_pFirstAttr)
{
newAttr->_pNext = _pFirstAttr;
_pFirstAttr = newAttr;
}
else
{
_pFirstAttr = newAttr;
}
newAttr->duplicate();
return newAttr;
}
NodeList* Element::getElementsByTagName(const XMLString& name) const
{
return new ElementsByTagNameList(this, name);
}
NodeList* Element::getElementsByTagNameNS(const XMLString& namespaceURI, const XMLString& localName) const
{
return new ElementsByTagNameListNS(this, namespaceURI, localName);
}
void Element::normalize()
{
Node* pCur = firstChild();
while (pCur)
{
if (pCur->nodeType() == Node::ELEMENT_NODE)
{
pCur->normalize();
}
else if (pCur->nodeType() == Node::TEXT_NODE)
{
Node* pNext = pCur->nextSibling();
while (pNext && pNext->nodeType() == Node::TEXT_NODE)
{
static_cast<Text*>(pCur)->appendData(pNext->nodeValue());
removeChild(pNext);
pNext = pCur->nextSibling();
}
}
pCur = pCur->nextSibling();
}
}
const XMLString& Element::nodeName() const
{
return tagName();
}
NamedNodeMap* Element::attributes() const
{
return new AttrMap(const_cast<Element*>(this));
}
unsigned short Element::nodeType() const
{
return Node::ELEMENT_NODE;
}
const XMLString& Element::getAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const
{
Attr* pAttr = getAttributeNodeNS(namespaceURI, localName);
if (pAttr)
return pAttr->getValue();
else
return EMPTY_STRING;
}
void Element::setAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName, const XMLString& value)
{
Attr* pAttr = getAttributeNodeNS(namespaceURI, qualifiedName);
if (pAttr)
{
pAttr->setValue(value);
}
else
{
pAttr = _pOwner->createAttributeNS(namespaceURI, qualifiedName);
pAttr->setValue(value);
setAttributeNodeNS(pAttr);
pAttr->release();
}
}
void Element::removeAttributeNS(const XMLString& namespaceURI, const XMLString& localName)
{
Attr* pAttr = getAttributeNodeNS(namespaceURI, localName);
if (pAttr) removeAttributeNode(pAttr);
}
Attr* Element::getAttributeNodeNS(const XMLString& namespaceURI, const XMLString& localName) const
{
Attr* pAttr = _pFirstAttr;
while (pAttr && (pAttr->_name.namespaceURI() != namespaceURI || pAttr->_name.localName() != localName)) pAttr = static_cast<Attr*>(pAttr->_pNext);
return pAttr;
}
Attr* Element::setAttributeNodeNS(Attr* newAttr)
{
poco_check_ptr (newAttr);
if (newAttr->ownerDocument() != ownerDocument())
throw DOMException(DOMException::WRONG_DOCUMENT_ERR);
if (newAttr->ownerElement())
throw DOMException(DOMException::INUSE_ATTRIBUTE_ERR);
Attr* oldAttr = getAttributeNodeNS(newAttr->namespaceURI(), newAttr->localName());
if (oldAttr) removeAttributeNode(oldAttr);
Attr* pCur = _pFirstAttr;
if (pCur)
{
while (pCur->_pNext) pCur = static_cast<Attr*>(pCur->_pNext);
pCur->_pNext = newAttr;
}
else _pFirstAttr = newAttr;
newAttr->_pParent = this;
newAttr->duplicate();
if (_pOwner->events())
dispatchAttrModified(newAttr, MutationEvent::ADDITION, EMPTY_STRING, newAttr->getValue());
return oldAttr;
}
bool Element::hasAttribute(const XMLString& name) const
{
return getAttributeNode(name) != 0;
}
bool Element::hasAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const
{
return getAttributeNodeNS(namespaceURI, localName) != 0;
}
const XMLString& Element::namespaceURI() const
{
return _name.namespaceURI();
}
XMLString Element::prefix() const
{
return _name.prefix();
}
const XMLString& Element::localName() const
{
return _name.localName();
}
bool Element::hasAttributes() const
{
return _pFirstAttr != 0;
}
XMLString Element::innerText() const
{
XMLString result;
Node* pChild = firstChild();
while (pChild)
{
result.append(pChild->innerText());
pChild = pChild->nextSibling();
}
return result;
}
Element* Element::getChildElement(const XMLString& name) const
{
Node* pNode = firstChild();
while (pNode && !(pNode->nodeType() == Node::ELEMENT_NODE && pNode->nodeName() == name))
pNode = pNode->nextSibling();
return static_cast<Element*>(pNode);
}
Element* Element::getChildElementNS(const XMLString& namespaceURI, const XMLString& localName) const
{
Node* pNode = firstChild();
while (pNode && !(pNode->nodeType() == Node::ELEMENT_NODE && pNode->namespaceURI() == namespaceURI && pNode->localName() == localName))
pNode = pNode->nextSibling();
return static_cast<Element*>(pNode);
}
void Element::dispatchNodeRemovedFromDocument()
{
AbstractContainerNode::dispatchNodeRemovedFromDocument();
Attr* pAttr = _pFirstAttr;
while (pAttr)
{
pAttr->dispatchNodeRemovedFromDocument();
pAttr = static_cast<Attr*>(pAttr->_pNext);
}
}
void Element::dispatchNodeInsertedIntoDocument()
{
AbstractContainerNode::dispatchNodeInsertedIntoDocument();
Attr* pAttr = _pFirstAttr;
while (pAttr)
{
pAttr->dispatchNodeInsertedIntoDocument();
pAttr = static_cast<Attr*>(pAttr->_pNext);
}
}
Node* Element::copyNode(bool deep, Document* pOwnerDocument) const
{
Element* pClone = new Element(pOwnerDocument, *this);
if (deep)
{
Node* pNode = firstChild();
while (pNode)
{
pClone->appendChild(static_cast<AbstractNode*>(pNode)->copyNode(true, pOwnerDocument))->release();
pNode = pNode->nextSibling();
}
}
return pClone;
}
Element* Element::getElementById(const XMLString& elementId, const XMLString& idAttribute) const
{
if (getAttribute(idAttribute) == elementId)
return const_cast<Element*>(this);
Node* pNode = firstChild();
while (pNode)
{
if (pNode->nodeType() == Node::ELEMENT_NODE)
{
Element* pResult = static_cast<Element*>(pNode)->getElementById(elementId, idAttribute);
if (pResult) return pResult;
}
pNode = pNode->nextSibling();
}
return 0;
}
Element* Element::getElementByIdNS(const XMLString& elementId, const XMLString& idAttributeURI, const XMLString& idAttributeLocalName) const
{
if (getAttributeNS(idAttributeURI, idAttributeLocalName) == elementId)
return const_cast<Element*>(this);
Node* pNode = firstChild();
while (pNode)
{
if (pNode->nodeType() == Node::ELEMENT_NODE)
{
Element* pResult = static_cast<Element*>(pNode)->getElementByIdNS(elementId, idAttributeURI, idAttributeLocalName);
if (pResult) return pResult;
}
pNode = pNode->nextSibling();
}
return 0;
}
} } // namespace Poco::XML

View File

@@ -0,0 +1,151 @@
//
// ElementsByTagNameList.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/ElementsByTagNameList.h"
#include "Poco/DOM/Node.h"
#include "Poco/DOM/Document.h"
#include <climits>
namespace Poco {
namespace XML {
ElementsByTagNameList::ElementsByTagNameList(const Node* pParent, const XMLString& name):
_pParent(pParent),
_name(name),
_count(0)
{
poco_check_ptr (pParent);
_pParent->duplicate();
}
ElementsByTagNameList::~ElementsByTagNameList()
{
_pParent->release();
}
Node* ElementsByTagNameList::item(unsigned long index) const
{
_count = 0;
return find(_pParent, index);
}
unsigned long ElementsByTagNameList::length() const
{
_count = 0;
find(_pParent, ULONG_MAX);
return _count;
}
namespace
{
static const XMLString asterisk = toXMLString("*");
}
Node* ElementsByTagNameList::find(const Node* pParent, unsigned long index) const
{
if (!pParent) return 0;
// preorder search
Node* pCur = pParent->firstChild();
while (pCur)
{
if (pCur->nodeType() == Node::ELEMENT_NODE && (_name == asterisk || pCur->nodeName() == _name))
{
if (_count == index) return pCur;
_count++;
}
Node* pNode = find(pCur, index);
if (pNode) return pNode;
pCur = pCur->nextSibling();
}
return pCur;
}
void ElementsByTagNameList::autoRelease()
{
_pParent->ownerDocument()->autoReleasePool().add(this);
}
ElementsByTagNameListNS::ElementsByTagNameListNS(const Node* pParent, const XMLString& namespaceURI, const XMLString& localName):
_pParent(pParent),
_localName(localName),
_namespaceURI(namespaceURI),
_count(0)
{
poco_check_ptr (pParent);
_pParent->duplicate();
}
ElementsByTagNameListNS::~ElementsByTagNameListNS()
{
_pParent->release();
}
Node* ElementsByTagNameListNS::item(unsigned long index) const
{
_count = 0;
return find(_pParent, index);
}
unsigned long ElementsByTagNameListNS::length() const
{
_count = 0;
find(_pParent, ULONG_MAX);
return _count;
}
Node* ElementsByTagNameListNS::find(const Node* pParent, unsigned long index) const
{
if (!pParent) return 0;
// preorder search
Node* pCur = pParent->firstChild();
while (pCur)
{
if (pCur->nodeType() == Node::ELEMENT_NODE && (_localName == asterisk || pCur->localName() == _localName) && (_namespaceURI == asterisk || pCur->namespaceURI() == _namespaceURI))
{
if (_count == index) return pCur;
_count++;
}
Node* pNode = find(pCur, index);
if (pNode) return pNode;
pCur = pCur->nextSibling();
}
return pCur;
}
void ElementsByTagNameListNS::autoRelease()
{
_pParent->ownerDocument()->autoReleasePool().add(this);
}
} } // namespace Poco::XML

68
vendor/POCO/XML/src/Entity.cpp vendored Normal file
View File

@@ -0,0 +1,68 @@
//
// Entity.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/Entity.h"
namespace Poco {
namespace XML {
const XMLString Entity::NODE_NAME = toXMLString("#entity");
Entity::Entity(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId, const XMLString& notationName):
AbstractContainerNode(pOwnerDocument),
_name(name),
_publicId(publicId),
_systemId(systemId),
_notationName(notationName)
{
}
Entity::Entity(Document* pOwnerDocument, const Entity& entity):
AbstractContainerNode(pOwnerDocument, entity),
_name(entity._name),
_publicId(entity._publicId),
_systemId(entity._systemId),
_notationName(entity._notationName)
{
}
Entity::~Entity()
{
}
const XMLString& Entity::nodeName() const
{
return _name;
}
unsigned short Entity::nodeType() const
{
return Node::ENTITY_NODE;
}
Node* Entity::copyNode(bool deep, Document* pOwnerDocument) const
{
return new Entity(pOwnerDocument, *this);
}
} } // namespace Poco::XML

59
vendor/POCO/XML/src/EntityReference.cpp vendored Normal file
View File

@@ -0,0 +1,59 @@
//
// EntityReference.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/EntityReference.h"
namespace Poco {
namespace XML {
EntityReference::EntityReference(Document* pOwnerDocument, const XMLString& name):
AbstractNode(pOwnerDocument),
_name(name)
{
}
EntityReference::EntityReference(Document* pOwnerDocument, const EntityReference& ref):
AbstractNode(pOwnerDocument, ref),
_name(ref._name)
{
}
EntityReference::~EntityReference()
{
}
const XMLString& EntityReference::nodeName() const
{
return _name;
}
unsigned short EntityReference::nodeType() const
{
return Node::ENTITY_REFERENCE_NODE;
}
Node* EntityReference::copyNode(bool deep, Document* pOwnerDocument) const
{
return new EntityReference(pOwnerDocument, *this);
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/EntityResolver.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// EntityResolver.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/EntityResolver.h"
namespace Poco {
namespace XML {
EntityResolver::~EntityResolver()
{
}
} } // namespace Poco::XML

View File

@@ -0,0 +1,78 @@
//
// EntityResolverImpl.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/EntityResolverImpl.h"
#include "Poco/SAX/InputSource.h"
#include "Poco/XML/XMLString.h"
#include "Poco/URI.h"
#include "Poco/Path.h"
#include "Poco/Exception.h"
using Poco::URIStreamOpener;
using Poco::URI;
using Poco::Path;
using Poco::Exception;
using Poco::IOException;
using Poco::OpenFileException;
namespace Poco {
namespace XML {
EntityResolverImpl::EntityResolverImpl():
_opener(URIStreamOpener::defaultOpener())
{
}
EntityResolverImpl::EntityResolverImpl(const URIStreamOpener& opener):
_opener(opener)
{
}
EntityResolverImpl::~EntityResolverImpl()
{
}
InputSource* EntityResolverImpl::resolveEntity(const XMLString* publicId, const XMLString& systemId)
{
std::istream* pIstr = resolveSystemId(systemId);
InputSource* pInputSource = new InputSource(systemId);
if (publicId) pInputSource->setPublicId(*publicId);
pInputSource->setByteStream(*pIstr);
return pInputSource;
}
void EntityResolverImpl::releaseInputSource(InputSource* pSource)
{
poco_check_ptr (pSource);
delete pSource->getByteStream();
delete pSource;
}
std::istream* EntityResolverImpl::resolveSystemId(const XMLString& systemId)
{
std::string sid = fromXMLString(systemId);
return _opener.open(sid);
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/ErrorHandler.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// ErrorHandler.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/ErrorHandler.h"
namespace Poco {
namespace XML {
ErrorHandler::~ErrorHandler()
{
}
} } // namespace Poco::XML

102
vendor/POCO/XML/src/Event.cpp vendored Normal file
View File

@@ -0,0 +1,102 @@
//
// Event.cpp
//
// Library: XML
// Package: DOM
// Module: DOMEvents
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/Event.h"
#include "Poco/DOM/Document.h"
namespace Poco {
namespace XML {
Event::Event(Document* pOwnerDocument, const XMLString& type):
_pOwner(pOwnerDocument),
_type(type),
_pTarget(0),
_pCurrentTarget(0),
_currentPhase(CAPTURING_PHASE),
_bubbles(true),
_cancelable(true),
_canceled(false),
_stopped(false)
{
}
Event::Event(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool isCancelable):
_pOwner(pOwnerDocument),
_type(type),
_pTarget(pTarget),
_pCurrentTarget(0),
_currentPhase(CAPTURING_PHASE),
_bubbles(canBubble),
_cancelable(isCancelable),
_canceled(false),
_stopped(false)
{
}
Event::~Event()
{
}
void Event::stopPropagation()
{
_stopped = true;
}
void Event::preventDefault()
{
_canceled = true;
}
void Event::initEvent(const XMLString& eventType, bool canBubble, bool isCancelable)
{
_type = eventType;
_bubbles = canBubble;
_cancelable = isCancelable;
_canceled = false;
_stopped = false;
}
void Event::setTarget(EventTarget* pTarget)
{
_pTarget = pTarget;
}
void Event::setCurrentPhase(PhaseType phase)
{
_currentPhase = phase;
}
void Event::setCurrentTarget(EventTarget* pTarget)
{
_pCurrentTarget = pTarget;
}
void Event::autoRelease()
{
_pOwner->autoReleasePool().add(this);
}
} } // namespace Poco::XML

146
vendor/POCO/XML/src/EventDispatcher.cpp vendored Normal file
View File

@@ -0,0 +1,146 @@
//
// EventDispatcher.cpp
//
// Library: XML
// Package: DOM
// Module: DOMEvents
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/EventDispatcher.h"
#include "Poco/DOM/Event.h"
#include "Poco/DOM/EventListener.h"
namespace
{
class DispatchGuard
{
public:
DispatchGuard(int& count):
_count(count)
{
++_count;
}
~DispatchGuard()
{
--_count;
}
private:
int& _count;
};
}
namespace Poco {
namespace XML {
EventDispatcher::EventDispatcher():
_inDispatch(0)
{
}
EventDispatcher::~EventDispatcher()
{
}
void EventDispatcher::addEventListener(const XMLString& type, EventListener* listener, bool useCapture)
{
EventListenerItem item;
item.type = type;
item.pListener = listener;
item.useCapture = useCapture;
_listeners.push_front(item);
}
void EventDispatcher::removeEventListener(const XMLString& type, EventListener* listener, bool useCapture)
{
EventListenerList::iterator it = _listeners.begin();
while (it != _listeners.end())
{
if (it->type == type && it->pListener == listener && it->useCapture == useCapture)
{
it->pListener = 0;
}
if (!_inDispatch && !it->pListener)
{
EventListenerList::iterator del = it++;
_listeners.erase(del);
}
else ++it;
}
}
void EventDispatcher::dispatchEvent(Event* evt)
{
DispatchGuard guard(_inDispatch);
EventListenerList::iterator it = _listeners.begin();
while (it != _listeners.end())
{
if (it->pListener && it->type == evt->type())
{
it->pListener->handleEvent(evt);
}
if (!it->pListener)
{
EventListenerList::iterator del = it++;
_listeners.erase(del);
}
else ++it;
}
}
void EventDispatcher::captureEvent(Event* evt)
{
DispatchGuard guard(_inDispatch);
EventListenerList::iterator it = _listeners.begin();
while (it != _listeners.end())
{
if (it->pListener && it->useCapture && it->type == evt->type())
{
it->pListener->handleEvent(evt);
}
if (!it->pListener)
{
EventListenerList::iterator del = it++;
_listeners.erase(del);
}
else ++it;
}
}
void EventDispatcher::bubbleEvent(Event* evt)
{
DispatchGuard guard(_inDispatch);
EventListenerList::iterator it = _listeners.begin();
while (it != _listeners.end())
{
if (it->pListener && !it->useCapture && it->type == evt->type())
{
it->pListener->handleEvent(evt);
}
if (!it->pListener)
{
EventListenerList::iterator del = it++;
_listeners.erase(del);
}
else ++it;
}
}
} } // namespace Poco::XML

65
vendor/POCO/XML/src/EventException.cpp vendored Normal file
View File

@@ -0,0 +1,65 @@
//
// EventException.cpp
//
// Library: XML
// Package: DOM
// Module: DOMEvents
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/EventException.h"
#include <typeinfo>
namespace Poco {
namespace XML {
EventException::EventException(int code):
XMLException("Unspecified event type")
{
}
EventException::EventException(const EventException& exc):
XMLException(exc)
{
}
EventException::~EventException() noexcept
{
}
EventException& EventException::operator = (const EventException& exc)
{
XMLException::operator = (exc);
return *this;
}
const char* EventException::name() const noexcept
{
return "EventException";
}
const char* EventException::className() const noexcept
{
return typeid(*this).name();
}
Poco::Exception* EventException::clone() const
{
return new EventException(*this);
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/EventListener.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// EventListener.cpp
//
// Library: XML
// Package: DOM
// Module: DOMEvents
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/EventListener.h"
namespace Poco {
namespace XML {
EventListener::~EventListener()
{
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/EventTarget.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// EventTarget.cpp
//
// Library: XML
// Package: DOM
// Module: DOMEvents
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/EventTarget.h"
namespace Poco {
namespace XML {
EventTarget::~EventTarget()
{
}
} } // namespace Poco::XML

80
vendor/POCO/XML/src/InputSource.cpp vendored Normal file
View File

@@ -0,0 +1,80 @@
//
// InputSource.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/InputSource.h"
namespace Poco {
namespace XML {
InputSource::InputSource():
_bistr(0),
_cistr(0)
{
}
InputSource::InputSource(const XMLString& systemId):
_systemId(systemId),
_bistr(0),
_cistr(0)
{
}
InputSource::InputSource(XMLByteInputStream& bistr):
_bistr(&bistr),
_cistr(0)
{
}
InputSource::~InputSource()
{
}
void InputSource::setPublicId(const XMLString& publicId)
{
_publicId = publicId;
}
void InputSource::setSystemId(const XMLString& systemId)
{
_systemId = systemId;
}
void InputSource::setEncoding(const XMLString& encoding)
{
_encoding = encoding;
}
void InputSource::setByteStream(XMLByteInputStream& bistr)
{
_bistr = &bistr;
}
void InputSource::setCharacterStream(XMLCharInputStream& cistr)
{
_cistr = &cistr;
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/LexicalHandler.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// LexicalHandler.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/LexicalHandler.h"
namespace Poco {
namespace XML {
LexicalHandler::~LexicalHandler()
{
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/Locator.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// Locator.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/Locator.h"
namespace Poco {
namespace XML {
Locator::~Locator()
{
}
} } // namespace Poco::XML

104
vendor/POCO/XML/src/LocatorImpl.cpp vendored Normal file
View File

@@ -0,0 +1,104 @@
//
// LocatorImpl.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/LocatorImpl.h"
namespace Poco {
namespace XML {
LocatorImpl::LocatorImpl()
{
_lineNumber = 0;
_columnNumber = 0;
}
LocatorImpl::LocatorImpl(const Locator& loc)
{
_publicId = loc.getPublicId();
_systemId = loc.getSystemId();
_lineNumber = loc.getLineNumber();
_columnNumber = loc.getColumnNumber();
}
LocatorImpl::~LocatorImpl()
{
}
LocatorImpl& LocatorImpl::operator = (const Locator& loc)
{
if (&loc != this)
{
_publicId = loc.getPublicId();
_systemId = loc.getSystemId();
_lineNumber = loc.getLineNumber();
_columnNumber = loc.getColumnNumber();
}
return *this;
}
XMLString LocatorImpl::getPublicId() const
{
return _publicId;
}
XMLString LocatorImpl::getSystemId() const
{
return _systemId;
}
int LocatorImpl::getLineNumber() const
{
return _lineNumber;
}
int LocatorImpl::getColumnNumber() const
{
return _columnNumber;
}
void LocatorImpl::setPublicId(const XMLString& publicId)
{
_publicId = publicId;
}
void LocatorImpl::setSystemId(const XMLString& systemId)
{
_systemId = systemId;
}
void LocatorImpl::setLineNumber(int lineNumber)
{
_lineNumber = lineNumber;
}
void LocatorImpl::setColumnNumber(int columnNumber)
{
_columnNumber = columnNumber;
}
} } // namespace Poco::XML

76
vendor/POCO/XML/src/MutationEvent.cpp vendored Normal file
View File

@@ -0,0 +1,76 @@
//
// MutationEvent.cpp
//
// Library: XML
// Package: DOM
// Module: DOMEvents
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/MutationEvent.h"
namespace Poco {
namespace XML {
const XMLString MutationEvent::DOMSubtreeModified = toXMLString("DOMSubtreeModified");
const XMLString MutationEvent::DOMNodeInserted = toXMLString("DOMNodeInserted");
const XMLString MutationEvent::DOMNodeRemoved = toXMLString("DOMNodeRemoved");
const XMLString MutationEvent::DOMNodeRemovedFromDocument = toXMLString("DOMNodeRemovedFromDocument");
const XMLString MutationEvent::DOMNodeInsertedIntoDocument = toXMLString("DOMNodeInsertedIntoDocument");
const XMLString MutationEvent::DOMAttrModified = toXMLString("DOMAttrModified");
const XMLString MutationEvent::DOMCharacterDataModified = toXMLString("DOMCharacterDataModified");
MutationEvent::MutationEvent(Document* pOwnerDocument, const XMLString& type):
Event(pOwnerDocument, type, 0, true, false),
_change(MODIFICATION),
_pRelatedNode(0)
{
}
MutationEvent::MutationEvent(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool cancelable, Node* relatedNode):
Event(pOwnerDocument, type, pTarget, canBubble, cancelable),
_change(MODIFICATION),
_pRelatedNode(relatedNode)
{
}
MutationEvent::MutationEvent(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool cancelable, Node* relatedNode,
const XMLString& prevValue, const XMLString& newValue, const XMLString& attrName, AttrChangeType change):
Event(pOwnerDocument, type, pTarget, canBubble, cancelable),
_prevValue(prevValue),
_newValue(newValue),
_attrName(attrName),
_change(change),
_pRelatedNode(relatedNode)
{
}
MutationEvent::~MutationEvent()
{
}
void MutationEvent::initMutationEvent(const XMLString& type, bool canBubble, bool cancelable, Node* relatedNode,
const XMLString& prevValue, const XMLString& newValue, const XMLString& attrName, AttrChangeType change)
{
initEvent(type, canBubble, cancelable);
_pRelatedNode = relatedNode;
_prevValue = prevValue;
_newValue = newValue;
_attrName = attrName;
_change = change;
}
} } // namespace Poco::XML

188
vendor/POCO/XML/src/Name.cpp vendored Normal file
View File

@@ -0,0 +1,188 @@
//
// Name.cpp
//
// Library: XML
// Package: XML
// Module: Name
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/XML/Name.h"
#include <algorithm>
namespace Poco {
namespace XML {
const XMLString Name::EMPTY_NAME;
Name::Name()
{
}
Name::Name(const XMLString& qname):
_qname(qname)
{
}
Name::Name(const XMLString& qname, const XMLString& namespaceURI):
_qname(qname),
_namespaceURI(namespaceURI),
_localName(localName(qname))
{
}
Name::Name(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName):
_qname(qname),
_namespaceURI(namespaceURI),
_localName(localName)
{
}
Name::Name(const Name& name):
_qname(name._qname),
_namespaceURI(name._namespaceURI),
_localName(name._localName)
{
}
Name::Name(Name&& name) noexcept:
_qname(std::move(name._qname)),
_namespaceURI(std::move(name._namespaceURI)),
_localName(std::move(name._localName))
{
}
Name::~Name()
{
}
Name& Name::operator = (const Name& name)
{
if (this != &name)
{
_qname = name._qname;
_namespaceURI = name._namespaceURI;
_localName = name._localName;
}
return *this;
}
Name& Name::operator = (Name&& name) noexcept
{
_qname = std::move(name._qname);
_namespaceURI = std::move(name._namespaceURI);
_localName = std::move(name._localName);
return *this;
}
void Name::swap(Name& name)
{
std::swap(_qname, name._qname);
std::swap(_namespaceURI, name._namespaceURI);
std::swap(_localName, name._localName);
}
void Name::assign(const XMLString& qname)
{
_qname = qname;
_namespaceURI.clear();
_localName.clear();
}
void Name::assign(const XMLString& qname, const XMLString& namespaceURI)
{
_qname = qname;
_namespaceURI = namespaceURI;
_localName = localName(qname);
}
void Name::assign(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
{
_qname = qname;
_namespaceURI = namespaceURI;
_localName = localName;
}
bool Name::equals(const Name& name) const
{
return name._namespaceURI == _namespaceURI && name._localName == _localName && name._qname == _qname;
}
bool Name::equals(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName) const
{
return _namespaceURI == namespaceURI && _localName == localName && _qname == qname;
}
bool Name::equalsWeakly(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName) const
{
return (_qname == qname && !qname.empty()) || (_namespaceURI == namespaceURI && _localName == localName && !_localName.empty());
}
XMLString Name::prefix() const
{
return prefix(_qname);
}
void Name::split(const XMLString& qname, XMLString& prefix, XMLString& localName)
{
XMLString::size_type pos = qname.find(':');
if (pos != XMLString::npos)
{
prefix.assign(qname, 0, pos);
localName.assign(qname, pos + 1, qname.size() - pos - 1);
}
else
{
prefix.clear();
localName.assign(qname);
}
}
XMLString Name::localName(const XMLString& qname)
{
XMLString::size_type pos = qname.find(':');
if (pos != XMLString::npos)
return XMLString(qname, pos + 1, qname.size() - pos - 1);
else
return qname;
}
XMLString Name::prefix(const XMLString& qname)
{
XMLString::size_type pos = qname.find(':');
if (pos != XMLString::npos)
return XMLString(qname, 0, pos);
else
return EMPTY_NAME;
}
} } // namespace Poco::XML

132
vendor/POCO/XML/src/NamePool.cpp vendored Normal file
View File

@@ -0,0 +1,132 @@
//
// NamePool.cpp
//
// Library: XML
// Package: XML
// Module: NamePool
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/XML/NamePool.h"
#include "Poco/Exception.h"
#include "Poco/Random.h"
namespace Poco {
namespace XML {
class NamePoolItem
{
public:
NamePoolItem(): _used(false)
{
}
~NamePoolItem()
{
}
bool set(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
{
if (!_used)
{
_name.assign(qname, namespaceURI, localName);
_used = true;
return true;
}
else return _name.equals(qname, namespaceURI, localName);
}
const Name& get() const
{
return _name;
}
bool used() const
{
return _used;
}
private:
Name _name;
bool _used;
};
NamePool::NamePool(unsigned long size):
_size(size),
_salt(0),
_rc(1)
{
poco_assert (size > 1);
_pItems = new NamePoolItem[size];
Poco::Random rnd;
rnd.seed();
_salt = rnd.next();
}
NamePool::~NamePool()
{
delete [] _pItems;
}
void NamePool::duplicate()
{
++_rc;
}
void NamePool::release()
{
if (--_rc == 0)
delete this;
}
const Name& NamePool::insert(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
{
unsigned long i = 0;
unsigned long n = (hash(qname, namespaceURI, localName) ^ _salt) % _size;
while (!_pItems[n].set(qname, namespaceURI, localName) && i++ < _size)
n = (n + 1) % _size;
if (i > _size) throw Poco::PoolOverflowException("XML name pool");
return _pItems[n].get();
}
const Name& NamePool::insert(const Name& name)
{
return insert(name.qname(), name.namespaceURI(), name.localName());
}
unsigned long NamePool::hash(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName)
{
unsigned long h = 0;
XMLString::const_iterator it = qname.begin();
XMLString::const_iterator end = qname.end();
while (it != end) h = (h << 5) + h + (unsigned long) *it++;
it = namespaceURI.begin();
end = namespaceURI.end();
while (it != end) h = (h << 5) + h + (unsigned long) *it++;
it = localName.begin();
end = localName.end();
while (it != end) h = (h << 5) + h + (unsigned long) *it++;
return h;
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/NamedNodeMap.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// NamedNodeMap.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/NamedNodeMap.h"
namespace Poco {
namespace XML {
NamedNodeMap::~NamedNodeMap()
{
}
} } // namespace Poco::XML

View File

@@ -0,0 +1,195 @@
//
// NamespaceStrategy.cpp
//
// Library: XML
// Package: XML
// Module: NamespaceStrategy
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/XML/NamespaceStrategy.h"
#include "Poco/SAX/AttributesImpl.h"
#include "Poco/SAX/ContentHandler.h"
#include "Poco/XML/XMLException.h"
#include "Poco/XML/Name.h"
namespace Poco {
namespace XML {
const XMLString NamespaceStrategy::NOTHING;
NamespaceStrategy::~NamespaceStrategy()
{
}
void NamespaceStrategy::splitName(const XMLChar* qname, XMLString& uri, XMLString& localName)
{
for (const XMLChar* p = qname; *p; ++p)
{
if (*p == '\t')
{
uri.assign(qname, p - qname);
localName.assign(p + 1);
return;
}
}
localName = qname;
}
void NamespaceStrategy::splitName(const XMLChar* qname, XMLString& uri, XMLString& localName, XMLString& prefix)
{
const XMLChar* p = qname;
while (*p && *p != '\t') ++p;
if (*p)
{
uri.assign(qname, p - qname);
++p;
const XMLChar* loc = p;
while (*p && *p != '\t') ++p;
localName.assign(loc, p - loc);
if (*p)
prefix.assign(++p);
else
prefix.assign(XML_LIT(""));
}
else
{
uri.assign(XML_LIT(""));
localName = qname;
prefix.assign(XML_LIT(""));
}
}
NoNamespacesStrategy::NoNamespacesStrategy()
{
_attrs.reserve(32);
}
NoNamespacesStrategy::~NoNamespacesStrategy()
{
}
void NoNamespacesStrategy::startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler)
{
poco_assert_dbg (name && atts && pContentHandler);
_attrs.clear();
for (int i = 0; *atts; ++i)
{
AttributesImpl::Attribute& attr = _attrs.addAttribute();
attr.qname.assign(*atts++);
attr.value.assign(*atts++);
attr.specified = i < specifiedCount;
}
_name.assign(name);
pContentHandler->startElement(NOTHING, NOTHING, _name, _attrs);
}
void NoNamespacesStrategy::endElement(const XMLChar* name, ContentHandler* pContentHandler)
{
poco_assert_dbg (name && pContentHandler);
_name.assign(name);
pContentHandler->endElement(NOTHING, NOTHING, _name);
}
NoNamespacePrefixesStrategy::NoNamespacePrefixesStrategy()
{
_attrs.reserve(32);
}
NoNamespacePrefixesStrategy::~NoNamespacePrefixesStrategy()
{
}
void NoNamespacePrefixesStrategy::startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler)
{
poco_assert_dbg (name && atts && pContentHandler);
_attrs.clear();
for (int i = 0; *atts; ++i)
{
const XMLChar* attrName = *atts++;
const XMLChar* attrValue = *atts++;
AttributesImpl::Attribute& attr = _attrs.addAttribute();
splitName(attrName, attr.namespaceURI, attr.localName);
attr.value.assign(attrValue);
attr.specified = i < specifiedCount;
}
splitName(name, _uri, _local);
pContentHandler->startElement(_uri, _local, NOTHING, _attrs);
}
void NoNamespacePrefixesStrategy::endElement(const XMLChar* name, ContentHandler* pContentHandler)
{
poco_assert_dbg (name && pContentHandler);
splitName(name, _uri, _local);
pContentHandler->endElement(_uri, _local, NOTHING);
}
NamespacePrefixesStrategy::NamespacePrefixesStrategy()
{
_attrs.reserve(32);
}
NamespacePrefixesStrategy::~NamespacePrefixesStrategy()
{
}
void NamespacePrefixesStrategy::startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler)
{
poco_assert_dbg (name && atts && pContentHandler);
_attrs.clear();
for (int i = 0; *atts; ++i)
{
const XMLChar* attrName = *atts++;
const XMLChar* attrValue = *atts++;
AttributesImpl::Attribute& attr = _attrs.addAttribute();
splitName(attrName, attr.namespaceURI, attr.localName, attr.qname);
if (!attr.qname.empty()) attr.qname += ':';
attr.qname.append(attr.localName);
attr.value.assign(attrValue);
attr.specified = i < specifiedCount;
}
splitName(name, _uri, _local, _qname);
if (!_qname.empty()) _qname += ':';
_qname.append(_local);
pContentHandler->startElement(_uri, _local, _qname, _attrs);
}
void NamespacePrefixesStrategy::endElement(const XMLChar* name, ContentHandler* pContentHandler)
{
poco_assert_dbg (name && pContentHandler);
splitName(name, _uri, _local, _qname);
if (!_qname.empty()) _qname += ':';
_qname.append(_local);
pContentHandler->endElement(_uri, _local, _qname);
}
} } // namespace Poco::XML

187
vendor/POCO/XML/src/NamespaceSupport.cpp vendored Normal file
View File

@@ -0,0 +1,187 @@
//
// NamespaceSupport.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/NamespaceSupport.h"
#include "Poco/XML/Name.h"
namespace Poco {
namespace XML {
const XMLString NamespaceSupport::EMPTY_STRING;
const XMLString NamespaceSupport::XML_NAMESPACE = toXMLString("http://www.w3.org/XML/1998/namespace");
const XMLString NamespaceSupport::XML_NAMESPACE_PREFIX = toXMLString("xml");
const XMLString NamespaceSupport::XMLNS_NAMESPACE = toXMLString("http://www.w3.org/xmlns/2000/");
const XMLString NamespaceSupport::XMLNS_NAMESPACE_PREFIX = toXMLString("xmlns");
NamespaceSupport::NamespaceSupport()
{
reset();
}
NamespaceSupport::~NamespaceSupport()
{
}
bool NamespaceSupport::declarePrefix(const XMLString& prefix, const XMLString& namespaceURI)
{
poco_assert (_contexts.size() > 0);
Context& ctx = _contexts.back();
if (ctx.find(prefix) == ctx.end())
{
ctx.insert(Context::value_type(prefix, namespaceURI));
return true;
}
else return false;
}
bool NamespaceSupport::undeclarePrefix(const XMLString& prefix)
{
for (ContextVec::reverse_iterator rit = _contexts.rbegin(); rit != _contexts.rend(); ++rit)
{
Context::iterator it = rit->find(prefix);
if (it != rit->end())
{
rit->erase(it);
return true;
}
}
return false;
}
void NamespaceSupport::getDeclaredPrefixes(PrefixSet& prefixes) const
{
prefixes.clear();
const Context& ctx = _contexts.back();
for (const auto& p: ctx)
prefixes.insert(p.first);
}
const XMLString& NamespaceSupport::getPrefix(const XMLString& namespaceURI) const
{
for (ContextVec::const_reverse_iterator rit = _contexts.rbegin(); rit != _contexts.rend(); ++rit)
{
for (Context::const_iterator it = rit->begin(); it != rit->end(); ++it)
{
if (it->second == namespaceURI)
return it->first;
}
}
return EMPTY_STRING;
}
bool NamespaceSupport::isMapped(const XMLString& namespaceURI) const
{
for (ContextVec::const_reverse_iterator rit = _contexts.rbegin(); rit != _contexts.rend(); ++rit)
{
for (Context::const_iterator it = rit->begin(); it != rit->end(); ++it)
{
if (it->second == namespaceURI)
return true;
}
}
return false;
}
void NamespaceSupport::getPrefixes(PrefixSet& prefixes) const
{
prefixes.clear();
for (ContextVec::const_reverse_iterator rit = _contexts.rbegin(); rit != _contexts.rend(); ++rit)
{
for (Context::const_iterator it = rit->begin(); it != rit->end(); ++it)
{
const XMLString& prefix = it->first;
if (!prefix.empty() && prefixes.find(prefix) == prefixes.end())
prefixes.insert(it->first);
}
}
}
void NamespaceSupport::getPrefixes(const XMLString& namespaceURI, PrefixSet& prefixes) const
{
prefixes.clear();
for (ContextVec::const_reverse_iterator rit = _contexts.rbegin(); rit != _contexts.rend(); ++rit)
{
for (Context::const_iterator it = rit->begin(); it != rit->end(); ++it)
{
const XMLString& prefix = it->first;
if (it->second == namespaceURI && !prefix.empty() && prefixes.find(prefix) == prefixes.end())
prefixes.insert(it->first);
}
}
}
const XMLString& NamespaceSupport::getURI(const XMLString& prefix) const
{
for (ContextVec::const_reverse_iterator rit = _contexts.rbegin(); rit != _contexts.rend(); ++rit)
{
Context::const_iterator it = rit->find(prefix);
if (it != rit->end())
return it->second;
}
return EMPTY_STRING;
}
void NamespaceSupport::pushContext()
{
_contexts.emplace_back();
}
void NamespaceSupport::popContext()
{
_contexts.pop_back();
}
bool NamespaceSupport::processName(const XMLString& qname, XMLString& namespaceURI, XMLString& localName, bool isAttribute) const
{
XMLString prefix;
Name::split(qname, prefix, localName);
if (prefix.empty() && isAttribute)
{
namespaceURI.clear();
return true;
}
else
{
namespaceURI = getURI(prefix);
return !namespaceURI.empty() || prefix.empty();
}
}
void NamespaceSupport::reset()
{
_contexts.clear();
pushContext();
declarePrefix(XML_NAMESPACE_PREFIX, XML_NAMESPACE);
declarePrefix(XMLNS_NAMESPACE_PREFIX, XMLNS_NAMESPACE);
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/Node.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// Node.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/Node.h"
namespace Poco {
namespace XML {
Node::~Node()
{
}
} } // namespace Poco::XML

82
vendor/POCO/XML/src/NodeAppender.cpp vendored Normal file
View File

@@ -0,0 +1,82 @@
//
// NodeAppender.cpp
//
// Library: XML
// Package: DOM
// Module: NodeAppender
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/NodeAppender.h"
#include "Poco/DOM/Element.h"
#include "Poco/DOM/DOMException.h"
namespace Poco {
namespace XML {
NodeAppender::NodeAppender(Element* parent):
_pParent(parent),
_pLast(0)
{
poco_check_ptr (parent);
_pLast = static_cast<AbstractNode*>(_pParent->lastChild());
}
NodeAppender::~NodeAppender()
{
}
void NodeAppender::appendChild(Node* newChild)
{
poco_check_ptr (newChild);
poco_assert (_pLast == 0 || _pLast->_pNext == 0);
if (static_cast<AbstractNode*>(newChild)->_pOwner != _pParent->_pOwner)
throw DOMException(DOMException::WRONG_DOCUMENT_ERR);
if (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
{
AbstractContainerNode* pFrag = static_cast<AbstractContainerNode*>(newChild);
AbstractNode* pChild = pFrag->_pFirstChild;
if (pChild)
{
if (_pLast)
_pLast->_pNext = pChild;
else
_pParent->_pFirstChild = pChild;
while (pChild)
{
_pLast = pChild;
pChild->_pParent = _pParent;
pChild = pChild->_pNext;
}
pFrag->_pFirstChild = 0;
}
}
else
{
AbstractNode* pAN = static_cast<AbstractNode*>(newChild);
pAN->duplicate();
if (pAN->_pParent)
pAN->_pParent->removeChild(pAN);
pAN->_pParent = _pParent;
if (_pLast)
_pLast->_pNext = pAN;
else
_pParent->_pFirstChild = pAN;
_pLast = pAN;
}
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/NodeFilter.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// NodeFilter.cpp
//
// Library: XML
// Package: DOM
// Module: NodeFilter
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/NodeFilter.h"
namespace Poco {
namespace XML {
NodeFilter::~NodeFilter()
{
}
} } // namespace Poco::XML

176
vendor/POCO/XML/src/NodeIterator.cpp vendored Normal file
View File

@@ -0,0 +1,176 @@
//
// NodeIterator.cpp
//
// Library: XML
// Package: DOM
// Module: NodeIterator
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/NodeIterator.h"
#include "Poco/DOM/AbstractNode.h"
#include "Poco/DOM/NodeFilter.h"
#include "Poco/DOM/DOMException.h"
namespace Poco {
namespace XML {
NodeIterator::NodeIterator(Node* root, unsigned long whatToShow, NodeFilter* pFilter):
_pRoot(root),
_whatToShow(whatToShow),
_pFilter(pFilter),
_pCurrent(0)
{
}
NodeIterator::NodeIterator(const NodeIterator& iterator):
_pRoot(iterator._pRoot),
_whatToShow(iterator._whatToShow),
_pFilter(iterator._pFilter),
_pCurrent(iterator._pCurrent)
{
}
NodeIterator& NodeIterator::operator = (const NodeIterator& iterator)
{
if (&iterator != this)
{
_pRoot = iterator._pRoot;
_whatToShow = iterator._whatToShow;
_pFilter = iterator._pFilter;
_pCurrent = iterator._pCurrent;
}
return *this;
}
NodeIterator::~NodeIterator()
{
}
Node* NodeIterator::nextNode()
{
if (!_pRoot) throw DOMException(DOMException::INVALID_STATE_ERR);
if (_pCurrent)
_pCurrent = next();
else
_pCurrent = _pRoot;
while (_pCurrent && !accept(_pCurrent))
_pCurrent = next();
return _pCurrent;
}
Node* NodeIterator::previousNode()
{
if (!_pRoot) throw DOMException(DOMException::INVALID_STATE_ERR);
if (_pCurrent)
_pCurrent = previous();
else
_pCurrent = last();
while (_pCurrent && !accept(_pCurrent))
_pCurrent = previous();
return _pCurrent;
}
void NodeIterator::detach()
{
_pRoot = 0;
_pCurrent = 0;
}
bool NodeIterator::accept(Node* pNode) const
{
bool accept = false;
switch (pNode->nodeType())
{
case Node::ELEMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ELEMENT) != 0; break;
case Node::ATTRIBUTE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ATTRIBUTE) != 0; break;
case Node::TEXT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_TEXT) != 0; break;
case Node::CDATA_SECTION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_CDATA_SECTION) != 0; break;
case Node::ENTITY_REFERENCE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ENTITY_REFERENCE) != 0; break;
case Node::ENTITY_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ENTITY) != 0; break;
case Node::PROCESSING_INSTRUCTION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_PROCESSING_INSTRUCTION) != 0; break;
case Node::COMMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_COMMENT) != 0; break;
case Node::DOCUMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT) != 0; break;
case Node::DOCUMENT_TYPE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_TYPE) != 0; break;
case Node::DOCUMENT_FRAGMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_FRAGMENT) != 0; break;
case Node::NOTATION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_NOTATION) != 0; break;
}
if (accept && _pFilter)
accept = _pFilter->acceptNode(pNode) == NodeFilter::FILTER_ACCEPT;
return accept;
}
Node* NodeIterator::next() const
{
Node* pNext = _pCurrent->firstChild();
if (pNext) return pNext;
pNext = _pCurrent;
while (pNext && pNext != _pRoot)
{
Node* pSibling = pNext->nextSibling();
if (pSibling) return pSibling;
pNext = pNext->parentNode();
}
return 0;
}
Node* NodeIterator::previous() const
{
if (_pCurrent == _pRoot) return 0;
Node* pPrev = _pCurrent->previousSibling();
while (pPrev)
{
Node* pLastChild = pPrev->lastChild();
if (pLastChild)
pPrev = pLastChild;
else
return pPrev;
}
return _pCurrent->parentNode();
}
Node* NodeIterator::last()
{
_pCurrent = _pRoot;
Node* pLast = 0;
while (_pCurrent)
{
pLast = _pCurrent;
_pCurrent = next();
}
return pLast;
}
} } // namespace Poco::XML

27
vendor/POCO/XML/src/NodeList.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// NodeList.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/NodeList.h"
namespace Poco {
namespace XML {
NodeList::~NodeList()
{
}
} } // namespace Poco::XML

63
vendor/POCO/XML/src/Notation.cpp vendored Normal file
View File

@@ -0,0 +1,63 @@
//
// Notation.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/Notation.h"
namespace Poco {
namespace XML {
Notation::Notation(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId):
AbstractNode(pOwnerDocument),
_name(name),
_publicId(publicId),
_systemId(systemId)
{
}
Notation::Notation(Document* pOwnerDocument, const Notation& notation):
AbstractNode(pOwnerDocument, notation),
_name(notation._name),
_publicId(notation._publicId),
_systemId(notation._systemId)
{
}
Notation::~Notation()
{
}
const XMLString& Notation::nodeName() const
{
return _name;
}
unsigned short Notation::nodeType() const
{
return Node::NOTATION_NODE;
}
Node* Notation::copyNode(bool deep, Document* pOwnerDocument) const
{
return new Notation(pOwnerDocument, *this);
}
} } // namespace Poco::XML

896
vendor/POCO/XML/src/ParserEngine.cpp vendored Normal file
View File

@@ -0,0 +1,896 @@
//
// ParserEngine.cpp
//
// Library: XML
// Package: XML
// Module: ParserEngine
//
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/XML/ParserEngine.h"
#include "Poco/XML/NamespaceStrategy.h"
#include "Poco/XML/XMLException.h"
#include "Poco/SAX/EntityResolver.h"
#include "Poco/SAX/EntityResolverImpl.h"
#include "Poco/SAX/DTDHandler.h"
#include "Poco/SAX/DeclHandler.h"
#include "Poco/SAX/ContentHandler.h"
#include "Poco/SAX/LexicalHandler.h"
#include "Poco/SAX/ErrorHandler.h"
#include "Poco/SAX/InputSource.h"
#include "Poco/SAX/Locator.h"
#include "Poco/SAX/LocatorImpl.h"
#include "Poco/SAX/SAXException.h"
#include "Poco/URI.h"
#include <cstring>
using Poco::URI;
using Poco::TextEncoding;
namespace Poco {
namespace XML {
class ContextLocator: public Locator
{
public:
ContextLocator(XML_Parser parser, const XMLString& publicId, const XMLString& systemId):
_parser(parser),
_publicId(publicId),
_systemId(systemId)
{
}
~ContextLocator()
{
}
XMLString getPublicId() const
{
return _publicId;
}
XMLString getSystemId() const
{
return _systemId;
}
int getLineNumber() const
{
return XML_GetCurrentLineNumber(_parser);
}
int getColumnNumber() const
{
return XML_GetCurrentColumnNumber(_parser);
}
private:
XML_Parser _parser;
XMLString _publicId;
XMLString _systemId;
};
const int ParserEngine::PARSE_BUFFER_SIZE = 4096;
const XMLString ParserEngine::EMPTY_STRING;
ParserEngine::ParserEngine():
_parser(0),
_pBuffer(0),
_encodingSpecified(false),
_expandInternalEntities(true),
_externalGeneralEntities(false),
_externalParameterEntities(false),
_enablePartialReads(false),
_pNamespaceStrategy(new NoNamespacesStrategy()),
_pEntityResolver(0),
_pDTDHandler(0),
_pDeclHandler(0),
_pContentHandler(0),
_pLexicalHandler(0),
_pErrorHandler(0)
{
}
ParserEngine::ParserEngine(const XMLString& encoding):
_parser(0),
_pBuffer(0),
_encodingSpecified(true),
_encoding(encoding),
_expandInternalEntities(true),
_externalGeneralEntities(false),
_externalParameterEntities(false),
_enablePartialReads(false),
_pNamespaceStrategy(new NoNamespacesStrategy()),
_pEntityResolver(0),
_pDTDHandler(0),
_pDeclHandler(0),
_pContentHandler(0),
_pLexicalHandler(0),
_pErrorHandler(0)
{
}
ParserEngine::~ParserEngine()
{
resetContext();
if (_parser) XML_ParserFree(_parser);
delete [] _pBuffer;
delete _pNamespaceStrategy;
}
void ParserEngine::setEncoding(const XMLString& encoding)
{
_encoding = encoding;
_encodingSpecified = true;
}
void ParserEngine::addEncoding(const XMLString& name, TextEncoding* pEncoding)
{
poco_check_ptr (pEncoding);
if (_encodings.find(name) == _encodings.end())
_encodings[name] = pEncoding;
else
throw XMLException("Encoding already defined");
}
void ParserEngine::setNamespaceStrategy(NamespaceStrategy* pStrategy)
{
poco_check_ptr (pStrategy);
delete _pNamespaceStrategy;
_pNamespaceStrategy = pStrategy;
}
void ParserEngine::setExpandInternalEntities(bool flag)
{
_expandInternalEntities = flag;
}
void ParserEngine::setExternalGeneralEntities(bool flag)
{
_externalGeneralEntities = flag;
}
void ParserEngine::setExternalParameterEntities(bool flag)
{
_externalParameterEntities = flag;
}
void ParserEngine::setEntityResolver(EntityResolver* pResolver)
{
_pEntityResolver = pResolver;
}
void ParserEngine::setDTDHandler(DTDHandler* pDTDHandler)
{
_pDTDHandler = pDTDHandler;
}
void ParserEngine::setDeclHandler(DeclHandler* pDeclHandler)
{
_pDeclHandler = pDeclHandler;
}
void ParserEngine::setContentHandler(ContentHandler* pContentHandler)
{
_pContentHandler = pContentHandler;
}
void ParserEngine::setLexicalHandler(LexicalHandler* pLexicalHandler)
{
_pLexicalHandler = pLexicalHandler;
}
void ParserEngine::setErrorHandler(ErrorHandler* pErrorHandler)
{
_pErrorHandler = pErrorHandler;
}
void ParserEngine::setEnablePartialReads(bool flag)
{
_enablePartialReads = flag;
}
void ParserEngine::parse(InputSource* pInputSource)
{
init();
resetContext();
pushContext(_parser, pInputSource);
if (_pContentHandler) _pContentHandler->setDocumentLocator(this);
if (_pContentHandler) _pContentHandler->startDocument();
if (pInputSource->getCharacterStream())
parseCharInputStream(*pInputSource->getCharacterStream());
else if (pInputSource->getByteStream())
parseByteInputStream(*pInputSource->getByteStream());
else throw XMLException("Input source has no stream");
if (_pContentHandler) _pContentHandler->endDocument();
popContext();
}
void ParserEngine::parse(const char* pBuffer, std::size_t size)
{
init();
resetContext();
InputSource src;
pushContext(_parser, &src);
if (_pContentHandler) _pContentHandler->setDocumentLocator(this);
if (_pContentHandler) _pContentHandler->startDocument();
std::size_t processed = 0;
while (processed < size)
{
const int bufferSize = processed + PARSE_BUFFER_SIZE < size ? PARSE_BUFFER_SIZE : static_cast<int>(size - processed);
if (!XML_Parse(_parser, pBuffer + processed, bufferSize, 0))
handleError(XML_GetErrorCode(_parser));
processed += bufferSize;
}
if (!XML_Parse(_parser, pBuffer+processed, 0, 1))
handleError(XML_GetErrorCode(_parser));
if (_pContentHandler) _pContentHandler->endDocument();
popContext();
}
void ParserEngine::parseByteInputStream(XMLByteInputStream& istr)
{
std::streamsize n = readBytes(istr, _pBuffer, PARSE_BUFFER_SIZE);
while (n > 0)
{
if (!XML_Parse(_parser, _pBuffer, static_cast<int>(n), 0))
handleError(XML_GetErrorCode(_parser));
if (istr.good())
n = readBytes(istr, _pBuffer, PARSE_BUFFER_SIZE);
else
n = 0;
}
if (!XML_Parse(_parser, _pBuffer, 0, 1))
handleError(XML_GetErrorCode(_parser));
}
void ParserEngine::parseCharInputStream(XMLCharInputStream& istr)
{
std::streamsize n = readChars(istr, reinterpret_cast<XMLChar*>(_pBuffer), PARSE_BUFFER_SIZE/sizeof(XMLChar));
while (n > 0)
{
if (!XML_Parse(_parser, _pBuffer, static_cast<int>(n*sizeof(XMLChar)), 0))
handleError(XML_GetErrorCode(_parser));
if (istr.good())
n = readChars(istr, reinterpret_cast<XMLChar*>(_pBuffer), PARSE_BUFFER_SIZE/sizeof(XMLChar));
else
n = 0;
}
if (!XML_Parse(_parser, _pBuffer, 0, 1))
handleError(XML_GetErrorCode(_parser));
}
void ParserEngine::parseExternal(XML_Parser extParser, InputSource* pInputSource)
{
pushContext(extParser, pInputSource);
if (pInputSource->getCharacterStream())
parseExternalCharInputStream(extParser, *pInputSource->getCharacterStream());
else if (pInputSource->getByteStream())
parseExternalByteInputStream(extParser, *pInputSource->getByteStream());
else throw XMLException("Input source has no stream");
popContext();
}
void ParserEngine::parseExternalByteInputStream(XML_Parser extParser, XMLByteInputStream& istr)
{
char *pBuffer = new char[PARSE_BUFFER_SIZE];
try
{
std::streamsize n = readBytes(istr, pBuffer, PARSE_BUFFER_SIZE);
while (n > 0)
{
if (!XML_Parse(extParser, pBuffer, static_cast<int>(n), 0))
handleError(XML_GetErrorCode(extParser));
if (istr.good())
n = readBytes(istr, pBuffer, PARSE_BUFFER_SIZE);
else
n = 0;
}
if (!XML_Parse(extParser, pBuffer, 0, 1))
handleError(XML_GetErrorCode(extParser));
}
catch (...)
{
delete [] pBuffer;
throw;
}
delete [] pBuffer;
}
void ParserEngine::parseExternalCharInputStream(XML_Parser extParser, XMLCharInputStream& istr)
{
XMLChar *pBuffer = new XMLChar[PARSE_BUFFER_SIZE/sizeof(XMLChar)];
try
{
std::streamsize n = readChars(istr, pBuffer, PARSE_BUFFER_SIZE/sizeof(XMLChar));
while (n > 0)
{
if (!XML_Parse(extParser, reinterpret_cast<char*>(pBuffer), static_cast<int>(n*sizeof(XMLChar)), 0))
handleError(XML_GetErrorCode(extParser));
if (istr.good())
n = readChars(istr, pBuffer, static_cast<int>(PARSE_BUFFER_SIZE/sizeof(XMLChar)));
else
n = 0;
}
if (!XML_Parse(extParser, reinterpret_cast<char*>(pBuffer), 0, 1))
handleError(XML_GetErrorCode(extParser));
}
catch (...)
{
delete [] pBuffer;
throw;
}
delete [] pBuffer;
}
std::streamsize ParserEngine::readBytes(XMLByteInputStream& istr, char* pBuffer, std::streamsize bufferSize)
{
if (_enablePartialReads)
{
istr.read(pBuffer, 1);
if (istr.gcount() == 1)
{
std::streamsize n = istr.readsome(pBuffer + 1, bufferSize - 1);
return n + 1;
}
else return 0;
}
else
{
istr.read(pBuffer, bufferSize);
return istr.gcount();
}
}
std::streamsize ParserEngine::readChars(XMLCharInputStream& istr, XMLChar* pBuffer, std::streamsize bufferSize)
{
if (_enablePartialReads)
{
istr.read(pBuffer, 1);
if (istr.gcount() == 1)
{
std::streamsize n = istr.readsome(pBuffer + 1, bufferSize - 1);
return n + 1;
}
else return 0;
}
else
{
istr.read(pBuffer, bufferSize);
return istr.gcount();
}
}
XMLString ParserEngine::getPublicId() const
{
return locator().getPublicId();
}
XMLString ParserEngine::getSystemId() const
{
return locator().getSystemId();
}
int ParserEngine::getLineNumber() const
{
return locator().getLineNumber();
}
int ParserEngine::getColumnNumber() const
{
return locator().getColumnNumber();
}
namespace
{
static LocatorImpl nullLocator;
}
const Locator& ParserEngine::locator() const
{
if (_context.empty())
return nullLocator;
else
return *_context.back();
}
void ParserEngine::init()
{
if (_parser)
XML_ParserFree(_parser);
if (!_pBuffer)
_pBuffer = new char[PARSE_BUFFER_SIZE];
if (dynamic_cast<NoNamespacePrefixesStrategy*>(_pNamespaceStrategy))
{
_parser = XML_ParserCreateNS(_encodingSpecified ? _encoding.c_str() : 0, '\t');
if (_parser)
{
XML_SetNamespaceDeclHandler(_parser, handleStartNamespaceDecl, handleEndNamespaceDecl);
}
}
else if (dynamic_cast<NamespacePrefixesStrategy*>(_pNamespaceStrategy))
{
_parser = XML_ParserCreateNS(_encodingSpecified ? _encoding.c_str() : 0, '\t');
if (_parser)
{
XML_SetReturnNSTriplet(_parser, 1);
XML_SetNamespaceDeclHandler(_parser, handleStartNamespaceDecl, handleEndNamespaceDecl);
}
}
else
{
_parser = XML_ParserCreate(_encodingSpecified ? _encoding.c_str() : 0);
}
if (!_parser) throw XMLException("Cannot create Expat parser");
XML_SetUserData(_parser, this);
XML_SetElementHandler(_parser, handleStartElement, handleEndElement);
XML_SetCharacterDataHandler(_parser, handleCharacterData);
XML_SetProcessingInstructionHandler(_parser, handleProcessingInstruction);
if (_expandInternalEntities)
XML_SetDefaultHandlerExpand(_parser, handleDefault);
else
XML_SetDefaultHandler(_parser, handleDefault);
XML_SetUnparsedEntityDeclHandler(_parser, handleUnparsedEntityDecl);
XML_SetNotationDeclHandler(_parser, handleNotationDecl);
XML_SetExternalEntityRefHandler(_parser, handleExternalEntityRef);
XML_SetCommentHandler(_parser, handleComment);
XML_SetCdataSectionHandler(_parser, handleStartCdataSection, handleEndCdataSection);
XML_SetDoctypeDeclHandler(_parser, handleStartDoctypeDecl, handleEndDoctypeDecl);
XML_SetEntityDeclHandler(_parser, handleEntityDecl);
XML_SetSkippedEntityHandler(_parser, handleSkippedEntity);
XML_SetParamEntityParsing(_parser, _externalParameterEntities ? XML_PARAM_ENTITY_PARSING_ALWAYS : XML_PARAM_ENTITY_PARSING_NEVER);
XML_SetUnknownEncodingHandler(_parser, handleUnknownEncoding, this);
}
void ParserEngine::handleError(int errorNo)
{
try
{
switch (errorNo)
{
case XML_ERROR_NO_MEMORY:
throw XMLException("No memory");
case XML_ERROR_SYNTAX:
throw SAXParseException("Syntax error", locator());
case XML_ERROR_NO_ELEMENTS:
throw SAXParseException("No element found", locator());
case XML_ERROR_INVALID_TOKEN:
throw SAXParseException("Invalid token", locator());
case XML_ERROR_UNCLOSED_TOKEN:
throw SAXParseException("Unclosed token", locator());
case XML_ERROR_PARTIAL_CHAR:
throw SAXParseException("Partial character", locator());
case XML_ERROR_TAG_MISMATCH:
throw SAXParseException("Tag mismatch", locator());
case XML_ERROR_DUPLICATE_ATTRIBUTE:
throw SAXParseException("Duplicate attribute", locator());
case XML_ERROR_JUNK_AFTER_DOC_ELEMENT:
throw SAXParseException("Junk after document element", locator());
case XML_ERROR_PARAM_ENTITY_REF:
throw SAXParseException("Illegal parameter entity reference", locator());
case XML_ERROR_UNDEFINED_ENTITY:
throw SAXParseException("Undefined entity", locator());
case XML_ERROR_RECURSIVE_ENTITY_REF:
throw SAXParseException("Recursive entity reference", locator());
case XML_ERROR_ASYNC_ENTITY:
throw SAXParseException("Asynchronous entity", locator());
case XML_ERROR_BAD_CHAR_REF:
throw SAXParseException("Reference to invalid character number", locator());
case XML_ERROR_BINARY_ENTITY_REF:
throw SAXParseException("Reference to binary entity", locator());
case XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF:
throw SAXParseException("Reference to external entity in attribute", locator());
case XML_ERROR_MISPLACED_XML_PI:
throw SAXParseException("XML processing instruction not at start of external entity", locator());
case XML_ERROR_UNKNOWN_ENCODING:
throw SAXParseException("Unknown encoding", locator());
case XML_ERROR_INCORRECT_ENCODING:
throw SAXParseException("Encoding specified in XML declaration is incorrect", locator());
case XML_ERROR_UNCLOSED_CDATA_SECTION:
throw SAXParseException("Unclosed CDATA section", locator());
case XML_ERROR_EXTERNAL_ENTITY_HANDLING:
throw SAXParseException("Error in processing external entity reference", locator());
case XML_ERROR_NOT_STANDALONE:
throw SAXParseException("Document is not standalone", locator());
case XML_ERROR_UNEXPECTED_STATE:
throw SAXParseException("Unexpected parser state - please send a bug report", locator());
case XML_ERROR_ENTITY_DECLARED_IN_PE:
throw SAXParseException("Entity declared in parameter entity", locator());
case XML_ERROR_FEATURE_REQUIRES_XML_DTD:
throw SAXParseException("Requested feature requires XML_DTD support in Expat", locator());
case XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING:
throw SAXParseException("Cannot change setting once parsing has begun", locator());
case XML_ERROR_UNBOUND_PREFIX:
throw SAXParseException("Unbound prefix", locator());
case XML_ERROR_UNDECLARING_PREFIX:
throw SAXParseException("Must not undeclare prefix", locator());
case XML_ERROR_INCOMPLETE_PE:
throw SAXParseException("Incomplete markup in parameter entity", locator());
case XML_ERROR_XML_DECL:
throw SAXParseException("XML declaration not well-formed", locator());
case XML_ERROR_TEXT_DECL:
throw SAXParseException("Text declaration not well-formed", locator());
case XML_ERROR_PUBLICID:
throw SAXParseException("Illegal character(s) in public identifier", locator());
case XML_ERROR_SUSPENDED:
throw SAXParseException("Parser suspended", locator());
case XML_ERROR_NOT_SUSPENDED:
throw SAXParseException("Parser not suspended", locator());
case XML_ERROR_ABORTED:
throw SAXParseException("Parsing aborted", locator());
case XML_ERROR_FINISHED:
throw SAXParseException("Parsing finished", locator());
case XML_ERROR_SUSPEND_PE:
throw SAXParseException("Cannot suspend in external parameter entity", locator());
}
throw XMLException("Unknown Expat error code");
}
catch (SAXException& exc)
{
if (_pErrorHandler) _pErrorHandler->error(exc);
throw;
}
catch (Poco::Exception& exc)
{
if (_pErrorHandler) _pErrorHandler->fatalError(SAXParseException("Fatal error", locator(), exc));
throw;
}
}
void ParserEngine::pushContext(XML_Parser parser, InputSource* pInputSource)
{
ContextLocator* pLocator = new ContextLocator(parser, pInputSource->getPublicId(), pInputSource->getSystemId());
_context.push_back(pLocator);
}
void ParserEngine::popContext()
{
poco_assert (!_context.empty());
delete _context.back();
_context.pop_back();
}
void ParserEngine::resetContext()
{
for (auto p: _context)
{
delete p;
}
_context.clear();
}
void ParserEngine::handleStartElement(void* userData, const XML_Char* name, const XML_Char** atts)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
{
try
{
pThis->_pNamespaceStrategy->startElement(name, atts, XML_GetSpecifiedAttributeCount(pThis->_parser)/2, pThis->_pContentHandler);
}
catch (XMLException& exc)
{
throw SAXParseException(exc.message(), pThis->locator());
}
}
}
void ParserEngine::handleEndElement(void* userData, const XML_Char* name)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
{
try
{
pThis->_pNamespaceStrategy->endElement(name, pThis->_pContentHandler);
}
catch (XMLException& exc)
{
throw SAXParseException(exc.message(), pThis->locator());
}
}
}
void ParserEngine::handleCharacterData(void* userData, const XML_Char* s, int len)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
pThis->_pContentHandler->characters(s, 0, len);
}
void ParserEngine::handleProcessingInstruction(void* userData, const XML_Char* target, const XML_Char* data)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
pThis->_pContentHandler->processingInstruction(target, data);
}
void ParserEngine::handleDefault(void* userData, const XML_Char* s, int len)
{
}
void ParserEngine::handleUnparsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId, const XML_Char* notationName)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
XMLString pubId;
if (publicId) pubId.assign(publicId);
if (pThis->_pDTDHandler)
pThis->_pDTDHandler->unparsedEntityDecl(entityName, publicId ? &pubId : 0, systemId, notationName);
}
void ParserEngine::handleNotationDecl(void* userData, const XML_Char* notationName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
XMLString pubId;
if (publicId) pubId.assign(publicId);
XMLString sysId;
if (systemId) sysId.assign(systemId);
if (pThis->_pDTDHandler)
pThis->_pDTDHandler->notationDecl(notationName, publicId ? &pubId : 0, systemId ? &sysId : 0);
}
int ParserEngine::handleExternalEntityRef(XML_Parser parser, const XML_Char* context, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(XML_GetUserData(parser));
if (!context && !pThis->_externalParameterEntities) return XML_STATUS_ERROR;
if (context && !pThis->_externalGeneralEntities) return XML_STATUS_ERROR;
InputSource* pInputSource = 0;
EntityResolver* pEntityResolver = 0;
EntityResolverImpl defaultResolver;
XMLString sysId(systemId);
XMLString pubId;
if (publicId) pubId.assign(publicId);
URI uri(fromXMLString(pThis->_context.back()->getSystemId()));
uri.resolve(fromXMLString(sysId));
if (pThis->_pEntityResolver)
{
pEntityResolver = pThis->_pEntityResolver;
pInputSource = pEntityResolver->resolveEntity(publicId ? &pubId : 0, toXMLString(uri.toString()));
}
if (!pInputSource && pThis->_externalGeneralEntities)
{
pEntityResolver = &defaultResolver;
pInputSource = pEntityResolver->resolveEntity(publicId ? &pubId : 0, toXMLString(uri.toString()));
}
if (pInputSource)
{
XML_Parser extParser = XML_ExternalEntityParserCreate(pThis->_parser, context, 0);
if (!extParser) throw XMLException("Cannot create external entity parser");
try
{
pThis->parseExternal(extParser, pInputSource);
}
catch (XMLException&)
{
pEntityResolver->releaseInputSource(pInputSource);
XML_ParserFree(extParser);
throw;
}
pEntityResolver->releaseInputSource(pInputSource);
XML_ParserFree(extParser);
return XML_STATUS_OK;
}
else return XML_STATUS_ERROR;
}
int ParserEngine::handleUnknownEncoding(void* encodingHandlerData, const XML_Char* name, XML_Encoding* info)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(encodingHandlerData);
XMLString encoding(name);
TextEncoding* knownEncoding = 0;
EncodingMap::const_iterator it = pThis->_encodings.find(encoding);
if (it != pThis->_encodings.end())
knownEncoding = it->second;
else
knownEncoding = Poco::TextEncoding::find(fromXMLString(encoding));
if (knownEncoding)
{
const TextEncoding::CharacterMap& map = knownEncoding->characterMap();
for (int i = 0; i < 256; ++i)
info->map[i] = map[i];
info->data = knownEncoding;
info->convert = &ParserEngine::convert;
info->release = 0;
return XML_STATUS_OK;
}
else return XML_STATUS_ERROR;
}
void ParserEngine::handleComment(void* userData, const XML_Char* data)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
#if defined(XML_UNICODE_WCHAR_T)
if (pThis->_pLexicalHandler)
pThis->_pLexicalHandler->comment(data, 0, (int) std::wcslen(data));
#else
if (pThis->_pLexicalHandler)
pThis->_pLexicalHandler->comment(data, 0, (int) std::strlen(data));
#endif
}
void ParserEngine::handleStartCdataSection(void* userData)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pLexicalHandler)
pThis->_pLexicalHandler->startCDATA();
}
void ParserEngine::handleEndCdataSection(void* userData)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pLexicalHandler)
pThis->_pLexicalHandler->endCDATA();
}
void ParserEngine::handleStartNamespaceDecl(void* userData, const XML_Char* prefix, const XML_Char* uri)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
pThis->_pContentHandler->startPrefixMapping((prefix ? XMLString(prefix) : EMPTY_STRING), (uri ? XMLString(uri) : EMPTY_STRING));
}
void ParserEngine::handleEndNamespaceDecl(void* userData, const XML_Char* prefix)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
pThis->_pContentHandler->endPrefixMapping(prefix ? XMLString(prefix) : EMPTY_STRING);
}
void ParserEngine::handleStartDoctypeDecl(void* userData, const XML_Char* doctypeName, const XML_Char *systemId, const XML_Char* publicId, int hasInternalSubset)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pLexicalHandler)
{
XMLString sysId = systemId ? XMLString(systemId) : EMPTY_STRING;
XMLString pubId = publicId ? XMLString(publicId) : EMPTY_STRING;
pThis->_pLexicalHandler->startDTD(doctypeName, pubId, sysId);
}
}
void ParserEngine::handleEndDoctypeDecl(void* userData)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pLexicalHandler)
pThis->_pLexicalHandler->endDTD();
}
void ParserEngine::handleEntityDecl(void *userData, const XML_Char *entityName, int isParamEntity, const XML_Char *value, int valueLength,
const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName)
{
if (value)
handleInternalParsedEntityDecl(userData, entityName, value, valueLength);
else
handleExternalParsedEntityDecl(userData, entityName, base, systemId, publicId);
}
void ParserEngine::handleExternalParsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
XMLString pubId;
if (publicId) pubId.assign(publicId);
if (pThis->_pDeclHandler)
pThis->_pDeclHandler->externalEntityDecl(entityName, publicId ? &pubId : 0, systemId);
}
void ParserEngine::handleInternalParsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* replacementText, int replacementTextLength)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
XMLString replText(replacementText, replacementTextLength);
if (pThis->_pDeclHandler)
pThis->_pDeclHandler->internalEntityDecl(entityName, replText);
}
void ParserEngine::handleSkippedEntity(void* userData, const XML_Char* entityName, int isParameterEntity)
{
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
if (pThis->_pContentHandler)
pThis->_pContentHandler->skippedEntity(entityName);
}
int ParserEngine::convert(void* data, const char* s)
{
TextEncoding* pEncoding = reinterpret_cast<TextEncoding*>(data);
return pEncoding->convert((const unsigned char*) s);
}
} } // namespace Poco::XML

View File

@@ -0,0 +1,79 @@
//
// ProcessingInstruction.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/ProcessingInstruction.h"
namespace Poco {
namespace XML {
ProcessingInstruction::ProcessingInstruction(Document* pOwnerDocument, const XMLString& target, const XMLString& data):
AbstractNode(pOwnerDocument),
_target(target),
_data(data)
{
}
ProcessingInstruction::ProcessingInstruction(Document* pOwnerDocument, const ProcessingInstruction& processingInstruction):
AbstractNode(pOwnerDocument, processingInstruction),
_target(processingInstruction._target),
_data(processingInstruction._data)
{
}
ProcessingInstruction::~ProcessingInstruction()
{
}
void ProcessingInstruction::setData(const XMLString& data)
{
_data = data;
}
const XMLString& ProcessingInstruction::nodeName() const
{
return _target;
}
const XMLString& ProcessingInstruction::getNodeValue() const
{
return _data;
}
void ProcessingInstruction::setNodeValue(const XMLString& data)
{
setData(data);
}
unsigned short ProcessingInstruction::nodeType() const
{
return Node::PROCESSING_INSTRUCTION_NODE;
}
Node* ProcessingInstruction::copyNode(bool deep, Document* pOwnerDocument) const
{
return new ProcessingInstruction(pOwnerDocument, *this);
}
} } // namespace Poco::XML

114
vendor/POCO/XML/src/QName.cpp vendored Normal file
View File

@@ -0,0 +1,114 @@
//
// QName.cpp
//
// Library: XML
// Package: XML
// Module: QName
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Based on libstudxml (http://www.codesynthesis.com/projects/libstudxml/).
// Copyright (c) 2009-2013 Code Synthesis Tools CC.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/XML/QName.h"
#include <ostream>
namespace Poco {
namespace XML {
QName::QName()
{
}
QName::QName(const std::string& name) :
_name(name)
{
}
QName::QName(const std::string& ns, const std::string& name) :
_ns(ns),
_name(name)
{
}
QName::QName(const std::string& ns, const std::string& name, const std::string& prefix) :
_ns(ns),
_name(name),
_prefix(prefix)
{
}
QName::QName(const QName& qname):
_ns(qname._ns),
_name(qname._name),
_prefix(qname._prefix)
{
}
QName::QName(QName&& qname) noexcept:
_ns(std::move(qname._ns)),
_name(std::move(qname._name)),
_prefix(std::move(qname._prefix))
{
}
QName& QName::operator = (const QName& qname)
{
QName tmp(qname);
swap(tmp);
return *this;
}
QName& QName::operator = (QName&& qname) noexcept
{
_ns = std::move(qname._ns);
_name = std::move(qname._name);
_prefix = std::move(qname._prefix);
return *this;
}
void QName::swap(QName& qname)
{
std::swap(_ns, qname._ns);
std::swap(_name, qname._name);
std::swap(_prefix, qname._prefix);
}
std::string QName::toString() const
{
std::string r;
if (!_ns.empty())
{
r += _ns;
r += '#';
}
r += _name;
return r;
}
std::ostream& operator << (std::ostream& os, const QName& qn)
{
return os << qn.toString();
}
} } // namespace Poco::XML

138
vendor/POCO/XML/src/SAXException.cpp vendored Normal file
View File

@@ -0,0 +1,138 @@
//
// SAXException.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/SAXException.h"
#include "Poco/SAX/Locator.h"
#include <typeinfo>
#include <sstream>
namespace Poco {
namespace XML {
POCO_IMPLEMENT_EXCEPTION(SAXException, XMLException, "SAX Exception")
POCO_IMPLEMENT_EXCEPTION(SAXNotRecognizedException, SAXException, "Unrecognized SAX feature or property identifier")
POCO_IMPLEMENT_EXCEPTION(SAXNotSupportedException, SAXException, "Unsupported SAX feature or property identifier")
SAXParseException::SAXParseException(const std::string& msg, const Locator& loc):
SAXException(buildMessage(msg, loc.getPublicId(), loc.getSystemId(), loc.getLineNumber(), loc.getColumnNumber())),
_publicId(loc.getPublicId()),
_systemId(loc.getSystemId()),
_lineNumber(loc.getLineNumber()),
_columnNumber(loc.getColumnNumber())
{
}
SAXParseException::SAXParseException(const std::string& msg, const Locator& loc, const Poco::Exception& exc):
SAXException(buildMessage(msg, loc.getPublicId(), loc.getSystemId(), loc.getLineNumber(), loc.getColumnNumber()), exc),
_publicId(loc.getPublicId()),
_systemId(loc.getSystemId()),
_lineNumber(loc.getLineNumber()),
_columnNumber(loc.getColumnNumber())
{
}
SAXParseException::SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber):
SAXException(buildMessage(msg, publicId, systemId, lineNumber, columnNumber)),
_publicId(publicId),
_systemId(systemId),
_lineNumber(lineNumber),
_columnNumber(columnNumber)
{
}
SAXParseException::SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber, const Poco::Exception& exc):
SAXException(buildMessage(msg, publicId, systemId, lineNumber, columnNumber), exc),
_publicId(publicId),
_systemId(systemId),
_lineNumber(lineNumber),
_columnNumber(columnNumber)
{
}
SAXParseException::SAXParseException(const SAXParseException& exc):
SAXException(exc),
_publicId(exc._publicId),
_systemId(exc._systemId),
_lineNumber(exc._lineNumber),
_columnNumber(exc._columnNumber)
{
}
SAXParseException::~SAXParseException() noexcept
{
}
SAXParseException& SAXParseException::operator = (const SAXParseException& exc)
{
if (&exc != this)
{
SAXException::operator = (exc);
_publicId = exc._publicId;
_systemId = exc._systemId;
_lineNumber = exc._lineNumber;
_columnNumber = exc._columnNumber;
}
return *this;
}
const char* SAXParseException::name() const noexcept
{
return "SAXParseException";
}
const char* SAXParseException::className() const noexcept
{
return typeid(*this).name();
}
Poco::Exception* SAXParseException::clone() const
{
return new SAXParseException(*this);
}
void SAXParseException::rethrow() const
{
throw *this;
}
std::string SAXParseException::buildMessage(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber)
{
std::ostringstream result;
if (!msg.empty()) result << msg << " ";
result << "in ";
if (!systemId.empty())
result << "'" << fromXMLString(systemId) << "', ";
else if (!publicId.empty())
result << "'" << fromXMLString(publicId) << "', ";
if (lineNumber > 0)
result << "line " << lineNumber << " column " << columnNumber;
return result.str();
}
} } // namespace Poco::XML

238
vendor/POCO/XML/src/SAXParser.cpp vendored Normal file
View File

@@ -0,0 +1,238 @@
//
// SAXParser.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/SAXParser.h"
#include "Poco/SAX/SAXException.h"
#include "Poco/SAX/EntityResolverImpl.h"
#include "Poco/SAX/InputSource.h"
#include "Poco/XML/NamespaceStrategy.h"
#include <sstream>
namespace Poco {
namespace XML {
const XMLString SAXParser::FEATURE_PARTIAL_READS = toXMLString("http://www.appinf.com/features/enable-partial-reads");
SAXParser::SAXParser():
_namespaces(true),
_namespacePrefixes(false)
{
}
SAXParser::SAXParser(const XMLString& encoding):
_engine(encoding),
_namespaces(true),
_namespacePrefixes(false)
{
}
SAXParser::~SAXParser()
{
}
void SAXParser::setEncoding(const XMLString& encoding)
{
_engine.setEncoding(encoding);
}
const XMLString& SAXParser::getEncoding() const
{
return _engine.getEncoding();
}
void SAXParser::addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding)
{
_engine.addEncoding(name, pEncoding);
}
void SAXParser::setEntityResolver(EntityResolver* pResolver)
{
_engine.setEntityResolver(pResolver);
}
EntityResolver* SAXParser::getEntityResolver() const
{
return _engine.getEntityResolver();
}
void SAXParser::setDTDHandler(DTDHandler* pDTDHandler)
{
_engine.setDTDHandler(pDTDHandler);
}
DTDHandler* SAXParser::getDTDHandler() const
{
return _engine.getDTDHandler();
}
void SAXParser::setContentHandler(ContentHandler* pContentHandler)
{
_engine.setContentHandler(pContentHandler);
}
ContentHandler* SAXParser::getContentHandler() const
{
return _engine.getContentHandler();
}
void SAXParser::setErrorHandler(ErrorHandler* pErrorHandler)
{
_engine.setErrorHandler(pErrorHandler);
}
ErrorHandler* SAXParser::getErrorHandler() const
{
return _engine.getErrorHandler();
}
void SAXParser::setFeature(const XMLString& featureId, bool state)
{
if (featureId == XMLReader::FEATURE_VALIDATION || featureId == XMLReader::FEATURE_STRING_INTERNING)
throw SAXNotSupportedException(fromXMLString(XMLReader::FEATURE_VALIDATION));
else if (featureId == XMLReader::FEATURE_EXTERNAL_GENERAL_ENTITIES)
_engine.setExternalGeneralEntities(state);
else if (featureId == XMLReader::FEATURE_EXTERNAL_PARAMETER_ENTITIES)
_engine.setExternalParameterEntities(state);
else if (featureId == XMLReader::FEATURE_NAMESPACES)
_namespaces = state;
else if (featureId == XMLReader::FEATURE_NAMESPACE_PREFIXES)
_namespacePrefixes = state;
else if (featureId == FEATURE_PARTIAL_READS)
_engine.setEnablePartialReads(state);
else throw SAXNotRecognizedException(fromXMLString(featureId));
}
bool SAXParser::getFeature(const XMLString& featureId) const
{
if (featureId == XMLReader::FEATURE_VALIDATION || featureId == XMLReader::FEATURE_STRING_INTERNING)
throw SAXNotSupportedException(fromXMLString(XMLReader::FEATURE_VALIDATION));
else if (featureId == XMLReader::FEATURE_EXTERNAL_GENERAL_ENTITIES)
return _engine.getExternalGeneralEntities();
else if (featureId == XMLReader::FEATURE_EXTERNAL_PARAMETER_ENTITIES)
return _engine.getExternalParameterEntities();
else if (featureId == XMLReader::FEATURE_NAMESPACES)
return _namespaces;
else if (featureId == XMLReader::FEATURE_NAMESPACE_PREFIXES)
return _namespacePrefixes;
else if (featureId == FEATURE_PARTIAL_READS)
return _engine.getEnablePartialReads();
else throw SAXNotRecognizedException(fromXMLString(featureId));
}
void SAXParser::setProperty(const XMLString& propertyId, const XMLString& value)
{
if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER || propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
throw SAXNotSupportedException(std::string("property does not take a string value: ") + fromXMLString(propertyId));
else
throw SAXNotRecognizedException(fromXMLString(propertyId));
}
void SAXParser::setProperty(const XMLString& propertyId, void* value)
{
if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER)
_engine.setDeclHandler(reinterpret_cast<DeclHandler*>(value));
else if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
_engine.setLexicalHandler(reinterpret_cast<LexicalHandler*>(value));
else throw SAXNotRecognizedException(fromXMLString(propertyId));
}
void* SAXParser::getProperty(const XMLString& propertyId) const
{
if (propertyId == XMLReader::PROPERTY_DECLARATION_HANDLER)
return _engine.getDeclHandler();
else if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
return _engine.getLexicalHandler();
else throw SAXNotSupportedException(fromXMLString(propertyId));
}
void SAXParser::parse(InputSource* pInputSource)
{
if (pInputSource->getByteStream() || pInputSource->getCharacterStream())
{
setupParse();
_engine.parse(pInputSource);
}
else parse(pInputSource->getSystemId());
}
void SAXParser::parse(const XMLString& systemId)
{
setupParse();
EntityResolverImpl entityResolver;
InputSource* pInputSource = entityResolver.resolveEntity(0, systemId);
if (pInputSource)
{
try
{
_engine.parse(pInputSource);
}
catch (...)
{
entityResolver.releaseInputSource(pInputSource);
throw;
}
entityResolver.releaseInputSource(pInputSource);
}
else throw XMLException("Cannot resolve system identifier", fromXMLString(systemId));
}
void SAXParser::parseString(const std::string& xml)
{
parseMemoryNP(xml.data(), xml.size());
}
void SAXParser::parseMemoryNP(const char* xml, std::size_t size)
{
setupParse();
_engine.parse(xml, size);
}
void SAXParser::setupParse()
{
if (_namespaces && !_namespacePrefixes)
_engine.setNamespaceStrategy(new NoNamespacePrefixesStrategy);
else if (_namespaces && _namespacePrefixes)
_engine.setNamespaceStrategy(new NamespacePrefixesStrategy);
else
_engine.setNamespaceStrategy(new NoNamespacesStrategy);
}
} } // namespace Poco::XML

80
vendor/POCO/XML/src/Text.cpp vendored Normal file
View File

@@ -0,0 +1,80 @@
//
// Text.cpp
//
// Library: XML
// Package: DOM
// Module: DOM
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/Text.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/DOMException.h"
namespace Poco {
namespace XML {
const XMLString Text::NODE_NAME = toXMLString("#text");
Text::Text(Document* pOwnerDocument, const XMLString& data):
CharacterData(pOwnerDocument, data)
{
}
Text::Text(Document* pOwnerDocument, const Text& text):
CharacterData(pOwnerDocument, text)
{
}
Text::~Text()
{
}
Text* Text::splitText(unsigned long offset)
{
Node* pParent = parentNode();
if (!pParent) throw DOMException(DOMException::HIERARCHY_REQUEST_ERR);
int n = length() - offset;
Text* pNew = ownerDocument()->createTextNode(substringData(offset, n));
deleteData(offset, n);
pParent->insertBefore(pNew, nextSibling())->release();
return pNew;
}
const XMLString& Text::nodeName() const
{
return NODE_NAME;
}
unsigned short Text::nodeType() const
{
return Node::TEXT_NODE;
}
XMLString Text::innerText() const
{
return nodeValue();
}
Node* Text::copyNode(bool deep, Document* pOwnerDocument) const
{
return new Text(pOwnerDocument, *this);
}
} } // namespace Poco::XML

227
vendor/POCO/XML/src/TreeWalker.cpp vendored Normal file
View File

@@ -0,0 +1,227 @@
//
// TreeWalker.cpp
//
// Library: XML
// Package: DOM
// Module: TreeWalker
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/DOM/TreeWalker.h"
#include "Poco/DOM/Node.h"
#include "Poco/DOM/NodeFilter.h"
namespace Poco {
namespace XML {
TreeWalker::TreeWalker(Node* root, unsigned long whatToShow, NodeFilter* pFilter):
_pRoot(root),
_whatToShow(whatToShow),
_pFilter(pFilter),
_pCurrent(root)
{
}
TreeWalker::TreeWalker(const TreeWalker& walker):
_pRoot(walker._pRoot),
_whatToShow(walker._whatToShow),
_pFilter(walker._pFilter),
_pCurrent(walker._pCurrent)
{
}
TreeWalker& TreeWalker::operator = (const TreeWalker& walker)
{
if (&walker != this)
{
_pRoot = walker._pRoot;
_whatToShow = walker._whatToShow;
_pFilter = walker._pFilter;
_pCurrent = walker._pCurrent;
}
return *this;
}
TreeWalker::~TreeWalker()
{
}
void TreeWalker::setCurrentNode(Node* pNode)
{
_pCurrent = pNode;
}
Node* TreeWalker::parentNode()
{
if (!_pCurrent || _pCurrent == _pRoot) return 0;
Node* pParent = _pCurrent->parentNode();
while (pParent && pParent != _pRoot && accept(pParent) != NodeFilter::FILTER_ACCEPT)
pParent = pParent->parentNode();
if (pParent && accept(pParent) == NodeFilter::FILTER_ACCEPT)
_pCurrent = pParent;
else
pParent = 0;
return pParent;
}
Node* TreeWalker::firstChild()
{
if (!_pCurrent) return 0;
Node* pNode = accept(_pCurrent) != NodeFilter::FILTER_REJECT ? _pCurrent->firstChild() : 0;
while (pNode && accept(pNode) != NodeFilter::FILTER_ACCEPT)
pNode = pNode->nextSibling();
if (pNode)
_pCurrent = pNode;
return pNode;
}
Node* TreeWalker::lastChild()
{
if (!_pCurrent) return 0;
Node* pNode = accept(_pCurrent) != NodeFilter::FILTER_REJECT ? _pCurrent->lastChild() : 0;
while (pNode && accept(pNode) != NodeFilter::FILTER_ACCEPT)
pNode = pNode->previousSibling();
if (pNode)
_pCurrent = pNode;
return pNode;
}
Node* TreeWalker::previousSibling()
{
if (!_pCurrent) return 0;
Node* pNode = _pCurrent->previousSibling();
while (pNode && accept(pNode) != NodeFilter::FILTER_ACCEPT)
pNode = pNode->previousSibling();
if (pNode)
_pCurrent = pNode;
return pNode;
}
Node* TreeWalker::nextSibling()
{
if (!_pCurrent) return 0;
Node* pNode = _pCurrent->nextSibling();
while (pNode && accept(pNode) != NodeFilter::FILTER_ACCEPT)
pNode = pNode->nextSibling();
if (pNode)
_pCurrent = pNode;
return pNode;
}
Node* TreeWalker::previousNode()
{
if (!_pCurrent) return 0;
Node* pPrev = previous(_pCurrent);
while (pPrev && accept(pPrev) != NodeFilter::FILTER_ACCEPT)
pPrev = previous(pPrev);
if (pPrev)
_pCurrent = pPrev;
return pPrev;
}
Node* TreeWalker::nextNode()
{
if (!_pCurrent) return 0;
Node* pNext = next(_pCurrent);
while (pNext && accept(pNext) != NodeFilter::FILTER_ACCEPT)
pNext = next(pNext);
if (pNext)
_pCurrent = pNext;
return pNext;
}
int TreeWalker::accept(Node* pNode) const
{
bool accept = false;
switch (pNode->nodeType())
{
case Node::ELEMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ELEMENT) != 0; break;
case Node::ATTRIBUTE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ATTRIBUTE) != 0; break;
case Node::TEXT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_TEXT) != 0; break;
case Node::CDATA_SECTION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_CDATA_SECTION) != 0; break;
case Node::ENTITY_REFERENCE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ENTITY_REFERENCE) != 0; break;
case Node::ENTITY_NODE:
accept = (_whatToShow & NodeFilter::SHOW_ENTITY) != 0; break;
case Node::PROCESSING_INSTRUCTION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_PROCESSING_INSTRUCTION) != 0; break;
case Node::COMMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_COMMENT) != 0; break;
case Node::DOCUMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT) != 0; break;
case Node::DOCUMENT_TYPE_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_TYPE) != 0; break;
case Node::DOCUMENT_FRAGMENT_NODE:
accept = (_whatToShow & NodeFilter::SHOW_DOCUMENT_FRAGMENT) != 0; break;
case Node::NOTATION_NODE:
accept = (_whatToShow & NodeFilter::SHOW_NOTATION) != 0; break;
}
if (accept && _pFilter)
return _pFilter->acceptNode(pNode);
else
return accept ? NodeFilter::FILTER_ACCEPT : NodeFilter::FILTER_REJECT;
}
Node* TreeWalker::next(Node* pNode) const
{
Node* pNext = accept(pNode) != NodeFilter::FILTER_REJECT ? pNode->firstChild() : 0;
if (pNext) return pNext;
pNext = pNode;
while (pNext && pNext != _pRoot)
{
Node* pSibling = pNext->nextSibling();
if (pSibling) return pSibling;
pNext = pNext->parentNode();
}
return 0;
}
Node* TreeWalker::previous(Node* pNode) const
{
if (pNode == _pRoot) return 0;
Node* pPrev = pNode->previousSibling();
while (pPrev)
{
Node* pLastChild = accept(pPrev) != NodeFilter::FILTER_REJECT ? pPrev->lastChild() : 0;
if (pLastChild)
pPrev = pLastChild;
else
return pPrev;
}
return pNode->parentNode();
}
} } // namespace Poco::XML

39
vendor/POCO/XML/src/ValueTraits.cpp vendored Normal file
View File

@@ -0,0 +1,39 @@
//
// ValueTraits.cpp
//
// Library: XML
// Package: XML
// Module: ValueTraits
//
// Definition of the ValueTraits templates.
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Based on libstudxml (http://www.codesynthesis.com/projects/libstudxml/).
// Copyright (c) 2009-2013 Code Synthesis Tools CC.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/XML/XMLStreamParser.h"
#include "Poco/XML/XMLStreamParserException.h"
namespace Poco {
namespace XML {
bool DefaultValueTraits<bool>::parse(std::string s, const XMLStreamParser& p)
{
if (s == "true" || s == "1" || s == "True" || s == "TRUE")
return true;
else if (s == "false" || s == "0" || s == "False" || s == "FALSE")
return false;
else
throw XMLStreamParserException(p, "invalid bool value '" + s + "'");
}
} } // namespace Poco::XML

212
vendor/POCO/XML/src/WhitespaceFilter.cpp vendored Normal file
View File

@@ -0,0 +1,212 @@
//
// WhitespaceFilter.cpp
//
// Library: XML
// Package: SAX
// Module: WhitespaceFilter
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/WhitespaceFilter.h"
#include "Poco/SAX/SAXException.h"
namespace Poco {
namespace XML {
WhitespaceFilter::WhitespaceFilter():
_pLexicalHandler(0),
_filter(true)
{
}
WhitespaceFilter::WhitespaceFilter(XMLReader* pReader):
XMLFilterImpl(pReader),
_pLexicalHandler(0),
_filter(true)
{
}
WhitespaceFilter::~WhitespaceFilter()
{
}
void WhitespaceFilter::setProperty(const XMLString& propertyId, const XMLString& value)
{
if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
throw SAXNotSupportedException(std::string("property does not take a string value: ") + fromXMLString(propertyId));
else
XMLFilterImpl::setProperty(propertyId, value);
}
void WhitespaceFilter::setProperty(const XMLString& propertyId, void* value)
{
if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
_pLexicalHandler = reinterpret_cast<LexicalHandler*>(value);
else
XMLFilterImpl::setProperty(propertyId, value);
}
void* WhitespaceFilter::getProperty(const XMLString& propertyId) const
{
if (propertyId == XMLReader::PROPERTY_LEXICAL_HANDLER)
return _pLexicalHandler;
else
return XMLFilterImpl::getProperty(propertyId);
}
void WhitespaceFilter::startDocument()
{
XMLFilterImpl::startDocument();
_filter = true;
_data.clear();
}
void WhitespaceFilter::endDocument()
{
XMLFilterImpl::endDocument();
_filter = true;
_data.clear();
}
void WhitespaceFilter::startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList)
{
XMLFilterImpl::startElement(uri, localName, qname, attrList);
_filter = true;
_data.clear();
}
void WhitespaceFilter::endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname)
{
XMLFilterImpl::endElement(uri, localName, qname);
_filter = true;
_data.clear();
}
void WhitespaceFilter::characters(const XMLChar ch[], int start, int length)
{
if (_filter)
{
bool ws = true;
const XMLChar* it = ch + start;
const XMLChar* end = ch + start + length;
_data.append(it, end);
while (it != end)
{
if (*it != '\r' && *it != '\n' && *it != '\t' && *it != ' ')
{
ws = false;
break;
}
++it;
}
if (!ws)
{
XMLFilterImpl::characters(_data.data(), 0, (int) _data.length());
_filter = false;
_data.clear();
}
}
else XMLFilterImpl::characters(ch, start, length);
}
void WhitespaceFilter::ignorableWhitespace(const XMLChar ch[], int start, int length)
{
// the handler name already says that this data can be ignored
}
void WhitespaceFilter::processingInstruction(const XMLString& target, const XMLString& data)
{
XMLFilterImpl::processingInstruction(target, data);
_filter = true;
_data.clear();
}
void WhitespaceFilter::startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId)
{
if (_pLexicalHandler)
_pLexicalHandler->startDTD(name, publicId, systemId);
}
void WhitespaceFilter::endDTD()
{
if (_pLexicalHandler)
_pLexicalHandler->endDTD();
}
void WhitespaceFilter::startEntity(const XMLString& name)
{
if (_pLexicalHandler)
_pLexicalHandler->startEntity(name);
_filter = true;
_data.clear();
}
void WhitespaceFilter::endEntity(const XMLString& name)
{
if (_pLexicalHandler)
_pLexicalHandler->endEntity(name);
_filter = true;
_data.clear();
}
void WhitespaceFilter::startCDATA()
{
if (_pLexicalHandler)
_pLexicalHandler->startCDATA();
_filter = false;
_data.clear();
}
void WhitespaceFilter::endCDATA()
{
if (_pLexicalHandler)
_pLexicalHandler->endCDATA();
_filter = true;
_data.clear();
}
void WhitespaceFilter::comment(const XMLChar ch[], int start, int length)
{
if (_pLexicalHandler)
_pLexicalHandler->comment(ch, start, length);
_filter = true;
_data.clear();
}
void WhitespaceFilter::setupParse()
{
XMLFilterImpl::setupParse();
parent()->setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER, static_cast<LexicalHandler*>(this));
}
} } // namespace Poco::XML

29
vendor/POCO/XML/src/XMLException.cpp vendored Normal file
View File

@@ -0,0 +1,29 @@
//
// XMLException.cpp
//
// Library: XML
// Package: XML
// Module: XMLException
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/XML/XMLException.h"
#include <typeinfo>
using Poco::RuntimeException;
namespace Poco {
namespace XML {
POCO_IMPLEMENT_EXCEPTION(XMLException, RuntimeException, "XML Exception")
} } // namespace Poco::XML

27
vendor/POCO/XML/src/XMLFilter.cpp vendored Normal file
View File

@@ -0,0 +1,27 @@
//
// XMLFilter.cpp
//
// Library: XML
// Package: SAX
// Module: SAXFilters
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/XMLFilter.h"
namespace Poco {
namespace XML {
XMLFilter::~XMLFilter()
{
}
} } // namespace Poco::XML

313
vendor/POCO/XML/src/XMLFilterImpl.cpp vendored Normal file
View File

@@ -0,0 +1,313 @@
//
// XMLFilterImpl.cpp
//
// Library: XML
// Package: SAX
// Module: SAXFilters
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/XMLFilterImpl.h"
#include "Poco/SAX/SAXException.h"
namespace Poco {
namespace XML {
XMLFilterImpl::XMLFilterImpl():
_pParent(0),
_pEntityResolver(0),
_pDTDHandler(0),
_pContentHandler(0),
_pErrorHandler(0)
{
}
XMLFilterImpl::XMLFilterImpl(XMLReader* pParent):
_pParent(pParent),
_pEntityResolver(0),
_pDTDHandler(0),
_pContentHandler(0),
_pErrorHandler(0)
{
}
XMLFilterImpl::~XMLFilterImpl()
{
}
XMLReader* XMLFilterImpl::getParent() const
{
return _pParent;
}
void XMLFilterImpl::setParent(XMLReader* pParent)
{
_pParent = pParent;
}
void XMLFilterImpl::setEntityResolver(EntityResolver* pResolver)
{
_pEntityResolver = pResolver;
}
EntityResolver* XMLFilterImpl::getEntityResolver() const
{
return _pEntityResolver;
}
void XMLFilterImpl::setDTDHandler(DTDHandler* pDTDHandler)
{
_pDTDHandler = pDTDHandler;
}
DTDHandler* XMLFilterImpl::getDTDHandler() const
{
return _pDTDHandler;
}
void XMLFilterImpl::setContentHandler(ContentHandler* pContentHandler)
{
_pContentHandler = pContentHandler;
}
ContentHandler* XMLFilterImpl::getContentHandler() const
{
return _pContentHandler;
}
void XMLFilterImpl::setErrorHandler(ErrorHandler* pErrorHandler)
{
_pErrorHandler = pErrorHandler;
}
ErrorHandler* XMLFilterImpl::getErrorHandler() const
{
return _pErrorHandler;
}
void XMLFilterImpl::setFeature(const XMLString& featureId, bool state)
{
if (_pParent)
_pParent->setFeature(featureId, state);
else
throw SAXNotRecognizedException(fromXMLString(featureId));
}
bool XMLFilterImpl::getFeature(const XMLString& featureId) const
{
if (_pParent)
return _pParent->getFeature(featureId);
else
throw SAXNotRecognizedException(fromXMLString(featureId));
}
void XMLFilterImpl::setProperty(const XMLString& propertyId, const XMLString& value)
{
if (_pParent)
_pParent->setProperty(propertyId, value);
else
throw SAXNotRecognizedException(fromXMLString(propertyId));
}
void XMLFilterImpl::setProperty(const XMLString& propertyId, void* value)
{
if (_pParent)
_pParent->setProperty(propertyId, value);
else
throw SAXNotRecognizedException(fromXMLString(propertyId));
}
void* XMLFilterImpl::getProperty(const XMLString& propertyId) const
{
if (_pParent)
return _pParent->getProperty(propertyId);
else
throw SAXNotRecognizedException(fromXMLString(propertyId));
}
void XMLFilterImpl::parse(InputSource* pSource)
{
setupParse();
_pParent->parse(pSource);
}
void XMLFilterImpl::parse(const XMLString& systemId)
{
setupParse();
_pParent->parse(systemId);
}
void XMLFilterImpl::parseMemoryNP(const char* xml, std::size_t size)
{
setupParse();
_pParent->parseMemoryNP(xml, size);
}
InputSource* XMLFilterImpl::resolveEntity(const XMLString* publicId, const XMLString& systemId)
{
if (_pEntityResolver)
return _pEntityResolver->resolveEntity(publicId, systemId);
else
return 0;
}
void XMLFilterImpl::releaseInputSource(InputSource* pSource)
{
if (_pEntityResolver)
_pEntityResolver->releaseInputSource(pSource);
}
void XMLFilterImpl::notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId)
{
if (_pDTDHandler)
_pDTDHandler->notationDecl(name, publicId, systemId);
}
void XMLFilterImpl::unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName)
{
if (_pDTDHandler)
_pDTDHandler->unparsedEntityDecl(name, publicId, systemId, notationName);
}
void XMLFilterImpl::setDocumentLocator(const Locator* loc)
{
if (_pContentHandler)
_pContentHandler->setDocumentLocator(loc);
}
void XMLFilterImpl::startDocument()
{
if (_pContentHandler)
_pContentHandler->startDocument();
}
void XMLFilterImpl::endDocument()
{
if (_pContentHandler)
_pContentHandler->endDocument();
}
void XMLFilterImpl::startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList)
{
if (_pContentHandler)
_pContentHandler->startElement(uri, localName, qname, attrList);
}
void XMLFilterImpl::endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname)
{
if (_pContentHandler)
_pContentHandler->endElement(uri, localName, qname);
}
void XMLFilterImpl::characters(const XMLChar ch[], int start, int length)
{
if (_pContentHandler)
_pContentHandler->characters(ch, start, length);
}
void XMLFilterImpl::ignorableWhitespace(const XMLChar ch[], int start, int length)
{
if (_pContentHandler)
_pContentHandler->ignorableWhitespace(ch, start, length);
}
void XMLFilterImpl::processingInstruction(const XMLString& target, const XMLString& data)
{
if (_pContentHandler)
_pContentHandler->processingInstruction(target, data);
}
void XMLFilterImpl::startPrefixMapping(const XMLString& prefix, const XMLString& uri)
{
if (_pContentHandler)
_pContentHandler->startPrefixMapping(prefix, uri);
}
void XMLFilterImpl::endPrefixMapping(const XMLString& prefix)
{
if (_pContentHandler)
_pContentHandler->endPrefixMapping(prefix);
}
void XMLFilterImpl::skippedEntity(const XMLString& prefix)
{
if (_pContentHandler)
_pContentHandler->skippedEntity(prefix);
}
void XMLFilterImpl::warning(const SAXException& e)
{
if (_pErrorHandler)
_pErrorHandler->warning(e);
}
void XMLFilterImpl::error(const SAXException& e)
{
if (_pErrorHandler)
_pErrorHandler->error(e);
}
void XMLFilterImpl::fatalError(const SAXException& e)
{
if (_pErrorHandler)
_pErrorHandler->fatalError(e);
}
void XMLFilterImpl::setupParse()
{
poco_check_ptr (_pParent);
_pParent->setEntityResolver(this);
_pParent->setDTDHandler(this);
_pParent->setContentHandler(this);
_pParent->setErrorHandler(this);
}
} } // namespace Poco::XML

37
vendor/POCO/XML/src/XMLReader.cpp vendored Normal file
View File

@@ -0,0 +1,37 @@
//
// XMLReader.cpp
//
// Library: XML
// Package: SAX
// Module: SAX
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/SAX/XMLReader.h"
namespace Poco {
namespace XML {
const XMLString XMLReader::FEATURE_VALIDATION = toXMLString("http://xml.org/sax/features/validation");
const XMLString XMLReader::FEATURE_NAMESPACES = toXMLString("http://xml.org/sax/features/namespaces");
const XMLString XMLReader::FEATURE_NAMESPACE_PREFIXES = toXMLString("http://xml.org/sax/features/namespace-prefixes");
const XMLString XMLReader::FEATURE_EXTERNAL_GENERAL_ENTITIES = toXMLString("http://xml.org/sax/features/external-general-entities");
const XMLString XMLReader::FEATURE_EXTERNAL_PARAMETER_ENTITIES = toXMLString("http://xml.org/sax/features/external-parameter-entities");
const XMLString XMLReader::FEATURE_STRING_INTERNING = toXMLString("http://xml.org/sax/features/string-interning");
const XMLString XMLReader::PROPERTY_DECLARATION_HANDLER = toXMLString("http://xml.org/sax/properties/declaration-handler");
const XMLString XMLReader::PROPERTY_LEXICAL_HANDLER = toXMLString("http://xml.org/sax/properties/lexical-handler");
XMLReader::~XMLReader()
{
}
} } // namespace Poco::XML

939
vendor/POCO/XML/src/XMLStreamParser.cpp vendored Normal file
View File

@@ -0,0 +1,939 @@
//
// XMLStreamParser.cpp
//
// Library: XML
// Package: XML
// Module: XMLStreamParser
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Based on libstudxml (http://www.codesynthesis.com/projects/libstudxml/).
// Copyright (c) 2009-2013 Code Synthesis Tools CC.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/XML/XMLStreamParser.h"
#include <new>
#include <cstring>
#include <istream>
#include <ostream>
#include <sstream>
namespace Poco {
namespace XML {
struct StreamExceptionController
{
StreamExceptionController(std::istream& is):
_istr(is),
_oldState(_istr.exceptions())
{
_istr.exceptions(_oldState & ~std::istream::failbit);
}
~StreamExceptionController()
{
std::istream::iostate s = _istr.rdstate();
s &= ~std::istream::failbit;
// If our error state (sans failbit) intersects with the
// exception state then that means we have an active
// exception and changing error/exception state will
// cause another to be thrown.
if (!(_oldState & s))
{
// Clear failbit if it was caused by eof.
//
if (_istr.fail() && _istr.eof())
_istr.clear(s);
_istr.exceptions(_oldState);
}
}
private:
StreamExceptionController(const StreamExceptionController&);
StreamExceptionController& operator = (const StreamExceptionController&);
private:
std::istream& _istr;
std::istream::iostate _oldState;
};
static const char* parserEventStrings[] =
{
"start element",
"end element",
"start attribute",
"end attribute",
"characters",
"start namespace declaration",
"end namespace declaration",
"end of file"
};
std::ostream& operator << (std::ostream& os, XMLStreamParser::EventType e)
{
return os << parserEventStrings[e];
}
XMLStreamParser::XMLStreamParser(std::istream& is, const std::string& iname, FeatureType f):
_size(0),
_inputName(iname),
_feature(f)
{
_data.is = &is;
init();
}
XMLStreamParser::XMLStreamParser(const void* data, std::size_t size, const std::string& iname, FeatureType f):
_size(size),
_inputName(iname),
_feature(f)
{
poco_assert(data != 0 && size != 0);
_data.buf = data;
init();
}
XMLStreamParser::~XMLStreamParser()
{
if (_parser) XML_ParserFree(_parser);
}
void XMLStreamParser::init()
{
_depth = 0;
_parserState = state_next;
_currentEvent = EV_EOF;
_queue = EV_EOF;
_qualifiedName = &_qname;
_pvalue = &_value;
_line = 0;
_column = 0;
_currentAttributeIndex = 0;
_startNamespaceIndex = 0;
_endNamespaceIndex = 0;
if ((_feature & RECEIVE_ATTRIBUTE_MAP) != 0 && (_feature & RECEIVE_ATTRIBUTES_EVENT) != 0)
_feature &= ~RECEIVE_ATTRIBUTE_MAP;
// Allocate the XMLStreamParser. Make sure nothing else can throw after
// this call since otherwise we will leak it.
//
_parser = XML_ParserCreateNS(0, XML_Char(' '));
if (_parser == 0)
throw std::bad_alloc();
// Get prefixes in addition to namespaces and local names.
//
XML_SetReturnNSTriplet(_parser, true);
// Set handlers.
//
XML_SetUserData(_parser, this);
if ((_feature & RECEIVE_ELEMENTS) != 0)
{
XML_SetStartElementHandler(_parser, &handleStartElement);
XML_SetEndElementHandler(_parser, &handleEndElement);
}
if ((_feature & RECEIVE_CHARACTERS) != 0)
XML_SetCharacterDataHandler(_parser, &handleCharacters);
if ((_feature & RECEIVE_NAMESPACE_DECLS) != 0)
XML_SetNamespaceDeclHandler(_parser, &handleStartNamespaceDecl, &handleEndNamespaceDecl);
}
void XMLStreamParser::handleError()
{
XML_Error e(XML_GetErrorCode(_parser));
if (e == XML_ERROR_ABORTED)
{
// For now we only abort the XMLStreamParser in the handleCharacters() and
// handleStartElement() handlers.
//
switch (content())
{
case Content::Empty:
throw XMLStreamParserException(*this, "characters in empty content");
case Content::Simple:
throw XMLStreamParserException(*this, "element in simple content");
case Content::Complex:
throw XMLStreamParserException(*this, "characters in complex content");
default:
poco_assert(false);
}
}
else
throw XMLStreamParserException(_inputName, XML_GetCurrentLineNumber(_parser), XML_GetCurrentColumnNumber(_parser), XML_ErrorString(e));
}
XMLStreamParser::EventType XMLStreamParser::next()
{
if (_parserState == state_next)
return nextImpl(false);
else
{
// If we previously peeked at start/end_element, then adjust
// state accordingly.
//
switch (_currentEvent)
{
case EV_END_ELEMENT:
{
if (!_elementState.empty() && _elementState.back().depth == _depth)
popElement();
_depth--;
break;
}
case EV_START_ELEMENT:
{
_depth++;
break;
}
default:
break;
}
_parserState = state_next;
return _currentEvent;
}
}
const std::string& XMLStreamParser::attribute(const QName& qn) const
{
if (const ElementEntry* e = getElement())
{
AttributeMapType::const_iterator i(e->attributeMap.find(qn));
if (i != e->attributeMap.end())
{
if (!i->second.handled)
{
i->second.handled = true;
e->attributesUnhandled--;
}
return i->second.value;
}
}
throw XMLStreamParserException(*this, "attribute '" + qn.toString() + "' expected");
}
std::string XMLStreamParser::attribute(const QName& qn, const std::string& dv) const
{
if (const ElementEntry* e = getElement())
{
AttributeMapType::const_iterator i(e->attributeMap.find(qn));
if (i != e->attributeMap.end())
{
if (!i->second.handled)
{
i->second.handled = true;
e->attributesUnhandled--;
}
return i->second.value;
}
}
return dv;
}
bool XMLStreamParser::attributePresent(const QName& qn) const
{
if (const ElementEntry* e = getElement())
{
AttributeMapType::const_iterator i(e->attributeMap.find(qn));
if (i != e->attributeMap.end())
{
if (!i->second.handled)
{
i->second.handled = true;
e->attributesUnhandled--;
}
return true;
}
}
return false;
}
void XMLStreamParser::nextExpect(EventType e)
{
if (next() != e)
throw XMLStreamParserException(*this, std::string(parserEventStrings[e]) + " expected");
}
void XMLStreamParser::nextExpect(EventType e, const std::string& ns, const std::string& n)
{
if (next() != e || namespaceURI() != ns || localName() != n)
throw XMLStreamParserException(*this, std::string(parserEventStrings[e]) + " '" + QName(ns, n).toString() + "' expected");
}
std::string XMLStreamParser::element()
{
content(Content::Simple);
std::string r;
// The content of the element can be empty in which case there
// will be no characters event.
//
EventType e(next());
if (e == EV_CHARACTERS)
{
r.swap(value());
e = next();
}
// We cannot really get anything other than end_element since
// the simple content validation won't allow it.
//
poco_assert(e == EV_END_ELEMENT);
return r;
}
std::string XMLStreamParser::element(const QName& qn, const std::string& dv)
{
if (peek() == EV_START_ELEMENT && getQName() == qn)
{
next();
return element();
}
return dv;
}
const XMLStreamParser::ElementEntry* XMLStreamParser::getElementImpl() const
{
// The handleStartElement() Expat handler may have already provisioned
// an entry in the element stack. In this case, we need to get the
// one before it, if any.
//
const ElementEntry* r(0);
ElementState::size_type n(_elementState.size() - 1);
if (_elementState[n].depth == _depth)
r = &_elementState[n];
else if (n != 0 && _elementState[n].depth > _depth)
{
n--;
if (_elementState[n].depth == _depth)
r = &_elementState[n];
}
return r;
}
void XMLStreamParser::popElement()
{
// Make sure there are no unhandled attributes left.
//
const ElementEntry& e(_elementState.back());
if (e.attributesUnhandled != 0)
{
// Find the first unhandled attribute and report it.
//
for (const auto& p: e.attributeMap)
{
if (!p.second.handled)
throw XMLStreamParserException(*this, "unexpected attribute '" + p.first.toString() + "'");
}
poco_assert(false);
}
_elementState.pop_back();
}
XMLStreamParser::EventType XMLStreamParser::nextImpl(bool peek)
{
EventType e(nextBody());
// Content-specific processing. Note that we handle characters in the
// handleCharacters() Expat handler for two reasons. Firstly, it is faster
// to ignore the whitespaces at the source. Secondly, this allows us
// to distinguish between element and attribute characters. We can
// move this processing to the handler because the characters event
// is never queued.
//
switch (e)
{
case EV_END_ELEMENT:
{
// If this is a peek, then avoid popping the stack just yet.
// This way, the attribute map will still be valid until we
// call next().
//
if (!peek)
{
if (!_elementState.empty() && _elementState.back().depth == _depth)
popElement();
_depth--;
}
break;
}
case EV_START_ELEMENT:
{
if (const ElementEntry* pEntry = getElement())
{
switch (pEntry->content)
{
case Content::Empty:
throw XMLStreamParserException(*this, "element in empty content");
case Content::Simple:
throw XMLStreamParserException(*this, "element in simple content");
default:
break;
}
}
// If this is a peek, then delay adjusting the depth.
//
if (!peek)
_depth++;
break;
}
default:
break;
}
return e;
}
XMLStreamParser::EventType XMLStreamParser::nextBody()
{
// See if we have any start namespace declarations we need to return.
//
if (_startNamespaceIndex < _startNamespace.size())
{
// Based on the previous event determine what's the next one must be.
//
switch (_currentEvent)
{
case EV_START_NAMESPACE_DECL:
{
if (++_startNamespaceIndex == _startNamespace.size())
{
_startNamespaceIndex = 0;
_startNamespace.clear();
_qualifiedName = &_qname;
break; // No more declarations.
}
// Fall through.
}
case EV_START_ELEMENT:
{
_currentEvent = EV_START_NAMESPACE_DECL;
_qualifiedName = &_startNamespace[_startNamespaceIndex];
return _currentEvent;
}
default:
{
poco_assert(false);
return _currentEvent = EV_EOF;
}
}
}
// See if we have any attributes we need to return as events.
//
if (_currentAttributeIndex < _attributes.size())
{
// Based on the previous event determine what's the next one must be.
//
switch (_currentEvent)
{
case EV_START_ATTRIBUTE:
{
_currentEvent = EV_CHARACTERS;
_pvalue = &_attributes[_currentAttributeIndex].value;
return _currentEvent;
}
case EV_CHARACTERS:
{
_currentEvent = EV_END_ATTRIBUTE; // Name is already set.
return _currentEvent;
}
case EV_END_ATTRIBUTE:
{
if (++_currentAttributeIndex == _attributes.size())
{
_currentAttributeIndex = 0;
_attributes.clear();
_qualifiedName = &_qname;
_pvalue = &_value;
break; // No more attributes.
}
// Fall through.
}
case EV_START_ELEMENT:
case EV_START_NAMESPACE_DECL:
{
_currentEvent = EV_START_ATTRIBUTE;
_qualifiedName = &_attributes[_currentAttributeIndex].qname;
return _currentEvent;
}
default:
{
poco_assert(false);
return _currentEvent = EV_EOF;
}
}
}
// See if we have any end namespace declarations we need to return.
//
if (_endNamespaceIndex < _endNamespace.size())
{
// Based on the previous event determine what's the next one must be.
//
switch (_currentEvent)
{
case EV_END_NAMESPACE_DECL:
{
if (++_endNamespaceIndex == _endNamespace.size())
{
_endNamespaceIndex = 0;
_endNamespace.clear();
_qualifiedName = &_qname;
break; // No more declarations.
}
// Fall through.
}
// The end namespace declaration comes before the end element
// which means it can follow pretty much any other event.
//
default:
{
_currentEvent = EV_END_NAMESPACE_DECL;
_qualifiedName = &_endNamespace[_endNamespaceIndex];
return _currentEvent;
}
}
}
// Check the queue.
//
if (_queue != EV_EOF)
{
_currentEvent = _queue;
_queue = EV_EOF;
_line = XML_GetCurrentLineNumber(_parser);
_column = XML_GetCurrentColumnNumber(_parser);
return _currentEvent;
}
// Reset the character accumulation flag.
//
_accumulateContent = false;
XML_ParsingStatus ps;
XML_GetParsingStatus(_parser, &ps);
switch (ps.parsing)
{
case XML_INITIALIZED:
{
// As if we finished the previous chunk.
break;
}
case XML_PARSING:
{
poco_assert(false);
return _currentEvent = EV_EOF;
}
case XML_FINISHED:
{
return _currentEvent = EV_EOF;
}
case XML_SUSPENDED:
{
switch (XML_ResumeParser(_parser))
{
case XML_STATUS_SUSPENDED:
{
// If the XMLStreamParser is again in the suspended state, then
// that means we have the next event.
//
return _currentEvent;
}
case XML_STATUS_OK:
{
// Otherwise, we need to get and parse the next chunk of data
// unless this was the last chunk, in which case this is eof.
//
if (ps.finalBuffer)
return _currentEvent = EV_EOF;
break;
}
case XML_STATUS_ERROR:
handleError();
}
break;
}
}
// Get and parse the next chunk of data until we get the next event
// or reach eof.
//
if (!_accumulateContent)
_currentEvent = EV_EOF;
XML_Status s;
do
{
if (_size != 0)
{
s = XML_Parse(_parser, static_cast<const char*>(_data.buf), static_cast<int>(_size), true);
if (s == XML_STATUS_ERROR)
handleError();
break;
}
else
{
const size_t cap(4096);
char* b(static_cast<char*>(XML_GetBuffer(_parser, cap)));
if (b == 0)
throw std::bad_alloc();
// Temporarily unset the exception failbit. Also clear the fail bit
// when we reset the old state if it was caused by eof.
//
std::istream& is(*_data.is);
{
StreamExceptionController sec(is);
is.read(b, static_cast<std::streamsize>(cap));
}
// If the caller hasn't configured the stream to use exceptions,
// then use the parsing exception to report an error.
//
if (is.bad() || (is.fail() && !is.eof()))
throw XMLStreamParserException(*this, "io failure");
bool eof(is.eof());
s = XML_ParseBuffer(_parser, static_cast<int>(is.gcount()), eof);
if (s == XML_STATUS_ERROR)
handleError();
if (eof)
break;
}
} while (s != XML_STATUS_SUSPENDED);
return _currentEvent;
}
static void splitName(const XML_Char* s, QName& qn)
{
std::string& ns(qn.namespaceURI());
std::string& name(qn.localName());
std::string& prefix(qn.prefix());
const char* p(strchr(s, ' '));
if (p == 0)
{
ns.clear();
name = s;
prefix.clear();
}
else
{
ns.assign(s, 0, p - s);
s = p + 1;
p = strchr(s, ' ');
if (p == 0)
{
name = s;
prefix.clear();
}
else
{
name.assign(s, 0, p - s);
prefix = p + 1;
}
}
}
void XMLCALL XMLStreamParser::handleStartElement(void* v, const XML_Char* name, const XML_Char** atts)
{
XMLStreamParser& p(*static_cast<XMLStreamParser*>(v));
XML_ParsingStatus ps;
XML_GetParsingStatus(p._parser, &ps);
// Expat has a (mis)-feature of a possibily calling handlers even
// after the non-resumable XML_StopParser call.
//
if (ps.parsing == XML_FINISHED)
return;
// Cannot be a followup event.
//
poco_assert(ps.parsing == XML_PARSING);
// When accumulating characters in simple content, we expect to
// see more characters or end element. Seeing start element is
// possible but means violation of the content model.
//
if (p._accumulateContent)
{
// It would have been easier to throw the exception directly,
// however, the Expat code is most likely not exception safe.
//
p._line = XML_GetCurrentLineNumber(p._parser);
p._column = XML_GetCurrentColumnNumber(p._parser);
XML_StopParser(p._parser, false);
return;
}
p._currentEvent = EV_START_ELEMENT;
splitName(name, p._qname);
p._line = XML_GetCurrentLineNumber(p._parser);
p._column = XML_GetCurrentColumnNumber(p._parser);
// Handle attributes.
//
if (*atts != 0)
{
bool am((p._feature & RECEIVE_ATTRIBUTE_MAP) != 0);
bool ae((p._feature & RECEIVE_ATTRIBUTES_EVENT) != 0);
// Provision an entry for this element.
//
ElementEntry* pe(0);
if (am)
{
p._elementState.emplace_back(p._depth + 1);
pe = &p._elementState.back();
}
if (am || ae)
{
for (; *atts != 0; atts += 2)
{
if (am)
{
QName qn;
splitName(*atts, qn);
AttributeMapType::value_type v(qn, AttributeValueType());
v.second.value = *(atts + 1);
v.second.handled = false;
pe->attributeMap.insert(v);
}
else
{
p._attributes.emplace_back();
splitName(*atts, p._attributes.back().qname);
p._attributes.back().value = *(atts + 1);
}
}
if (am)
pe->attributesUnhandled = pe->attributeMap.size();
}
}
XML_StopParser(p._parser, true);
}
void XMLCALL XMLStreamParser::handleEndElement(void* v, const XML_Char* name)
{
XMLStreamParser& p(*static_cast<XMLStreamParser*>(v));
XML_ParsingStatus ps;
XML_GetParsingStatus(p._parser, &ps);
// Expat has a (mis)-feature of a possibily calling handlers even
// after the non-resumable XML_StopParser call.
//
if (ps.parsing == XML_FINISHED)
return;
// This can be a followup event for empty elements (<foo/>). In this
// case the element name is already set.
//
if (ps.parsing != XML_PARSING)
p._queue = EV_END_ELEMENT;
else
{
splitName(name, p._qname);
// If we are accumulating characters, then queue this event.
//
if (p._accumulateContent)
p._queue = EV_END_ELEMENT;
else
{
p._currentEvent = EV_END_ELEMENT;
p._line = XML_GetCurrentLineNumber(p._parser);
p._column = XML_GetCurrentColumnNumber(p._parser);
}
XML_StopParser(p._parser, true);
}
}
void XMLCALL XMLStreamParser::handleCharacters(void* v, const XML_Char* s, int n)
{
XMLStreamParser& p(*static_cast<XMLStreamParser*>(v));
XML_ParsingStatus ps;
XML_GetParsingStatus(p._parser, &ps);
// Expat has a (mis)-feature of a possibily calling handlers even
// after the non-resumable XML_StopParser call.
//
if (ps.parsing == XML_FINISHED)
return;
Content cont(p.content());
// If this is empty or complex content, see if these are whitespaces.
//
switch (cont)
{
case Content::Empty:
case Content::Complex:
{
for (int i(0); i != n; ++i)
{
char c(s[i]);
if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09)
continue;
// It would have been easier to throw the exception directly,
// however, the Expat code is most likely not exception safe.
//
p._line = XML_GetCurrentLineNumber(p._parser);
p._column = XML_GetCurrentColumnNumber(p._parser);
XML_StopParser(p._parser, false);
break;
}
return;
}
default:
break;
}
// Append the characters if we are accumulating. This can also be a
// followup event for another character event. In this case also
// append the data.
//
if (p._accumulateContent || ps.parsing != XML_PARSING)
{
poco_assert(p._currentEvent == EV_CHARACTERS);
p._value.append(s, n);
}
else
{
p._currentEvent = EV_CHARACTERS;
p._value.assign(s, n);
p._line = XML_GetCurrentLineNumber(p._parser);
p._column = XML_GetCurrentColumnNumber(p._parser);
// In simple content we need to accumulate all the characters
// into a single event. To do this we will let the XMLStreamParser run
// until we reach the end of the element.
//
if (cont == Content::Simple)
p._accumulateContent = true;
else
XML_StopParser(p._parser, true);
}
}
void XMLCALL XMLStreamParser::handleStartNamespaceDecl(void* v, const XML_Char* prefix, const XML_Char* ns)
{
XMLStreamParser& p(*static_cast<XMLStreamParser*>(v));
XML_ParsingStatus ps;
XML_GetParsingStatus(p._parser, &ps);
// Expat has a (mis)-feature of a possibily calling handlers even
// after the non-resumable XML_StopParser call.
//
if (ps.parsing == XML_FINISHED)
return;
p._startNamespace.emplace_back();
p._startNamespace.back().prefix() = (prefix != 0 ? prefix : "");
p._startNamespace.back().namespaceURI() = (ns != 0 ? ns : "");
}
void XMLCALL XMLStreamParser::handleEndNamespaceDecl(void* v, const XML_Char* prefix)
{
XMLStreamParser& p(*static_cast<XMLStreamParser*>(v));
XML_ParsingStatus ps;
XML_GetParsingStatus(p._parser, &ps);
// Expat has a (mis)-feature of a possibily calling handlers even
// after the non-resumable XML_StopParser call.
//
if (ps.parsing == XML_FINISHED)
return;
p._endNamespace.emplace_back();
p._endNamespace.back().prefix() = (prefix != 0 ? prefix : "");
}
} } // namespace Poco::XML

View File

@@ -0,0 +1,88 @@
//
// XMLStreamParserException.cpp
//
// Library: XML
// Package: XML
// Module: XMLStreamParserException
//
// Copyright (c) 2015, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/XML/XMLStreamParserException.h"
#include "Poco/XML/XMLStreamParser.h"
namespace Poco {
namespace XML {
XMLStreamParserException::~XMLStreamParserException() throw ()
{
}
XMLStreamParserException::XMLStreamParserException(const std::string& n, Poco::UInt64 l, Poco::UInt64 c, const std::string& d):
_name(n),
_line(l),
_column(c),
_description(d)
{
init();
}
XMLStreamParserException::XMLStreamParserException(const XMLStreamParser& p, const std::string& d):
_name(p.inputName()),
_line(p.line()),
_column(p.column()),
_description(d)
{
init();
}
void XMLStreamParserException::init()
{
std::ostringstream os;
if (!_name.empty())
os << _name << ':';
os << _line << ':' << _column << ": error: " << _description;
_what = os.str();
}
const char* XMLStreamParserException::name() const noexcept
{
return _name.c_str();
}
Poco::UInt64 XMLStreamParserException::line() const
{
return _line;
}
Poco::UInt64 XMLStreamParserException::column() const
{
return _column;
}
const std::string& XMLStreamParserException::description() const
{
return _description;
}
char const* XMLStreamParserException::what() const throw ()
{
return _what.c_str();
}
} } // namespace Poco::XML

64
vendor/POCO/XML/src/XMLString.cpp vendored Normal file
View File

@@ -0,0 +1,64 @@
//
// XMLString.cpp
//
// Library: XML
// Package: XML
// Module: XMLString
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/XML/XMLString.h"
#if defined(XML_UNICODE_WCHAR_T)
#include <stdlib.h>
#endif
namespace Poco {
namespace XML {
#if defined(XML_UNICODE_WCHAR_T)
std::string fromXMLString(const XMLString& str)
{
std::string result;
result.reserve(str.size());
for (auto xc: str)
{
char c;
wctomb(&c, xc);
result += c;
}
return result;
}
XMLString toXMLString(const std::string& str)
{
XMLString result;
result.reserve(str.size());
for (std::string::const_iterator it = str.begin(); it != str.end();)
{
wchar_t c;
int n = mbtowc(&c, &*it, MB_CUR_MAX);
result += c;
it += (n > 0 ? n : 1);
}
return result;
}
#endif // XML_UNICODE_WCHAR_T
} } // namespace Poco::XML

1068
vendor/POCO/XML/src/XMLWriter.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

120
vendor/POCO/XML/src/ascii.h vendored Normal file
View File

@@ -0,0 +1,120 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define ASCII_A 0x41
#define ASCII_B 0x42
#define ASCII_C 0x43
#define ASCII_D 0x44
#define ASCII_E 0x45
#define ASCII_F 0x46
#define ASCII_G 0x47
#define ASCII_H 0x48
#define ASCII_I 0x49
#define ASCII_J 0x4A
#define ASCII_K 0x4B
#define ASCII_L 0x4C
#define ASCII_M 0x4D
#define ASCII_N 0x4E
#define ASCII_O 0x4F
#define ASCII_P 0x50
#define ASCII_Q 0x51
#define ASCII_R 0x52
#define ASCII_S 0x53
#define ASCII_T 0x54
#define ASCII_U 0x55
#define ASCII_V 0x56
#define ASCII_W 0x57
#define ASCII_X 0x58
#define ASCII_Y 0x59
#define ASCII_Z 0x5A
#define ASCII_a 0x61
#define ASCII_b 0x62
#define ASCII_c 0x63
#define ASCII_d 0x64
#define ASCII_e 0x65
#define ASCII_f 0x66
#define ASCII_g 0x67
#define ASCII_h 0x68
#define ASCII_i 0x69
#define ASCII_j 0x6A
#define ASCII_k 0x6B
#define ASCII_l 0x6C
#define ASCII_m 0x6D
#define ASCII_n 0x6E
#define ASCII_o 0x6F
#define ASCII_p 0x70
#define ASCII_q 0x71
#define ASCII_r 0x72
#define ASCII_s 0x73
#define ASCII_t 0x74
#define ASCII_u 0x75
#define ASCII_v 0x76
#define ASCII_w 0x77
#define ASCII_x 0x78
#define ASCII_y 0x79
#define ASCII_z 0x7A
#define ASCII_0 0x30
#define ASCII_1 0x31
#define ASCII_2 0x32
#define ASCII_3 0x33
#define ASCII_4 0x34
#define ASCII_5 0x35
#define ASCII_6 0x36
#define ASCII_7 0x37
#define ASCII_8 0x38
#define ASCII_9 0x39
#define ASCII_TAB 0x09
#define ASCII_SPACE 0x20
#define ASCII_EXCL 0x21
#define ASCII_QUOT 0x22
#define ASCII_AMP 0x26
#define ASCII_APOS 0x27
#define ASCII_MINUS 0x2D
#define ASCII_PERIOD 0x2E
#define ASCII_COLON 0x3A
#define ASCII_SEMI 0x3B
#define ASCII_LT 0x3C
#define ASCII_EQUALS 0x3D
#define ASCII_GT 0x3E
#define ASCII_LSQB 0x5B
#define ASCII_RSQB 0x5D
#define ASCII_UNDERSCORE 0x5F
#define ASCII_LPAREN 0x28
#define ASCII_RPAREN 0x29
#define ASCII_FF 0x0C
#define ASCII_SLASH 0x2F
#define ASCII_HASH 0x23
#define ASCII_PIPE 0x7C
#define ASCII_COMMA 0x2C

64
vendor/POCO/XML/src/asciitab.h vendored Normal file
View File

@@ -0,0 +1,64 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,

39
vendor/POCO/XML/src/expat_config.h vendored Normal file
View File

@@ -0,0 +1,39 @@
//
// expat_config.h
//
// Poco XML specific configuration for expat.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef EXPAT_CONFIG_H
#define EXPAT_CONFIG_H
#include "Poco/Platform.h"
#if !defined(POCO_VXWORKS)
#include <memory.h>
#endif
#include <string.h>
#define XML_CONTEXT_BYTES 1024
#if defined POCO_ARCH_LITTLE_ENDIAN
#define BYTEORDER 1234
#else
#define BYTEORDER 4321
#endif
#define HAVE_MEMMOVE
#endif /* EXPAT_CONFIG_H */

65
vendor/POCO/XML/src/iasciitab.h vendored Normal file
View File

@@ -0,0 +1,65 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,

123
vendor/POCO/XML/src/internal.h vendored Normal file
View File

@@ -0,0 +1,123 @@
/* internal.h
Internal definitions used by Expat. This is not needed to compile
client code.
The following calling convention macros are defined for frequently
called functions:
FASTCALL - Used for those internal functions that have a simple
body and a low number of arguments and local variables.
PTRCALL - Used for functions called though function pointers.
PTRFASTCALL - Like PTRCALL, but for low number of arguments.
inline - Used for selected internal functions for which inlining
may improve performance on some platforms.
Note: Use of these macros is based on judgement, not hard rules,
and therefore subject to change.
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#if defined(__GNUC__) && defined(__i386__) && ! defined(__MINGW32__)
/* We'll use this version by default only where we know it helps.
regparm() generates warnings on Solaris boxes. See SF bug #692878.
Instability reported with egcs on a RedHat Linux 7.3.
Let's comment out:
#define FASTCALL __attribute__((stdcall, regparm(3)))
and let's try this:
*/
# define FASTCALL __attribute__((regparm(3)))
# define PTRFASTCALL __attribute__((regparm(3)))
#endif
/* Using __fastcall seems to have an unexpected negative effect under
MS VC++, especially for function pointers, so we won't use it for
now on that platform. It may be reconsidered for a future release
if it can be made more effective.
Likely reason: __fastcall on Windows is like stdcall, therefore
the compiler cannot perform stack optimizations for call clusters.
*/
/* Make sure all of these are defined if they aren't already. */
#ifndef FASTCALL
# define FASTCALL
#endif
#ifndef PTRCALL
# define PTRCALL
#endif
#ifndef PTRFASTCALL
# define PTRFASTCALL
#endif
#ifndef XML_MIN_SIZE
# if ! defined(__cplusplus) && ! defined(inline)
# ifdef __GNUC__
# define inline __inline
# endif /* __GNUC__ */
# endif
#endif /* XML_MIN_SIZE */
#ifdef __cplusplus
# define inline inline
#else
# ifndef inline
# define inline
# endif
#endif
#ifndef UNUSED_P
# define UNUSED_P(p) (void)p
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifdef XML_ENABLE_VISIBILITY
# if XML_ENABLE_VISIBILITY
__attribute__((visibility("default")))
# endif
#endif
void
_INTERNAL_trim_to_complete_utf8_characters(const char *from,
const char **fromLimRef);
#ifdef __cplusplus
}
#endif

64
vendor/POCO/XML/src/latin1tab.h vendored Normal file
View File

@@ -0,0 +1,64 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,

136
vendor/POCO/XML/src/nametab.h vendored Normal file
View File

@@ -0,0 +1,136 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
static const unsigned namingBitmap[] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x04000000,
0x87FFFFFE, 0x07FFFFFE, 0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFE00F, 0xFC31FFFF, 0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF, 0xFFFF0003, 0xFFFFFFFF,
0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF, 0x00000000, 0x07FFFFFE,
0x000007FE, 0xFFFE0000, 0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003, 0xFFF99FE0, 0x03C5FDFF,
0xB0000000, 0x00030003, 0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001, 0xFFF99FE0, 0x23CDFDFF,
0xB0000000, 0x00000003, 0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003, 0xFFFDDFE0, 0x03EFFDFF,
0x40000000, 0x00000003, 0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFE, 0x000D7FFF,
0x0000003F, 0x00000000, 0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF, 0x0007DAED, 0x50000000,
0x82315001, 0x002C62AB, 0x40000000, 0xF580C900, 0x00000007, 0x02010800,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0FFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0x03FFFFFF, 0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, 0x00000000, 0x00004C40,
0x00000000, 0x00000000, 0x00000007, 0x00000000, 0x00000000, 0x00000000,
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF, 0x001FFFFF, 0xFFFFFFFE,
0xFFFFFFFF, 0x07FFFFFF, 0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000000F,
0x00000000, 0x00000000, 0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF, 0x00FFFFFF, 0x00000000,
0xFFFF0000, 0xFFFFFFFF, 0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003, 0xFFFFD7C0, 0xFFFFFFFB,
0x547F7FFF, 0x000FFFFD, 0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF, 0x00000000, 0xFFFE0000,
0x027FFFFF, 0xFFFFFFFE, 0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF, 0xFFFFFFFF, 0x7CFFFFFF,
0xFFEF7FFF, 0x03FF3DFF, 0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF, 0xFFF987E4, 0xD36DFDFF,
0x5E003987, 0x001FFFC0, 0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3, 0xD63DC7EC, 0xC3BFC718,
0x00803DC7, 0x0000FF80, 0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3, 0xFFFDDFEC, 0xC3FFFDFF,
0x00803DCF, 0x0000FFC3, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000, 0xFEF02596, 0x3BFF6CAE,
0x03FF3F5F, 0x00000000, 0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF, 0x661FFFFF, 0xFFFFFFFE,
0xFFFFFFFF, 0x77FFFFFF,
};
static const unsigned char nmstrtPages[] = {
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00, 0x00, 0x09, 0x0A, 0x0B,
0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x00, 0x14, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
static const unsigned char namePages[] = {
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00, 0x00, 0x1F, 0x20, 0x21,
0x22, 0x23, 0x24, 0x25, 0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13, 0x26, 0x14, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};

398
vendor/POCO/XML/src/siphash.h vendored Normal file
View File

@@ -0,0 +1,398 @@
/* ==========================================================================
* siphash.h - SipHash-2-4 in a single header file
* --------------------------------------------------------------------------
* Derived by William Ahern from the reference implementation[1] published[2]
* by Jean-Philippe Aumasson and Daniel J. Berstein.
* Minimal changes by Sebastian Pipping and Victor Stinner on top, see below.
* Licensed under the CC0 Public Domain Dedication license.
*
* 1. https://www.131002.net/siphash/siphash24.c
* 2. https://www.131002.net/siphash/
* --------------------------------------------------------------------------
* HISTORY:
*
* 2019-08-03 (Sebastian Pipping)
* - Mark part of sip24_valid as to be excluded from clang-format
* - Re-format code using clang-format 9
*
* 2018-07-08 (Anton Maklakov)
* - Add "fall through" markers for GCC's -Wimplicit-fallthrough
*
* 2017-11-03 (Sebastian Pipping)
* - Hide sip_tobin and sip_binof unless SIPHASH_TOBIN macro is defined
*
* 2017-07-25 (Vadim Zeitlin)
* - Fix use of SIPHASH_MAIN macro
*
* 2017-07-05 (Sebastian Pipping)
* - Use _SIP_ULL macro to not require a C++11 compiler if compiled as C++
* - Add const qualifiers at two places
* - Ensure <=80 characters line length (assuming tab width 4)
*
* 2017-06-23 (Victor Stinner)
* - Address Win64 compile warnings
*
* 2017-06-18 (Sebastian Pipping)
* - Clarify license note in the header
* - Address C89 issues:
* - Stop using inline keyword (and let compiler decide)
* - Replace _Bool by int
* - Turn macro siphash24 into a function
* - Address invalid conversion (void pointer) by explicit cast
* - Address lack of stdint.h for Visual Studio 2003 to 2008
* - Always expose sip24_valid (for self-tests)
*
* 2012-11-04 - Born. (William Ahern)
* --------------------------------------------------------------------------
* USAGE:
*
* SipHash-2-4 takes as input two 64-bit words as the key, some number of
* message bytes, and outputs a 64-bit word as the message digest. This
* implementation employs two data structures: a struct sipkey for
* representing the key, and a struct siphash for representing the hash
* state.
*
* For converting a 16-byte unsigned char array to a key, use either the
* macro sip_keyof or the routine sip_tokey. The former instantiates a
* compound literal key, while the latter requires a key object as a
* parameter.
*
* unsigned char secret[16];
* arc4random_buf(secret, sizeof secret);
* struct sipkey *key = sip_keyof(secret);
*
* For hashing a message, use either the convenience macro siphash24 or the
* routines sip24_init, sip24_update, and sip24_final.
*
* struct siphash state;
* void *msg;
* size_t len;
* uint64_t hash;
*
* sip24_init(&state, key);
* sip24_update(&state, msg, len);
* hash = sip24_final(&state);
*
* or
*
* hash = siphash24(msg, len, key);
*
* To convert the 64-bit hash value to a canonical 8-byte little-endian
* binary representation, use either the macro sip_binof or the routine
* sip_tobin. The former instantiates and returns a compound literal array,
* while the latter requires an array object as a parameter.
* --------------------------------------------------------------------------
* NOTES:
*
* o Neither sip_keyof, sip_binof, nor siphash24 will work with compilers
* lacking compound literal support. Instead, you must use the lower-level
* interfaces which take as parameters the temporary state objects.
*
* o Uppercase macros may evaluate parameters more than once. Lowercase
* macros should not exhibit any such side effects.
* ==========================================================================
*/
#ifndef SIPHASH_H
#define SIPHASH_H
#include <stddef.h> /* size_t */
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600)
/* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */
typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#else
# include <stdint.h> /* uint64_t uint32_t uint8_t */
#endif
/*
* Workaround to not require a C++11 compiler for using ULL suffix
* if this code is included and compiled as C++; related GCC warning is:
* warning: use of C++11 long long integer constant [-Wlong-long]
*/
#define _SIP_ULL(high, low) (((uint64_t)high << 32) | low)
#define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
#define SIP_U32TO8_LE(p, v) \
(p)[0] = (uint8_t)((v) >> 0); \
(p)[1] = (uint8_t)((v) >> 8); \
(p)[2] = (uint8_t)((v) >> 16); \
(p)[3] = (uint8_t)((v) >> 24);
#define SIP_U64TO8_LE(p, v) \
SIP_U32TO8_LE((p) + 0, (uint32_t)((v) >> 0)); \
SIP_U32TO8_LE((p) + 4, (uint32_t)((v) >> 32));
#define SIP_U8TO64_LE(p) \
(((uint64_t)((p)[0]) << 0) | ((uint64_t)((p)[1]) << 8) \
| ((uint64_t)((p)[2]) << 16) | ((uint64_t)((p)[3]) << 24) \
| ((uint64_t)((p)[4]) << 32) | ((uint64_t)((p)[5]) << 40) \
| ((uint64_t)((p)[6]) << 48) | ((uint64_t)((p)[7]) << 56))
#define SIPHASH_INITIALIZER \
{ 0, 0, 0, 0, {0}, 0, 0 }
struct siphash {
uint64_t v0, v1, v2, v3;
unsigned char buf[8], *p;
uint64_t c;
}; /* struct siphash */
#define SIP_KEYLEN 16
struct sipkey {
uint64_t k[2];
}; /* struct sipkey */
#define sip_keyof(k) sip_tokey(&(struct sipkey){{0}}, (k))
static struct sipkey *
sip_tokey(struct sipkey *key, const void *src) {
key->k[0] = SIP_U8TO64_LE((const unsigned char *)src);
key->k[1] = SIP_U8TO64_LE((const unsigned char *)src + 8);
return key;
} /* sip_tokey() */
#ifdef SIPHASH_TOBIN
# define sip_binof(v) sip_tobin((unsigned char[8]){0}, (v))
static void *
sip_tobin(void *dst, uint64_t u64) {
SIP_U64TO8_LE((unsigned char *)dst, u64);
return dst;
} /* sip_tobin() */
#endif /* SIPHASH_TOBIN */
static void
sip_round(struct siphash *H, const int rounds) {
int i;
for (i = 0; i < rounds; i++) {
H->v0 += H->v1;
H->v1 = SIP_ROTL(H->v1, 13);
H->v1 ^= H->v0;
H->v0 = SIP_ROTL(H->v0, 32);
H->v2 += H->v3;
H->v3 = SIP_ROTL(H->v3, 16);
H->v3 ^= H->v2;
H->v0 += H->v3;
H->v3 = SIP_ROTL(H->v3, 21);
H->v3 ^= H->v0;
H->v2 += H->v1;
H->v1 = SIP_ROTL(H->v1, 17);
H->v1 ^= H->v2;
H->v2 = SIP_ROTL(H->v2, 32);
}
} /* sip_round() */
static struct siphash *
sip24_init(struct siphash *H, const struct sipkey *key) {
H->v0 = _SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0];
H->v1 = _SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1];
H->v2 = _SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0];
H->v3 = _SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1];
H->p = H->buf;
H->c = 0;
return H;
} /* sip24_init() */
#define sip_endof(a) (&(a)[sizeof(a) / sizeof *(a)])
static struct siphash *
sip24_update(struct siphash *H, const void *src, size_t len) {
const unsigned char *p = (const unsigned char *)src, *pe = p + len;
uint64_t m;
do {
while (p < pe && H->p < sip_endof(H->buf))
*H->p++ = *p++;
if (H->p < sip_endof(H->buf))
break;
m = SIP_U8TO64_LE(H->buf);
H->v3 ^= m;
sip_round(H, 2);
H->v0 ^= m;
H->p = H->buf;
H->c += 8;
} while (p < pe);
return H;
} /* sip24_update() */
static uint64_t
sip24_final(struct siphash *H) {
const char left = (char)(H->p - H->buf);
uint64_t b = (H->c + left) << 56;
switch (left) {
case 7:
b |= (uint64_t)H->buf[6] << 48;
/* fall through */
case 6:
b |= (uint64_t)H->buf[5] << 40;
/* fall through */
case 5:
b |= (uint64_t)H->buf[4] << 32;
/* fall through */
case 4:
b |= (uint64_t)H->buf[3] << 24;
/* fall through */
case 3:
b |= (uint64_t)H->buf[2] << 16;
/* fall through */
case 2:
b |= (uint64_t)H->buf[1] << 8;
/* fall through */
case 1:
b |= (uint64_t)H->buf[0] << 0;
/* fall through */
case 0:
break;
}
H->v3 ^= b;
sip_round(H, 2);
H->v0 ^= b;
H->v2 ^= 0xff;
sip_round(H, 4);
return H->v0 ^ H->v1 ^ H->v2 ^ H->v3;
} /* sip24_final() */
static uint64_t
siphash24(const void *src, size_t len, const struct sipkey *key) {
struct siphash state = SIPHASH_INITIALIZER;
return sip24_final(sip24_update(sip24_init(&state, key), src, len));
} /* siphash24() */
/*
* SipHash-2-4 output with
* k = 00 01 02 ...
* and
* in = (empty string)
* in = 00 (1 byte)
* in = 00 01 (2 bytes)
* in = 00 01 02 (3 bytes)
* ...
* in = 00 01 02 ... 3e (63 bytes)
*/
static int
sip24_valid(void) {
/* clang-format off */
static const unsigned char vectors[64][8] = {
{ 0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72, },
{ 0xfd, 0x67, 0xdc, 0x93, 0xc5, 0x39, 0xf8, 0x74, },
{ 0x5a, 0x4f, 0xa9, 0xd9, 0x09, 0x80, 0x6c, 0x0d, },
{ 0x2d, 0x7e, 0xfb, 0xd7, 0x96, 0x66, 0x67, 0x85, },
{ 0xb7, 0x87, 0x71, 0x27, 0xe0, 0x94, 0x27, 0xcf, },
{ 0x8d, 0xa6, 0x99, 0xcd, 0x64, 0x55, 0x76, 0x18, },
{ 0xce, 0xe3, 0xfe, 0x58, 0x6e, 0x46, 0xc9, 0xcb, },
{ 0x37, 0xd1, 0x01, 0x8b, 0xf5, 0x00, 0x02, 0xab, },
{ 0x62, 0x24, 0x93, 0x9a, 0x79, 0xf5, 0xf5, 0x93, },
{ 0xb0, 0xe4, 0xa9, 0x0b, 0xdf, 0x82, 0x00, 0x9e, },
{ 0xf3, 0xb9, 0xdd, 0x94, 0xc5, 0xbb, 0x5d, 0x7a, },
{ 0xa7, 0xad, 0x6b, 0x22, 0x46, 0x2f, 0xb3, 0xf4, },
{ 0xfb, 0xe5, 0x0e, 0x86, 0xbc, 0x8f, 0x1e, 0x75, },
{ 0x90, 0x3d, 0x84, 0xc0, 0x27, 0x56, 0xea, 0x14, },
{ 0xee, 0xf2, 0x7a, 0x8e, 0x90, 0xca, 0x23, 0xf7, },
{ 0xe5, 0x45, 0xbe, 0x49, 0x61, 0xca, 0x29, 0xa1, },
{ 0xdb, 0x9b, 0xc2, 0x57, 0x7f, 0xcc, 0x2a, 0x3f, },
{ 0x94, 0x47, 0xbe, 0x2c, 0xf5, 0xe9, 0x9a, 0x69, },
{ 0x9c, 0xd3, 0x8d, 0x96, 0xf0, 0xb3, 0xc1, 0x4b, },
{ 0xbd, 0x61, 0x79, 0xa7, 0x1d, 0xc9, 0x6d, 0xbb, },
{ 0x98, 0xee, 0xa2, 0x1a, 0xf2, 0x5c, 0xd6, 0xbe, },
{ 0xc7, 0x67, 0x3b, 0x2e, 0xb0, 0xcb, 0xf2, 0xd0, },
{ 0x88, 0x3e, 0xa3, 0xe3, 0x95, 0x67, 0x53, 0x93, },
{ 0xc8, 0xce, 0x5c, 0xcd, 0x8c, 0x03, 0x0c, 0xa8, },
{ 0x94, 0xaf, 0x49, 0xf6, 0xc6, 0x50, 0xad, 0xb8, },
{ 0xea, 0xb8, 0x85, 0x8a, 0xde, 0x92, 0xe1, 0xbc, },
{ 0xf3, 0x15, 0xbb, 0x5b, 0xb8, 0x35, 0xd8, 0x17, },
{ 0xad, 0xcf, 0x6b, 0x07, 0x63, 0x61, 0x2e, 0x2f, },
{ 0xa5, 0xc9, 0x1d, 0xa7, 0xac, 0xaa, 0x4d, 0xde, },
{ 0x71, 0x65, 0x95, 0x87, 0x66, 0x50, 0xa2, 0xa6, },
{ 0x28, 0xef, 0x49, 0x5c, 0x53, 0xa3, 0x87, 0xad, },
{ 0x42, 0xc3, 0x41, 0xd8, 0xfa, 0x92, 0xd8, 0x32, },
{ 0xce, 0x7c, 0xf2, 0x72, 0x2f, 0x51, 0x27, 0x71, },
{ 0xe3, 0x78, 0x59, 0xf9, 0x46, 0x23, 0xf3, 0xa7, },
{ 0x38, 0x12, 0x05, 0xbb, 0x1a, 0xb0, 0xe0, 0x12, },
{ 0xae, 0x97, 0xa1, 0x0f, 0xd4, 0x34, 0xe0, 0x15, },
{ 0xb4, 0xa3, 0x15, 0x08, 0xbe, 0xff, 0x4d, 0x31, },
{ 0x81, 0x39, 0x62, 0x29, 0xf0, 0x90, 0x79, 0x02, },
{ 0x4d, 0x0c, 0xf4, 0x9e, 0xe5, 0xd4, 0xdc, 0xca, },
{ 0x5c, 0x73, 0x33, 0x6a, 0x76, 0xd8, 0xbf, 0x9a, },
{ 0xd0, 0xa7, 0x04, 0x53, 0x6b, 0xa9, 0x3e, 0x0e, },
{ 0x92, 0x59, 0x58, 0xfc, 0xd6, 0x42, 0x0c, 0xad, },
{ 0xa9, 0x15, 0xc2, 0x9b, 0xc8, 0x06, 0x73, 0x18, },
{ 0x95, 0x2b, 0x79, 0xf3, 0xbc, 0x0a, 0xa6, 0xd4, },
{ 0xf2, 0x1d, 0xf2, 0xe4, 0x1d, 0x45, 0x35, 0xf9, },
{ 0x87, 0x57, 0x75, 0x19, 0x04, 0x8f, 0x53, 0xa9, },
{ 0x10, 0xa5, 0x6c, 0xf5, 0xdf, 0xcd, 0x9a, 0xdb, },
{ 0xeb, 0x75, 0x09, 0x5c, 0xcd, 0x98, 0x6c, 0xd0, },
{ 0x51, 0xa9, 0xcb, 0x9e, 0xcb, 0xa3, 0x12, 0xe6, },
{ 0x96, 0xaf, 0xad, 0xfc, 0x2c, 0xe6, 0x66, 0xc7, },
{ 0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee, },
{ 0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1, },
{ 0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a, },
{ 0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81, },
{ 0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f, },
{ 0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24, },
{ 0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7, },
{ 0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea, },
{ 0x13, 0x50, 0x79, 0xa3, 0x23, 0x1c, 0xe6, 0x60, },
{ 0x93, 0x2b, 0x28, 0x46, 0xe4, 0xd7, 0x06, 0x66, },
{ 0xe1, 0x91, 0x5f, 0x5c, 0xb1, 0xec, 0xa4, 0x6c, },
{ 0xf3, 0x25, 0x96, 0x5c, 0xa1, 0x6d, 0x62, 0x9f, },
{ 0x57, 0x5f, 0xf2, 0x8e, 0x60, 0x38, 0x1b, 0xe5, },
{ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95, }
};
/* clang-format on */
unsigned char in[64];
struct sipkey k;
size_t i;
sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011"
"\012\013\014\015\016\017");
for (i = 0; i < sizeof in; ++i) {
in[i] = (unsigned char)i;
if (siphash24(in, i, &k) != SIP_U8TO64_LE(vectors[i]))
return 0;
}
return 1;
} /* sip24_valid() */
#ifdef SIPHASH_MAIN
# include <stdio.h>
int
main(void) {
const int ok = sip24_valid();
if (ok)
puts("OK");
else
puts("FAIL");
return ! ok;
} /* main() */
#endif /* SIPHASH_MAIN */
#endif /* SIPHASH_H */

64
vendor/POCO/XML/src/utf8tab.h vendored Normal file
View File

@@ -0,0 +1,64 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,

6909
vendor/POCO/XML/src/xmlparse.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

1247
vendor/POCO/XML/src/xmlrole.c vendored Normal file

File diff suppressed because it is too large Load Diff

133
vendor/POCO/XML/src/xmlrole.h vendored Normal file
View File

@@ -0,0 +1,133 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef XmlRole_INCLUDED
#define XmlRole_INCLUDED 1
#include "xmltok.h"
#ifdef __cplusplus
extern "C" {
#endif
enum {
XML_ROLE_ERROR = -1,
XML_ROLE_NONE = 0,
XML_ROLE_XML_DECL,
XML_ROLE_INSTANCE_START,
XML_ROLE_DOCTYPE_NONE,
XML_ROLE_DOCTYPE_NAME,
XML_ROLE_DOCTYPE_SYSTEM_ID,
XML_ROLE_DOCTYPE_PUBLIC_ID,
XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
XML_ROLE_DOCTYPE_CLOSE,
XML_ROLE_GENERAL_ENTITY_NAME,
XML_ROLE_PARAM_ENTITY_NAME,
XML_ROLE_ENTITY_NONE,
XML_ROLE_ENTITY_VALUE,
XML_ROLE_ENTITY_SYSTEM_ID,
XML_ROLE_ENTITY_PUBLIC_ID,
XML_ROLE_ENTITY_COMPLETE,
XML_ROLE_ENTITY_NOTATION_NAME,
XML_ROLE_NOTATION_NONE,
XML_ROLE_NOTATION_NAME,
XML_ROLE_NOTATION_SYSTEM_ID,
XML_ROLE_NOTATION_NO_SYSTEM_ID,
XML_ROLE_NOTATION_PUBLIC_ID,
XML_ROLE_ATTRIBUTE_NAME,
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
XML_ROLE_ATTRIBUTE_TYPE_ID,
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
XML_ROLE_ATTLIST_NONE,
XML_ROLE_ATTLIST_ELEMENT_NAME,
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
XML_ROLE_ELEMENT_NONE,
XML_ROLE_ELEMENT_NAME,
XML_ROLE_CONTENT_ANY,
XML_ROLE_CONTENT_EMPTY,
XML_ROLE_CONTENT_PCDATA,
XML_ROLE_GROUP_OPEN,
XML_ROLE_GROUP_CLOSE,
XML_ROLE_GROUP_CLOSE_REP,
XML_ROLE_GROUP_CLOSE_OPT,
XML_ROLE_GROUP_CLOSE_PLUS,
XML_ROLE_GROUP_CHOICE,
XML_ROLE_GROUP_SEQUENCE,
XML_ROLE_CONTENT_ELEMENT,
XML_ROLE_CONTENT_ELEMENT_REP,
XML_ROLE_CONTENT_ELEMENT_OPT,
XML_ROLE_CONTENT_ELEMENT_PLUS,
XML_ROLE_PI,
XML_ROLE_COMMENT,
#ifdef XML_DTD
XML_ROLE_TEXT_DECL,
XML_ROLE_IGNORE_SECT,
XML_ROLE_INNER_PARAM_ENTITY_REF,
#endif /* XML_DTD */
XML_ROLE_PARAM_ENTITY_REF
};
typedef struct prolog_state {
int(PTRCALL *handler)(struct prolog_state *state, int tok, const char *ptr,
const char *end, const ENCODING *enc);
unsigned level;
int role_none;
#ifdef XML_DTD
unsigned includeLevel;
int documentEntity;
int inEntityValue;
#endif /* XML_DTD */
} PROLOG_STATE;
void XmlPrologStateInit(PROLOG_STATE *);
#ifdef XML_DTD
void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
#endif /* XML_DTD */
#define XmlTokenRole(state, tok, ptr, end, enc) \
(((state)->handler)(state, tok, ptr, end, enc))
#ifdef __cplusplus
}
#endif
#endif /* not XmlRole_INCLUDED */

1672
vendor/POCO/XML/src/xmltok.c vendored Normal file

File diff suppressed because it is too large Load Diff

315
vendor/POCO/XML/src/xmltok.h vendored Normal file
View File

@@ -0,0 +1,315 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef XmlTok_INCLUDED
#define XmlTok_INCLUDED 1
#ifdef __cplusplus
extern "C" {
#endif
/* The following token may be returned by XmlContentTok */
#define XML_TOK_TRAILING_RSQB \
-5 /* ] or ]] at the end of the scan; might be \
start of illegal ]]> sequence */
/* The following tokens may be returned by both XmlPrologTok and
XmlContentTok.
*/
#define XML_TOK_NONE -4 /* The string to be scanned is empty */
#define XML_TOK_TRAILING_CR \
-3 /* A CR at the end of the scan; \
might be part of CRLF sequence */
#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
#define XML_TOK_PARTIAL -1 /* only part of a token */
#define XML_TOK_INVALID 0
/* The following tokens are returned by XmlContentTok; some are also
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
*/
#define XML_TOK_START_TAG_WITH_ATTS 1
#define XML_TOK_START_TAG_NO_ATTS 2
#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
#define XML_TOK_END_TAG 5
#define XML_TOK_DATA_CHARS 6
#define XML_TOK_DATA_NEWLINE 7
#define XML_TOK_CDATA_SECT_OPEN 8
#define XML_TOK_ENTITY_REF 9
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
/* The following tokens may be returned by both XmlPrologTok and
XmlContentTok.
*/
#define XML_TOK_PI 11 /* processing instruction */
#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
#define XML_TOK_COMMENT 13
#define XML_TOK_BOM 14 /* Byte order mark */
/* The following tokens are returned only by XmlPrologTok */
#define XML_TOK_PROLOG_S 15
#define XML_TOK_DECL_OPEN 16 /* <!foo */
#define XML_TOK_DECL_CLOSE 17 /* > */
#define XML_TOK_NAME 18
#define XML_TOK_NMTOKEN 19
#define XML_TOK_POUND_NAME 20 /* #name */
#define XML_TOK_OR 21 /* | */
#define XML_TOK_PERCENT 22
#define XML_TOK_OPEN_PAREN 23
#define XML_TOK_CLOSE_PAREN 24
#define XML_TOK_OPEN_BRACKET 25
#define XML_TOK_CLOSE_BRACKET 26
#define XML_TOK_LITERAL 27
#define XML_TOK_PARAM_ENTITY_REF 28
#define XML_TOK_INSTANCE_START 29
/* The following occur only in element type declarations */
#define XML_TOK_NAME_QUESTION 30 /* name? */
#define XML_TOK_NAME_ASTERISK 31 /* name* */
#define XML_TOK_NAME_PLUS 32 /* name+ */
#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
#define XML_TOK_COMMA 38
/* The following token is returned only by XmlAttributeValueTok */
#define XML_TOK_ATTRIBUTE_VALUE_S 39
/* The following token is returned only by XmlCdataSectionTok */
#define XML_TOK_CDATA_SECT_CLOSE 40
/* With namespace processing this is returned by XmlPrologTok for a
name with a colon.
*/
#define XML_TOK_PREFIXED_NAME 41
#ifdef XML_DTD
# define XML_TOK_IGNORE_SECT 42
#endif /* XML_DTD */
#ifdef XML_DTD
# define XML_N_STATES 4
#else /* not XML_DTD */
# define XML_N_STATES 3
#endif /* not XML_DTD */
#define XML_PROLOG_STATE 0
#define XML_CONTENT_STATE 1
#define XML_CDATA_SECTION_STATE 2
#ifdef XML_DTD
# define XML_IGNORE_SECTION_STATE 3
#endif /* XML_DTD */
#define XML_N_LITERAL_TYPES 2
#define XML_ATTRIBUTE_VALUE_LITERAL 0
#define XML_ENTITY_VALUE_LITERAL 1
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
#define XML_UTF8_ENCODE_MAX 4
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
#define XML_UTF16_ENCODE_MAX 2
typedef struct position {
/* first line and first column are 0 not 1 */
XML_Size lineNumber;
XML_Size columnNumber;
} POSITION;
typedef struct {
const char *name;
const char *valuePtr;
const char *valueEnd;
char normalized;
} ATTRIBUTE;
struct encoding;
typedef struct encoding ENCODING;
typedef int(PTRCALL *SCANNER)(const ENCODING *, const char *, const char *,
const char **);
enum XML_Convert_Result {
XML_CONVERT_COMPLETED = 0,
XML_CONVERT_INPUT_INCOMPLETE = 1,
XML_CONVERT_OUTPUT_EXHAUSTED
= 2 /* and therefore potentially input remaining as well */
};
struct encoding {
SCANNER scanners[XML_N_STATES];
SCANNER literalScanners[XML_N_LITERAL_TYPES];
int(PTRCALL *nameMatchesAscii)(const ENCODING *, const char *, const char *,
const char *);
int(PTRFASTCALL *nameLength)(const ENCODING *, const char *);
const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
int(PTRCALL *getAtts)(const ENCODING *enc, const char *ptr, int attsMax,
ATTRIBUTE *atts);
int(PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
int(PTRCALL *predefinedEntityName)(const ENCODING *, const char *,
const char *);
void(PTRCALL *updatePosition)(const ENCODING *, const char *ptr,
const char *end, POSITION *);
int(PTRCALL *isPublicId)(const ENCODING *enc, const char *ptr,
const char *end, const char **badPtr);
enum XML_Convert_Result(PTRCALL *utf8Convert)(const ENCODING *enc,
const char **fromP,
const char *fromLim, char **toP,
const char *toLim);
enum XML_Convert_Result(PTRCALL *utf16Convert)(const ENCODING *enc,
const char **fromP,
const char *fromLim,
unsigned short **toP,
const unsigned short *toLim);
int minBytesPerChar;
char isUtf8;
char isUtf16;
};
/* Scan the string starting at ptr until the end of the next complete
token, but do not scan past eptr. Return an integer giving the
type of token.
Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
Return XML_TOK_PARTIAL when the string does not contain a complete
token; nextTokPtr will not be set.
Return XML_TOK_INVALID when the string does not start a valid
token; nextTokPtr will be set to point to the character which made
the token invalid.
Otherwise the string starts with a valid token; nextTokPtr will be
set to point to the character following the end of that token.
Each data character counts as a single token, but adjacent data
characters may be returned together. Similarly for characters in
the prolog outside literals, comments and processing instructions.
*/
#define XmlTok(enc, state, ptr, end, nextTokPtr) \
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
#define XmlContentTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
#ifdef XML_DTD
# define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
#endif /* XML_DTD */
/* This is used for performing a 2nd-level tokenization on the content
of a literal that has already been returned by XmlTok.
*/
#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
#define XmlNameLength(enc, ptr) (((enc)->nameLength)(enc, ptr))
#define XmlSkipS(enc, ptr) (((enc)->skipS)(enc, ptr))
#define XmlGetAttributes(enc, ptr, attsMax, atts) \
(((enc)->getAtts)(enc, ptr, attsMax, atts))
#define XmlCharRefNumber(enc, ptr) (((enc)->charRefNumber)(enc, ptr))
#define XmlPredefinedEntityName(enc, ptr, end) \
(((enc)->predefinedEntityName)(enc, ptr, end))
#define XmlUpdatePosition(enc, ptr, end, pos) \
(((enc)->updatePosition)(enc, ptr, end, pos))
#define XmlIsPublicId(enc, ptr, end, badPtr) \
(((enc)->isPublicId)(enc, ptr, end, badPtr))
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
typedef struct {
ENCODING initEnc;
const ENCODING **encPtr;
} INIT_ENCODING;
int XmlParseXmlDecl(int isGeneralTextEntity, const ENCODING *enc,
const char *ptr, const char *end, const char **badPtr,
const char **versionPtr, const char **versionEndPtr,
const char **encodingNamePtr,
const ENCODING **namedEncodingPtr, int *standalonePtr);
int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING *XmlGetUtf8InternalEncoding(void);
const ENCODING *XmlGetUtf16InternalEncoding(void);
int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
int XmlSizeOfUnknownEncoding(void);
typedef int(XMLCALL *CONVERTER)(void *userData, const char *p);
ENCODING *XmlInitUnknownEncoding(void *mem, int *table, CONVERTER convert,
void *userData);
int XmlParseXmlDeclNS(int isGeneralTextEntity, const ENCODING *enc,
const char *ptr, const char *end, const char **badPtr,
const char **versionPtr, const char **versionEndPtr,
const char **encodingNamePtr,
const ENCODING **namedEncodingPtr, int *standalonePtr);
int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
ENCODING *XmlInitUnknownEncodingNS(void *mem, int *table, CONVERTER convert,
void *userData);
#ifdef __cplusplus
}
#endif
#endif /* not XmlTok_INCLUDED */

1804
vendor/POCO/XML/src/xmltok_impl.c vendored Normal file

File diff suppressed because it is too large Load Diff

73
vendor/POCO/XML/src/xmltok_impl.h vendored Normal file
View File

@@ -0,0 +1,73 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
enum {
BT_NONXML, /* e.g. noncharacter-FFFF */
BT_MALFORM, /* illegal, with regard to encoding */
BT_LT, /* less than = "<" */
BT_AMP, /* ampersand = "&" */
BT_RSQB, /* right square bracket = "[" */
BT_LEAD2, /* lead byte of a 2-byte UTF-8 character */
BT_LEAD3, /* lead byte of a 3-byte UTF-8 character */
BT_LEAD4, /* lead byte of a 4-byte UTF-8 character */
BT_TRAIL, /* trailing unit, e.g. second 16-bit unit of a 4-byte char. */
BT_CR, /* carriage return = "\r" */
BT_LF, /* line feed = "\n" */
BT_GT, /* greater than = ">" */
BT_QUOT, /* quotation character = "\"" */
BT_APOS, /* aposthrophe = "'" */
BT_EQUALS, /* equal sign = "=" */
BT_QUEST, /* question mark = "?" */
BT_EXCL, /* exclamation mark = "!" */
BT_SOL, /* solidus, slash = "/" */
BT_SEMI, /* semicolon = ";" */
BT_NUM, /* number sign = "#" */
BT_LSQB, /* left square bracket = "[" */
BT_S, /* white space, e.g. "\t", " "[, "\r"] */
BT_NMSTRT, /* non-hex name start letter = "G".."Z" + "g".."z" + "_" */
BT_COLON, /* colon = ":" */
BT_HEX, /* hex letter = "A".."F" + "a".."f" */
BT_DIGIT, /* digit = "0".."9" */
BT_NAME, /* dot and middle dot = "." + chr(0xb7) */
BT_MINUS, /* minus = "-" */
BT_OTHER, /* known not to be a name or name start character */
BT_NONASCII, /* might be a name or name start character */
BT_PERCNT, /* percent sign = "%" */
BT_LPAR, /* left parenthesis = "(" */
BT_RPAR, /* right parenthesis = "(" */
BT_AST, /* asterisk = "*" */
BT_PLUS, /* plus sign = "+" */
BT_COMMA, /* comma = "," */
BT_VERBAR /* vertical bar = "|" */
};
#include <stddef.h>

118
vendor/POCO/XML/src/xmltok_ns.c vendored Normal file
View File

@@ -0,0 +1,118 @@
/* This file is included!
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifdef XML_TOK_NS_C
const ENCODING *
NS(XmlGetUtf8InternalEncoding)(void) {
return &ns(internal_utf8_encoding).enc;
}
const ENCODING *
NS(XmlGetUtf16InternalEncoding)(void) {
# if BYTEORDER == 1234
return &ns(internal_little2_encoding).enc;
# elif BYTEORDER == 4321
return &ns(internal_big2_encoding).enc;
# else
const short n = 1;
return (*(const char *)&n ? &ns(internal_little2_encoding).enc
: &ns(internal_big2_encoding).enc);
# endif
}
static const ENCODING *const NS(encodings)[] = {
&ns(latin1_encoding).enc, &ns(ascii_encoding).enc,
&ns(utf8_encoding).enc, &ns(big2_encoding).enc,
&ns(big2_encoding).enc, &ns(little2_encoding).enc,
&ns(utf8_encoding).enc /* NO_ENC */
};
static int PTRCALL
NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) {
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE,
ptr, end, nextTokPtr);
}
static int PTRCALL
NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
const char **nextTokPtr) {
return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE,
ptr, end, nextTokPtr);
}
int
NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
const char *name) {
int i = getEncodingIndex(name);
if (i == UNKNOWN_ENC)
return 0;
SET_INIT_ENC_INDEX(p, i);
p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
p->initEnc.updatePosition = initUpdatePosition;
p->encPtr = encPtr;
*encPtr = &(p->initEnc);
return 1;
}
static const ENCODING *
NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) {
# define ENCODING_MAX 128
char buf[ENCODING_MAX];
char *p = buf;
int i;
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
if (ptr != end)
return 0;
*p = 0;
if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
return enc;
i = getEncodingIndex(buf);
if (i == UNKNOWN_ENC)
return 0;
return NS(encodings)[i];
}
int
NS(XmlParseXmlDecl)(int isGeneralTextEntity, const ENCODING *enc,
const char *ptr, const char *end, const char **badPtr,
const char **versionPtr, const char **versionEndPtr,
const char **encodingName, const ENCODING **encoding,
int *standalone) {
return doParseXmlDecl(NS(findEncoding), isGeneralTextEntity, enc, ptr, end,
badPtr, versionPtr, versionEndPtr, encodingName,
encoding, standalone);
}
#endif /* XML_TOK_NS_C */