diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/libs/poco/XML | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/poco/XML')
147 files changed, 20653 insertions, 20653 deletions
diff --git a/contrib/libs/poco/XML/include/Poco/DOM/AbstractContainerNode.h b/contrib/libs/poco/XML/include/Poco/DOM/AbstractContainerNode.h index 60dc9589d7..0bc75b6ac4 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/AbstractContainerNode.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/AbstractContainerNode.h @@ -1,78 +1,78 @@ -// -// AbstractContainerNode.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the AbstractContainerNode class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_AbstractContainerNode_INCLUDED -#define DOM_AbstractContainerNode_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractNode.h" - - -namespace Poco { -namespace XML { - - -class XML_API AbstractContainerNode: public AbstractNode - /// AbstractContainerNode is an implementation of Node - /// that stores and manages child nodes. - /// - /// Child nodes are organized in a single linked list. -{ -public: - // Node - Node* firstChild() const; - Node* lastChild() const; - Node* insertBefore(Node* newChild, Node* refChild); - Node* replaceChild(Node* newChild, Node* oldChild); - Node* removeChild(Node* oldChild); - Node* appendChild(Node* newChild); - bool hasChildNodes() const; - bool hasAttributes() const; - Node* getNodeByPath(const XMLString& path) const; - Node* getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const; - -protected: - AbstractContainerNode(Document* pOwnerDocument); - AbstractContainerNode(Document* pOwnerDocument, const AbstractContainerNode& node); - ~AbstractContainerNode(); - - void dispatchNodeRemovedFromDocument(); - void dispatchNodeInsertedIntoDocument(); - - static const Node* findNode(XMLString::const_iterator& it, const XMLString::const_iterator& end, const Node* pNode, const NSMap* pNSMap); - static const Node* findElement(const XMLString& name, const Node* pNode, const NSMap* pNSMap); - static const Node* findElement(int index, const Node* pNode, const NSMap* pNSMap); - static const Node* findElement(const XMLString& attr, const XMLString& value, const Node* pNode, const NSMap* pNSMap); - static const Attr* findAttribute(const XMLString& name, const Node* pNode, const NSMap* pNSMap); - bool hasAttributeValue(const XMLString& name, const XMLString& value, const NSMap* pNSMap) const; - static bool namesAreEqual(const Node* pNode1, const Node* pNode2, const NSMap* pNSMap); - static bool namesAreEqual(const Node* pNode, const XMLString& name, const NSMap* pNSMap); - - static const XMLString WILDCARD; - -private: - AbstractNode* _pFirstChild; - - friend class AbstractNode; - friend class NodeAppender; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_AbstractContainerNode_INCLUDED +// +// AbstractContainerNode.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the AbstractContainerNode class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_AbstractContainerNode_INCLUDED +#define DOM_AbstractContainerNode_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractNode.h" + + +namespace Poco { +namespace XML { + + +class XML_API AbstractContainerNode: public AbstractNode + /// AbstractContainerNode is an implementation of Node + /// that stores and manages child nodes. + /// + /// Child nodes are organized in a single linked list. +{ +public: + // Node + Node* firstChild() const; + Node* lastChild() const; + Node* insertBefore(Node* newChild, Node* refChild); + Node* replaceChild(Node* newChild, Node* oldChild); + Node* removeChild(Node* oldChild); + Node* appendChild(Node* newChild); + bool hasChildNodes() const; + bool hasAttributes() const; + Node* getNodeByPath(const XMLString& path) const; + Node* getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const; + +protected: + AbstractContainerNode(Document* pOwnerDocument); + AbstractContainerNode(Document* pOwnerDocument, const AbstractContainerNode& node); + ~AbstractContainerNode(); + + void dispatchNodeRemovedFromDocument(); + void dispatchNodeInsertedIntoDocument(); + + static const Node* findNode(XMLString::const_iterator& it, const XMLString::const_iterator& end, const Node* pNode, const NSMap* pNSMap); + static const Node* findElement(const XMLString& name, const Node* pNode, const NSMap* pNSMap); + static const Node* findElement(int index, const Node* pNode, const NSMap* pNSMap); + static const Node* findElement(const XMLString& attr, const XMLString& value, const Node* pNode, const NSMap* pNSMap); + static const Attr* findAttribute(const XMLString& name, const Node* pNode, const NSMap* pNSMap); + bool hasAttributeValue(const XMLString& name, const XMLString& value, const NSMap* pNSMap) const; + static bool namesAreEqual(const Node* pNode1, const Node* pNode2, const NSMap* pNSMap); + static bool namesAreEqual(const Node* pNode, const XMLString& name, const NSMap* pNSMap); + + static const XMLString WILDCARD; + +private: + AbstractNode* _pFirstChild; + + friend class AbstractNode; + friend class NodeAppender; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_AbstractContainerNode_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/AbstractNode.h b/contrib/libs/poco/XML/include/Poco/DOM/AbstractNode.h index cedcc73920..fd0761e572 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/AbstractNode.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/AbstractNode.h @@ -1,125 +1,125 @@ -// -// AbstractNode.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the AbstractNode class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_AbstractNode_INCLUDED -#define DOM_AbstractNode_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/Node.h" -#include "Poco/DOM/MutationEvent.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class AbstractContainerNode; -class Attr; -class EventDispatcher; - - -class XML_API AbstractNode: public Node - /// AbstractNode provides a basic implementation - /// of the Node interface for all types of nodes - /// that do not contain other nodes. -{ -public: - // Node - const XMLString& nodeName() const; - const XMLString& getNodeValue() const; - void setNodeValue(const XMLString& value); - Node* parentNode() const; - NodeList* childNodes() const; - Node* firstChild() const; - Node* lastChild() const; - Node* previousSibling() const; - Node* nextSibling() const; - NamedNodeMap* attributes() const; - Document* ownerDocument() const; - Node* insertBefore(Node* newChild, Node* refChild); - Node* replaceChild(Node* newChild, Node* oldChild); - Node* removeChild(Node* oldChild); - Node* appendChild(Node* newChild); - bool hasChildNodes() const; - Node* cloneNode(bool deep) const; - void normalize(); - bool isSupported(const XMLString& feature, const XMLString& version) const; - const XMLString& namespaceURI() const; - XMLString prefix() const; - const XMLString& localName() const; - bool hasAttributes() const; - - // EventTarget - void addEventListener(const XMLString& type, EventListener* listener, bool useCapture); - void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture); - bool dispatchEvent(Event* evt); - - // Extensions - XMLString innerText() const; - Node* getNodeByPath(const XMLString& path) const; - Node* getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const; - - virtual void autoRelease(); - -protected: - AbstractNode(Document* pOwnerDocument); - AbstractNode(Document* pOwnerDocument, const AbstractNode& node); - ~AbstractNode(); - - virtual Node* copyNode(bool deep, Document* pOwnerDocument) const = 0; - - virtual bool events() const; - virtual bool eventsSuspended() const; - void captureEvent(Event* evt); - void bubbleEvent(Event* evt); - void dispatchSubtreeModified(); - void dispatchNodeInserted(); - void dispatchNodeRemoved(); - virtual void dispatchNodeRemovedFromDocument(); - virtual void dispatchNodeInsertedIntoDocument(); - void dispatchAttrModified(Attr* pAttr, MutationEvent::AttrChangeType changeType, const XMLString& prevValue, const XMLString& newValue); - void dispatchCharacterDataModified(const XMLString& prevValue, const XMLString& newValue); - void setOwnerDocument(Document* pOwnerDocument); - - static const XMLString EMPTY_STRING; - -private: - AbstractNode(); - - AbstractContainerNode* _pParent; - AbstractNode* _pNext; - Document* _pOwner; - EventDispatcher* _pEventDispatcher; - - static const XMLString NODE_NAME; - - friend class AbstractContainerNode; - friend class Document; - friend class DocumentFragment; - friend class Element; - friend class Attr; - friend class CharacterData; - friend class DOMBuilder; - friend class NodeAppender; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_AbstractNode_INCLUDED +// +// AbstractNode.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the AbstractNode class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_AbstractNode_INCLUDED +#define DOM_AbstractNode_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/Node.h" +#include "Poco/DOM/MutationEvent.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class AbstractContainerNode; +class Attr; +class EventDispatcher; + + +class XML_API AbstractNode: public Node + /// AbstractNode provides a basic implementation + /// of the Node interface for all types of nodes + /// that do not contain other nodes. +{ +public: + // Node + const XMLString& nodeName() const; + const XMLString& getNodeValue() const; + void setNodeValue(const XMLString& value); + Node* parentNode() const; + NodeList* childNodes() const; + Node* firstChild() const; + Node* lastChild() const; + Node* previousSibling() const; + Node* nextSibling() const; + NamedNodeMap* attributes() const; + Document* ownerDocument() const; + Node* insertBefore(Node* newChild, Node* refChild); + Node* replaceChild(Node* newChild, Node* oldChild); + Node* removeChild(Node* oldChild); + Node* appendChild(Node* newChild); + bool hasChildNodes() const; + Node* cloneNode(bool deep) const; + void normalize(); + bool isSupported(const XMLString& feature, const XMLString& version) const; + const XMLString& namespaceURI() const; + XMLString prefix() const; + const XMLString& localName() const; + bool hasAttributes() const; + + // EventTarget + void addEventListener(const XMLString& type, EventListener* listener, bool useCapture); + void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture); + bool dispatchEvent(Event* evt); + + // Extensions + XMLString innerText() const; + Node* getNodeByPath(const XMLString& path) const; + Node* getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const; + + virtual void autoRelease(); + +protected: + AbstractNode(Document* pOwnerDocument); + AbstractNode(Document* pOwnerDocument, const AbstractNode& node); + ~AbstractNode(); + + virtual Node* copyNode(bool deep, Document* pOwnerDocument) const = 0; + + virtual bool events() const; + virtual bool eventsSuspended() const; + void captureEvent(Event* evt); + void bubbleEvent(Event* evt); + void dispatchSubtreeModified(); + void dispatchNodeInserted(); + void dispatchNodeRemoved(); + virtual void dispatchNodeRemovedFromDocument(); + virtual void dispatchNodeInsertedIntoDocument(); + void dispatchAttrModified(Attr* pAttr, MutationEvent::AttrChangeType changeType, const XMLString& prevValue, const XMLString& newValue); + void dispatchCharacterDataModified(const XMLString& prevValue, const XMLString& newValue); + void setOwnerDocument(Document* pOwnerDocument); + + static const XMLString EMPTY_STRING; + +private: + AbstractNode(); + + AbstractContainerNode* _pParent; + AbstractNode* _pNext; + Document* _pOwner; + EventDispatcher* _pEventDispatcher; + + static const XMLString NODE_NAME; + + friend class AbstractContainerNode; + friend class Document; + friend class DocumentFragment; + friend class Element; + friend class Attr; + friend class CharacterData; + friend class DOMBuilder; + friend class NodeAppender; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_AbstractNode_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/Attr.h b/contrib/libs/poco/XML/include/Poco/DOM/Attr.h index 13ace7ecce..3498a0385b 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/Attr.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/Attr.h @@ -1,180 +1,180 @@ -// -// Attr.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM Attr class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_Attr_INCLUDED -#define DOM_Attr_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractNode.h" -#include "Poco/DOM/Element.h" -#include "Poco/XML/Name.h" - - -namespace Poco { -namespace XML { - - -class XML_API Attr: public AbstractNode - /// The Attr interface represents an attribute in an Element object. Typically - /// the allowable values for the attribute are defined in a document type definition. - /// - /// Attr objects inherit the Node interface, but since they are not actually - /// child nodes of the element they describe, the DOM does not consider them - /// part of the document tree. Thus, the Node attributes parentNode, previousSibling, - /// and nextSibling have a null value for Attr objects. The DOM takes the view - /// that attributes are properties of elements rather than having a separate - /// identity from the elements they are associated with; this should make it - /// more efficient to implement such features as default attributes associated - /// with all elements of a given type. Furthermore, Attr nodes may not be immediate - /// children of a DocumentFragment. However, they can be associated with Element - /// nodes contained within a DocumentFragment. In short, users and implementors - /// of the DOM need to be aware that Attr nodes have some things in common with - /// other objects inheriting the Node interface, but they also are quite distinct. - /// - /// The attribute's effective value is determined as follows: if this attribute - /// has been explicitly assigned any value, that value is the attribute's effective - /// value; otherwise, if there is a declaration for this attribute, and that - /// declaration includes a default value, then that default value is the attribute's - /// effective value; otherwise, the attribute does not exist on this element - /// in the structure model until it has been explicitly added. Note that the - /// nodeValue attribute on the Attr instance can also be used to retrieve the - /// string version of the attribute's value(s). - /// - /// In XML, where the value of an attribute can contain entity references, the - /// child nodes of the Attr node provide a representation in which entity references - /// are not expanded. These child nodes may be either Text or EntityReference - /// nodes. Because the attribute type may be unknown, there are no tokenized - /// attribute values. -{ -public: - const XMLString& name() const; - /// Returns the name of this attribute. - - bool specified() const; - /// If this attribute was explicitly given a value in the original document, - /// this is true; otherwise, it is false. Note that the implementation is in - /// charge of this attribute, not the user. If the user changes the value of - /// the attribute (even if it ends up having the same value as the default value) - /// then the specified flag is automatically flipped to true. To re-specify - /// the attribute as the default value from the DTD, the user must delete the - /// attribute. The implementation will then make a new attribute available with - /// specified set to false and the default value (if one exists). - /// In summary: - /// - /// * If the attribute has an assigned value in the document then specified - /// is true, and the value is the assigned value. - /// * If the attribute has no assigned value in the document and has a default - /// value in the DTD, then specified is false, and the value is the default - /// value in the DTD. - /// * If the attribute has no assigned value in the document and has a value - /// of #IMPLIED in the DTD, then the attribute does not appear in the structure - /// model of the document. - /// * If the attribute is not associated to any element (i.e. because it - /// was just created or was obtained from some removal or cloning operation) - /// specified is true. - - const XMLString& value() const; - /// Returns the value of the attribute as a string. Character - /// and general entity references are replaced with their values. See also the - /// method getAttribute on the Element interface. - - const XMLString& getValue() const; - /// Returns the value of the attribute as a string. Character - /// and general entity references are replaced with their values. See also the - /// method getAttribute on the Element interface. - - void setValue(const XMLString& value); - /// Sets the value of the attribute as a string. - /// This creates a Text node with the unparsed contents of the string. - /// I.e. any characters that an XML processor would recognize as markup are - /// instead treated as literal text. See also the method setAttribute on the - /// Element interface. - - // DOM Level 2 - Element* ownerElement() const; - /// The Element node this attribute is attached to or null - /// if this attribute is not in use. - - // Node - Node* parentNode() const; - const XMLString& nodeName() const; - const XMLString& getNodeValue() const; - void setNodeValue(const XMLString& value); - unsigned short nodeType() const; - Node* previousSibling() const; - const XMLString& namespaceURI() const; - XMLString prefix() const; - const XMLString& localName() const; - - // Non-standard extensions - XMLString innerText() const; - -protected: - Attr(Document* pOwnerDocument, Element* pOwnerElement, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& value, bool specified = true); - Attr(Document* pOwnerDocument, const Attr& attr); - ~Attr(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - -private: - const Name& _name; - XMLString _value; - bool _specified; - - friend class Document; - friend class Element; - friend class DOMBuilder; -}; - - -// -// inlines -// -inline const XMLString& Attr::name() const -{ - return _name.qname(); -} - - -inline const XMLString& Attr::value() const -{ - return _value; -} - - -inline const XMLString& Attr::getValue() const -{ - return _value; -} - - -inline bool Attr::specified() const -{ - return _specified; -} - - -inline Element* Attr::ownerElement() const -{ - return static_cast<Element*>(_pParent); -} - - -} } // namespace Poco::XML - - -#endif // DOM_Attr_INCLUDED +// +// Attr.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM Attr class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_Attr_INCLUDED +#define DOM_Attr_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractNode.h" +#include "Poco/DOM/Element.h" +#include "Poco/XML/Name.h" + + +namespace Poco { +namespace XML { + + +class XML_API Attr: public AbstractNode + /// The Attr interface represents an attribute in an Element object. Typically + /// the allowable values for the attribute are defined in a document type definition. + /// + /// Attr objects inherit the Node interface, but since they are not actually + /// child nodes of the element they describe, the DOM does not consider them + /// part of the document tree. Thus, the Node attributes parentNode, previousSibling, + /// and nextSibling have a null value for Attr objects. The DOM takes the view + /// that attributes are properties of elements rather than having a separate + /// identity from the elements they are associated with; this should make it + /// more efficient to implement such features as default attributes associated + /// with all elements of a given type. Furthermore, Attr nodes may not be immediate + /// children of a DocumentFragment. However, they can be associated with Element + /// nodes contained within a DocumentFragment. In short, users and implementors + /// of the DOM need to be aware that Attr nodes have some things in common with + /// other objects inheriting the Node interface, but they also are quite distinct. + /// + /// The attribute's effective value is determined as follows: if this attribute + /// has been explicitly assigned any value, that value is the attribute's effective + /// value; otherwise, if there is a declaration for this attribute, and that + /// declaration includes a default value, then that default value is the attribute's + /// effective value; otherwise, the attribute does not exist on this element + /// in the structure model until it has been explicitly added. Note that the + /// nodeValue attribute on the Attr instance can also be used to retrieve the + /// string version of the attribute's value(s). + /// + /// In XML, where the value of an attribute can contain entity references, the + /// child nodes of the Attr node provide a representation in which entity references + /// are not expanded. These child nodes may be either Text or EntityReference + /// nodes. Because the attribute type may be unknown, there are no tokenized + /// attribute values. +{ +public: + const XMLString& name() const; + /// Returns the name of this attribute. + + bool specified() const; + /// If this attribute was explicitly given a value in the original document, + /// this is true; otherwise, it is false. Note that the implementation is in + /// charge of this attribute, not the user. If the user changes the value of + /// the attribute (even if it ends up having the same value as the default value) + /// then the specified flag is automatically flipped to true. To re-specify + /// the attribute as the default value from the DTD, the user must delete the + /// attribute. The implementation will then make a new attribute available with + /// specified set to false and the default value (if one exists). + /// In summary: + /// + /// * If the attribute has an assigned value in the document then specified + /// is true, and the value is the assigned value. + /// * If the attribute has no assigned value in the document and has a default + /// value in the DTD, then specified is false, and the value is the default + /// value in the DTD. + /// * If the attribute has no assigned value in the document and has a value + /// of #IMPLIED in the DTD, then the attribute does not appear in the structure + /// model of the document. + /// * If the attribute is not associated to any element (i.e. because it + /// was just created or was obtained from some removal or cloning operation) + /// specified is true. + + const XMLString& value() const; + /// Returns the value of the attribute as a string. Character + /// and general entity references are replaced with their values. See also the + /// method getAttribute on the Element interface. + + const XMLString& getValue() const; + /// Returns the value of the attribute as a string. Character + /// and general entity references are replaced with their values. See also the + /// method getAttribute on the Element interface. + + void setValue(const XMLString& value); + /// Sets the value of the attribute as a string. + /// This creates a Text node with the unparsed contents of the string. + /// I.e. any characters that an XML processor would recognize as markup are + /// instead treated as literal text. See also the method setAttribute on the + /// Element interface. + + // DOM Level 2 + Element* ownerElement() const; + /// The Element node this attribute is attached to or null + /// if this attribute is not in use. + + // Node + Node* parentNode() const; + const XMLString& nodeName() const; + const XMLString& getNodeValue() const; + void setNodeValue(const XMLString& value); + unsigned short nodeType() const; + Node* previousSibling() const; + const XMLString& namespaceURI() const; + XMLString prefix() const; + const XMLString& localName() const; + + // Non-standard extensions + XMLString innerText() const; + +protected: + Attr(Document* pOwnerDocument, Element* pOwnerElement, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& value, bool specified = true); + Attr(Document* pOwnerDocument, const Attr& attr); + ~Attr(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + +private: + const Name& _name; + XMLString _value; + bool _specified; + + friend class Document; + friend class Element; + friend class DOMBuilder; +}; + + +// +// inlines +// +inline const XMLString& Attr::name() const +{ + return _name.qname(); +} + + +inline const XMLString& Attr::value() const +{ + return _value; +} + + +inline const XMLString& Attr::getValue() const +{ + return _value; +} + + +inline bool Attr::specified() const +{ + return _specified; +} + + +inline Element* Attr::ownerElement() const +{ + return static_cast<Element*>(_pParent); +} + + +} } // namespace Poco::XML + + +#endif // DOM_Attr_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/AttrMap.h b/contrib/libs/poco/XML/include/Poco/DOM/AttrMap.h index 41f34fd638..ba09d16a18 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/AttrMap.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/AttrMap.h @@ -1,65 +1,65 @@ -// -// AttrMap.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the AttrMap class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_AttrMap_INCLUDED -#define DOM_AttrMap_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/NamedNodeMap.h" - - -namespace Poco { -namespace XML { - - -class Element; - - -class XML_API AttrMap: public NamedNodeMap - // This implementation of NamedNodeMap is - // returned by Element::attributes() -{ -public: - Node* getNamedItem(const XMLString& name) const; - Node* setNamedItem(Node* arg); - Node* removeNamedItem(const XMLString& name); - Node* item(unsigned long index) const; - unsigned long length() const; - - Node* getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const; - Node* setNamedItemNS(Node* arg); - Node* removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName); - - void autoRelease(); - -protected: - AttrMap(Element* pElement); - ~AttrMap(); - -private: - AttrMap(); - - Element* _pElement; - - friend class Element; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_AttrMap_INCLUDED +// +// AttrMap.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the AttrMap class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_AttrMap_INCLUDED +#define DOM_AttrMap_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/NamedNodeMap.h" + + +namespace Poco { +namespace XML { + + +class Element; + + +class XML_API AttrMap: public NamedNodeMap + // This implementation of NamedNodeMap is + // returned by Element::attributes() +{ +public: + Node* getNamedItem(const XMLString& name) const; + Node* setNamedItem(Node* arg); + Node* removeNamedItem(const XMLString& name); + Node* item(unsigned long index) const; + unsigned long length() const; + + Node* getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const; + Node* setNamedItemNS(Node* arg); + Node* removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName); + + void autoRelease(); + +protected: + AttrMap(Element* pElement); + ~AttrMap(); + +private: + AttrMap(); + + Element* _pElement; + + friend class Element; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_AttrMap_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/AutoPtr.h b/contrib/libs/poco/XML/include/Poco/DOM/AutoPtr.h index 85f83d49f7..5be1728f95 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/AutoPtr.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/AutoPtr.h @@ -1,35 +1,35 @@ -// -// AutoPtr.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Import Poco::AutoPtr into the XML namespace. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DOMAutoPtr_INCLUDED -#define DOM_DOMAutoPtr_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/AutoPtr.h" - - -namespace Poco { -namespace XML { - - -using Poco::AutoPtr; - - -} } // namespace Poco::XML - - -#endif // DOM_DOMAutoPtr_INCLUDED +// +// AutoPtr.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Import Poco::AutoPtr into the XML namespace. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DOMAutoPtr_INCLUDED +#define DOM_DOMAutoPtr_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/AutoPtr.h" + + +namespace Poco { +namespace XML { + + +using Poco::AutoPtr; + + +} } // namespace Poco::XML + + +#endif // DOM_DOMAutoPtr_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/CDATASection.h b/contrib/libs/poco/XML/include/Poco/DOM/CDATASection.h index 7a0e82b18a..c38c7d1da7 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/CDATASection.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/CDATASection.h @@ -1,84 +1,84 @@ -// -// CDATASection.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM CDATASection class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_CDATASection_INCLUDED -#define DOM_CDATASection_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/Text.h" - - -namespace Poco { -namespace XML { - - -class XML_API CDATASection: public Text - /// CDATA sections are used to escape blocks of text containing characters that - /// would otherwise be regarded as markup. The only delimiter that is recognized - /// in a CDATA section is the "]]>" string that ends the CDATA section. CDATA - /// sections cannot be nested. Their primary purpose is for including material - /// such as XML fragments, without needing to escape all the delimiters. - /// - /// The DOMString attribute of the Text node holds the text that is contained - /// by the CDATA section. Note that this may contain characters that need to - /// be escaped outside of CDATA sections and that, depending on the character - /// encoding ("charset") chosen for serialization, it may be impossible to write - /// out some characters as part of a CDATA section. - /// - /// The CDATASection interface inherits from the CharacterData interface through - /// the Text interface. Adjacent CDATASection nodes are not merged by use of - /// the normalize method on the Element interface. - /// - /// Note: Because no markup is recognized within a CDATASection, character numeric - /// references cannot be used as an escape mechanism when serializing. Therefore, - /// action needs to be taken when serializing a CDATASection with a character - /// encoding where some of the contained characters cannot be represented. Failure - /// to do so would not produce well-formed XML. - /// One potential solution in the serialization process is to end the CDATA - /// section before the character, output the character using a character reference - /// or entity reference, and open a new CDATA section for any further characters - /// in the text node. Note, however, that some code conversion libraries at - /// the time of writing do not return an error or exception when a character - /// is missing from the encoding, making the task of ensuring that data is not - /// corrupted on serialization more difficult. -{ -public: - // Text - Text* splitText(unsigned long offset); - - // Node - const XMLString& nodeName() const; - unsigned short nodeType() const; - -protected: - CDATASection(Document* pOwnerDocument, const XMLString& data); - CDATASection(Document* pOwnerDocument, const CDATASection& sec); - ~CDATASection(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - -private: - static const XMLString NODE_NAME; - - friend class Document; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_CDATASection_INCLUDED +// +// CDATASection.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM CDATASection class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_CDATASection_INCLUDED +#define DOM_CDATASection_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/Text.h" + + +namespace Poco { +namespace XML { + + +class XML_API CDATASection: public Text + /// CDATA sections are used to escape blocks of text containing characters that + /// would otherwise be regarded as markup. The only delimiter that is recognized + /// in a CDATA section is the "]]>" string that ends the CDATA section. CDATA + /// sections cannot be nested. Their primary purpose is for including material + /// such as XML fragments, without needing to escape all the delimiters. + /// + /// The DOMString attribute of the Text node holds the text that is contained + /// by the CDATA section. Note that this may contain characters that need to + /// be escaped outside of CDATA sections and that, depending on the character + /// encoding ("charset") chosen for serialization, it may be impossible to write + /// out some characters as part of a CDATA section. + /// + /// The CDATASection interface inherits from the CharacterData interface through + /// the Text interface. Adjacent CDATASection nodes are not merged by use of + /// the normalize method on the Element interface. + /// + /// Note: Because no markup is recognized within a CDATASection, character numeric + /// references cannot be used as an escape mechanism when serializing. Therefore, + /// action needs to be taken when serializing a CDATASection with a character + /// encoding where some of the contained characters cannot be represented. Failure + /// to do so would not produce well-formed XML. + /// One potential solution in the serialization process is to end the CDATA + /// section before the character, output the character using a character reference + /// or entity reference, and open a new CDATA section for any further characters + /// in the text node. Note, however, that some code conversion libraries at + /// the time of writing do not return an error or exception when a character + /// is missing from the encoding, making the task of ensuring that data is not + /// corrupted on serialization more difficult. +{ +public: + // Text + Text* splitText(unsigned long offset); + + // Node + const XMLString& nodeName() const; + unsigned short nodeType() const; + +protected: + CDATASection(Document* pOwnerDocument, const XMLString& data); + CDATASection(Document* pOwnerDocument, const CDATASection& sec); + ~CDATASection(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + +private: + static const XMLString NODE_NAME; + + friend class Document; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_CDATASection_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/CharacterData.h b/contrib/libs/poco/XML/include/Poco/DOM/CharacterData.h index af5697da7f..29d73519b1 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/CharacterData.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/CharacterData.h @@ -1,123 +1,123 @@ -// -// CharacterData.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM CharacterData class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_CharacterData_INCLUDED -#define DOM_CharacterData_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractNode.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API CharacterData: public AbstractNode - /// The CharacterData interface extends Node with a set of attributes and methods - /// for accessing character data in the DOM. For clarity this set is defined - /// here rather than on each object that uses these attributes and methods. - /// No DOM objects correspond directly to CharacterData, though Text and others - /// do inherit the interface from it. All offsets in this interface start from 0. - /// - /// Text strings in the DOM are represented in either UTF-8 (if XML_UNICODE_WCHAR_T is - /// not defined) or in UTF-16 (if XML_UNICODE_WCHAR_T is defined). - /// Indexing on character data is done in XMLChar units. -{ -public: - const XMLString& data() const; - /// Returns the character data of the node that - /// implements the interface. - - const XMLString& getData() const; - /// Returns the character data of the node that - /// implements the interface. - - void setData(const XMLString& data); - /// Sets the character data of the node that - /// implements the interface. - - unsigned long length() const; - /// Returns the number of XMLChars that are available - /// through getData and substringData. This may have the - /// value zero. - - XMLString substringData(unsigned long offset, unsigned long count) const; - /// Extracts a range of data from the node. - /// If offset and count exceeds the length, then all - /// the characters to the end of the data are returned. - - void appendData(const XMLString& arg); - /// Append the string to the end of the character data - /// of the node. - - void insertData(unsigned long offset, const XMLString& arg); - /// Insert a string at the specified character offset. - - void deleteData(unsigned long offset, unsigned long count); - /// Remove a range of characters from the node. - - void replaceData(unsigned long offset, unsigned long count, const XMLString& arg); - /// Replace the characters starting at the specified character - /// offset with the specified string. - - // Non-standard extensions - XMLString trimmedData() const; - /// Returns the character data of that node with - /// all surrounding whitespace removed. - /// - /// This method is an extension to the W3C Document Object Model. - - // Node - const XMLString& getNodeValue() const; - void setNodeValue(const XMLString& value); - -protected: - CharacterData(Document* pOwnerDocument, const XMLString& data); - CharacterData(Document* pOwnerDocument, const CharacterData& data); - ~CharacterData(); - -private: - XMLString _data; -}; - - -// -// inlines -// -inline const XMLString& CharacterData::data() const -{ - return _data; -} - - -inline const XMLString& CharacterData::getData() const -{ - return _data; -} - - -inline unsigned long CharacterData::length() const -{ - return (unsigned long) _data.length(); -} - - -} } // namespace Poco::XML - - -#endif // DOM_CharacterData_INCLUDED +// +// CharacterData.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM CharacterData class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_CharacterData_INCLUDED +#define DOM_CharacterData_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractNode.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API CharacterData: public AbstractNode + /// The CharacterData interface extends Node with a set of attributes and methods + /// for accessing character data in the DOM. For clarity this set is defined + /// here rather than on each object that uses these attributes and methods. + /// No DOM objects correspond directly to CharacterData, though Text and others + /// do inherit the interface from it. All offsets in this interface start from 0. + /// + /// Text strings in the DOM are represented in either UTF-8 (if XML_UNICODE_WCHAR_T is + /// not defined) or in UTF-16 (if XML_UNICODE_WCHAR_T is defined). + /// Indexing on character data is done in XMLChar units. +{ +public: + const XMLString& data() const; + /// Returns the character data of the node that + /// implements the interface. + + const XMLString& getData() const; + /// Returns the character data of the node that + /// implements the interface. + + void setData(const XMLString& data); + /// Sets the character data of the node that + /// implements the interface. + + unsigned long length() const; + /// Returns the number of XMLChars that are available + /// through getData and substringData. This may have the + /// value zero. + + XMLString substringData(unsigned long offset, unsigned long count) const; + /// Extracts a range of data from the node. + /// If offset and count exceeds the length, then all + /// the characters to the end of the data are returned. + + void appendData(const XMLString& arg); + /// Append the string to the end of the character data + /// of the node. + + void insertData(unsigned long offset, const XMLString& arg); + /// Insert a string at the specified character offset. + + void deleteData(unsigned long offset, unsigned long count); + /// Remove a range of characters from the node. + + void replaceData(unsigned long offset, unsigned long count, const XMLString& arg); + /// Replace the characters starting at the specified character + /// offset with the specified string. + + // Non-standard extensions + XMLString trimmedData() const; + /// Returns the character data of that node with + /// all surrounding whitespace removed. + /// + /// This method is an extension to the W3C Document Object Model. + + // Node + const XMLString& getNodeValue() const; + void setNodeValue(const XMLString& value); + +protected: + CharacterData(Document* pOwnerDocument, const XMLString& data); + CharacterData(Document* pOwnerDocument, const CharacterData& data); + ~CharacterData(); + +private: + XMLString _data; +}; + + +// +// inlines +// +inline const XMLString& CharacterData::data() const +{ + return _data; +} + + +inline const XMLString& CharacterData::getData() const +{ + return _data; +} + + +inline unsigned long CharacterData::length() const +{ + return (unsigned long) _data.length(); +} + + +} } // namespace Poco::XML + + +#endif // DOM_CharacterData_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/ChildNodesList.h b/contrib/libs/poco/XML/include/Poco/DOM/ChildNodesList.h index aa7ece1db8..2f387ddfe5 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/ChildNodesList.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/ChildNodesList.h @@ -1,55 +1,55 @@ -// -// ChildNodesList.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the ChildNodesList class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_ChildNodesList_INCLUDED -#define DOM_ChildNodesList_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/NodeList.h" - - -namespace Poco { -namespace XML { - - -class XML_API ChildNodesList: public NodeList - // This implementation of NodeList is returned - // by Node::getChildNodes(). -{ -public: - Node* item(unsigned long index) const; - unsigned long length() const; - - void autoRelease(); - -protected: - ChildNodesList(const Node* pParent); - ~ChildNodesList(); - -private: - ChildNodesList(); - - const Node* _pParent; - - friend class AbstractNode; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_ChildNodesList_INCLUDED +// +// ChildNodesList.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the ChildNodesList class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_ChildNodesList_INCLUDED +#define DOM_ChildNodesList_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/NodeList.h" + + +namespace Poco { +namespace XML { + + +class XML_API ChildNodesList: public NodeList + // This implementation of NodeList is returned + // by Node::getChildNodes(). +{ +public: + Node* item(unsigned long index) const; + unsigned long length() const; + + void autoRelease(); + +protected: + ChildNodesList(const Node* pParent); + ~ChildNodesList(); + +private: + ChildNodesList(); + + const Node* _pParent; + + friend class AbstractNode; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_ChildNodesList_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/Comment.h b/contrib/libs/poco/XML/include/Poco/DOM/Comment.h index d1de793064..5e2437e9bb 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/Comment.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/Comment.h @@ -1,58 +1,58 @@ -// -// Comment.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM Comment class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_Comment_INCLUDED -#define DOM_Comment_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/CharacterData.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API Comment: public CharacterData - /// This interface inherits from CharacterData and represents the content of - /// a comment, i.e., all the characters between the starting '<!--' and ending - /// '-->'. Note that this is the definition of a comment in XML, and, in practice, - /// HTML, although some HTML tools may implement the full SGML comment structure. -{ -public: - // Node - const XMLString& nodeName() const; - unsigned short nodeType() const; - -protected: - Comment(Document* pOwnerDocument, const XMLString& data); - Comment(Document* pOwnerDocument, const Comment& comment); - ~Comment(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - -private: - static const XMLString NODE_NAME; - - friend class Document; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_Comment_INCLUDED +// +// Comment.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM Comment class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_Comment_INCLUDED +#define DOM_Comment_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/CharacterData.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API Comment: public CharacterData + /// This interface inherits from CharacterData and represents the content of + /// a comment, i.e., all the characters between the starting '<!--' and ending + /// '-->'. Note that this is the definition of a comment in XML, and, in practice, + /// HTML, although some HTML tools may implement the full SGML comment structure. +{ +public: + // Node + const XMLString& nodeName() const; + unsigned short nodeType() const; + +protected: + Comment(Document* pOwnerDocument, const XMLString& data); + Comment(Document* pOwnerDocument, const Comment& comment); + ~Comment(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + +private: + static const XMLString NODE_NAME; + + friend class Document; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_Comment_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DOMBuilder.h b/contrib/libs/poco/XML/include/Poco/DOM/DOMBuilder.h index ad91da45f4..0e6c57da47 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DOMBuilder.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DOMBuilder.h @@ -1,112 +1,112 @@ -// -// DOMBuilder.h -// -// Library: XML -// Package: DOM -// Module: DOMBuilder -// -// Definition of the DOMBuilder class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DOMBuilder_INCLUDED -#define DOM_DOMBuilder_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/ContentHandler.h" -#include "Poco/SAX/LexicalHandler.h" -#include "Poco/SAX/DTDHandler.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XMLReader; -class Document; -class InputSource; -class AbstractNode; -class AbstractContainerNode; -class NamePool; - - -class XML_API DOMBuilder: protected DTDHandler, protected ContentHandler, protected LexicalHandler - /// This class builds a tree representation of an - /// XML document, according to the W3C Document Object Model, Level 1 and 2 - /// specifications. - /// - /// The actual XML parsing is done by an XMLReader, which - /// must be supplied to the DOMBuilder. -{ -public: - DOMBuilder(XMLReader& xmlReader, NamePool* pNamePool = 0); - /// Creates a DOMBuilder using the given XMLReader. - /// If a NamePool is given, it becomes the Document's NamePool. - - virtual ~DOMBuilder(); - /// Destroys the DOMBuilder. - - virtual Document* parse(const XMLString& uri); - /// Parse an XML document from a location identified by an URI. - - virtual Document* parse(InputSource* pInputSource); - /// Parse an XML document from a location identified by an InputSource. - - virtual Document* parseMemoryNP(const char* xml, std::size_t size); - /// Parses an XML document from memory. - -protected: - // DTDHandler - void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId); - void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName); - - // ContentHandler - void setDocumentLocator(const Locator* loc); - void startDocument(); - void endDocument(); - void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attributes); - void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname); - void characters(const XMLChar ch[], int start, int length); - void ignorableWhitespace(const XMLChar ch[], int start, int length); - void processingInstruction(const XMLString& target, const XMLString& data); - void startPrefixMapping(const XMLString& prefix, const XMLString& uri); - void endPrefixMapping(const XMLString& prefix); - void skippedEntity(const XMLString& name); - - // LexicalHandler - void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId); - void endDTD(); - void startEntity(const XMLString& name); - void endEntity(const XMLString& name); - void startCDATA(); - void endCDATA(); - void comment(const XMLChar ch[], int start, int length); - - void appendNode(AbstractNode* pNode); - - void setupParse(); - -private: - static const XMLString EMPTY_STRING; - - XMLReader& _xmlReader; - NamePool* _pNamePool; - Document* _pDocument; - AbstractContainerNode* _pParent; - AbstractNode* _pPrevious; - bool _inCDATA; - bool _namespaces; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_DOMBuilder_INCLUDED +// +// DOMBuilder.h +// +// Library: XML +// Package: DOM +// Module: DOMBuilder +// +// Definition of the DOMBuilder class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DOMBuilder_INCLUDED +#define DOM_DOMBuilder_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/ContentHandler.h" +#include "Poco/SAX/LexicalHandler.h" +#include "Poco/SAX/DTDHandler.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XMLReader; +class Document; +class InputSource; +class AbstractNode; +class AbstractContainerNode; +class NamePool; + + +class XML_API DOMBuilder: protected DTDHandler, protected ContentHandler, protected LexicalHandler + /// This class builds a tree representation of an + /// XML document, according to the W3C Document Object Model, Level 1 and 2 + /// specifications. + /// + /// The actual XML parsing is done by an XMLReader, which + /// must be supplied to the DOMBuilder. +{ +public: + DOMBuilder(XMLReader& xmlReader, NamePool* pNamePool = 0); + /// Creates a DOMBuilder using the given XMLReader. + /// If a NamePool is given, it becomes the Document's NamePool. + + virtual ~DOMBuilder(); + /// Destroys the DOMBuilder. + + virtual Document* parse(const XMLString& uri); + /// Parse an XML document from a location identified by an URI. + + virtual Document* parse(InputSource* pInputSource); + /// Parse an XML document from a location identified by an InputSource. + + virtual Document* parseMemoryNP(const char* xml, std::size_t size); + /// Parses an XML document from memory. + +protected: + // DTDHandler + void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId); + void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName); + + // ContentHandler + void setDocumentLocator(const Locator* loc); + void startDocument(); + void endDocument(); + void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attributes); + void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname); + void characters(const XMLChar ch[], int start, int length); + void ignorableWhitespace(const XMLChar ch[], int start, int length); + void processingInstruction(const XMLString& target, const XMLString& data); + void startPrefixMapping(const XMLString& prefix, const XMLString& uri); + void endPrefixMapping(const XMLString& prefix); + void skippedEntity(const XMLString& name); + + // LexicalHandler + void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId); + void endDTD(); + void startEntity(const XMLString& name); + void endEntity(const XMLString& name); + void startCDATA(); + void endCDATA(); + void comment(const XMLChar ch[], int start, int length); + + void appendNode(AbstractNode* pNode); + + void setupParse(); + +private: + static const XMLString EMPTY_STRING; + + XMLReader& _xmlReader; + NamePool* _pNamePool; + Document* _pDocument; + AbstractContainerNode* _pParent; + AbstractNode* _pPrevious; + bool _inCDATA; + bool _namespaces; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_DOMBuilder_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DOMException.h b/contrib/libs/poco/XML/include/Poco/DOM/DOMException.h index 456526f111..3285a7c526 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DOMException.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DOMException.h @@ -1,112 +1,112 @@ -// -// DOMException.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM DOMException class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DOMException_INCLUDED -#define DOM_DOMException_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLException.h" - - -namespace Poco { -namespace XML { - - -class XML_API DOMException: public XMLException - /// DOM operations only raise exceptions in "exceptional" circumstances, i.e., - /// when an operation is impossible to perform (either for logical reasons, - /// because data is lost, or because the implementation has become unstable). - /// In general, DOM methods return specific error values in ordinary processing - /// situations, such as out-of-bound errors when using NodeList. - /// - /// Implementations should raise other exceptions under other circumstances. - /// For example, implementations should raise an implementation-dependent exception - /// if a null argument is passed when null was not expected. -{ -public: - enum - { - INDEX_SIZE_ERR = 1, /// index or size is negative or greater than allowed value - DOMSTRING_SIZE_ERR, /// the specified range of text does not fit into a DOMString (not used) - HIERARCHY_REQUEST_ERR, /// a node is inserted somewhere it doesn't belong - WRONG_DOCUMENT_ERR, /// a node is used in a different document than the one that created it - INVALID_CHARACTER_ERR, /// an invalid character is specified (not used) - NO_DATA_ALLOWED_ERR, /// data is specified for a node which does not support data - NO_MODIFICATION_ALLOWED_ERR, /// an attempt is made to modify an object where modifications are not allowed - NOT_FOUND_ERR, /// an attempt was made to reference a node in a context where it does not exist - NOT_SUPPORTED_ERR, /// the implementation does not support the type of object requested - INUSE_ATTRIBUTE_ERR, /// an attempt is made to add an attribute that is already in use elsewhere - INVALID_STATE_ERR, /// a parameter or an operation is not supported by the underlying object - SYNTAX_ERR, /// an invalid or illegal string is specified - INVALID_MODIFICATION_ERR, /// an attempt is made to modify the type of the underlying object - NAMESPACE_ERR, /// an attempt is made to create or change an object in a way which is incorrect with regard to namespaces - INVALID_ACCESS_ERR, /// an attempt is made to use an object that is not, or is no longer, usable - - _NUMBER_OF_MESSAGES - }; - - DOMException(unsigned short code); - /// Creates a DOMException with the given error code. - - DOMException(const DOMException& exc); - /// Creates a DOMException by copying another one. - - ~DOMException() noexcept; - /// Destroys the DOMException. - - DOMException& operator = (const DOMException& exc); - +// +// DOMException.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM DOMException class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DOMException_INCLUDED +#define DOM_DOMException_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLException.h" + + +namespace Poco { +namespace XML { + + +class XML_API DOMException: public XMLException + /// DOM operations only raise exceptions in "exceptional" circumstances, i.e., + /// when an operation is impossible to perform (either for logical reasons, + /// because data is lost, or because the implementation has become unstable). + /// In general, DOM methods return specific error values in ordinary processing + /// situations, such as out-of-bound errors when using NodeList. + /// + /// Implementations should raise other exceptions under other circumstances. + /// For example, implementations should raise an implementation-dependent exception + /// if a null argument is passed when null was not expected. +{ +public: + enum + { + INDEX_SIZE_ERR = 1, /// index or size is negative or greater than allowed value + DOMSTRING_SIZE_ERR, /// the specified range of text does not fit into a DOMString (not used) + HIERARCHY_REQUEST_ERR, /// a node is inserted somewhere it doesn't belong + WRONG_DOCUMENT_ERR, /// a node is used in a different document than the one that created it + INVALID_CHARACTER_ERR, /// an invalid character is specified (not used) + NO_DATA_ALLOWED_ERR, /// data is specified for a node which does not support data + NO_MODIFICATION_ALLOWED_ERR, /// an attempt is made to modify an object where modifications are not allowed + NOT_FOUND_ERR, /// an attempt was made to reference a node in a context where it does not exist + NOT_SUPPORTED_ERR, /// the implementation does not support the type of object requested + INUSE_ATTRIBUTE_ERR, /// an attempt is made to add an attribute that is already in use elsewhere + INVALID_STATE_ERR, /// a parameter or an operation is not supported by the underlying object + SYNTAX_ERR, /// an invalid or illegal string is specified + INVALID_MODIFICATION_ERR, /// an attempt is made to modify the type of the underlying object + NAMESPACE_ERR, /// an attempt is made to create or change an object in a way which is incorrect with regard to namespaces + INVALID_ACCESS_ERR, /// an attempt is made to use an object that is not, or is no longer, usable + + _NUMBER_OF_MESSAGES + }; + + DOMException(unsigned short code); + /// Creates a DOMException with the given error code. + + DOMException(const DOMException& exc); + /// Creates a DOMException by copying another one. + + ~DOMException() noexcept; + /// Destroys the DOMException. + + DOMException& operator = (const DOMException& exc); + const char* name() const noexcept; - /// Returns a static string describing the exception. - + /// Returns a static string describing the exception. + const char* className() const noexcept; - /// Returns the name of the exception class. - - Poco::Exception* clone() const; - /// Creates an exact copy of the exception. - - void rethrow() const; - /// (Re)Throws the exception. - - unsigned short code() const; - /// Returns the DOM exception code. - -protected: - static const std::string& message(unsigned short code); - -private: - DOMException(); - - unsigned short _code; - - static const std::string MESSAGES[_NUMBER_OF_MESSAGES]; -}; - - -// -// inlines -// -inline unsigned short DOMException::code() const -{ - return _code; -} - - -} } // namespace Poco::XML - - -#endif // DOM_DOMException_INCLUDED + /// Returns the name of the exception class. + + Poco::Exception* clone() const; + /// Creates an exact copy of the exception. + + void rethrow() const; + /// (Re)Throws the exception. + + unsigned short code() const; + /// Returns the DOM exception code. + +protected: + static const std::string& message(unsigned short code); + +private: + DOMException(); + + unsigned short _code; + + static const std::string MESSAGES[_NUMBER_OF_MESSAGES]; +}; + + +// +// inlines +// +inline unsigned short DOMException::code() const +{ + return _code; +} + + +} } // namespace Poco::XML + + +#endif // DOM_DOMException_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DOMImplementation.h b/contrib/libs/poco/XML/include/Poco/DOM/DOMImplementation.h index 0c2d7af187..3a9aa6cdd8 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DOMImplementation.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DOMImplementation.h @@ -1,82 +1,82 @@ -// -// DOMImplementation.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM DOMImplementation class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DOMImplementation_INCLUDED -#define DOM_DOMImplementation_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class DocumentType; -class Document; -class NamePool; - - -class XML_API DOMImplementation - /// The DOMImplementation interface provides a number of methods for - /// performing operations that are independent of any particular instance - /// of the document object model. - /// In this implementation, DOMImplementation is implemented as a singleton. -{ -public: - DOMImplementation(); - /// Creates the DOMImplementation. - - ~DOMImplementation(); - /// Destroys the DOMImplementation. - - bool hasFeature(const XMLString& feature, const XMLString& version) const; - /// Tests if the DOM implementation implements a specific feature. - /// - /// The only supported features are "XML", version "1.0" and "Core", - /// "Events", "MutationEvents" and "Traversal", version "2.0". - - // DOM Level 2 - DocumentType* createDocumentType(const XMLString& name, const XMLString& publicId, const XMLString& systemId) const; - /// Creates an empty DocumentType node. Entity declarations and notations - /// are not made available. Entity reference expansions and default attribute - /// additions do not occur. - - Document* createDocument(const XMLString& namespaceURI, const XMLString& qualifiedName, DocumentType* doctype) const; - /// Creates an XML Document object of the specified type with its document element. - /// - /// Note: You can also create a Document directly using the new operator. - - static const DOMImplementation& instance(); - /// Returns a reference to the default DOMImplementation - /// object. - -private: - static const XMLString FEATURE_XML; - static const XMLString FEATURE_CORE; - static const XMLString FEATURE_EVENTS; - static const XMLString FEATURE_MUTATIONEVENTS; - static const XMLString FEATURE_TRAVERSAL; - static const XMLString VERSION_1_0; - static const XMLString VERSION_2_0; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_DOMImplementation_INCLUDED +// +// DOMImplementation.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM DOMImplementation class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DOMImplementation_INCLUDED +#define DOM_DOMImplementation_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class DocumentType; +class Document; +class NamePool; + + +class XML_API DOMImplementation + /// The DOMImplementation interface provides a number of methods for + /// performing operations that are independent of any particular instance + /// of the document object model. + /// In this implementation, DOMImplementation is implemented as a singleton. +{ +public: + DOMImplementation(); + /// Creates the DOMImplementation. + + ~DOMImplementation(); + /// Destroys the DOMImplementation. + + bool hasFeature(const XMLString& feature, const XMLString& version) const; + /// Tests if the DOM implementation implements a specific feature. + /// + /// The only supported features are "XML", version "1.0" and "Core", + /// "Events", "MutationEvents" and "Traversal", version "2.0". + + // DOM Level 2 + DocumentType* createDocumentType(const XMLString& name, const XMLString& publicId, const XMLString& systemId) const; + /// Creates an empty DocumentType node. Entity declarations and notations + /// are not made available. Entity reference expansions and default attribute + /// additions do not occur. + + Document* createDocument(const XMLString& namespaceURI, const XMLString& qualifiedName, DocumentType* doctype) const; + /// Creates an XML Document object of the specified type with its document element. + /// + /// Note: You can also create a Document directly using the new operator. + + static const DOMImplementation& instance(); + /// Returns a reference to the default DOMImplementation + /// object. + +private: + static const XMLString FEATURE_XML; + static const XMLString FEATURE_CORE; + static const XMLString FEATURE_EVENTS; + static const XMLString FEATURE_MUTATIONEVENTS; + static const XMLString FEATURE_TRAVERSAL; + static const XMLString VERSION_1_0; + static const XMLString VERSION_2_0; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_DOMImplementation_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DOMObject.h b/contrib/libs/poco/XML/include/Poco/DOM/DOMObject.h index 40b29fb2cf..8cbcba5165 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DOMObject.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DOMObject.h @@ -1,103 +1,103 @@ -// -// DOMObject.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOMObject class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DOMObject_INCLUDED -#define DOM_DOMObject_INCLUDED - - -#include "Poco/XML/XML.h" - - -namespace Poco { -namespace XML { - - -class XML_API DOMObject - /// The base class for all objects in the Document Object Model. - /// - /// DOMObject defines the rules for memory management - /// in this implementation of the DOM. Violation of these - /// rules, which are outlined in the following, results - /// in memory leaks or dangling pointers. - /// - /// Every object created by new or by a factory - /// method (for example, Document::create*) must be released - /// with a call to release() or autoRelease() when it - /// is no longer needed. - /// - /// Every object created by cloning or importing another - /// object must be released. - /// For every call to duplicate() there must be a matching - /// call to release(). - /// An object obtained via any other way must not be - /// released, except ownership of it has been explicitly - /// taken with a call to duplicate(). - /// - /// While DOMObjects are safe for use in multithreaded programs, - /// a DOMObject or one of its subclasses must not be accessed - /// from multiple threads simultaneously. -{ -public: - DOMObject(); - /// Creates the DOMObject. - /// The object's reference count is initialized to one. - - void duplicate() const; - /// Increases the object's reference count. - - void release() const; - /// Decreases the object's reference count. - /// If the reference count reaches zero, - /// the object is deleted. - - virtual void autoRelease() = 0; - /// Adds the object to an appropriate - /// AutoReleasePool, which is usually the - /// AutoReleasePool managed by the Document - /// to which this object belongs. - -protected: - virtual ~DOMObject(); - /// Destroys the DOMObject. - -private: - DOMObject(const DOMObject&); - DOMObject& operator = (const DOMObject&); - - mutable int _rc; -}; - - -// -// inlines -// -inline void DOMObject::duplicate() const -{ - ++_rc; -} - - -inline void DOMObject::release() const -{ - if (--_rc == 0) - delete this; -} - - -} } // namespace Poco::XML - - -#endif // DOM_DOMObject_INCLUDED +// +// DOMObject.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOMObject class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DOMObject_INCLUDED +#define DOM_DOMObject_INCLUDED + + +#include "Poco/XML/XML.h" + + +namespace Poco { +namespace XML { + + +class XML_API DOMObject + /// The base class for all objects in the Document Object Model. + /// + /// DOMObject defines the rules for memory management + /// in this implementation of the DOM. Violation of these + /// rules, which are outlined in the following, results + /// in memory leaks or dangling pointers. + /// + /// Every object created by new or by a factory + /// method (for example, Document::create*) must be released + /// with a call to release() or autoRelease() when it + /// is no longer needed. + /// + /// Every object created by cloning or importing another + /// object must be released. + /// For every call to duplicate() there must be a matching + /// call to release(). + /// An object obtained via any other way must not be + /// released, except ownership of it has been explicitly + /// taken with a call to duplicate(). + /// + /// While DOMObjects are safe for use in multithreaded programs, + /// a DOMObject or one of its subclasses must not be accessed + /// from multiple threads simultaneously. +{ +public: + DOMObject(); + /// Creates the DOMObject. + /// The object's reference count is initialized to one. + + void duplicate() const; + /// Increases the object's reference count. + + void release() const; + /// Decreases the object's reference count. + /// If the reference count reaches zero, + /// the object is deleted. + + virtual void autoRelease() = 0; + /// Adds the object to an appropriate + /// AutoReleasePool, which is usually the + /// AutoReleasePool managed by the Document + /// to which this object belongs. + +protected: + virtual ~DOMObject(); + /// Destroys the DOMObject. + +private: + DOMObject(const DOMObject&); + DOMObject& operator = (const DOMObject&); + + mutable int _rc; +}; + + +// +// inlines +// +inline void DOMObject::duplicate() const +{ + ++_rc; +} + + +inline void DOMObject::release() const +{ + if (--_rc == 0) + delete this; +} + + +} } // namespace Poco::XML + + +#endif // DOM_DOMObject_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DOMParser.h b/contrib/libs/poco/XML/include/Poco/DOM/DOMParser.h index 69d0f5aaac..4ae22dbe2e 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DOMParser.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DOMParser.h @@ -1,114 +1,114 @@ -// -// DOMParser.h -// -// Library: XML -// Package: DOM -// Module: DOMParser -// -// Definition of the DOMParser class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DOMParser_INCLUDED -#define DOM_DOMParser_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/SAXParser.h" - - -namespace Poco { -namespace XML { - - -class NamePool; -class Document; -class InputSource; -class EntityResolver; - - -class XML_API DOMParser - /// This is a convenience class that combines a - /// DOMBuilder with a SAXParser, with the optional - /// support of a WhitespaceFilter. -{ -public: - explicit DOMParser(NamePool* pNamePool = 0); - /// Creates a new DOMParser. - /// If a NamePool is given, it becomes the Document's NamePool. - - explicit DOMParser(unsigned long namePoolSize); - /// Creates a new DOMParser, using the given NamePool size. - /// - /// The given namePoolSize should be a suitable prime number, - /// e.g. 251, 509, 1021 or 4093, depending on the expected - /// size of the document. - - ~DOMParser(); - /// Destroys the DOMParser. - - void setEncoding(const XMLString& encoding); - /// Sets the encoding used by the parser if no - /// encoding is specified in the XML document. - - const XMLString& getEncoding() const; - /// Returns the name of the encoding used by - /// the parser if no encoding is specified in - /// the XML document. - - void addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding); - /// Adds an encoding to the parser. - - void setFeature(const XMLString& name, bool state); - /// Set the state of a feature. - /// - /// If a feature is not recognized by the DOMParser, it is - /// passed on to the underlying XMLReader. - /// - /// The only currently supported feature is - /// http://www.appinf.com/features/no-whitespace-in-element-content - /// which, when activated, causes the WhitespaceFilter to - /// be used. - - bool getFeature(const XMLString& name) const; - /// Look up the value of a feature. - /// - /// If a feature is not recognized by the DOMParser, the - /// DOMParser queries the underlying SAXParser for the feature. - - Document* parse(const XMLString& uri); - /// Parse an XML document from a location identified by an URI. - - Document* parse(InputSource* pInputSource); - /// Parse an XML document from a location identified by an InputSource. - - Document* parseString(const std::string& xml); - /// Parse an XML document from a string. - - Document* parseMemory(const char* xml, std::size_t size); - /// Parse an XML document from memory. - - EntityResolver* getEntityResolver() const; - /// Returns the entity resolver used by the underlying SAXParser. - - void setEntityResolver(EntityResolver* pEntityResolver); - /// Sets the entity resolver on the underlying SAXParser. - - static const XMLString FEATURE_FILTER_WHITESPACE; - -private: - SAXParser _saxParser; - NamePool* _pNamePool; - bool _filterWhitespace; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_DOMParser_INCLUDED +// +// DOMParser.h +// +// Library: XML +// Package: DOM +// Module: DOMParser +// +// Definition of the DOMParser class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DOMParser_INCLUDED +#define DOM_DOMParser_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/SAXParser.h" + + +namespace Poco { +namespace XML { + + +class NamePool; +class Document; +class InputSource; +class EntityResolver; + + +class XML_API DOMParser + /// This is a convenience class that combines a + /// DOMBuilder with a SAXParser, with the optional + /// support of a WhitespaceFilter. +{ +public: + explicit DOMParser(NamePool* pNamePool = 0); + /// Creates a new DOMParser. + /// If a NamePool is given, it becomes the Document's NamePool. + + explicit DOMParser(unsigned long namePoolSize); + /// Creates a new DOMParser, using the given NamePool size. + /// + /// The given namePoolSize should be a suitable prime number, + /// e.g. 251, 509, 1021 or 4093, depending on the expected + /// size of the document. + + ~DOMParser(); + /// Destroys the DOMParser. + + void setEncoding(const XMLString& encoding); + /// Sets the encoding used by the parser if no + /// encoding is specified in the XML document. + + const XMLString& getEncoding() const; + /// Returns the name of the encoding used by + /// the parser if no encoding is specified in + /// the XML document. + + void addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding); + /// Adds an encoding to the parser. + + void setFeature(const XMLString& name, bool state); + /// Set the state of a feature. + /// + /// If a feature is not recognized by the DOMParser, it is + /// passed on to the underlying XMLReader. + /// + /// The only currently supported feature is + /// http://www.appinf.com/features/no-whitespace-in-element-content + /// which, when activated, causes the WhitespaceFilter to + /// be used. + + bool getFeature(const XMLString& name) const; + /// Look up the value of a feature. + /// + /// If a feature is not recognized by the DOMParser, the + /// DOMParser queries the underlying SAXParser for the feature. + + Document* parse(const XMLString& uri); + /// Parse an XML document from a location identified by an URI. + + Document* parse(InputSource* pInputSource); + /// Parse an XML document from a location identified by an InputSource. + + Document* parseString(const std::string& xml); + /// Parse an XML document from a string. + + Document* parseMemory(const char* xml, std::size_t size); + /// Parse an XML document from memory. + + EntityResolver* getEntityResolver() const; + /// Returns the entity resolver used by the underlying SAXParser. + + void setEntityResolver(EntityResolver* pEntityResolver); + /// Sets the entity resolver on the underlying SAXParser. + + static const XMLString FEATURE_FILTER_WHITESPACE; + +private: + SAXParser _saxParser; + NamePool* _pNamePool; + bool _filterWhitespace; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_DOMParser_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DOMSerializer.h b/contrib/libs/poco/XML/include/Poco/DOM/DOMSerializer.h index b535105dca..593d433861 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DOMSerializer.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DOMSerializer.h @@ -1,122 +1,122 @@ -// -// DOMSerializer.h -// -// Library: XML -// Package: DOM -// Module: DOMSerializer -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DOMSerializer_INCLUDED -#define DOM_DOMSerializer_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/XMLReader.h" - - -namespace Poco { -namespace XML { - - -class Node; -class Element; -class Text; -class Comment; -class ProcessingInstruction; -class Entity; -class CDATASection; -class Notation; -class Document; -class DocumentType; -class DocumentFragment; -class DeclHandler; -class LexicalHandler; - - -class XML_API DOMSerializer: public XMLReader - /// The DOMSerializer serializes a DOM document - /// into a sequence of SAX events which are - /// reported to the registered SAX event - /// handlers. - /// - /// The DOMWriter uses a DOMSerializer with an - /// XMLWriter to serialize a DOM document into - /// textual XML. -{ -public: - DOMSerializer(); - /// Creates the DOMSerializer. - - ~DOMSerializer(); - /// Destroys the DOMSerializer. - - void serialize(const Node* pNode); - /// Serializes a DOM node and its children - /// into a sequence of SAX events, which are - /// reported to the registered SAX event - /// handlers. - - // XMLReader - void setEntityResolver(EntityResolver* pResolver); - EntityResolver* getEntityResolver() const; - void setDTDHandler(DTDHandler* pDTDHandler); - DTDHandler* getDTDHandler() const; - void setContentHandler(ContentHandler* pContentHandler); - ContentHandler* getContentHandler() const; - void setErrorHandler(ErrorHandler* pErrorHandler); - ErrorHandler* getErrorHandler() const; - - void setFeature(const XMLString& featureId, bool state); - bool getFeature(const XMLString& featureId) const; - void setProperty(const XMLString& propertyId, const XMLString& value); - void setProperty(const XMLString& propertyId, void* value); - void* getProperty(const XMLString& propertyId) const; - -protected: - void parse(InputSource* pSource); - /// The DOMSerializer cannot parse an InputSource, - /// so this method simply throws an XMLException when invoked. - - void parse(const XMLString& systemId); - /// The DOMSerializer cannot parse from a system identifier, - /// so this method simply throws an XMLException when invoked. - - void parseMemoryNP(const char* xml, std::size_t size); - /// The DOMSerializer cannot parse from a system identifier, - /// so this method simply throws an XMLException when invoked. - - void iterate(const Node* pNode) const; - void handleNode(const Node* pNode) const; - void handleElement(const Element* pElement) const; - void handleCharacterData(const Text* pText) const; - void handleComment(const Comment* pComment) const; - void handlePI(const ProcessingInstruction* pPI) const; - void handleCDATASection(const CDATASection* pCDATA) const; - void handleDocument(const Document* pDocument) const; - void handleDocumentType(const DocumentType* pDocumentType) const; - void handleFragment(const DocumentFragment* pFragment) const; - void handleNotation(const Notation* pNotation) const; - void handleEntity(const Entity* pEntity) const; - -private: - EntityResolver* _pEntityResolver; - DTDHandler* _pDTDHandler; - ContentHandler* _pContentHandler; - ErrorHandler* _pErrorHandler; - DeclHandler* _pDeclHandler; - LexicalHandler* _pLexicalHandler; - - static const XMLString CDATA; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_DOMSerializer_INCLUDED +// +// DOMSerializer.h +// +// Library: XML +// Package: DOM +// Module: DOMSerializer +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DOMSerializer_INCLUDED +#define DOM_DOMSerializer_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/XMLReader.h" + + +namespace Poco { +namespace XML { + + +class Node; +class Element; +class Text; +class Comment; +class ProcessingInstruction; +class Entity; +class CDATASection; +class Notation; +class Document; +class DocumentType; +class DocumentFragment; +class DeclHandler; +class LexicalHandler; + + +class XML_API DOMSerializer: public XMLReader + /// The DOMSerializer serializes a DOM document + /// into a sequence of SAX events which are + /// reported to the registered SAX event + /// handlers. + /// + /// The DOMWriter uses a DOMSerializer with an + /// XMLWriter to serialize a DOM document into + /// textual XML. +{ +public: + DOMSerializer(); + /// Creates the DOMSerializer. + + ~DOMSerializer(); + /// Destroys the DOMSerializer. + + void serialize(const Node* pNode); + /// Serializes a DOM node and its children + /// into a sequence of SAX events, which are + /// reported to the registered SAX event + /// handlers. + + // XMLReader + void setEntityResolver(EntityResolver* pResolver); + EntityResolver* getEntityResolver() const; + void setDTDHandler(DTDHandler* pDTDHandler); + DTDHandler* getDTDHandler() const; + void setContentHandler(ContentHandler* pContentHandler); + ContentHandler* getContentHandler() const; + void setErrorHandler(ErrorHandler* pErrorHandler); + ErrorHandler* getErrorHandler() const; + + void setFeature(const XMLString& featureId, bool state); + bool getFeature(const XMLString& featureId) const; + void setProperty(const XMLString& propertyId, const XMLString& value); + void setProperty(const XMLString& propertyId, void* value); + void* getProperty(const XMLString& propertyId) const; + +protected: + void parse(InputSource* pSource); + /// The DOMSerializer cannot parse an InputSource, + /// so this method simply throws an XMLException when invoked. + + void parse(const XMLString& systemId); + /// The DOMSerializer cannot parse from a system identifier, + /// so this method simply throws an XMLException when invoked. + + void parseMemoryNP(const char* xml, std::size_t size); + /// The DOMSerializer cannot parse from a system identifier, + /// so this method simply throws an XMLException when invoked. + + void iterate(const Node* pNode) const; + void handleNode(const Node* pNode) const; + void handleElement(const Element* pElement) const; + void handleCharacterData(const Text* pText) const; + void handleComment(const Comment* pComment) const; + void handlePI(const ProcessingInstruction* pPI) const; + void handleCDATASection(const CDATASection* pCDATA) const; + void handleDocument(const Document* pDocument) const; + void handleDocumentType(const DocumentType* pDocumentType) const; + void handleFragment(const DocumentFragment* pFragment) const; + void handleNotation(const Notation* pNotation) const; + void handleEntity(const Entity* pEntity) const; + +private: + EntityResolver* _pEntityResolver; + DTDHandler* _pDTDHandler; + ContentHandler* _pContentHandler; + ErrorHandler* _pErrorHandler; + DeclHandler* _pDeclHandler; + LexicalHandler* _pLexicalHandler; + + static const XMLString CDATA; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_DOMSerializer_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DOMWriter.h b/contrib/libs/poco/XML/include/Poco/DOM/DOMWriter.h index 5a5132d566..c953ac19ef 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DOMWriter.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DOMWriter.h @@ -1,127 +1,127 @@ -// -// DOMWriter.h -// -// Library: XML -// Package: DOM -// Module: DOMWriter -// -// Definition of class DOMWriter. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DOMWriter_INCLUDED -#define DOM_DOMWriter_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" -#include "Poco/XML/XMLStream.h" -#include "Poco/TextEncoding.h" - - -namespace Poco { -namespace XML { - - -class Node; -class Document; - - -class XML_API DOMWriter - /// The DOMWriter uses a DOMSerializer with an - /// XMLWriter to serialize a DOM document into - /// textual XML. -{ -public: - DOMWriter(); - /// Creates a DOMWriter. - - ~DOMWriter(); - /// Destroys a DOMWriter. - - void setEncoding(const std::string& encodingName, Poco::TextEncoding& textEncoding); - /// Sets the encoding, which will be reflected in the written XML declaration. - - const std::string& getEncoding() const; - /// Returns the encoding name set with setEncoding. - - void setOptions(int options); - /// Sets options for the internal XMLWriter. - /// - /// See class XMLWriter for available options. - - int getOptions() const; - /// Returns the options for the internal XMLWriter. - - void setNewLine(const std::string& newLine); - /// Sets the line ending characters for the internal - /// XMLWriter. See XMLWriter::setNewLine() for a list - /// of supported values. - - const std::string& getNewLine() const; - /// Returns the line ending characters used by the - /// internal XMLWriter. - - void setIndent(const std::string& indent); - /// Sets the string used for one indentation step. - /// - /// The default is a single TAB character. - /// The given string should only contain TAB or SPACE - /// characters (e.g., a single TAB character, or - /// two to four SPACE characters). - - const std::string& getIndent() const; - /// Returns the string used for one indentation step. - - void writeNode(XMLByteOutputStream& ostr, const Node* pNode); - /// Writes the XML for the given node to the specified stream. - - void writeNode(const std::string& systemId, const Node* pNode); - /// Writes the XML for the given node to the file specified in systemId, - /// using a standard file output stream (Poco::FileOutputStream). - -private: - std::string _encodingName; - Poco::TextEncoding* _pTextEncoding; - int _options; - std::string _newLine; - std::string _indent; -}; - - -// -// inlines -// -inline const std::string& DOMWriter::getEncoding() const -{ - return _encodingName; -} - - -inline int DOMWriter::getOptions() const -{ - return _options; -} - - -inline const std::string& DOMWriter::getNewLine() const -{ - return _newLine; -} - - -inline const std::string& DOMWriter::getIndent() const -{ - return _indent; -} - - -} } // namespace Poco::XML - - -#endif // DOM_DOMWriter_INCLUDED +// +// DOMWriter.h +// +// Library: XML +// Package: DOM +// Module: DOMWriter +// +// Definition of class DOMWriter. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DOMWriter_INCLUDED +#define DOM_DOMWriter_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" +#include "Poco/XML/XMLStream.h" +#include "Poco/TextEncoding.h" + + +namespace Poco { +namespace XML { + + +class Node; +class Document; + + +class XML_API DOMWriter + /// The DOMWriter uses a DOMSerializer with an + /// XMLWriter to serialize a DOM document into + /// textual XML. +{ +public: + DOMWriter(); + /// Creates a DOMWriter. + + ~DOMWriter(); + /// Destroys a DOMWriter. + + void setEncoding(const std::string& encodingName, Poco::TextEncoding& textEncoding); + /// Sets the encoding, which will be reflected in the written XML declaration. + + const std::string& getEncoding() const; + /// Returns the encoding name set with setEncoding. + + void setOptions(int options); + /// Sets options for the internal XMLWriter. + /// + /// See class XMLWriter for available options. + + int getOptions() const; + /// Returns the options for the internal XMLWriter. + + void setNewLine(const std::string& newLine); + /// Sets the line ending characters for the internal + /// XMLWriter. See XMLWriter::setNewLine() for a list + /// of supported values. + + const std::string& getNewLine() const; + /// Returns the line ending characters used by the + /// internal XMLWriter. + + void setIndent(const std::string& indent); + /// Sets the string used for one indentation step. + /// + /// The default is a single TAB character. + /// The given string should only contain TAB or SPACE + /// characters (e.g., a single TAB character, or + /// two to four SPACE characters). + + const std::string& getIndent() const; + /// Returns the string used for one indentation step. + + void writeNode(XMLByteOutputStream& ostr, const Node* pNode); + /// Writes the XML for the given node to the specified stream. + + void writeNode(const std::string& systemId, const Node* pNode); + /// Writes the XML for the given node to the file specified in systemId, + /// using a standard file output stream (Poco::FileOutputStream). + +private: + std::string _encodingName; + Poco::TextEncoding* _pTextEncoding; + int _options; + std::string _newLine; + std::string _indent; +}; + + +// +// inlines +// +inline const std::string& DOMWriter::getEncoding() const +{ + return _encodingName; +} + + +inline int DOMWriter::getOptions() const +{ + return _options; +} + + +inline const std::string& DOMWriter::getNewLine() const +{ + return _newLine; +} + + +inline const std::string& DOMWriter::getIndent() const +{ + return _indent; +} + + +} } // namespace Poco::XML + + +#endif // DOM_DOMWriter_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DTDMap.h b/contrib/libs/poco/XML/include/Poco/DOM/DTDMap.h index 2a475c358e..82b8af7e0e 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DTDMap.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DTDMap.h @@ -1,67 +1,67 @@ -// -// DTDMap.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DTDMap class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DTDMap_INCLUDED -#define DOM_DTDMap_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/NamedNodeMap.h" - - -namespace Poco { -namespace XML { - - -class DocumentType; - - -class XML_API DTDMap: public NamedNodeMap - /// This implementation of NamedNodeMap - /// is returned by DocumentType::entities() - /// and DocumentType::notations(). -{ -public: - Node* getNamedItem(const XMLString& name) const; - Node* setNamedItem(Node* arg); - Node* removeNamedItem(const XMLString& name); - Node* item(unsigned long index) const; - unsigned long length() const; - - Node* getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const; - Node* setNamedItemNS(Node* arg); - Node* removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName); - - void autoRelease(); - -protected: - DTDMap(const DocumentType* pDocumentType, unsigned short type); - ~DTDMap(); - -private: - DTDMap(); - - const DocumentType* _pDocumentType; - unsigned short _type; - - friend class DocumentType; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_DTDMap_INCLUDED +// +// DTDMap.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DTDMap class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DTDMap_INCLUDED +#define DOM_DTDMap_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/NamedNodeMap.h" + + +namespace Poco { +namespace XML { + + +class DocumentType; + + +class XML_API DTDMap: public NamedNodeMap + /// This implementation of NamedNodeMap + /// is returned by DocumentType::entities() + /// and DocumentType::notations(). +{ +public: + Node* getNamedItem(const XMLString& name) const; + Node* setNamedItem(Node* arg); + Node* removeNamedItem(const XMLString& name); + Node* item(unsigned long index) const; + unsigned long length() const; + + Node* getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const; + Node* setNamedItemNS(Node* arg); + Node* removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName); + + void autoRelease(); + +protected: + DTDMap(const DocumentType* pDocumentType, unsigned short type); + ~DTDMap(); + +private: + DTDMap(); + + const DocumentType* _pDocumentType; + unsigned short _type; + + friend class DocumentType; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_DTDMap_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/Document.h b/contrib/libs/poco/XML/include/Poco/DOM/Document.h index e66c0e6b51..7afb517267 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/Document.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/Document.h @@ -1,285 +1,285 @@ -// -// Document.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM Document class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_Document_INCLUDED -#define DOM_Document_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractContainerNode.h" -#include "Poco/DOM/DocumentEvent.h" -#include "Poco/DOM/Element.h" -#include "Poco/XML/XMLString.h" -#include "Poco/XML/NamePool.h" -#include "Poco/AutoReleasePool.h" - - -namespace Poco { -namespace XML { - - -class NamePool; -class DocumentType; -class DOMImplementation; -class DocumentFragment; -class Text; -class Comment; -class CDATASection; -class ProcessingInstruction; -class Attr; -class EntityReference; -class NodeList; -class Entity; -class Notation; - - -class XML_API Document: public AbstractContainerNode, public DocumentEvent - /// The Document interface represents the entire HTML or XML document. Conceptually, - /// it is the root of the document tree, and provides the primary access to the - /// document's data. - /// - /// Since elements, text nodes, comments, processing instructions, etc. cannot exist - /// outside the context of a Document, the Document interface also contains the - /// factory methods needed to create these objects. The Node objects created have a - /// ownerDocument attribute which associates them with the Document within whose - /// context they were created. -{ -public: - typedef Poco::AutoReleasePool<DOMObject> AutoReleasePool; - - explicit Document(NamePool* pNamePool = 0); - /// Creates a new document. If pNamePool == 0, the document - /// creates its own name pool, otherwise it uses the given name pool. - /// Sharing a name pool makes sense for documents containing instances - /// of the same schema, thus reducing memory usage. - - explicit Document(unsigned long namePoolSize); - /// Creates a new document using a name pool with the given size, which - /// should be a prime number (e.g., 251, 509, 1021, 4093). - - Document(DocumentType* pDocumentType, NamePool* pNamePool = 0); - /// Creates a new document. If pNamePool == 0, the document - /// creates its own name pool, otherwise it uses the given name pool. - /// Sharing a name pool makes sense for documents containing instances - /// of the same schema, thus reducing memory usage. - - Document(DocumentType* pDocumentType, unsigned long namePoolSize); - /// Creates a new document using a name pool with the given size, which - /// should be a prime number (e.g., 251, 509, 1021, 4093). - - NamePool& namePool(); - /// Returns a pointer to the documents Name Pool. - - AutoReleasePool& autoReleasePool(); - /// Returns a pointer to the documents Auto Release Pool. - - void collectGarbage(); - /// Releases all objects in the Auto Release Pool. - - void suspendEvents(); - /// Suspends all events until resumeEvents() is called. - - void resumeEvents(); - /// Resumes all events suspended with suspendEvent(); - - bool eventsSuspended() const; - /// Returns true if events are suspended. - - bool events() const; - /// Returns true if events are not suspended. - - const DocumentType* doctype() const; - /// The Document Type Declaration (see DocumentType) associated with this document. - /// For HTML documents as well as XML documents without a document type declaration - /// this returns null. The DOM Level 1 does not support editing the Document - /// Type Declaration. docType cannot be altered in any way, including through - /// the use of methods inherited from the Node interface, such as insertNode - /// or removeNode. - - const DOMImplementation& implementation() const; - /// The DOMImplementation object that handles this document. A DOM application - /// may use objects from multiple implementations. - - Element* documentElement() const; - /// This is a convenience attribute that allows direct access to the child node - /// that is the root element of the document. For HTML documents, this is the - /// element with the tagName "HTML". - - Element* createElement(const XMLString& tagName) const; - /// Creates an element of the type specified. Note that the instance returned - /// implements the Element interface, so attributes can be specified directly - /// on the returned object. - /// - /// In addition, if there are known attributes with default values, Attr nodes - /// representing them are automatically created and attached to the element. - - DocumentFragment* createDocumentFragment() const; - /// Creates an empty DocumentFragment object. - - Text* createTextNode(const XMLString& data) const; - /// Creates a text node given the specified string. - - Comment* createComment(const XMLString& data) const; - /// Creates a comment node given the specified string. - - CDATASection* createCDATASection(const XMLString& data) const; - /// Creates a CDATASection node whose value is the specified string. - - ProcessingInstruction* createProcessingInstruction(const XMLString& target, const XMLString& data) const; - /// Creates a ProcessingInstruction node given the specified target and data strings. - - Attr* createAttribute(const XMLString& name) const; - /// Creates an Attr of the given name. Note that the Attr instance can then - /// be set on an Element using the setAttributeNode method. - - EntityReference* createEntityReference(const XMLString& name) const; - /// Creates an EntityReference object. In addition, if the referenced entity - /// is known, the child list of the EntityReference node is made the same as - /// that of the corresponding Entity node. - - NodeList* getElementsByTagName(const XMLString& name) const; - /// Returns a NodeList of all Elements with a given tag name in the order - /// in which they would be encountered in a preorder traversal of the - /// document tree. - /// - /// The returned NodeList must be released with a call to release() - /// when no longer needed. - - // DOM Level 2 - Node* importNode(Node* importedNode, bool deep); - /// Imports a node from another document to this document. The returned node - /// has no parent; (parentNode is null). The source node is not altered or removed - /// from the original document; this method creates a new copy of the source - /// node. - /// For all nodes, importing a node creates a node object owned by the importing - /// document, with attribute values identical to the source node's nodeName - /// and nodeType, plus the attributes related to namespaces (prefix, localName, - /// and namespaceURI). As in the cloneNode operation on a Node, the source node - /// is not altered. - /// Additional information is copied as appropriate to the nodeType, attempting - /// to mirror the behavior expected if a fragment of XML or HTML source was - /// copied from one document to another, recognizing that the two documents - /// may have different DTDs in the XML case. - - Element* createElementNS(const XMLString& namespaceURI, const XMLString& qualifiedName) const; - /// Creates an element of the given qualified name and namespace URI. - - Attr* createAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName) const; - /// Creates an attribute of the given qualified name and namespace URI. - - NodeList* getElementsByTagNameNS(const XMLString& namespaceURI, const XMLString& localName) const; - /// Returns a NodeList of all the Elements with a given local name and - /// namespace URI in the order in which they are encountered in a - /// preorder traversal of the Document tree. - - Element* getElementById(const XMLString& elementId) const; - /// Returns the Element whose ID is given by elementId. If no such - /// element exists, returns null. Behavior is not defined if more - /// than one element has this ID. - /// - /// Note: The DOM implementation must have information that says - /// which attributes are of type ID. Attributes with the name "ID" - /// are not of type ID unless so defined. Implementations that do - /// not know whether attributes are of type ID or not are expected to - /// return null. This implementation therefore returns null. - /// - /// See also the non-standard two argument variant of getElementById() - /// and getElementByIdNS(). - - // DocumentEvent - Event* createEvent(const XMLString& eventType) const; - - // Node - const XMLString& nodeName() const; - unsigned short nodeType() const; - - // EventTarget - bool dispatchEvent(Event* evt); - - // Extensions - Entity* createEntity(const XMLString& name, const XMLString& publicId, const XMLString& systemId, const XMLString& notationName) const; - /// Creates an Entity with the given name, publicId, systemId and notationName. - /// - /// This method is not part of the W3C Document Object Model. - - Notation* createNotation(const XMLString& name, const XMLString& publicId, const XMLString& systemId) const; - /// Creates a Notation with the given name, publicId and systemId. - /// - /// This method is not part of the W3C Document Object Model. - - Element* getElementById(const XMLString& elementId, const XMLString& idAttribute) const; - /// Returns the first Element whose ID attribute (given in idAttribute) - /// has the given elementId. If no such element exists, returns null. - /// - /// This method is an extension to the W3C Document Object Model. - - Element* getElementByIdNS(const XMLString& elementId, const XMLString& idAttributeURI, const XMLString& idAttributeLocalName) const; - /// Returns the first Element whose ID attribute (given in idAttributeURI and idAttributeLocalName) - /// has the given elementId. If no such element exists, returns null. - /// - /// This method is an extension to the W3C Document Object Model. - -protected: - ~Document(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - - DocumentType* getDoctype(); - void setDoctype(DocumentType* pDoctype); - -private: - DocumentType* _pDocumentType; - NamePool* _pNamePool; - AutoReleasePool _autoReleasePool; - int _eventSuspendLevel; - - static const XMLString NODE_NAME; - - friend class DOMBuilder; -}; - - -// -// inlines -// -inline NamePool& Document::namePool() -{ - return *_pNamePool; -} - - -inline Document::AutoReleasePool& Document::autoReleasePool() -{ - return _autoReleasePool; -} - - -inline const DocumentType* Document::doctype() const -{ - return _pDocumentType; -} - - -inline DocumentType* Document::getDoctype() -{ - return _pDocumentType; -} - - -} } // namespace Poco::XML - - -#endif // DOM_Document_INCLUDED +// +// Document.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM Document class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_Document_INCLUDED +#define DOM_Document_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractContainerNode.h" +#include "Poco/DOM/DocumentEvent.h" +#include "Poco/DOM/Element.h" +#include "Poco/XML/XMLString.h" +#include "Poco/XML/NamePool.h" +#include "Poco/AutoReleasePool.h" + + +namespace Poco { +namespace XML { + + +class NamePool; +class DocumentType; +class DOMImplementation; +class DocumentFragment; +class Text; +class Comment; +class CDATASection; +class ProcessingInstruction; +class Attr; +class EntityReference; +class NodeList; +class Entity; +class Notation; + + +class XML_API Document: public AbstractContainerNode, public DocumentEvent + /// The Document interface represents the entire HTML or XML document. Conceptually, + /// it is the root of the document tree, and provides the primary access to the + /// document's data. + /// + /// Since elements, text nodes, comments, processing instructions, etc. cannot exist + /// outside the context of a Document, the Document interface also contains the + /// factory methods needed to create these objects. The Node objects created have a + /// ownerDocument attribute which associates them with the Document within whose + /// context they were created. +{ +public: + typedef Poco::AutoReleasePool<DOMObject> AutoReleasePool; + + explicit Document(NamePool* pNamePool = 0); + /// Creates a new document. If pNamePool == 0, the document + /// creates its own name pool, otherwise it uses the given name pool. + /// Sharing a name pool makes sense for documents containing instances + /// of the same schema, thus reducing memory usage. + + explicit Document(unsigned long namePoolSize); + /// Creates a new document using a name pool with the given size, which + /// should be a prime number (e.g., 251, 509, 1021, 4093). + + Document(DocumentType* pDocumentType, NamePool* pNamePool = 0); + /// Creates a new document. If pNamePool == 0, the document + /// creates its own name pool, otherwise it uses the given name pool. + /// Sharing a name pool makes sense for documents containing instances + /// of the same schema, thus reducing memory usage. + + Document(DocumentType* pDocumentType, unsigned long namePoolSize); + /// Creates a new document using a name pool with the given size, which + /// should be a prime number (e.g., 251, 509, 1021, 4093). + + NamePool& namePool(); + /// Returns a pointer to the documents Name Pool. + + AutoReleasePool& autoReleasePool(); + /// Returns a pointer to the documents Auto Release Pool. + + void collectGarbage(); + /// Releases all objects in the Auto Release Pool. + + void suspendEvents(); + /// Suspends all events until resumeEvents() is called. + + void resumeEvents(); + /// Resumes all events suspended with suspendEvent(); + + bool eventsSuspended() const; + /// Returns true if events are suspended. + + bool events() const; + /// Returns true if events are not suspended. + + const DocumentType* doctype() const; + /// The Document Type Declaration (see DocumentType) associated with this document. + /// For HTML documents as well as XML documents without a document type declaration + /// this returns null. The DOM Level 1 does not support editing the Document + /// Type Declaration. docType cannot be altered in any way, including through + /// the use of methods inherited from the Node interface, such as insertNode + /// or removeNode. + + const DOMImplementation& implementation() const; + /// The DOMImplementation object that handles this document. A DOM application + /// may use objects from multiple implementations. + + Element* documentElement() const; + /// This is a convenience attribute that allows direct access to the child node + /// that is the root element of the document. For HTML documents, this is the + /// element with the tagName "HTML". + + Element* createElement(const XMLString& tagName) const; + /// Creates an element of the type specified. Note that the instance returned + /// implements the Element interface, so attributes can be specified directly + /// on the returned object. + /// + /// In addition, if there are known attributes with default values, Attr nodes + /// representing them are automatically created and attached to the element. + + DocumentFragment* createDocumentFragment() const; + /// Creates an empty DocumentFragment object. + + Text* createTextNode(const XMLString& data) const; + /// Creates a text node given the specified string. + + Comment* createComment(const XMLString& data) const; + /// Creates a comment node given the specified string. + + CDATASection* createCDATASection(const XMLString& data) const; + /// Creates a CDATASection node whose value is the specified string. + + ProcessingInstruction* createProcessingInstruction(const XMLString& target, const XMLString& data) const; + /// Creates a ProcessingInstruction node given the specified target and data strings. + + Attr* createAttribute(const XMLString& name) const; + /// Creates an Attr of the given name. Note that the Attr instance can then + /// be set on an Element using the setAttributeNode method. + + EntityReference* createEntityReference(const XMLString& name) const; + /// Creates an EntityReference object. In addition, if the referenced entity + /// is known, the child list of the EntityReference node is made the same as + /// that of the corresponding Entity node. + + NodeList* getElementsByTagName(const XMLString& name) const; + /// Returns a NodeList of all Elements with a given tag name in the order + /// in which they would be encountered in a preorder traversal of the + /// document tree. + /// + /// The returned NodeList must be released with a call to release() + /// when no longer needed. + + // DOM Level 2 + Node* importNode(Node* importedNode, bool deep); + /// Imports a node from another document to this document. The returned node + /// has no parent; (parentNode is null). The source node is not altered or removed + /// from the original document; this method creates a new copy of the source + /// node. + /// For all nodes, importing a node creates a node object owned by the importing + /// document, with attribute values identical to the source node's nodeName + /// and nodeType, plus the attributes related to namespaces (prefix, localName, + /// and namespaceURI). As in the cloneNode operation on a Node, the source node + /// is not altered. + /// Additional information is copied as appropriate to the nodeType, attempting + /// to mirror the behavior expected if a fragment of XML or HTML source was + /// copied from one document to another, recognizing that the two documents + /// may have different DTDs in the XML case. + + Element* createElementNS(const XMLString& namespaceURI, const XMLString& qualifiedName) const; + /// Creates an element of the given qualified name and namespace URI. + + Attr* createAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName) const; + /// Creates an attribute of the given qualified name and namespace URI. + + NodeList* getElementsByTagNameNS(const XMLString& namespaceURI, const XMLString& localName) const; + /// Returns a NodeList of all the Elements with a given local name and + /// namespace URI in the order in which they are encountered in a + /// preorder traversal of the Document tree. + + Element* getElementById(const XMLString& elementId) const; + /// Returns the Element whose ID is given by elementId. If no such + /// element exists, returns null. Behavior is not defined if more + /// than one element has this ID. + /// + /// Note: The DOM implementation must have information that says + /// which attributes are of type ID. Attributes with the name "ID" + /// are not of type ID unless so defined. Implementations that do + /// not know whether attributes are of type ID or not are expected to + /// return null. This implementation therefore returns null. + /// + /// See also the non-standard two argument variant of getElementById() + /// and getElementByIdNS(). + + // DocumentEvent + Event* createEvent(const XMLString& eventType) const; + + // Node + const XMLString& nodeName() const; + unsigned short nodeType() const; + + // EventTarget + bool dispatchEvent(Event* evt); + + // Extensions + Entity* createEntity(const XMLString& name, const XMLString& publicId, const XMLString& systemId, const XMLString& notationName) const; + /// Creates an Entity with the given name, publicId, systemId and notationName. + /// + /// This method is not part of the W3C Document Object Model. + + Notation* createNotation(const XMLString& name, const XMLString& publicId, const XMLString& systemId) const; + /// Creates a Notation with the given name, publicId and systemId. + /// + /// This method is not part of the W3C Document Object Model. + + Element* getElementById(const XMLString& elementId, const XMLString& idAttribute) const; + /// Returns the first Element whose ID attribute (given in idAttribute) + /// has the given elementId. If no such element exists, returns null. + /// + /// This method is an extension to the W3C Document Object Model. + + Element* getElementByIdNS(const XMLString& elementId, const XMLString& idAttributeURI, const XMLString& idAttributeLocalName) const; + /// Returns the first Element whose ID attribute (given in idAttributeURI and idAttributeLocalName) + /// has the given elementId. If no such element exists, returns null. + /// + /// This method is an extension to the W3C Document Object Model. + +protected: + ~Document(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + + DocumentType* getDoctype(); + void setDoctype(DocumentType* pDoctype); + +private: + DocumentType* _pDocumentType; + NamePool* _pNamePool; + AutoReleasePool _autoReleasePool; + int _eventSuspendLevel; + + static const XMLString NODE_NAME; + + friend class DOMBuilder; +}; + + +// +// inlines +// +inline NamePool& Document::namePool() +{ + return *_pNamePool; +} + + +inline Document::AutoReleasePool& Document::autoReleasePool() +{ + return _autoReleasePool; +} + + +inline const DocumentType* Document::doctype() const +{ + return _pDocumentType; +} + + +inline DocumentType* Document::getDoctype() +{ + return _pDocumentType; +} + + +} } // namespace Poco::XML + + +#endif // DOM_Document_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DocumentEvent.h b/contrib/libs/poco/XML/include/Poco/DOM/DocumentEvent.h index 14bcf270b8..67727009b2 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DocumentEvent.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DocumentEvent.h @@ -1,65 +1,65 @@ -// -// DocumentEvent.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM DocumentEvent interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DocumentEvent_INCLUDED -#define DOM_DocumentEvent_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class Event; - - -class XML_API DocumentEvent - /// The DocumentEvent interface provides a mechanism by which the user can create - /// an Event of a type supported by the implementation. It is expected that - /// the DocumentEvent interface will be implemented on the same object which - /// implements the Document interface in an implementation which supports the - /// Event model. -{ -public: - virtual Event* createEvent(const XMLString& eventType) const = 0; - /// Creates an event of the specified type. - /// - /// The eventType parameter specifies the type of Event interface to be created. - /// If the Event interface specified is supported by the implementation this - /// method will return a new Event of the interface type requested. If the Event - /// is to be dispatched via the dispatchEvent method the appropriate event init - /// method must be called after creation in order to initialize the Event's - /// values. As an example, a user wishing to synthesize some kind of UIEvent - /// would call createEvent with the parameter "UIEvents". The initUIEvent method - /// could then be called on the newly created UIEvent to set the specific type - /// of UIEvent to be dispatched and set its context information. - /// The createEvent method is used in creating Events when it is either inconvenient - /// or unnecessary for the user to create an Event themselves. In cases where - /// the implementation provided Event is insufficient, users may supply their - /// own Event implementations for use with the dispatchEvent method. - -protected: - virtual ~DocumentEvent(); -}; - - -} } // namespace Poco::XML - - -#endif // DOM_DocumentEvent_INCLUDED +// +// DocumentEvent.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM DocumentEvent interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DocumentEvent_INCLUDED +#define DOM_DocumentEvent_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class Event; + + +class XML_API DocumentEvent + /// The DocumentEvent interface provides a mechanism by which the user can create + /// an Event of a type supported by the implementation. It is expected that + /// the DocumentEvent interface will be implemented on the same object which + /// implements the Document interface in an implementation which supports the + /// Event model. +{ +public: + virtual Event* createEvent(const XMLString& eventType) const = 0; + /// Creates an event of the specified type. + /// + /// The eventType parameter specifies the type of Event interface to be created. + /// If the Event interface specified is supported by the implementation this + /// method will return a new Event of the interface type requested. If the Event + /// is to be dispatched via the dispatchEvent method the appropriate event init + /// method must be called after creation in order to initialize the Event's + /// values. As an example, a user wishing to synthesize some kind of UIEvent + /// would call createEvent with the parameter "UIEvents". The initUIEvent method + /// could then be called on the newly created UIEvent to set the specific type + /// of UIEvent to be dispatched and set its context information. + /// The createEvent method is used in creating Events when it is either inconvenient + /// or unnecessary for the user to create an Event themselves. In cases where + /// the implementation provided Event is insufficient, users may supply their + /// own Event implementations for use with the dispatchEvent method. + +protected: + virtual ~DocumentEvent(); +}; + + +} } // namespace Poco::XML + + +#endif // DOM_DocumentEvent_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DocumentFragment.h b/contrib/libs/poco/XML/include/Poco/DOM/DocumentFragment.h index 105a2171db..22d8d94440 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DocumentFragment.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DocumentFragment.h @@ -1,84 +1,84 @@ -// -// DocumentFragment.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM DocumentFragment class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DocumentFragment_INCLUDED -#define DOM_DocumentFragment_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractContainerNode.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API DocumentFragment: public AbstractContainerNode - /// DocumentFragment is a "lightweight" or "minimal" Document object. It is - /// very common to want to be able to extract a portion of a document's tree - /// or to create a new fragment of a document. Imagine implementing a user command - /// like cut or rearranging a document by moving fragments around. It is desirable - /// to have an object which can hold such fragments and it is quite natural - /// to use a Node for this purpose. While it is true that a Document object - /// could fulfill this role, a Document object can potentially be a heavyweight - /// object, depending on the underlying implementation. What is really needed - /// for this is a very lightweight object. DocumentFragment is such an object. - /// - /// Furthermore, various operations -- such as inserting nodes as children of - /// another Node -- may take DocumentFragment objects as arguments; this results - /// in all the child nodes of the DocumentFragment being moved to the child - /// list of this node. - /// - /// The children of a DocumentFragment node are zero or more nodes representing - /// the tops of any sub-trees defining the structure of the document. DocumentFragment - /// nodes do not need to be well-formed XML documents (although they do need - /// to follow the rules imposed upon well-formed XML parsed entities, which - /// can have multiple top nodes). For example, a DocumentFragment might have - /// only one child and that child node could be a Text node. Such a structure - /// model represents neither an HTML document nor a well-formed XML document. - /// - /// When a DocumentFragment is inserted into a Document (or indeed any other - /// Node that may take children) the children of the DocumentFragment and not - /// the DocumentFragment itself are inserted into the Node. This makes the DocumentFragment - /// very useful when the user wishes to create nodes that are siblings; the - /// DocumentFragment acts as the parent of these nodes so that the user can - /// use the standard methods from the Node interface, such as insertBefore and - /// appendChild. -{ -public: - // Node - const XMLString& nodeName() const; - unsigned short nodeType() const; - -protected: - DocumentFragment(Document* pOwnerDocument); - DocumentFragment(Document* pOwnerDocument, const DocumentFragment& fragment); - ~DocumentFragment(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - -private: - static const XMLString NODE_NAME; - - friend class Document; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_DocumentFragment_INCLUDED +// +// DocumentFragment.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM DocumentFragment class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DocumentFragment_INCLUDED +#define DOM_DocumentFragment_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractContainerNode.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API DocumentFragment: public AbstractContainerNode + /// DocumentFragment is a "lightweight" or "minimal" Document object. It is + /// very common to want to be able to extract a portion of a document's tree + /// or to create a new fragment of a document. Imagine implementing a user command + /// like cut or rearranging a document by moving fragments around. It is desirable + /// to have an object which can hold such fragments and it is quite natural + /// to use a Node for this purpose. While it is true that a Document object + /// could fulfill this role, a Document object can potentially be a heavyweight + /// object, depending on the underlying implementation. What is really needed + /// for this is a very lightweight object. DocumentFragment is such an object. + /// + /// Furthermore, various operations -- such as inserting nodes as children of + /// another Node -- may take DocumentFragment objects as arguments; this results + /// in all the child nodes of the DocumentFragment being moved to the child + /// list of this node. + /// + /// The children of a DocumentFragment node are zero or more nodes representing + /// the tops of any sub-trees defining the structure of the document. DocumentFragment + /// nodes do not need to be well-formed XML documents (although they do need + /// to follow the rules imposed upon well-formed XML parsed entities, which + /// can have multiple top nodes). For example, a DocumentFragment might have + /// only one child and that child node could be a Text node. Such a structure + /// model represents neither an HTML document nor a well-formed XML document. + /// + /// When a DocumentFragment is inserted into a Document (or indeed any other + /// Node that may take children) the children of the DocumentFragment and not + /// the DocumentFragment itself are inserted into the Node. This makes the DocumentFragment + /// very useful when the user wishes to create nodes that are siblings; the + /// DocumentFragment acts as the parent of these nodes so that the user can + /// use the standard methods from the Node interface, such as insertBefore and + /// appendChild. +{ +public: + // Node + const XMLString& nodeName() const; + unsigned short nodeType() const; + +protected: + DocumentFragment(Document* pOwnerDocument); + DocumentFragment(Document* pOwnerDocument, const DocumentFragment& fragment); + ~DocumentFragment(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + +private: + static const XMLString NODE_NAME; + + friend class Document; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_DocumentFragment_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/DocumentType.h b/contrib/libs/poco/XML/include/Poco/DOM/DocumentType.h index 3d8909798b..011251563a 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/DocumentType.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/DocumentType.h @@ -1,125 +1,125 @@ -// -// DocumentType.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM DocumentType class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_DocumentType_INCLUDED -#define DOM_DocumentType_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractContainerNode.h" - - -namespace Poco { -namespace XML { - - -class NamedNodeMap; - - -class XML_API DocumentType: public AbstractContainerNode - /// Each Document has a doctype attribute whose value is either null or a DocumentType - /// object. The DocumentType interface in the DOM Level 1 Core provides an - /// interface to the list of entities that are defined for the document, and - /// little else because the effect of namespaces and the various XML scheme - /// efforts on DTD representation are not clearly understood as of this writing. - /// - /// The DOM Level 1 doesn't support editing DocumentType nodes. -{ -public: - const XMLString& name() const; - /// The name of the DTD; i.e., the name immediately following the - /// DOCTYPE keyword. - - NamedNodeMap* entities() const; - /// A NamedNodeMap containing the general entities, - /// both external and internal, declared in the DTD. - /// Duplicates are discarded. - /// - /// Note: In this implementation, only the - /// external entities are reported. - /// Every node in this map also implements the - /// Entity interface. +// +// DocumentType.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM DocumentType class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_DocumentType_INCLUDED +#define DOM_DocumentType_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractContainerNode.h" + + +namespace Poco { +namespace XML { + + +class NamedNodeMap; + + +class XML_API DocumentType: public AbstractContainerNode + /// Each Document has a doctype attribute whose value is either null or a DocumentType + /// object. The DocumentType interface in the DOM Level 1 Core provides an + /// interface to the list of entities that are defined for the document, and + /// little else because the effect of namespaces and the various XML scheme + /// efforts on DTD representation are not clearly understood as of this writing. + /// + /// The DOM Level 1 doesn't support editing DocumentType nodes. +{ +public: + const XMLString& name() const; + /// The name of the DTD; i.e., the name immediately following the + /// DOCTYPE keyword. + + NamedNodeMap* entities() const; + /// A NamedNodeMap containing the general entities, + /// both external and internal, declared in the DTD. + /// Duplicates are discarded. /// - /// The returned NamedNodeMap must be released with a call - /// to release() when no longer needed. - - NamedNodeMap* notations() const; - /// A NamedNodeMap containing the notations declared in the DTD. Duplicates - /// are discarded. Every node in this map also implements the Notation interface. - /// The DOM Level 1 does not support editing notations, therefore notations - /// cannot be altered in any way. - /// - /// The returned NamedNodeMap must be released with a call - /// to release() when no longer needed. - - // DOM Level 2 - const XMLString& publicId() const; - /// Returns the public identifier of the external DTD subset. - - const XMLString& systemId() const; - /// Returns the system identifier of the external DTD subset. - - const XMLString& internalSubset() const; - /// Returns the internal DTD subset. This implementation - /// returns an empty string. - - // Node - const XMLString& nodeName() const; - unsigned short nodeType() const; - -protected: - DocumentType(Document* pOwner, const XMLString& name, const XMLString& publicId, const XMLString& systemId); - DocumentType(Document* pOwner, const DocumentType& dt); - ~DocumentType(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - -private: - XMLString _name; - XMLString _publicId; - XMLString _systemId; - - friend class DOMImplementation; - friend class Document; - friend class DOMBuilder; -}; - - -// -// inlines -// -inline const XMLString& DocumentType::name() const -{ - return _name; -} - - -inline const XMLString& DocumentType::publicId() const -{ - return _publicId; -} - - -inline const XMLString& DocumentType::systemId() const -{ - return _systemId; -} - - -} } // namespace Poco::XML - - -#endif // DOM_DocumentType_INCLUDED + /// Note: In this implementation, only the + /// external entities are reported. + /// Every node in this map also implements the + /// Entity interface. + /// + /// The returned NamedNodeMap must be released with a call + /// to release() when no longer needed. + + NamedNodeMap* notations() const; + /// A NamedNodeMap containing the notations declared in the DTD. Duplicates + /// are discarded. Every node in this map also implements the Notation interface. + /// The DOM Level 1 does not support editing notations, therefore notations + /// cannot be altered in any way. + /// + /// The returned NamedNodeMap must be released with a call + /// to release() when no longer needed. + + // DOM Level 2 + const XMLString& publicId() const; + /// Returns the public identifier of the external DTD subset. + + const XMLString& systemId() const; + /// Returns the system identifier of the external DTD subset. + + const XMLString& internalSubset() const; + /// Returns the internal DTD subset. This implementation + /// returns an empty string. + + // Node + const XMLString& nodeName() const; + unsigned short nodeType() const; + +protected: + DocumentType(Document* pOwner, const XMLString& name, const XMLString& publicId, const XMLString& systemId); + DocumentType(Document* pOwner, const DocumentType& dt); + ~DocumentType(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + +private: + XMLString _name; + XMLString _publicId; + XMLString _systemId; + + friend class DOMImplementation; + friend class Document; + friend class DOMBuilder; +}; + + +// +// inlines +// +inline const XMLString& DocumentType::name() const +{ + return _name; +} + + +inline const XMLString& DocumentType::publicId() const +{ + return _publicId; +} + + +inline const XMLString& DocumentType::systemId() const +{ + return _systemId; +} + + +} } // namespace Poco::XML + + +#endif // DOM_DocumentType_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/Element.h b/contrib/libs/poco/XML/include/Poco/DOM/Element.h index 90217baab8..4d7cf0dd34 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/Element.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/Element.h @@ -1,219 +1,219 @@ -// -// Element.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM Element class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_Element_INCLUDED -#define DOM_Element_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractContainerNode.h" -#include "Poco/XML/Name.h" - - -namespace Poco { -namespace XML { - - -class Attr; -class NodeList; -class Document; - - -class XML_API Element: public AbstractContainerNode - /// The Element interface represents an element in an XML document. - /// Elements may have attributes associated with them; since the Element interface - /// inherits from Node, the generic Node interface attribute attributes may - /// be used to retrieve the set of all attributes for an element. There are - /// methods on the Element interface to retrieve either an Attr object by name - /// or an attribute value by name. In XML, where an attribute value may contain - /// entity references, an Attr object should be retrieved to examine the possibly - /// fairly complex sub-tree representing the attribute value. -{ -public: - const XMLString& tagName() const; - /// Returns the name of the element. - /// - /// For example, in +// +// Element.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM Element class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_Element_INCLUDED +#define DOM_Element_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractContainerNode.h" +#include "Poco/XML/Name.h" + + +namespace Poco { +namespace XML { + + +class Attr; +class NodeList; +class Document; + + +class XML_API Element: public AbstractContainerNode + /// The Element interface represents an element in an XML document. + /// Elements may have attributes associated with them; since the Element interface + /// inherits from Node, the generic Node interface attribute attributes may + /// be used to retrieve the set of all attributes for an element. There are + /// methods on the Element interface to retrieve either an Attr object by name + /// or an attribute value by name. In XML, where an attribute value may contain + /// entity references, an Attr object should be retrieved to examine the possibly + /// fairly complex sub-tree representing the attribute value. +{ +public: + const XMLString& tagName() const; + /// Returns the name of the element. + /// + /// For example, in + /// + /// <elementExample id="demo"> + /// ... + /// </elementExample> + /// + /// tagName has the value "elementExample". Note that this is case-preserving in XML, + /// as are all of the operations of the DOM. + + const XMLString& getAttribute(const XMLString& name) const; + /// Retrieves an attribute value by name. /// - /// <elementExample id="demo"> - /// ... - /// </elementExample> - /// - /// tagName has the value "elementExample". Note that this is case-preserving in XML, - /// as are all of the operations of the DOM. - - const XMLString& getAttribute(const XMLString& name) const; - /// Retrieves an attribute value by name. - /// - /// Returns the attribute's value, if the attribute - /// exists, or an empty string otherwise. - - void setAttribute(const XMLString& name, const XMLString& value); - /// Adds a new attribute. If an attribute with that name is already present - /// in the element, its value is changed to be that of the value parameter. - /// This value is a simple string; it is not parsed as it is being set. So any - /// markup (such as syntax to be recognized as an entity reference) is treated - /// as literal text, and needs to be appropriately escaped by the implementation - /// when it is written out. - - void removeAttribute(const XMLString& name); - /// Removes an attribute by name. - - Attr* getAttributeNode(const XMLString& name) const; - /// Retrieves an Attr node by name. - - Attr* setAttributeNode(Attr* newAttr); - /// Adds a new attribute. If an attribute with that name is already - /// present in the element, it is replaced by the new one. - - Attr* addAttributeNodeNP(Attr* oldAttr, Attr* newAttr); - /// For internal use only. - /// Adds a new attribute after oldAttr. - /// If oldAttr is 0, newAttr is set as first attribute. - /// Returns newAttr. - /// Does not fire any events. - - Attr* removeAttributeNode(Attr* oldAttr); - /// Removes the specified attribute. - - NodeList* getElementsByTagName(const XMLString& name) const; - /// Returns a NodeList of all descendant elements with a given tag - /// name, in the order in which they would be encountered in a - /// preorder traversal of the Element tree. - /// - /// The special name "*" matches all tags. - /// - /// The returned NodeList must be released with a call - /// to release() when no longer needed. - - void normalize(); - /// Puts all Text nodes in the full depth of the sub-tree underneath this Element, - /// including attribute nodes, into a "normal" form where only markup (e.g., - /// tags, comments, processing instructions, CDATA sections, and entity references) - /// separates Text nodes, i.e., there are no adjacent Text nodes. This can be - /// used to ensure that the DOM view of a document is the same as if it were - /// saved and re-loaded, and is useful when operations (such as XPointer - /// lookups) that depend on a particular document tree structure are to be used. + /// Returns the attribute's value, if the attribute + /// exists, or an empty string otherwise. + + void setAttribute(const XMLString& name, const XMLString& value); + /// Adds a new attribute. If an attribute with that name is already present + /// in the element, its value is changed to be that of the value parameter. + /// This value is a simple string; it is not parsed as it is being set. So any + /// markup (such as syntax to be recognized as an entity reference) is treated + /// as literal text, and needs to be appropriately escaped by the implementation + /// when it is written out. + + void removeAttribute(const XMLString& name); + /// Removes an attribute by name. + + Attr* getAttributeNode(const XMLString& name) const; + /// Retrieves an Attr node by name. + + Attr* setAttributeNode(Attr* newAttr); + /// Adds a new attribute. If an attribute with that name is already + /// present in the element, it is replaced by the new one. + + Attr* addAttributeNodeNP(Attr* oldAttr, Attr* newAttr); + /// For internal use only. + /// Adds a new attribute after oldAttr. + /// If oldAttr is 0, newAttr is set as first attribute. + /// Returns newAttr. + /// Does not fire any events. + + Attr* removeAttributeNode(Attr* oldAttr); + /// Removes the specified attribute. + + NodeList* getElementsByTagName(const XMLString& name) const; + /// Returns a NodeList of all descendant elements with a given tag + /// name, in the order in which they would be encountered in a + /// preorder traversal of the Element tree. + /// + /// The special name "*" matches all tags. /// - /// Note: In cases where the document contains CDATASections, the normalize - /// operation alone may not be sufficient, since XPointers do not differentiate - /// between Text nodes and CDATASection nodes. - - // DOM Level 2 - const XMLString& getAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const; - /// Retrieves an attribute value by name. - /// - /// Returns the attribute's value, if the attribute - /// exists, or an empty string otherwise. - - void setAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName, const XMLString& value); - /// Adds a new attribute. If an attribute with that name - /// is already present in the element, its value is changed - /// to be that of the value parameter. - - void removeAttributeNS(const XMLString& namespaceURI, const XMLString& localName); - /// Removes an attribute by name. - - Attr* getAttributeNodeNS(const XMLString& namespaceURI, const XMLString& localName) const; - /// Retrieves an Attr node by name. - - Attr* setAttributeNodeNS(Attr* newAttr); - /// Adds a new attribute. If an attribute with that name is already - /// present in the element, it is replaced by the new one. - - bool hasAttribute(const XMLString& name) const; - /// Returns true if and only if the element has the specified attribute. - - bool hasAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const; - /// Returns true if and only if the element has the specified attribute. - - NodeList* getElementsByTagNameNS(const XMLString& namespaceURI, const XMLString& localName) const; - /// Returns a NodeList of all the descendant Elements with a given local name and namespace URI - /// in the order in which they are encountered in a preorder traversal of this Element tree. - /// - /// The special value "*" matches all namespaces, or local names respectively. - /// - /// The returned NodeList must be released with a call - /// to release() when no longer needed. - - const XMLString& namespaceURI() const; - XMLString prefix() const; - const XMLString& localName() const; - bool hasAttributes() const; - XMLString innerText() const; - - Element* getChildElement(const XMLString& name) const; - /// Returns the first child element with the given name, or null - /// if such an element does not exist. - /// - /// This method is an extension to the W3C Document Object Model. - - Element* getChildElementNS(const XMLString& namespaceURI, const XMLString& localName) const; - /// Returns the first child element with the given namespaceURI and localName, - /// or null if such an element does not exist. - /// - /// This method is an extension to the W3C Document Object Model. - - Element* getElementById(const XMLString& elementId, const XMLString& idAttribute) const; - /// Returns the first Element whose ID attribute (given in idAttribute) - /// has the given elementId. If no such element exists, returns null. - /// - /// This method is an extension to the W3C Document Object Model. - - Element* getElementByIdNS(const XMLString& elementId, const XMLString& idAttributeURI, const XMLString& idAttributeLocalName) const; - /// Returns the first Element whose ID attribute (given in idAttributeURI and idAttributeLocalName) - /// has the given elementId. If no such element exists, returns null. - /// - /// This method is an extension to the W3C Document Object Model. - - // Node - const XMLString& nodeName() const; - NamedNodeMap* attributes() const; - unsigned short nodeType() const; - -protected: - Element(Document* pOwnerDocument, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname); - Element(Document* pOwnerDocument, const Element& elem); - ~Element(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - - void dispatchNodeRemovedFromDocument(); - void dispatchNodeInsertedIntoDocument(); - -private: - const Name& _name; - Attr* _pFirstAttr; - - friend class Attr; - friend class Document; - friend class AttrMap; -}; - - -// -// inlines -// -inline const XMLString& Element::tagName() const -{ - return _name.qname(); -} - - -} } // namespace Poco::XML - - -#endif // DOM_Element_INCLUDED + /// The returned NodeList must be released with a call + /// to release() when no longer needed. + + void normalize(); + /// Puts all Text nodes in the full depth of the sub-tree underneath this Element, + /// including attribute nodes, into a "normal" form where only markup (e.g., + /// tags, comments, processing instructions, CDATA sections, and entity references) + /// separates Text nodes, i.e., there are no adjacent Text nodes. This can be + /// used to ensure that the DOM view of a document is the same as if it were + /// saved and re-loaded, and is useful when operations (such as XPointer + /// lookups) that depend on a particular document tree structure are to be used. + /// + /// Note: In cases where the document contains CDATASections, the normalize + /// operation alone may not be sufficient, since XPointers do not differentiate + /// between Text nodes and CDATASection nodes. + + // DOM Level 2 + const XMLString& getAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const; + /// Retrieves an attribute value by name. + /// + /// Returns the attribute's value, if the attribute + /// exists, or an empty string otherwise. + + void setAttributeNS(const XMLString& namespaceURI, const XMLString& qualifiedName, const XMLString& value); + /// Adds a new attribute. If an attribute with that name + /// is already present in the element, its value is changed + /// to be that of the value parameter. + + void removeAttributeNS(const XMLString& namespaceURI, const XMLString& localName); + /// Removes an attribute by name. + + Attr* getAttributeNodeNS(const XMLString& namespaceURI, const XMLString& localName) const; + /// Retrieves an Attr node by name. + + Attr* setAttributeNodeNS(Attr* newAttr); + /// Adds a new attribute. If an attribute with that name is already + /// present in the element, it is replaced by the new one. + + bool hasAttribute(const XMLString& name) const; + /// Returns true if and only if the element has the specified attribute. + + bool hasAttributeNS(const XMLString& namespaceURI, const XMLString& localName) const; + /// Returns true if and only if the element has the specified attribute. + + NodeList* getElementsByTagNameNS(const XMLString& namespaceURI, const XMLString& localName) const; + /// Returns a NodeList of all the descendant Elements with a given local name and namespace URI + /// in the order in which they are encountered in a preorder traversal of this Element tree. + /// + /// The special value "*" matches all namespaces, or local names respectively. + /// + /// The returned NodeList must be released with a call + /// to release() when no longer needed. + + const XMLString& namespaceURI() const; + XMLString prefix() const; + const XMLString& localName() const; + bool hasAttributes() const; + XMLString innerText() const; + + Element* getChildElement(const XMLString& name) const; + /// Returns the first child element with the given name, or null + /// if such an element does not exist. + /// + /// This method is an extension to the W3C Document Object Model. + + Element* getChildElementNS(const XMLString& namespaceURI, const XMLString& localName) const; + /// Returns the first child element with the given namespaceURI and localName, + /// or null if such an element does not exist. + /// + /// This method is an extension to the W3C Document Object Model. + + Element* getElementById(const XMLString& elementId, const XMLString& idAttribute) const; + /// Returns the first Element whose ID attribute (given in idAttribute) + /// has the given elementId. If no such element exists, returns null. + /// + /// This method is an extension to the W3C Document Object Model. + + Element* getElementByIdNS(const XMLString& elementId, const XMLString& idAttributeURI, const XMLString& idAttributeLocalName) const; + /// Returns the first Element whose ID attribute (given in idAttributeURI and idAttributeLocalName) + /// has the given elementId. If no such element exists, returns null. + /// + /// This method is an extension to the W3C Document Object Model. + + // Node + const XMLString& nodeName() const; + NamedNodeMap* attributes() const; + unsigned short nodeType() const; + +protected: + Element(Document* pOwnerDocument, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname); + Element(Document* pOwnerDocument, const Element& elem); + ~Element(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + + void dispatchNodeRemovedFromDocument(); + void dispatchNodeInsertedIntoDocument(); + +private: + const Name& _name; + Attr* _pFirstAttr; + + friend class Attr; + friend class Document; + friend class AttrMap; +}; + + +// +// inlines +// +inline const XMLString& Element::tagName() const +{ + return _name.qname(); +} + + +} } // namespace Poco::XML + + +#endif // DOM_Element_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/ElementsByTagNameList.h b/contrib/libs/poco/XML/include/Poco/DOM/ElementsByTagNameList.h index 98af2e8207..a44e5af43b 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/ElementsByTagNameList.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/ElementsByTagNameList.h @@ -1,86 +1,86 @@ -// -// ElementsByTagNameList.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the ElementsByTagNameList and ElementsByTagNameListNS classes. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_ElementsByTagNameList_INCLUDED -#define DOM_ElementsByTagNameList_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/NodeList.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API ElementsByTagNameList: public NodeList - // This implementation of NodeList is returned - // by Document::getElementsByTagName() and - // Element::getElementsByTagName(). -{ -public: - Node* item(unsigned long index) const; - unsigned long length() const; - void autoRelease(); - -protected: - ElementsByTagNameList(const Node* pParent, const XMLString& name); - ~ElementsByTagNameList(); - - Node* find(const Node* pParent, unsigned long index) const; - - const Node* _pParent; - XMLString _name; - mutable unsigned long _count; - - friend class AbstractContainerNode; - friend class Element; - friend class Document; -}; - - -class XML_API ElementsByTagNameListNS: public NodeList - // This implementation of NodeList is returned - // by Document::getElementsByTagNameNS() and - // Element::getElementsByTagNameNS(). -{ -public: - virtual Node* item(unsigned long index) const; - virtual unsigned long length() const; - virtual void autoRelease(); - -protected: - ElementsByTagNameListNS(const Node* pParent, const XMLString& namespaceURI, const XMLString& localName); - ~ElementsByTagNameListNS(); - - Node* find(const Node* pParent, unsigned long index) const; - - const Node* _pParent; - XMLString _localName; - XMLString _namespaceURI; - mutable unsigned long _count; - - friend class AbstractContainerNode; - friend class Element; - friend class Document; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_ElementsByTagNameList_INCLUDED +// +// ElementsByTagNameList.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the ElementsByTagNameList and ElementsByTagNameListNS classes. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_ElementsByTagNameList_INCLUDED +#define DOM_ElementsByTagNameList_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/NodeList.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API ElementsByTagNameList: public NodeList + // This implementation of NodeList is returned + // by Document::getElementsByTagName() and + // Element::getElementsByTagName(). +{ +public: + Node* item(unsigned long index) const; + unsigned long length() const; + void autoRelease(); + +protected: + ElementsByTagNameList(const Node* pParent, const XMLString& name); + ~ElementsByTagNameList(); + + Node* find(const Node* pParent, unsigned long index) const; + + const Node* _pParent; + XMLString _name; + mutable unsigned long _count; + + friend class AbstractContainerNode; + friend class Element; + friend class Document; +}; + + +class XML_API ElementsByTagNameListNS: public NodeList + // This implementation of NodeList is returned + // by Document::getElementsByTagNameNS() and + // Element::getElementsByTagNameNS(). +{ +public: + virtual Node* item(unsigned long index) const; + virtual unsigned long length() const; + virtual void autoRelease(); + +protected: + ElementsByTagNameListNS(const Node* pParent, const XMLString& namespaceURI, const XMLString& localName); + ~ElementsByTagNameListNS(); + + Node* find(const Node* pParent, unsigned long index) const; + + const Node* _pParent; + XMLString _localName; + XMLString _namespaceURI; + mutable unsigned long _count; + + friend class AbstractContainerNode; + friend class Element; + friend class Document; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_ElementsByTagNameList_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/Entity.h b/contrib/libs/poco/XML/include/Poco/DOM/Entity.h index 40c21f59cd..7fb284b022 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/Entity.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/Entity.h @@ -1,126 +1,126 @@ -// -// Entity.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM Entity class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_Entity_INCLUDED -#define DOM_Entity_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractContainerNode.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API Entity: public AbstractContainerNode - /// This interface represents an entity, either parsed or unparsed, in an XML - /// document. Note that this models the entity itself not the entity declaration. - /// Entity declaration modeling has been left for a later Level of the DOM - /// specification. - /// - /// The nodeName attribute that is inherited from Node contains the name of - /// the entity. - /// - /// An XML processor may choose to completely expand entities before the structure - /// model is passed to the DOM; in this case there will be no EntityReference - /// nodes in the document tree. - /// - /// XML does not mandate that a non-validating XML processor read and process - /// entity declarations made in the external subset or declared in external - /// parameter entities. This means that parsed entities declared in the external - /// subset need not be expanded by some classes of applications, and that the - /// replacement value of the entity may not be available. When the replacement - /// value is available, the corresponding Entity node's child list represents - /// the structure of that replacement text. Otherwise, the child list is empty. - /// - /// The resolution of the children of the Entity (the replacement value) may - /// be lazily evaluated; actions by the user (such as calling the childNodes - /// method on the Entity Node) are assumed to trigger the evaluation. - /// - /// The DOM Level 1 does not support editing Entity nodes; if a user wants to - /// make changes to the contents of an Entity, every related EntityReference - /// node has to be replaced in the structure model by a clone of the Entity's - /// contents, and then the desired changes must be made to each of those clones - /// instead. Entity nodes and all their descendants are readonly. - /// - /// An Entity node does not have any parent. -{ -public: - const XMLString& publicId() const; - /// Returns the public identifier associated with - /// the entity, if specified. If the public identifier - /// was not specified, this is the empty string. - - const XMLString& systemId() const; - /// Returns the system identifier associated with - /// the entity, if specified. If the system identifier - /// was not specified, this is the empty string. - - const XMLString& notationName() const; - /// Returns, for unparsed entities, the name of the - /// notation for the entity. For parsed entities, this - /// is the empty string. - - // Node - const XMLString& nodeName() const; - unsigned short nodeType() const; - -protected: - Entity(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId, const XMLString& notationName); - Entity(Document* pOwnerDocument, const Entity& entity); - ~Entity(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - -private: - static const XMLString NODE_NAME; - - XMLString _name; - XMLString _publicId; - XMLString _systemId; - XMLString _notationName; - - friend class Document; -}; - - -// -// inlines -// -inline const XMLString& Entity::publicId() const -{ - return _publicId; -} - - -inline const XMLString& Entity::systemId() const -{ - return _systemId; -} - - -inline const XMLString& Entity::notationName() const -{ - return _notationName; -} - - -} } // namespace Poco::XML - - -#endif // DOM_Entity_INCLUDED +// +// Entity.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM Entity class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_Entity_INCLUDED +#define DOM_Entity_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractContainerNode.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API Entity: public AbstractContainerNode + /// This interface represents an entity, either parsed or unparsed, in an XML + /// document. Note that this models the entity itself not the entity declaration. + /// Entity declaration modeling has been left for a later Level of the DOM + /// specification. + /// + /// The nodeName attribute that is inherited from Node contains the name of + /// the entity. + /// + /// An XML processor may choose to completely expand entities before the structure + /// model is passed to the DOM; in this case there will be no EntityReference + /// nodes in the document tree. + /// + /// XML does not mandate that a non-validating XML processor read and process + /// entity declarations made in the external subset or declared in external + /// parameter entities. This means that parsed entities declared in the external + /// subset need not be expanded by some classes of applications, and that the + /// replacement value of the entity may not be available. When the replacement + /// value is available, the corresponding Entity node's child list represents + /// the structure of that replacement text. Otherwise, the child list is empty. + /// + /// The resolution of the children of the Entity (the replacement value) may + /// be lazily evaluated; actions by the user (such as calling the childNodes + /// method on the Entity Node) are assumed to trigger the evaluation. + /// + /// The DOM Level 1 does not support editing Entity nodes; if a user wants to + /// make changes to the contents of an Entity, every related EntityReference + /// node has to be replaced in the structure model by a clone of the Entity's + /// contents, and then the desired changes must be made to each of those clones + /// instead. Entity nodes and all their descendants are readonly. + /// + /// An Entity node does not have any parent. +{ +public: + const XMLString& publicId() const; + /// Returns the public identifier associated with + /// the entity, if specified. If the public identifier + /// was not specified, this is the empty string. + + const XMLString& systemId() const; + /// Returns the system identifier associated with + /// the entity, if specified. If the system identifier + /// was not specified, this is the empty string. + + const XMLString& notationName() const; + /// Returns, for unparsed entities, the name of the + /// notation for the entity. For parsed entities, this + /// is the empty string. + + // Node + const XMLString& nodeName() const; + unsigned short nodeType() const; + +protected: + Entity(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId, const XMLString& notationName); + Entity(Document* pOwnerDocument, const Entity& entity); + ~Entity(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + +private: + static const XMLString NODE_NAME; + + XMLString _name; + XMLString _publicId; + XMLString _systemId; + XMLString _notationName; + + friend class Document; +}; + + +// +// inlines +// +inline const XMLString& Entity::publicId() const +{ + return _publicId; +} + + +inline const XMLString& Entity::systemId() const +{ + return _systemId; +} + + +inline const XMLString& Entity::notationName() const +{ + return _notationName; +} + + +} } // namespace Poco::XML + + +#endif // DOM_Entity_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/EntityReference.h b/contrib/libs/poco/XML/include/Poco/DOM/EntityReference.h index 5ecd044b57..a6568a6df9 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/EntityReference.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/EntityReference.h @@ -1,73 +1,73 @@ -// -// EntityReference.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM EntityReference class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_EntityReference_INCLUDED -#define DOM_EntityReference_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractNode.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API EntityReference: public AbstractNode - /// EntityReference objects may be inserted into the structure model when an - /// entity reference is in the source document, or when the user wishes to insert - /// an entity reference. Note that character references and references to predefined - /// entities are considered to be expanded by the HTML or XML processor so that - /// characters are represented by their Unicode equivalent rather than by an - /// entity reference. Moreover, the XML processor may completely expand references - /// to entities while building the structure model, instead of providing EntityReference - /// objects. If it does provide such objects, then for a given EntityReference - /// node, it may be that there is no Entity node representing the referenced - /// entity. If such an Entity exists, then the child list of the EntityReference - /// node is the same as that of the Entity node. - /// - /// As for Entity nodes, EntityReference nodes and all their descendants are - /// readonly. - /// - /// The resolution of the children of the EntityReference (the replacement value - /// of the referenced Entity) may be lazily evaluated; actions by the user (such - /// as calling the childNodes method on the EntityReference node) are assumed - /// to trigger the evaluation. -{ -public: - // Node - const XMLString& nodeName() const; - unsigned short nodeType() const; - -protected: - EntityReference(Document* pOwnerDocument, const XMLString& name); - EntityReference(Document* pOwnerDocument, const EntityReference& ref); - ~EntityReference(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - -private: - XMLString _name; - - friend class Document; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_EntityReference_INCLUDED +// +// EntityReference.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM EntityReference class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_EntityReference_INCLUDED +#define DOM_EntityReference_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractNode.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API EntityReference: public AbstractNode + /// EntityReference objects may be inserted into the structure model when an + /// entity reference is in the source document, or when the user wishes to insert + /// an entity reference. Note that character references and references to predefined + /// entities are considered to be expanded by the HTML or XML processor so that + /// characters are represented by their Unicode equivalent rather than by an + /// entity reference. Moreover, the XML processor may completely expand references + /// to entities while building the structure model, instead of providing EntityReference + /// objects. If it does provide such objects, then for a given EntityReference + /// node, it may be that there is no Entity node representing the referenced + /// entity. If such an Entity exists, then the child list of the EntityReference + /// node is the same as that of the Entity node. + /// + /// As for Entity nodes, EntityReference nodes and all their descendants are + /// readonly. + /// + /// The resolution of the children of the EntityReference (the replacement value + /// of the referenced Entity) may be lazily evaluated; actions by the user (such + /// as calling the childNodes method on the EntityReference node) are assumed + /// to trigger the evaluation. +{ +public: + // Node + const XMLString& nodeName() const; + unsigned short nodeType() const; + +protected: + EntityReference(Document* pOwnerDocument, const XMLString& name); + EntityReference(Document* pOwnerDocument, const EntityReference& ref); + ~EntityReference(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + +private: + XMLString _name; + + friend class Document; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_EntityReference_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/Event.h b/contrib/libs/poco/XML/include/Poco/DOM/Event.h index 5396aa3f5a..cbdc5f9f50 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/Event.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/Event.h @@ -1,209 +1,209 @@ -// -// Event.h -// -// Library: XML -// Package: DOM -// Module: DOMEvents -// -// Definition of the DOM Event class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_Event_INCLUDED -#define DOM_Event_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" -#include "Poco/DOM/DOMObject.h" - - -namespace Poco { -namespace XML { - - -class EventTarget; -class Document; - - -class XML_API Event: public DOMObject - /// The Event interface is used to provide contextual information about an event - /// to the handler processing the event. An object which implements the Event - /// interface is generally passed as the first parameter to an event handler. - /// More specific context information is passed to event handlers by deriving - /// additional interfaces from Event which contain information directly relating - /// to the type of event they accompany. These derived interfaces are also implemented - /// by the object passed to the event listener. -{ -public: - enum PhaseType - { - CAPTURING_PHASE = 1, /// The event is currently being evaluated at the target EventTarget. - AT_TARGET = 2, /// The current event phase is the bubbling phase. - BUBBLING_PHASE = 3 /// The current event phase is the capturing phase. - }; - - const XMLString& type() const; - /// The name of the event (case-insensitive). The name must be an XML name. - - EventTarget* target() const; - /// Used to indicate the EventTarget to which the event was originally dispatched. - - EventTarget* currentTarget() const; - /// Used to indicate the EventTarget whose EventListeners are currently being - /// processed. This is particularly useful during capturing and bubbling. - - PhaseType eventPhase() const; - /// Used to indicate which phase of event flow is currently being evaluated. - - bool bubbles() const; - /// Used to indicate whether or not an event is a bubbling event. - /// If the event can bubble the value is true, else the value is false. - - bool cancelable() const; - /// Used to indicate whether or not an event can have its default action - /// prevented. If the default action can be prevented the value is - /// true, else the value is false. - - Poco::UInt64 timeStamp() const; - /// Used to specify the time (in milliseconds relative to the epoch) at - /// which the event was created. Due to the fact that some - /// systems may not provide this information the value of timeStamp may - /// be not available for all events. When not available, a - /// value of 0 will be returned. Examples of epoch time are the time of the - /// system start or 0:0:0 UTC 1st January 1970. - /// This implementation always returns 0. - - void stopPropagation(); - /// The stopPropagation method is used prevent further propagation of an - /// event during event flow. If this method is called by - /// any EventListener the event will cease propagating through the tree. - /// The event will complete dispatch to all listeners on the - /// current EventTarget before event flow stops. This method may be used - /// during any stage of event flow. - - void preventDefault(); - /// If an event is cancelable, the preventDefault method is used to signify - /// that the event is to be canceled, meaning any default - /// action normally taken by the implementation as a result of - /// the event will not occur. If, during any stage of event flow, the - /// preventDefault method is called the event is canceled. Any default - /// action associated with the event will not occur. Calling - /// this method for a non-cancelable event has no effect. Once - /// preventDefault has been called it will remain in effect throughout - /// the remainder of the event's propagation. This method may be - /// used during any stage of event flow. - - void initEvent(const XMLString& eventType, bool canBubble, bool isCancelable); - /// The initEvent method is used to initialize the value of an - /// Event created through the DocumentEvent interface. This method - /// may only be called before the Event has been dispatched via the - /// dispatchEvent method, though it may be called multiple - /// times during that phase if necessary. If called multiple - /// times the final invocation takes precedence. If called from - /// a subclass of Event interface only the values specified in the - /// initEvent method are modified, all other attributes are left unchanged. - - void autoRelease(); - -protected: - Event(Document* pOwnerDocument, const XMLString& type); - Event(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool isCancelable); - ~Event(); - - bool isCanceled() const; - /// returns true if and only if the event has been cancelled. - - bool isStopped() const; - /// returns true if and only if propagation of the event has been stopped. - - void setTarget(EventTarget* pTarget); - /// sets the target - - void setCurrentPhase(PhaseType phase); - /// sets the current phase - - void setCurrentTarget(EventTarget* pTarget); - /// sets the current target - -private: - Document* _pOwner; - XMLString _type; - EventTarget* _pTarget; - EventTarget* _pCurrentTarget; - PhaseType _currentPhase; - bool _bubbles; - bool _cancelable; - bool _canceled; - bool _stopped; - - friend class AbstractNode; -}; - - -// -// inlines -// -inline const XMLString& Event::type() const -{ - return _type; -} - - -inline EventTarget* Event::target() const -{ - return _pTarget; -} - - -inline EventTarget* Event::currentTarget() const -{ - return _pCurrentTarget; -} - - -inline Event::PhaseType Event::eventPhase() const -{ - return _currentPhase; -} - - -inline bool Event::bubbles() const -{ - return _bubbles; -} - - -inline bool Event::cancelable() const -{ - return _cancelable; -} - - -inline Poco::UInt64 Event::timeStamp() const -{ - return 0; -} - - -inline bool Event::isCanceled() const -{ - return _canceled; -} - - -inline bool Event::isStopped() const -{ - return _stopped; -} - - -} } // namespace Poco::XML - - -#endif // DOM_Event_INCLUDED +// +// Event.h +// +// Library: XML +// Package: DOM +// Module: DOMEvents +// +// Definition of the DOM Event class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_Event_INCLUDED +#define DOM_Event_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" +#include "Poco/DOM/DOMObject.h" + + +namespace Poco { +namespace XML { + + +class EventTarget; +class Document; + + +class XML_API Event: public DOMObject + /// The Event interface is used to provide contextual information about an event + /// to the handler processing the event. An object which implements the Event + /// interface is generally passed as the first parameter to an event handler. + /// More specific context information is passed to event handlers by deriving + /// additional interfaces from Event which contain information directly relating + /// to the type of event they accompany. These derived interfaces are also implemented + /// by the object passed to the event listener. +{ +public: + enum PhaseType + { + CAPTURING_PHASE = 1, /// The event is currently being evaluated at the target EventTarget. + AT_TARGET = 2, /// The current event phase is the bubbling phase. + BUBBLING_PHASE = 3 /// The current event phase is the capturing phase. + }; + + const XMLString& type() const; + /// The name of the event (case-insensitive). The name must be an XML name. + + EventTarget* target() const; + /// Used to indicate the EventTarget to which the event was originally dispatched. + + EventTarget* currentTarget() const; + /// Used to indicate the EventTarget whose EventListeners are currently being + /// processed. This is particularly useful during capturing and bubbling. + + PhaseType eventPhase() const; + /// Used to indicate which phase of event flow is currently being evaluated. + + bool bubbles() const; + /// Used to indicate whether or not an event is a bubbling event. + /// If the event can bubble the value is true, else the value is false. + + bool cancelable() const; + /// Used to indicate whether or not an event can have its default action + /// prevented. If the default action can be prevented the value is + /// true, else the value is false. + + Poco::UInt64 timeStamp() const; + /// Used to specify the time (in milliseconds relative to the epoch) at + /// which the event was created. Due to the fact that some + /// systems may not provide this information the value of timeStamp may + /// be not available for all events. When not available, a + /// value of 0 will be returned. Examples of epoch time are the time of the + /// system start or 0:0:0 UTC 1st January 1970. + /// This implementation always returns 0. + + void stopPropagation(); + /// The stopPropagation method is used prevent further propagation of an + /// event during event flow. If this method is called by + /// any EventListener the event will cease propagating through the tree. + /// The event will complete dispatch to all listeners on the + /// current EventTarget before event flow stops. This method may be used + /// during any stage of event flow. + + void preventDefault(); + /// If an event is cancelable, the preventDefault method is used to signify + /// that the event is to be canceled, meaning any default + /// action normally taken by the implementation as a result of + /// the event will not occur. If, during any stage of event flow, the + /// preventDefault method is called the event is canceled. Any default + /// action associated with the event will not occur. Calling + /// this method for a non-cancelable event has no effect. Once + /// preventDefault has been called it will remain in effect throughout + /// the remainder of the event's propagation. This method may be + /// used during any stage of event flow. + + void initEvent(const XMLString& eventType, bool canBubble, bool isCancelable); + /// The initEvent method is used to initialize the value of an + /// Event created through the DocumentEvent interface. This method + /// may only be called before the Event has been dispatched via the + /// dispatchEvent method, though it may be called multiple + /// times during that phase if necessary. If called multiple + /// times the final invocation takes precedence. If called from + /// a subclass of Event interface only the values specified in the + /// initEvent method are modified, all other attributes are left unchanged. + + void autoRelease(); + +protected: + Event(Document* pOwnerDocument, const XMLString& type); + Event(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool isCancelable); + ~Event(); + + bool isCanceled() const; + /// returns true if and only if the event has been cancelled. + + bool isStopped() const; + /// returns true if and only if propagation of the event has been stopped. + + void setTarget(EventTarget* pTarget); + /// sets the target + + void setCurrentPhase(PhaseType phase); + /// sets the current phase + + void setCurrentTarget(EventTarget* pTarget); + /// sets the current target + +private: + Document* _pOwner; + XMLString _type; + EventTarget* _pTarget; + EventTarget* _pCurrentTarget; + PhaseType _currentPhase; + bool _bubbles; + bool _cancelable; + bool _canceled; + bool _stopped; + + friend class AbstractNode; +}; + + +// +// inlines +// +inline const XMLString& Event::type() const +{ + return _type; +} + + +inline EventTarget* Event::target() const +{ + return _pTarget; +} + + +inline EventTarget* Event::currentTarget() const +{ + return _pCurrentTarget; +} + + +inline Event::PhaseType Event::eventPhase() const +{ + return _currentPhase; +} + + +inline bool Event::bubbles() const +{ + return _bubbles; +} + + +inline bool Event::cancelable() const +{ + return _cancelable; +} + + +inline Poco::UInt64 Event::timeStamp() const +{ + return 0; +} + + +inline bool Event::isCanceled() const +{ + return _canceled; +} + + +inline bool Event::isStopped() const +{ + return _stopped; +} + + +} } // namespace Poco::XML + + +#endif // DOM_Event_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/EventDispatcher.h b/contrib/libs/poco/XML/include/Poco/DOM/EventDispatcher.h index 4e825df9c4..b97a8dafd5 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/EventDispatcher.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/EventDispatcher.h @@ -1,97 +1,97 @@ -// -// EventDispatcher.h -// -// Library: XML -// Package: DOM -// Module: DOMEvents -// -// Definition of the EventDispatcher class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_EventDispatcher_INCLUDED -#define DOM_EventDispatcher_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" -#include <list> - - -namespace Poco { -namespace XML { - - -class Event; -class EventListener; - - -class XML_API EventDispatcher - /// This helper class manages event listener subscriptions - /// and event dispatching for AbstractNode. - /// - /// The EventListener list is managed in such a way that - /// event listeners can be added and removed even - /// from within an EventListener, while events are being - /// dispatched. -{ -public: - EventDispatcher(); - /// Creates the EventDispatcher. - - ~EventDispatcher(); - /// Destroys the EventDispatcher. - - void addEventListener(const XMLString& type, EventListener* listener, bool useCapture); - /// Adds an EventListener to the internal list. - - void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture); - /// Removes an EventListener from the internal list. - /// - /// If a dispatch is currently in progress, the list - /// entry is only marked for deletion. - /// If no dispatch is currently in progress, all EventListeners - /// marked for deletion are removed from the list. - - void dispatchEvent(Event* evt); - /// Dispatches the event. - /// - /// Also removes all EventListeners marked for deletion from the - /// event dispatcher list. - - void captureEvent(Event* evt); - /// Dispatches the event in its capturing phase. - /// - /// Also removes all EventListeners marked for deletion from the - /// event dispatcher list. - - void bubbleEvent(Event* evt); - /// Dispatches the event in its bubbling phase. - /// - /// Also removes all EventListeners marked for deletion from the - /// event dispatcher list. - -private: - struct EventListenerItem - { - XMLString type; - EventListener* pListener; - bool useCapture; - }; - - typedef std::list<EventListenerItem> EventListenerList; - - int _inDispatch; - EventListenerList _listeners; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_EventDispatcher_INCLUDED +// +// EventDispatcher.h +// +// Library: XML +// Package: DOM +// Module: DOMEvents +// +// Definition of the EventDispatcher class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_EventDispatcher_INCLUDED +#define DOM_EventDispatcher_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" +#include <list> + + +namespace Poco { +namespace XML { + + +class Event; +class EventListener; + + +class XML_API EventDispatcher + /// This helper class manages event listener subscriptions + /// and event dispatching for AbstractNode. + /// + /// The EventListener list is managed in such a way that + /// event listeners can be added and removed even + /// from within an EventListener, while events are being + /// dispatched. +{ +public: + EventDispatcher(); + /// Creates the EventDispatcher. + + ~EventDispatcher(); + /// Destroys the EventDispatcher. + + void addEventListener(const XMLString& type, EventListener* listener, bool useCapture); + /// Adds an EventListener to the internal list. + + void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture); + /// Removes an EventListener from the internal list. + /// + /// If a dispatch is currently in progress, the list + /// entry is only marked for deletion. + /// If no dispatch is currently in progress, all EventListeners + /// marked for deletion are removed from the list. + + void dispatchEvent(Event* evt); + /// Dispatches the event. + /// + /// Also removes all EventListeners marked for deletion from the + /// event dispatcher list. + + void captureEvent(Event* evt); + /// Dispatches the event in its capturing phase. + /// + /// Also removes all EventListeners marked for deletion from the + /// event dispatcher list. + + void bubbleEvent(Event* evt); + /// Dispatches the event in its bubbling phase. + /// + /// Also removes all EventListeners marked for deletion from the + /// event dispatcher list. + +private: + struct EventListenerItem + { + XMLString type; + EventListener* pListener; + bool useCapture; + }; + + typedef std::list<EventListenerItem> EventListenerList; + + int _inDispatch; + EventListenerList _listeners; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_EventDispatcher_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/EventException.h b/contrib/libs/poco/XML/include/Poco/DOM/EventException.h index cb82441058..b2f3561fe0 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/EventException.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/EventException.h @@ -1,81 +1,81 @@ -// -// EventException.h -// -// Library: XML -// Package: DOM -// Module: DOMEvents -// -// Definition of the DOM EventException class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_EventException_INCLUDED -#define DOM_EventException_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLException.h" - - -namespace Poco { -namespace XML { - - -class XML_API EventException: public XMLException - /// Event operations may throw an EventException as - /// specified in their method descriptions. -{ -public: - enum - { - UNSPECIFIED_EVENT_TYPE_ERR = 0 /// If the Event's type was not specified by initializing the - /// event before the method was called. Specification of the Event's - /// type as null or an empty string will also trigger this exception. - }; - - EventException(int code); - /// Creates an EventException with the given error code. - - EventException(const EventException& exc); - /// Creates an EventException by copying another one. - - ~EventException() noexcept; - /// Destroys the EventException. - - EventException& operator = (const EventException& exc); - +// +// EventException.h +// +// Library: XML +// Package: DOM +// Module: DOMEvents +// +// Definition of the DOM EventException class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_EventException_INCLUDED +#define DOM_EventException_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLException.h" + + +namespace Poco { +namespace XML { + + +class XML_API EventException: public XMLException + /// Event operations may throw an EventException as + /// specified in their method descriptions. +{ +public: + enum + { + UNSPECIFIED_EVENT_TYPE_ERR = 0 /// If the Event's type was not specified by initializing the + /// event before the method was called. Specification of the Event's + /// type as null or an empty string will also trigger this exception. + }; + + EventException(int code); + /// Creates an EventException with the given error code. + + EventException(const EventException& exc); + /// Creates an EventException by copying another one. + + ~EventException() noexcept; + /// Destroys the EventException. + + EventException& operator = (const EventException& exc); + const char* name() const noexcept; - /// Returns a static string describing the exception. - + /// Returns a static string describing the exception. + const char* className() const noexcept; - /// Returns the name of the exception class. - - unsigned short code() const; - /// Returns the Event exception code. - -protected: - Poco::Exception* clone() const; - -private: - EventException(); -}; - - -// -// inlines -// -inline unsigned short EventException::code() const -{ - return UNSPECIFIED_EVENT_TYPE_ERR; -} - - -} } // namespace Poco::XML - - -#endif // DOM_EventException_INCLUDED + /// Returns the name of the exception class. + + unsigned short code() const; + /// Returns the Event exception code. + +protected: + Poco::Exception* clone() const; + +private: + EventException(); +}; + + +// +// inlines +// +inline unsigned short EventException::code() const +{ + return UNSPECIFIED_EVENT_TYPE_ERR; +} + + +} } // namespace Poco::XML + + +#endif // DOM_EventException_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/EventListener.h b/contrib/libs/poco/XML/include/Poco/DOM/EventListener.h index f0951b10a2..ed358a8194 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/EventListener.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/EventListener.h @@ -1,57 +1,57 @@ -// -// EventListener.h -// -// Library: XML -// Package: DOM -// Module: DOMEvents -// -// Definition of the DOM EventListener interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_EventListener_INCLUDED -#define DOM_EventListener_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class Event; - - -class XML_API EventListener - /// The EventListener interface is the primary method for handling events. Users - /// implement the EventListener interface and register their listener on an - /// EventTarget using the AddEventListener method. The users should also remove - /// their EventListener from its EventTarget after they have completed using - /// the listener. - /// - /// When a Node is copied using the cloneNode method the EventListeners attached - /// to the source Node are not attached to the copied Node. If the user wishes - /// the same EventListeners to be added to the newly created copy the user must - /// add them manually. -{ -public: - virtual void handleEvent(Event* evt) = 0; - /// This method is called whenever an event occurs of the - /// type for which the EventListener interface was registered. - -protected: - virtual ~EventListener(); -}; - - -} } // namespace Poco::XML - - -#endif // DOM_EventListener_INCLUDED +// +// EventListener.h +// +// Library: XML +// Package: DOM +// Module: DOMEvents +// +// Definition of the DOM EventListener interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_EventListener_INCLUDED +#define DOM_EventListener_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class Event; + + +class XML_API EventListener + /// The EventListener interface is the primary method for handling events. Users + /// implement the EventListener interface and register their listener on an + /// EventTarget using the AddEventListener method. The users should also remove + /// their EventListener from its EventTarget after they have completed using + /// the listener. + /// + /// When a Node is copied using the cloneNode method the EventListeners attached + /// to the source Node are not attached to the copied Node. If the user wishes + /// the same EventListeners to be added to the newly created copy the user must + /// add them manually. +{ +public: + virtual void handleEvent(Event* evt) = 0; + /// This method is called whenever an event occurs of the + /// type for which the EventListener interface was registered. + +protected: + virtual ~EventListener(); +}; + + +} } // namespace Poco::XML + + +#endif // DOM_EventListener_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/EventTarget.h b/contrib/libs/poco/XML/include/Poco/DOM/EventTarget.h index 466d2151ed..34ba6ddbf4 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/EventTarget.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/EventTarget.h @@ -1,76 +1,76 @@ -// -// EventTarget.h -// -// Library: XML -// Package: DOM -// Module: DOMEvents -// -// Definition of the DOM EventTarget interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_EventTarget_INCLUDED -#define DOM_EventTarget_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/DOMObject.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class EventListener; -class Event; - - -class XML_API EventTarget: public DOMObject - /// The EventTarget interface is implemented by all Nodes in an implementation - /// which supports the DOM Event Model. Therefore, this interface can be obtained - /// by using binding-specific casting methods on an instance of the Node interface. - /// The interface allows registration and removal of EventListeners on an EventTarget - /// and dispatch of events to that EventTarget. -{ -public: - virtual void addEventListener(const XMLString& type, EventListener* listener, bool useCapture) = 0; - /// This method allows the registration of event listeners on - /// the event target. If an EventListener is added to an - /// EventTarget while it is processing an event, it will not - /// be triggered by the current actions but may be triggered - /// during a later stage of event flow, such as the bubbling phase. - /// If multiple identical EventListeners are registered on the same - /// EventTarget with the same parameters the duplicate instances are - /// discarded. They do not cause the EventListener to be called twice and since they are - /// discarded they do not need to be removed with the removeEventListener method. - - virtual void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture) = 0; - /// This method allows the removal of event listeners from the event - /// target. If an EventListener is removed from an EventTarget while it is - /// processing an event, it will not be triggered by the current actions. - /// EventListeners can never be invoked after being removed. - /// Calling removeEventListener with arguments which do not identify - /// any currently registered EventListener on the EventTarget has no effect. - - virtual bool dispatchEvent(Event* evt) = 0; - /// This method allows the dispatch of events into the implementations - /// event model. Events dispatched in this manner will have the same capturing and - /// bubbling behavior as events dispatched directly by the - /// implementation. The target of the event is the EventTarget on - /// which dispatchEvent is called. - -protected: - virtual ~EventTarget(); -}; - - -} } // namespace Poco::XML - - -#endif // DOM_EventTarget_INCLUDED +// +// EventTarget.h +// +// Library: XML +// Package: DOM +// Module: DOMEvents +// +// Definition of the DOM EventTarget interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_EventTarget_INCLUDED +#define DOM_EventTarget_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/DOMObject.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class EventListener; +class Event; + + +class XML_API EventTarget: public DOMObject + /// The EventTarget interface is implemented by all Nodes in an implementation + /// which supports the DOM Event Model. Therefore, this interface can be obtained + /// by using binding-specific casting methods on an instance of the Node interface. + /// The interface allows registration and removal of EventListeners on an EventTarget + /// and dispatch of events to that EventTarget. +{ +public: + virtual void addEventListener(const XMLString& type, EventListener* listener, bool useCapture) = 0; + /// This method allows the registration of event listeners on + /// the event target. If an EventListener is added to an + /// EventTarget while it is processing an event, it will not + /// be triggered by the current actions but may be triggered + /// during a later stage of event flow, such as the bubbling phase. + /// If multiple identical EventListeners are registered on the same + /// EventTarget with the same parameters the duplicate instances are + /// discarded. They do not cause the EventListener to be called twice and since they are + /// discarded they do not need to be removed with the removeEventListener method. + + virtual void removeEventListener(const XMLString& type, EventListener* listener, bool useCapture) = 0; + /// This method allows the removal of event listeners from the event + /// target. If an EventListener is removed from an EventTarget while it is + /// processing an event, it will not be triggered by the current actions. + /// EventListeners can never be invoked after being removed. + /// Calling removeEventListener with arguments which do not identify + /// any currently registered EventListener on the EventTarget has no effect. + + virtual bool dispatchEvent(Event* evt) = 0; + /// This method allows the dispatch of events into the implementations + /// event model. Events dispatched in this manner will have the same capturing and + /// bubbling behavior as events dispatched directly by the + /// implementation. The target of the event is the EventTarget on + /// which dispatchEvent is called. + +protected: + virtual ~EventTarget(); +}; + + +} } // namespace Poco::XML + + +#endif // DOM_EventTarget_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/MutationEvent.h b/contrib/libs/poco/XML/include/Poco/DOM/MutationEvent.h index 33a8521c50..aede86ec63 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/MutationEvent.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/MutationEvent.h @@ -1,143 +1,143 @@ -// -// MutationEvent.h -// -// Library: XML -// Package: DOM -// Module: DOMEvents -// -// Definition of the DOM MutationEvent class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_MutationEvent_INCLUDED -#define DOM_MutationEvent_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/Event.h" - - -namespace Poco { -namespace XML { - - -class Node; - - -class XML_API MutationEvent: public Event - /// The MutationEvent interface provides specific contextual - /// information associated with Mutation events. -{ -public: - enum AttrChangeType - { - MODIFICATION = 1, /// The Attr was modified in place. - ADDITION = 2, /// The Attr was just added. - REMOVAL = 3 /// The Attr was just removed. - }; - - Node* relatedNode() const; - /// relatedNode is used to identify a secondary node related to a mutation - /// event. For example, if a mutation event is dispatched - /// to a node indicating that its parent has changed, the relatedNode is the - /// changed parent. If an event is instead dispatched to a - /// subtree indicating a node was changed within it, the relatedNode is - /// the changed node. In the case of the DOMAttrModified - /// event it indicates the Attr node which was modified, added, or removed. - - const XMLString& prevValue() const; - /// prevValue indicates the previous value of the Attr node in DOMAttrModified - /// events, and of the CharacterData node in DOMCharDataModified events. - - const XMLString& newValue() const; - /// newValue indicates the new value of the Attr node in DOMAttrModified - /// events, and of the CharacterData node in DOMCharDataModified events. - - const XMLString& attrName() const; - /// attrName indicates the name of the changed Attr node in a DOMAttrModified event. - - AttrChangeType attrChange() const; - /// attrChange indicates the type of change which triggered the - /// DOMAttrModified event. The values can be MODIFICATION, - /// ADDITION, or REMOVAL. - - void initMutationEvent(const XMLString& type, bool canBubble, bool cancelable, Node* relatedNode, - const XMLString& prevValue, const XMLString& newValue, const XMLString& attrName, AttrChangeType change); - /// The initMutationEvent method is used to initialize the value of a - /// MutationEvent created through the DocumentEvent - /// interface. This method may only be called before the MutationEvent - /// has been dispatched via the dispatchEvent method, - /// though it may be called multiple times during that phase if - /// necessary. If called multiple times, the final invocation takes - /// precedence. - - // Event Types - static const XMLString DOMSubtreeModified; - static const XMLString DOMNodeInserted; - static const XMLString DOMNodeRemoved; - static const XMLString DOMNodeRemovedFromDocument; - static const XMLString DOMNodeInsertedIntoDocument; - static const XMLString DOMAttrModified; - static const XMLString DOMCharacterDataModified; - -protected: - MutationEvent(Document* pOwnerDocument, const XMLString& type); - MutationEvent(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool cancelable, Node* relatedNode); - 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); - ~MutationEvent(); - -private: - XMLString _prevValue; - XMLString _newValue; - XMLString _attrName; - AttrChangeType _change; - Node* _pRelatedNode; - - friend class AbstractNode; - friend class Document; -}; - - -// -// inlines -// -inline Node* MutationEvent::relatedNode() const -{ - return _pRelatedNode; -} - - -inline const XMLString& MutationEvent::prevValue() const -{ - return _prevValue; -} - - -inline const XMLString& MutationEvent::newValue() const -{ - return _newValue; -} - - -inline const XMLString& MutationEvent::attrName() const -{ - return _attrName; -} - - -inline MutationEvent::AttrChangeType MutationEvent::attrChange() const -{ - return _change; -} - - -} } // namespace Poco::XML - - -#endif // DOM_MutationEvent_INCLUDED +// +// MutationEvent.h +// +// Library: XML +// Package: DOM +// Module: DOMEvents +// +// Definition of the DOM MutationEvent class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_MutationEvent_INCLUDED +#define DOM_MutationEvent_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/Event.h" + + +namespace Poco { +namespace XML { + + +class Node; + + +class XML_API MutationEvent: public Event + /// The MutationEvent interface provides specific contextual + /// information associated with Mutation events. +{ +public: + enum AttrChangeType + { + MODIFICATION = 1, /// The Attr was modified in place. + ADDITION = 2, /// The Attr was just added. + REMOVAL = 3 /// The Attr was just removed. + }; + + Node* relatedNode() const; + /// relatedNode is used to identify a secondary node related to a mutation + /// event. For example, if a mutation event is dispatched + /// to a node indicating that its parent has changed, the relatedNode is the + /// changed parent. If an event is instead dispatched to a + /// subtree indicating a node was changed within it, the relatedNode is + /// the changed node. In the case of the DOMAttrModified + /// event it indicates the Attr node which was modified, added, or removed. + + const XMLString& prevValue() const; + /// prevValue indicates the previous value of the Attr node in DOMAttrModified + /// events, and of the CharacterData node in DOMCharDataModified events. + + const XMLString& newValue() const; + /// newValue indicates the new value of the Attr node in DOMAttrModified + /// events, and of the CharacterData node in DOMCharDataModified events. + + const XMLString& attrName() const; + /// attrName indicates the name of the changed Attr node in a DOMAttrModified event. + + AttrChangeType attrChange() const; + /// attrChange indicates the type of change which triggered the + /// DOMAttrModified event. The values can be MODIFICATION, + /// ADDITION, or REMOVAL. + + void initMutationEvent(const XMLString& type, bool canBubble, bool cancelable, Node* relatedNode, + const XMLString& prevValue, const XMLString& newValue, const XMLString& attrName, AttrChangeType change); + /// The initMutationEvent method is used to initialize the value of a + /// MutationEvent created through the DocumentEvent + /// interface. This method may only be called before the MutationEvent + /// has been dispatched via the dispatchEvent method, + /// though it may be called multiple times during that phase if + /// necessary. If called multiple times, the final invocation takes + /// precedence. + + // Event Types + static const XMLString DOMSubtreeModified; + static const XMLString DOMNodeInserted; + static const XMLString DOMNodeRemoved; + static const XMLString DOMNodeRemovedFromDocument; + static const XMLString DOMNodeInsertedIntoDocument; + static const XMLString DOMAttrModified; + static const XMLString DOMCharacterDataModified; + +protected: + MutationEvent(Document* pOwnerDocument, const XMLString& type); + MutationEvent(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool cancelable, Node* relatedNode); + 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); + ~MutationEvent(); + +private: + XMLString _prevValue; + XMLString _newValue; + XMLString _attrName; + AttrChangeType _change; + Node* _pRelatedNode; + + friend class AbstractNode; + friend class Document; +}; + + +// +// inlines +// +inline Node* MutationEvent::relatedNode() const +{ + return _pRelatedNode; +} + + +inline const XMLString& MutationEvent::prevValue() const +{ + return _prevValue; +} + + +inline const XMLString& MutationEvent::newValue() const +{ + return _newValue; +} + + +inline const XMLString& MutationEvent::attrName() const +{ + return _attrName; +} + + +inline MutationEvent::AttrChangeType MutationEvent::attrChange() const +{ + return _change; +} + + +} } // namespace Poco::XML + + +#endif // DOM_MutationEvent_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/NamedNodeMap.h b/contrib/libs/poco/XML/include/Poco/DOM/NamedNodeMap.h index 7b42ca88f4..209ee6b080 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/NamedNodeMap.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/NamedNodeMap.h @@ -1,93 +1,93 @@ -// -// NamedNodeMap.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM NamedNodeMap interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_NamedNodeMap_INCLUDED -#define DOM_NamedNodeMap_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/DOMObject.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class Node; - - -class XML_API NamedNodeMap: public DOMObject - /// Objects implementing the NamedNodeMap interface are used to represent collections - /// of nodes that can be accessed by name. Note that NamedNodeMap does not inherit - /// from NodeList; NamedNodeMaps are not maintained in any particular order. - /// Objects contained in an object implementing NamedNodeMap may also be accessed - /// by an ordinal index, but this is simply to allow convenient enumeration - /// of the contents of a NamedNodeMap, and does not imply that the DOM specifies - /// an order to these Nodes. - /// - /// NamedNodeMap objects in the DOM are live. - /// - /// A NamedNodeMap returned from a method must be released with a call to - /// release() when no longer needed. -{ -public: - virtual Node* getNamedItem(const XMLString& name) const = 0; - /// Retrieves a node specified by name. - - virtual Node* setNamedItem(Node* arg) = 0; - /// Adds a node using its nodeName attribute. If a node with that name is already - /// present in this map, it is replaced by the new one. - /// As the nodeName attribute is used to derive the name which the node must - /// be stored under, multiple nodes of certain types (those that have a "special" - /// string value) cannot be stored as the names would clash. This is seen as - /// preferable to allowing nodes to be aliased. - - virtual Node* removeNamedItem(const XMLString& name) = 0; - /// Removes a node specified by name. When this map contains the attributes - /// attached to an element, if the removed attribute is known to have a default - /// value, an attribute immediately appears containing the default value. - - virtual Node* item(unsigned long index) const = 0; - /// Returns the index'th item in the map. If index is greater - /// than or equal to the number of nodes in the map, this - /// returns null. - - virtual unsigned long length() const = 0; - /// Returns the number of nodes in the map. The range of valid - /// child node indices is 0 to length - 1 inclusive. - - // DOM Level 2 - virtual Node* getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const = 0; - /// Retrieves a node specified by name. - - virtual Node* setNamedItemNS(Node* arg) = 0; - /// Adds a node using its nodeName attribute. - /// If a node with that namespace URI and that local name is already - /// present in this map, it is replaced by the new one. - - virtual Node* removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) = 0; - /// Removes a node specified by name. - -protected: - virtual ~NamedNodeMap(); -}; - - -} } // namespace Poco::XML - - -#endif // DOM_NamedNodeMap_INCLUDED +// +// NamedNodeMap.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM NamedNodeMap interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_NamedNodeMap_INCLUDED +#define DOM_NamedNodeMap_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/DOMObject.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class Node; + + +class XML_API NamedNodeMap: public DOMObject + /// Objects implementing the NamedNodeMap interface are used to represent collections + /// of nodes that can be accessed by name. Note that NamedNodeMap does not inherit + /// from NodeList; NamedNodeMaps are not maintained in any particular order. + /// Objects contained in an object implementing NamedNodeMap may also be accessed + /// by an ordinal index, but this is simply to allow convenient enumeration + /// of the contents of a NamedNodeMap, and does not imply that the DOM specifies + /// an order to these Nodes. + /// + /// NamedNodeMap objects in the DOM are live. + /// + /// A NamedNodeMap returned from a method must be released with a call to + /// release() when no longer needed. +{ +public: + virtual Node* getNamedItem(const XMLString& name) const = 0; + /// Retrieves a node specified by name. + + virtual Node* setNamedItem(Node* arg) = 0; + /// Adds a node using its nodeName attribute. If a node with that name is already + /// present in this map, it is replaced by the new one. + /// As the nodeName attribute is used to derive the name which the node must + /// be stored under, multiple nodes of certain types (those that have a "special" + /// string value) cannot be stored as the names would clash. This is seen as + /// preferable to allowing nodes to be aliased. + + virtual Node* removeNamedItem(const XMLString& name) = 0; + /// Removes a node specified by name. When this map contains the attributes + /// attached to an element, if the removed attribute is known to have a default + /// value, an attribute immediately appears containing the default value. + + virtual Node* item(unsigned long index) const = 0; + /// Returns the index'th item in the map. If index is greater + /// than or equal to the number of nodes in the map, this + /// returns null. + + virtual unsigned long length() const = 0; + /// Returns the number of nodes in the map. The range of valid + /// child node indices is 0 to length - 1 inclusive. + + // DOM Level 2 + virtual Node* getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const = 0; + /// Retrieves a node specified by name. + + virtual Node* setNamedItemNS(Node* arg) = 0; + /// Adds a node using its nodeName attribute. + /// If a node with that namespace URI and that local name is already + /// present in this map, it is replaced by the new one. + + virtual Node* removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) = 0; + /// Removes a node specified by name. + +protected: + virtual ~NamedNodeMap(); +}; + + +} } // namespace Poco::XML + + +#endif // DOM_NamedNodeMap_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/Node.h b/contrib/libs/poco/XML/include/Poco/DOM/Node.h index f6a3c4afd4..7b04deb4f6 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/Node.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/Node.h @@ -1,285 +1,285 @@ -// -// Node.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM Node interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_Node_INCLUDED -#define DOM_Node_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/EventTarget.h" -#include "Poco/XML/XMLString.h" -#include "Poco/SAX/NamespaceSupport.h" - - -namespace Poco { -namespace XML { - - -class NamedNodeMap; -class Document; -class NodeList; - - -class XML_API Node: public EventTarget - /// The Node interface is the primary datatype for the entire Document Object - /// Model. It represents a single node in the document tree. While all objects - /// implementing the Node interface expose methods for dealing with children, - /// not all objects implementing the Node interface may have children. For - /// example, Text nodes may not have children, and adding children to such - /// nodes results in a DOMException being raised. +// +// Node.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM Node interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_Node_INCLUDED +#define DOM_Node_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/EventTarget.h" +#include "Poco/XML/XMLString.h" +#include "Poco/SAX/NamespaceSupport.h" + + +namespace Poco { +namespace XML { + + +class NamedNodeMap; +class Document; +class NodeList; + + +class XML_API Node: public EventTarget + /// The Node interface is the primary datatype for the entire Document Object + /// Model. It represents a single node in the document tree. While all objects + /// implementing the Node interface expose methods for dealing with children, + /// not all objects implementing the Node interface may have children. For + /// example, Text nodes may not have children, and adding children to such + /// nodes results in a DOMException being raised. + /// + /// The attributes nodeName, nodeValue and attributes are included as a mechanism + /// to get at node information without casting down to the specific derived + /// interface. In cases where there is no obvious mapping of these attributes + /// for a specific nodeType (e.g., nodeValue for an Element or attributes for + /// a Comment), this returns null. Note that the specialized interfaces may + /// contain additional and more convenient mechanisms to get and set the relevant + /// information. /// - /// The attributes nodeName, nodeValue and attributes are included as a mechanism - /// to get at node information without casting down to the specific derived - /// interface. In cases where there is no obvious mapping of these attributes - /// for a specific nodeType (e.g., nodeValue for an Element or attributes for - /// a Comment), this returns null. Note that the specialized interfaces may - /// contain additional and more convenient mechanisms to get and set the relevant - /// information. - /// - /// This implementation differs in some ways from the W3C DOM recommendations. - /// For example, the DOM specifies that some methods can return null strings. - /// Instead of null strings, this implementation always returns empty strings. -{ -public: - enum - { - ELEMENT_NODE = 1, /// The node is an Element. - ATTRIBUTE_NODE, /// The node is an Attr. - TEXT_NODE, /// The node is a Text node. - CDATA_SECTION_NODE, /// The node is a CDATASection. - ENTITY_REFERENCE_NODE, /// The node is an EntityReference. - ENTITY_NODE, /// The node is an Entity. - PROCESSING_INSTRUCTION_NODE, /// The node is a ProcessingInstruction. - COMMENT_NODE, /// The node is a Comment. - DOCUMENT_NODE, /// The node is a Document. - DOCUMENT_TYPE_NODE, /// The node is a DocumentType. - DOCUMENT_FRAGMENT_NODE, /// The node is a DocumentFragment. - NOTATION_NODE /// The node is a Notation. - }; - - virtual const XMLString& nodeName() const = 0; - /// Returns the name of this node, depending on its type. - - const XMLString& nodeValue() const; - /// Returns the value of this node, depending on its type. - - virtual const XMLString& getNodeValue() const = 0; - /// Returns the value of this node, depending on its type. - - virtual void setNodeValue(const XMLString& value) = 0; - /// Sets the value of this node. Throws an exception - /// if the node is read-only. - - virtual unsigned short nodeType() const = 0; - /// Returns a code representing the type of the underlying object. - - virtual Node* parentNode() const = 0; - /// The parent of this node. All nodes, except Attr, Document, DocumentFragment, - /// Entity, and Notation may have a parent. However, if a node has just been - /// created and not yet added to the tree, or if it has been removed from the - /// tree, this is null. - - virtual NodeList* childNodes() const = 0; - /// Returns a NodeList containing all children of this node. - /// - /// The returned NodeList must be released with a call - /// to release() when no longer needed. - - virtual Node* firstChild() const = 0; - /// Returns the first child of this node. If there is no such - /// node, this returns null. - - virtual Node* lastChild() const = 0; - /// Returns the last child of this node. If there is no such - /// node, this returns null. - - virtual Node* previousSibling() const = 0; - /// Returns the node immediately preceding this node. If there - /// is no such node, this returns null. - - virtual Node* nextSibling() const = 0; - /// Returns the node immediately following this node. If there - /// is no such node, this returns null. - - virtual NamedNodeMap* attributes() const = 0; - /// Returns a NamedNodeMap containing the attributes of this - /// node (if it is an Element) or null otherwise. + /// This implementation differs in some ways from the W3C DOM recommendations. + /// For example, the DOM specifies that some methods can return null strings. + /// Instead of null strings, this implementation always returns empty strings. +{ +public: + enum + { + ELEMENT_NODE = 1, /// The node is an Element. + ATTRIBUTE_NODE, /// The node is an Attr. + TEXT_NODE, /// The node is a Text node. + CDATA_SECTION_NODE, /// The node is a CDATASection. + ENTITY_REFERENCE_NODE, /// The node is an EntityReference. + ENTITY_NODE, /// The node is an Entity. + PROCESSING_INSTRUCTION_NODE, /// The node is a ProcessingInstruction. + COMMENT_NODE, /// The node is a Comment. + DOCUMENT_NODE, /// The node is a Document. + DOCUMENT_TYPE_NODE, /// The node is a DocumentType. + DOCUMENT_FRAGMENT_NODE, /// The node is a DocumentFragment. + NOTATION_NODE /// The node is a Notation. + }; + + virtual const XMLString& nodeName() const = 0; + /// Returns the name of this node, depending on its type. + + const XMLString& nodeValue() const; + /// Returns the value of this node, depending on its type. + + virtual const XMLString& getNodeValue() const = 0; + /// Returns the value of this node, depending on its type. + + virtual void setNodeValue(const XMLString& value) = 0; + /// Sets the value of this node. Throws an exception + /// if the node is read-only. + + virtual unsigned short nodeType() const = 0; + /// Returns a code representing the type of the underlying object. + + virtual Node* parentNode() const = 0; + /// The parent of this node. All nodes, except Attr, Document, DocumentFragment, + /// Entity, and Notation may have a parent. However, if a node has just been + /// created and not yet added to the tree, or if it has been removed from the + /// tree, this is null. + + virtual NodeList* childNodes() const = 0; + /// Returns a NodeList containing all children of this node. /// - /// The returned NamedNodeMap must be released with a call - /// to release() when no longer needed. - - virtual Document* ownerDocument() const = 0; - /// Returns the Document object associated with this node. - /// This is also the Document object used to create new nodes. - /// When this node is a Document, this is null. - - virtual Node* insertBefore(Node* newChild, Node* refChild) = 0; - /// Inserts the node newChild before the existing child node refChild. - /// - /// If refChild is null, insert newChild at the end of the list of children. - /// If newChild is a DocumentFragment object, all of its children are - /// inserted in the same order, before refChild. If the newChild is already - /// in the tree, it is first removed. - - virtual Node* replaceChild(Node* newChild, Node* oldChild) = 0; - /// Replaces the child node oldChild with newChild in the list of children, - /// and returns the oldChild node. - /// If newChild is a DocumentFragment object, oldChild is replaced by all of - /// the DocumentFragment children, which are inserted in the same order. If - /// the newChild is already in the tree, it is first removed. - - virtual Node* removeChild(Node* oldChild) = 0; - /// Removes the child node indicated by oldChild from the list of children - /// and returns it. - - virtual Node* appendChild(Node* newChild) = 0; - /// Appends the node newChild to the end of the list of children of this node. - /// If newChild is already in the tree, it is first removed. - - virtual bool hasChildNodes() const = 0; - /// This is a convenience method to allow easy determination of whether a - /// node has any children. - /// Returns true if the node has any children, false otherwise. - - virtual Node* cloneNode(bool deep) const = 0; - /// Returns a duplicate of this node, i.e., serves as a generic copy constructor - /// for nodes. The duplicate node has no parent; (parentNode is null.). - /// Cloning an Element copies all attributes and their values, including those - /// generated by the XML processor to represent defaulted attributes, but this - /// method does not copy any text it contains unless it is a deep clone, since - /// the text is contained in a child Text node. Cloning an Attribute directly, - /// as opposed to be cloned as part of an Element cloning operation, returns - /// a specified attribute (specified is true). Cloning any other type of node - /// simply returns a copy of this node. - /// Note that cloning an immutable subtree results in a mutable copy, but the - /// children of an EntityReference clone are readonly. In addition, clones of - /// unspecified Attr nodes are specified. And, cloning Document, DocumentType, - /// Entity, and Notation nodes is implementation dependent. - - // DOM Level 2 - virtual void normalize() = 0; - /// Puts all Text nodes in the full depth of the sub-tree underneath this Node, - /// including attribute nodes, into a "normal" form where only structure (e.g., - /// elements, comments, processing instructions, CDATA sections, and entity - /// references) separates Text nodes, i.e., there are neither adjacent Text - /// nodes nor empty Text nodes. This can be used to ensure that the DOM view - /// of a document is the same as if it were saved and re-loaded, and is useful - /// when operations (such as XPointer lookups) that depend on a particular - /// document tree structure are to be used. + /// The returned NodeList must be released with a call + /// to release() when no longer needed. + + virtual Node* firstChild() const = 0; + /// Returns the first child of this node. If there is no such + /// node, this returns null. + + virtual Node* lastChild() const = 0; + /// Returns the last child of this node. If there is no such + /// node, this returns null. + + virtual Node* previousSibling() const = 0; + /// Returns the node immediately preceding this node. If there + /// is no such node, this returns null. + + virtual Node* nextSibling() const = 0; + /// Returns the node immediately following this node. If there + /// is no such node, this returns null. + + virtual NamedNodeMap* attributes() const = 0; + /// Returns a NamedNodeMap containing the attributes of this + /// node (if it is an Element) or null otherwise. + /// + /// The returned NamedNodeMap must be released with a call + /// to release() when no longer needed. + + virtual Document* ownerDocument() const = 0; + /// Returns the Document object associated with this node. + /// This is also the Document object used to create new nodes. + /// When this node is a Document, this is null. + + virtual Node* insertBefore(Node* newChild, Node* refChild) = 0; + /// Inserts the node newChild before the existing child node refChild. /// - /// Note: In cases where the document contains CDATASections, the normalize - /// operation alone may not be sufficient, since XPointers do not differentiate - /// between Text nodes and CDATASection nodes. - - virtual bool isSupported(const XMLString& feature, const XMLString& version) const = 0; - /// Tests whether the DOM implementation implements a specific - /// feature and that feature is supported by this node. - - virtual const XMLString& namespaceURI() const = 0; - /// Returns the namespace URI of the node. - /// This is not a computed value that is the result of a namespace lookup based on an - /// examination of the namespace declarations in scope. It is merely the namespace URI - /// given at creation time. - /// - /// For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a - /// DOM Level 1 method, such as createElement from the Document interface, this is always the - /// empty string. - - virtual XMLString prefix() const = 0; - /// Returns the namespace prefix from the qualified name of the node. - - virtual const XMLString& localName() const = 0; - /// Returns the local name of the node. - - virtual bool hasAttributes() const = 0; - /// Returns whether this node (if it is an element) has any attributes. - - // Extensions - typedef Poco::XML::NamespaceSupport NSMap; - - virtual XMLString innerText() const = 0; - /// Returns a string containing the concatenated values of the node - /// and all its child nodes. - /// - /// This method is not part of the W3C Document Object Model. - - virtual Node* getNodeByPath(const XMLString& path) const = 0; - /// Searches a node (element or attribute) based on a simplified XPath - /// expression. - /// - /// Only simple XPath expressions are supported. These are the slash - /// notation for specifying paths to elements, and the square bracket - /// expression for finding elements by their index, by attribute value, - /// or finding attributes by names. - /// - /// The slash at the beginning is optional, the evaluation always starts - /// at this element. A double-slash at the beginning recursively searches - /// the entire subtree for the first element. - /// - /// Examples: - /// elem1/elem2/elem3 - /// /elem1/elem2/elem3 - /// /elem1/elem2[1] - /// /elem1/elem2[@attr1] - /// /elem1/elem2[@attr1='value'] - /// //elem2[@attr1='value'] - /// //[@attr1='value'] - /// - /// This method is an extension to the W3C Document Object Model. - - virtual Node* getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const = 0; - /// Searches a node (element or attribute) based on a simplified XPath - /// expression. The given NSMap must contain mappings from namespace - /// prefixes to namespace URIs for all namespace prefixes used in - /// the path expression. - /// - /// Only simple XPath expressions are supported. These are the slash - /// notation for specifying paths to elements, and the square bracket - /// expression for finding elements by their index, by attribute value, - /// or finding attributes by names. - /// - /// The slash at the beginning is optional, the evaluation always starts - /// at this element. A double-slash at the beginning recursively searches - /// the entire subtree for the first element. - /// - /// Examples: - /// /ns1:elem1/ns2:elem2/ns2:elem3 - /// /ns1:elem1/ns2:elem2[1] - /// /ns1:elem1/ns2:elem2[@attr1] - /// /ns1:elem1/ns2:elem2[@attr1='value'] - /// //ns2:elem2[@ns1:attr1='value'] - /// //[@ns1:attr1='value'] - /// - /// This method is an extension to the W3C Document Object Model. - -protected: - virtual ~Node(); -}; - - -// -// inlines -// -inline const XMLString& Node::nodeValue() const -{ - return getNodeValue(); -} - - -} } // namespace Poco::XML - - -#endif // DOM_Node_INCLUDED + /// If refChild is null, insert newChild at the end of the list of children. + /// If newChild is a DocumentFragment object, all of its children are + /// inserted in the same order, before refChild. If the newChild is already + /// in the tree, it is first removed. + + virtual Node* replaceChild(Node* newChild, Node* oldChild) = 0; + /// Replaces the child node oldChild with newChild in the list of children, + /// and returns the oldChild node. + /// If newChild is a DocumentFragment object, oldChild is replaced by all of + /// the DocumentFragment children, which are inserted in the same order. If + /// the newChild is already in the tree, it is first removed. + + virtual Node* removeChild(Node* oldChild) = 0; + /// Removes the child node indicated by oldChild from the list of children + /// and returns it. + + virtual Node* appendChild(Node* newChild) = 0; + /// Appends the node newChild to the end of the list of children of this node. + /// If newChild is already in the tree, it is first removed. + + virtual bool hasChildNodes() const = 0; + /// This is a convenience method to allow easy determination of whether a + /// node has any children. + /// Returns true if the node has any children, false otherwise. + + virtual Node* cloneNode(bool deep) const = 0; + /// Returns a duplicate of this node, i.e., serves as a generic copy constructor + /// for nodes. The duplicate node has no parent; (parentNode is null.). + /// Cloning an Element copies all attributes and their values, including those + /// generated by the XML processor to represent defaulted attributes, but this + /// method does not copy any text it contains unless it is a deep clone, since + /// the text is contained in a child Text node. Cloning an Attribute directly, + /// as opposed to be cloned as part of an Element cloning operation, returns + /// a specified attribute (specified is true). Cloning any other type of node + /// simply returns a copy of this node. + /// Note that cloning an immutable subtree results in a mutable copy, but the + /// children of an EntityReference clone are readonly. In addition, clones of + /// unspecified Attr nodes are specified. And, cloning Document, DocumentType, + /// Entity, and Notation nodes is implementation dependent. + + // DOM Level 2 + virtual void normalize() = 0; + /// Puts all Text nodes in the full depth of the sub-tree underneath this Node, + /// including attribute nodes, into a "normal" form where only structure (e.g., + /// elements, comments, processing instructions, CDATA sections, and entity + /// references) separates Text nodes, i.e., there are neither adjacent Text + /// nodes nor empty Text nodes. This can be used to ensure that the DOM view + /// of a document is the same as if it were saved and re-loaded, and is useful + /// when operations (such as XPointer lookups) that depend on a particular + /// document tree structure are to be used. + /// + /// Note: In cases where the document contains CDATASections, the normalize + /// operation alone may not be sufficient, since XPointers do not differentiate + /// between Text nodes and CDATASection nodes. + + virtual bool isSupported(const XMLString& feature, const XMLString& version) const = 0; + /// Tests whether the DOM implementation implements a specific + /// feature and that feature is supported by this node. + + virtual const XMLString& namespaceURI() const = 0; + /// Returns the namespace URI of the node. + /// This is not a computed value that is the result of a namespace lookup based on an + /// examination of the namespace declarations in scope. It is merely the namespace URI + /// given at creation time. + /// + /// For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a + /// DOM Level 1 method, such as createElement from the Document interface, this is always the + /// empty string. + + virtual XMLString prefix() const = 0; + /// Returns the namespace prefix from the qualified name of the node. + + virtual const XMLString& localName() const = 0; + /// Returns the local name of the node. + + virtual bool hasAttributes() const = 0; + /// Returns whether this node (if it is an element) has any attributes. + + // Extensions + typedef Poco::XML::NamespaceSupport NSMap; + + virtual XMLString innerText() const = 0; + /// Returns a string containing the concatenated values of the node + /// and all its child nodes. + /// + /// This method is not part of the W3C Document Object Model. + + virtual Node* getNodeByPath(const XMLString& path) const = 0; + /// Searches a node (element or attribute) based on a simplified XPath + /// expression. + /// + /// Only simple XPath expressions are supported. These are the slash + /// notation for specifying paths to elements, and the square bracket + /// expression for finding elements by their index, by attribute value, + /// or finding attributes by names. + /// + /// The slash at the beginning is optional, the evaluation always starts + /// at this element. A double-slash at the beginning recursively searches + /// the entire subtree for the first element. + /// + /// Examples: + /// elem1/elem2/elem3 + /// /elem1/elem2/elem3 + /// /elem1/elem2[1] + /// /elem1/elem2[@attr1] + /// /elem1/elem2[@attr1='value'] + /// //elem2[@attr1='value'] + /// //[@attr1='value'] + /// + /// This method is an extension to the W3C Document Object Model. + + virtual Node* getNodeByPathNS(const XMLString& path, const NSMap& nsMap) const = 0; + /// Searches a node (element or attribute) based on a simplified XPath + /// expression. The given NSMap must contain mappings from namespace + /// prefixes to namespace URIs for all namespace prefixes used in + /// the path expression. + /// + /// Only simple XPath expressions are supported. These are the slash + /// notation for specifying paths to elements, and the square bracket + /// expression for finding elements by their index, by attribute value, + /// or finding attributes by names. + /// + /// The slash at the beginning is optional, the evaluation always starts + /// at this element. A double-slash at the beginning recursively searches + /// the entire subtree for the first element. + /// + /// Examples: + /// /ns1:elem1/ns2:elem2/ns2:elem3 + /// /ns1:elem1/ns2:elem2[1] + /// /ns1:elem1/ns2:elem2[@attr1] + /// /ns1:elem1/ns2:elem2[@attr1='value'] + /// //ns2:elem2[@ns1:attr1='value'] + /// //[@ns1:attr1='value'] + /// + /// This method is an extension to the W3C Document Object Model. + +protected: + virtual ~Node(); +}; + + +// +// inlines +// +inline const XMLString& Node::nodeValue() const +{ + return getNodeValue(); +} + + +} } // namespace Poco::XML + + +#endif // DOM_Node_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/NodeAppender.h b/contrib/libs/poco/XML/include/Poco/DOM/NodeAppender.h index 2d36be2e3c..c7db3a99d7 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/NodeAppender.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/NodeAppender.h @@ -1,81 +1,81 @@ -// -// NodeAppender.h -// -// Library: XML -// Package: DOM -// Module: NodeAppender -// -// Definition of the NodeAppender class. -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_NodeAppender_INCLUDED -#define DOM_NodeAppender_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/Node.h" - - -namespace Poco { -namespace XML { - - -class AbstractNode; -class Element; - - -class XML_API NodeAppender - /// The NodeAppender class provides a very fast way to - /// build larger DOM documents. - /// - /// In the DOM, child nodes are usually appended to a parent - /// node using the appendChild() method. For nodes containing - /// more than a few children, this method can be quite slow, - /// due to the way it's implemented, and because of the - /// requirements of the DOM specification. - /// - /// While the NodeAppender is being used on an Element, no - /// children-modifying methods of that Element must be used. - /// - /// This class is not part of the DOM specification. -{ -public: - NodeAppender(Element* parent); - /// Creates the NodeAppender for the given parent node, - /// which must be an Element. - - ~NodeAppender(); - /// Destroys the NodeAppender. - - void appendChild(Node* newChild); - /// Appends the node newChild to the end of the list of children of - /// the parent node specified in the constructor. - /// If the newChild is already in the tree, it is first removed. - /// - /// NewChild can be a DocumentFragment. In this case, all children - /// of the fragment become children of the parent element. - /// - /// In order to speed up the function, no DOM events - /// are fired. - -private: - NodeAppender(); - NodeAppender(const NodeAppender&); - NodeAppender& operator = (const NodeAppender&); - - Element* _pParent; - AbstractNode* _pLast; -}; - - -} } // namespace Poco::XML - - -#endif // #include "Poco/XML/XML.h" - +// +// NodeAppender.h +// +// Library: XML +// Package: DOM +// Module: NodeAppender +// +// Definition of the NodeAppender class. +// +// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_NodeAppender_INCLUDED +#define DOM_NodeAppender_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/Node.h" + + +namespace Poco { +namespace XML { + + +class AbstractNode; +class Element; + + +class XML_API NodeAppender + /// The NodeAppender class provides a very fast way to + /// build larger DOM documents. + /// + /// In the DOM, child nodes are usually appended to a parent + /// node using the appendChild() method. For nodes containing + /// more than a few children, this method can be quite slow, + /// due to the way it's implemented, and because of the + /// requirements of the DOM specification. + /// + /// While the NodeAppender is being used on an Element, no + /// children-modifying methods of that Element must be used. + /// + /// This class is not part of the DOM specification. +{ +public: + NodeAppender(Element* parent); + /// Creates the NodeAppender for the given parent node, + /// which must be an Element. + + ~NodeAppender(); + /// Destroys the NodeAppender. + + void appendChild(Node* newChild); + /// Appends the node newChild to the end of the list of children of + /// the parent node specified in the constructor. + /// If the newChild is already in the tree, it is first removed. + /// + /// NewChild can be a DocumentFragment. In this case, all children + /// of the fragment become children of the parent element. + /// + /// In order to speed up the function, no DOM events + /// are fired. + +private: + NodeAppender(); + NodeAppender(const NodeAppender&); + NodeAppender& operator = (const NodeAppender&); + + Element* _pParent; + AbstractNode* _pLast; +}; + + +} } // namespace Poco::XML + + +#endif // #include "Poco/XML/XML.h" + diff --git a/contrib/libs/poco/XML/include/Poco/DOM/NodeFilter.h b/contrib/libs/poco/XML/include/Poco/DOM/NodeFilter.h index ae8677bf28..8ddd1b73df 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/NodeFilter.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/NodeFilter.h @@ -1,146 +1,146 @@ -// -// NodeFilter.h -// -// Library: XML -// Package: DOM -// Module: NodeFilter -// -// Definition of the DOM NodeFilter interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_NodeFilter_INCLUDED -#define DOM_NodeFilter_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class Node; - - -class XML_API NodeFilter - /// Filters are objects that know how to "filter out" nodes. If a NodeIterator - /// or TreeWalker is given a NodeFilter, it applies the filter before it returns - /// the next node. If the filter says to accept the node, the traversal logic - /// returns it; otherwise, traversal looks for the next node and pretends that - /// the node that was rejected was not there. - /// - /// The DOM does not provide any filters. NodeFilter is just an interface that - /// users can implement to provide their own filters. - /// - /// NodeFilters do not need to know how to traverse from node to node, nor do - /// they need to know anything about the data structure that is being traversed. - /// This makes it very easy to write filters, since the only thing they have - /// to know how to do is evaluate a single node. One filter may be used with - /// a number of different kinds of traversals, encouraging code reuse. -{ -public: - enum - { - FILTER_ACCEPT = 1, - /// Accept the node. Navigation methods defined for NodeIterator or TreeWalker will return this node. - - FILTER_REJECT = 2, - /// Reject the node. Navigation methods defined for NodeIterator or TreeWalker - /// will not return this node. For TreeWalker, the children of this node will - /// also be rejected. NodeIterators treat this as a synonym for FILTER_SKIP. - - FILTER_SKIP = 3 - /// Skip this single node. Navigation methods defined for NodeIterator or TreeWalker - /// will not return this node. For both NodeIterator and TreeWalker, the children - /// of this node will still be considered. - }; - - enum WhatToShow - /// These are the available values for the whatToShow parameter used in TreeWalkers - /// and NodeIterators. They are the same as the set of possible types for Node, - /// and their values are derived by using a bit position corresponding to the - /// value of nodeType for the equivalent node type. If a bit in whatToShow is - /// set false, that will be taken as a request to skip over this type of node; - /// the behavior in that case is similar to that of FILTER_SKIP. +// +// NodeFilter.h +// +// Library: XML +// Package: DOM +// Module: NodeFilter +// +// Definition of the DOM NodeFilter interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_NodeFilter_INCLUDED +#define DOM_NodeFilter_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class Node; + + +class XML_API NodeFilter + /// Filters are objects that know how to "filter out" nodes. If a NodeIterator + /// or TreeWalker is given a NodeFilter, it applies the filter before it returns + /// the next node. If the filter says to accept the node, the traversal logic + /// returns it; otherwise, traversal looks for the next node and pretends that + /// the node that was rejected was not there. + /// + /// The DOM does not provide any filters. NodeFilter is just an interface that + /// users can implement to provide their own filters. + /// + /// NodeFilters do not need to know how to traverse from node to node, nor do + /// they need to know anything about the data structure that is being traversed. + /// This makes it very easy to write filters, since the only thing they have + /// to know how to do is evaluate a single node. One filter may be used with + /// a number of different kinds of traversals, encouraging code reuse. +{ +public: + enum + { + FILTER_ACCEPT = 1, + /// Accept the node. Navigation methods defined for NodeIterator or TreeWalker will return this node. + + FILTER_REJECT = 2, + /// Reject the node. Navigation methods defined for NodeIterator or TreeWalker + /// will not return this node. For TreeWalker, the children of this node will + /// also be rejected. NodeIterators treat this as a synonym for FILTER_SKIP. + + FILTER_SKIP = 3 + /// Skip this single node. Navigation methods defined for NodeIterator or TreeWalker + /// will not return this node. For both NodeIterator and TreeWalker, the children + /// of this node will still be considered. + }; + + enum WhatToShow + /// These are the available values for the whatToShow parameter used in TreeWalkers + /// and NodeIterators. They are the same as the set of possible types for Node, + /// and their values are derived by using a bit position corresponding to the + /// value of nodeType for the equivalent node type. If a bit in whatToShow is + /// set false, that will be taken as a request to skip over this type of node; + /// the behavior in that case is similar to that of FILTER_SKIP. + /// + /// Note that if node types greater than 32 are ever introduced, they may not + /// be individually testable via whatToShow. If that need should arise, it can + /// be handled by selecting SHOW_ALL together with an appropriate NodeFilter. + { + SHOW_ALL = 0xFFFFFFFF, + /// Show all Nodes. + + SHOW_ELEMENT = 0x00000001, + /// Show Element nodes. + + SHOW_ATTRIBUTE = 0x00000002, + /// Show Attr nodes. This is meaningful only when creating an iterator or tree-walker + /// with an attribute node as its root; in this case, it means that the attribute + /// node will appear in the first position of the iteration or traversal. Since + /// attributes are never children of other nodes, they do not appear when traversing + /// over the document tree. + + SHOW_TEXT = 0x00000004, + /// Show Text nodes. + + SHOW_CDATA_SECTION = 0x00000008, + /// Show CDATASection nodes. + + SHOW_ENTITY_REFERENCE = 0x00000010, + /// Show EntityReference nodes. + + SHOW_ENTITY = 0x00000020, + /// Show Entity nodes. This is meaningful only when creating an iterator or + /// tree-walker with an Entity node as its root; in this case, it means that + /// the Entity node will appear in the first position of the traversal. Since + /// entities are not part of the document tree, they do not appear when traversing + /// over the document tree. + + SHOW_PROCESSING_INSTRUCTION = 0x00000040, + /// Show ProcessingInstruction nodes. + + SHOW_COMMENT = 0x00000080, + /// Show Comment nodes. + + SHOW_DOCUMENT = 0x00000100, + /// Show Document nodes. + + SHOW_DOCUMENT_TYPE = 0x00000200, + /// Show DocumentType nodes. + + SHOW_DOCUMENT_FRAGMENT = 0x00000400, + /// Show DocumentFragment nodes. + + SHOW_NOTATION = 0x00000800 + /// Show Notation nodes. This is meaningful only when creating an iterator or + /// tree-walker with a Notation node as its root; in this case, it means that + /// the Notation node will appear in the first position of the traversal. Since + /// notations are not part of the document tree, they do not appear when traversing + /// over the document tree. + }; + + virtual short acceptNode(Node* node) = 0; + /// Test whether a specified node is visible in the logical view of a TreeWalker + /// or NodeIterator. This function will be called by the implementation of TreeWalker + /// and NodeIterator; it is not normally called directly from user code. (Though + /// you could do so if you wanted to use the same filter to guide your own application + /// logic.) /// - /// Note that if node types greater than 32 are ever introduced, they may not - /// be individually testable via whatToShow. If that need should arise, it can - /// be handled by selecting SHOW_ALL together with an appropriate NodeFilter. - { - SHOW_ALL = 0xFFFFFFFF, - /// Show all Nodes. - - SHOW_ELEMENT = 0x00000001, - /// Show Element nodes. - - SHOW_ATTRIBUTE = 0x00000002, - /// Show Attr nodes. This is meaningful only when creating an iterator or tree-walker - /// with an attribute node as its root; in this case, it means that the attribute - /// node will appear in the first position of the iteration or traversal. Since - /// attributes are never children of other nodes, they do not appear when traversing - /// over the document tree. - - SHOW_TEXT = 0x00000004, - /// Show Text nodes. - - SHOW_CDATA_SECTION = 0x00000008, - /// Show CDATASection nodes. - - SHOW_ENTITY_REFERENCE = 0x00000010, - /// Show EntityReference nodes. - - SHOW_ENTITY = 0x00000020, - /// Show Entity nodes. This is meaningful only when creating an iterator or - /// tree-walker with an Entity node as its root; in this case, it means that - /// the Entity node will appear in the first position of the traversal. Since - /// entities are not part of the document tree, they do not appear when traversing - /// over the document tree. - - SHOW_PROCESSING_INSTRUCTION = 0x00000040, - /// Show ProcessingInstruction nodes. - - SHOW_COMMENT = 0x00000080, - /// Show Comment nodes. - - SHOW_DOCUMENT = 0x00000100, - /// Show Document nodes. - - SHOW_DOCUMENT_TYPE = 0x00000200, - /// Show DocumentType nodes. - - SHOW_DOCUMENT_FRAGMENT = 0x00000400, - /// Show DocumentFragment nodes. - - SHOW_NOTATION = 0x00000800 - /// Show Notation nodes. This is meaningful only when creating an iterator or - /// tree-walker with a Notation node as its root; in this case, it means that - /// the Notation node will appear in the first position of the traversal. Since - /// notations are not part of the document tree, they do not appear when traversing - /// over the document tree. - }; - - virtual short acceptNode(Node* node) = 0; - /// Test whether a specified node is visible in the logical view of a TreeWalker - /// or NodeIterator. This function will be called by the implementation of TreeWalker - /// and NodeIterator; it is not normally called directly from user code. (Though - /// you could do so if you wanted to use the same filter to guide your own application - /// logic.) - /// - /// Returns FILTER_ACCEPT, FILTER_REJECT or FILTER_SKIP. - -protected: - virtual ~NodeFilter(); -}; - - -} } // namespace Poco::XML - - -#endif // DOM_NodeFilter_INCLUDED + /// Returns FILTER_ACCEPT, FILTER_REJECT or FILTER_SKIP. + +protected: + virtual ~NodeFilter(); +}; + + +} } // namespace Poco::XML + + +#endif // DOM_NodeFilter_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/NodeIterator.h b/contrib/libs/poco/XML/include/Poco/DOM/NodeIterator.h index 1f8e9a063b..fc233a9187 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/NodeIterator.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/NodeIterator.h @@ -1,167 +1,167 @@ -// -// NodeIterator.h -// -// Library: XML -// Package: DOM -// Module: NodeIterator -// -// Definition of the DOM NodeIterator class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_NodeIterator_INCLUDED -#define DOM_NodeIterator_INCLUDED - - -#include "Poco/XML/XML.h" - - -namespace Poco { -namespace XML { - - -class Node; -class NodeFilter; - - -class XML_API NodeIterator - /// Iterators are used to step through a set of nodes, e.g. the set of nodes - /// in a NodeList, the document subtree governed by a particular Node, the results - /// of a query, or any other set of nodes. The set of nodes to be iterated is - /// determined by the implementation of the NodeIterator. DOM Level 2 specifies - /// a single NodeIterator implementation for document-order traversal of a document - /// subtree. - /// - /// A NodeIterator can be directly instantiated using one of its constructors - - /// the DocumentTraversal interface is not needed and therefore not implemented. - /// Unlike most other DOM classes, NodeIterator supports value semantics. - /// - /// If the NodeIterator's current node is removed from the document, the - /// result of calling any of the movement methods is undefined. This behavior does - /// not conform to the DOM Level 2 Traversal specification. -{ -public: - NodeIterator(Node* root, unsigned long whatToShow, NodeFilter* pFilter = 0); - /// Creates a NodeIterator over the subtree rooted at the specified node. - - NodeIterator(const NodeIterator& iterator); - /// Creates a NodeIterator by copying another NodeIterator. - - NodeIterator& operator = (const NodeIterator& iterator); - /// Assignment operator. - - ~NodeIterator(); - /// Destroys the NodeIterator. - - Node* root() const; - /// The root node of the NodeIterator, as specified when it was created. - - unsigned long whatToShow() const; - /// This attribute determines which node types are presented via the iterator. - /// The available set of constants is defined in the NodeFilter interface. - /// Nodes not accepted by whatToShow will be skipped, but their children may - /// still be considered. Note that this skip takes precedence over the filter, - /// if any. - - NodeFilter* filter() const; - /// The NodeFilter used to screen nodes. - - bool expandEntityReferences() const; - /// The value of this flag determines whether the children of entity reference - /// nodes are visible to the iterator. If false, they and their descendants - /// will be rejected. Note that this rejection takes precedence over whatToShow - /// and the filter. Also note that this is currently the only situation where - /// NodeIterators may reject a complete subtree rather than skipping individual - /// nodes. +// +// NodeIterator.h +// +// Library: XML +// Package: DOM +// Module: NodeIterator +// +// Definition of the DOM NodeIterator class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_NodeIterator_INCLUDED +#define DOM_NodeIterator_INCLUDED + + +#include "Poco/XML/XML.h" + + +namespace Poco { +namespace XML { + + +class Node; +class NodeFilter; + + +class XML_API NodeIterator + /// Iterators are used to step through a set of nodes, e.g. the set of nodes + /// in a NodeList, the document subtree governed by a particular Node, the results + /// of a query, or any other set of nodes. The set of nodes to be iterated is + /// determined by the implementation of the NodeIterator. DOM Level 2 specifies + /// a single NodeIterator implementation for document-order traversal of a document + /// subtree. + /// + /// A NodeIterator can be directly instantiated using one of its constructors - + /// the DocumentTraversal interface is not needed and therefore not implemented. + /// Unlike most other DOM classes, NodeIterator supports value semantics. + /// + /// If the NodeIterator's current node is removed from the document, the + /// result of calling any of the movement methods is undefined. This behavior does + /// not conform to the DOM Level 2 Traversal specification. +{ +public: + NodeIterator(Node* root, unsigned long whatToShow, NodeFilter* pFilter = 0); + /// Creates a NodeIterator over the subtree rooted at the specified node. + + NodeIterator(const NodeIterator& iterator); + /// Creates a NodeIterator by copying another NodeIterator. + + NodeIterator& operator = (const NodeIterator& iterator); + /// Assignment operator. + + ~NodeIterator(); + /// Destroys the NodeIterator. + + Node* root() const; + /// The root node of the NodeIterator, as specified when it was created. + + unsigned long whatToShow() const; + /// This attribute determines which node types are presented via the iterator. + /// The available set of constants is defined in the NodeFilter interface. + /// Nodes not accepted by whatToShow will be skipped, but their children may + /// still be considered. Note that this skip takes precedence over the filter, + /// if any. + + NodeFilter* filter() const; + /// The NodeFilter used to screen nodes. + + bool expandEntityReferences() const; + /// The value of this flag determines whether the children of entity reference + /// nodes are visible to the iterator. If false, they and their descendants + /// will be rejected. Note that this rejection takes precedence over whatToShow + /// and the filter. Also note that this is currently the only situation where + /// NodeIterators may reject a complete subtree rather than skipping individual + /// nodes. + /// + /// To produce a view of the document that has entity references expanded and + /// does not expose the entity reference node itself, use the whatToShow flags + /// to hide the entity reference node and set expandEntityReferences to true + /// when creating the iterator. To produce a view of the document that has entity + /// reference nodes but no entity expansion, use the whatToShow flags to show + /// the entity reference node and set expandEntityReferences to false. /// - /// To produce a view of the document that has entity references expanded and - /// does not expose the entity reference node itself, use the whatToShow flags - /// to hide the entity reference node and set expandEntityReferences to true - /// when creating the iterator. To produce a view of the document that has entity - /// reference nodes but no entity expansion, use the whatToShow flags to show - /// the entity reference node and set expandEntityReferences to false. - /// - /// This implementation does not support entity reference expansion and - /// thus always returns false. - - Node* nextNode(); - /// Returns the next node in the set and advances the position of the iterator - /// in the set. After a NodeIterator is created, the first call to nextNode() - /// returns the first node in the set. - - Node* previousNode(); - /// Returns the previous node in the set and moves the position of the NodeIterator - /// backwards in the set. - - Node* currentNodeNP() const; - /// Returns the current node in the set. - /// - /// Leaves the NodeIterator unchanged. - /// - /// Warning: This is a proprietary extension to the DOM Level 2 NodeIterator - /// interface. - - void detach(); - /// Detaches the NodeIterator from the set which it iterated over, releasing - /// any computational resources and placing the iterator in the INVALID state. - /// After detach has been invoked, calls to nextNode or previousNode will raise - /// the exception INVALID_STATE_ERR. - -protected: - bool accept(Node* pNode) const; - Node* next() const; - Node* previous() const; - Node* last(); - -private: - NodeIterator(); - - Node* _pRoot; - unsigned long _whatToShow; - NodeFilter* _pFilter; - Node* _pCurrent; -}; - - -// -// inlines -// -inline Node* NodeIterator::root() const -{ - return _pRoot; -} - - -inline Node* NodeIterator::currentNodeNP() const -{ - return _pCurrent; -} - - -inline unsigned long NodeIterator::whatToShow() const -{ - return _whatToShow; -} - - -inline NodeFilter* NodeIterator::filter() const -{ - return _pFilter; -} - - -inline bool NodeIterator::expandEntityReferences() const -{ - return false; -} - - -} } // namespace Poco::XML - - -#endif // DOM_NodeIterator_INCLUDED + /// This implementation does not support entity reference expansion and + /// thus always returns false. + + Node* nextNode(); + /// Returns the next node in the set and advances the position of the iterator + /// in the set. After a NodeIterator is created, the first call to nextNode() + /// returns the first node in the set. + + Node* previousNode(); + /// Returns the previous node in the set and moves the position of the NodeIterator + /// backwards in the set. + + Node* currentNodeNP() const; + /// Returns the current node in the set. + /// + /// Leaves the NodeIterator unchanged. + /// + /// Warning: This is a proprietary extension to the DOM Level 2 NodeIterator + /// interface. + + void detach(); + /// Detaches the NodeIterator from the set which it iterated over, releasing + /// any computational resources and placing the iterator in the INVALID state. + /// After detach has been invoked, calls to nextNode or previousNode will raise + /// the exception INVALID_STATE_ERR. + +protected: + bool accept(Node* pNode) const; + Node* next() const; + Node* previous() const; + Node* last(); + +private: + NodeIterator(); + + Node* _pRoot; + unsigned long _whatToShow; + NodeFilter* _pFilter; + Node* _pCurrent; +}; + + +// +// inlines +// +inline Node* NodeIterator::root() const +{ + return _pRoot; +} + + +inline Node* NodeIterator::currentNodeNP() const +{ + return _pCurrent; +} + + +inline unsigned long NodeIterator::whatToShow() const +{ + return _whatToShow; +} + + +inline NodeFilter* NodeIterator::filter() const +{ + return _pFilter; +} + + +inline bool NodeIterator::expandEntityReferences() const +{ + return false; +} + + +} } // namespace Poco::XML + + +#endif // DOM_NodeIterator_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/NodeList.h b/contrib/libs/poco/XML/include/Poco/DOM/NodeList.h index 1f8c12f4cd..ce7af280a8 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/NodeList.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/NodeList.h @@ -1,61 +1,61 @@ -// -// NodeList.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM NodeList interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_NodeList_INCLUDED -#define DOM_NodeList_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/DOMObject.h" - - -namespace Poco { -namespace XML { - - -class Node; - - -class XML_API NodeList: public DOMObject - /// The NodeList interface provides the abstraction of an ordered - /// collection of nodes, without defining or constraining how this - /// collection is implemented. - /// - /// The items in the NodeList are accessible via an integral index, - /// starting from 0. - /// - /// A NodeList returned from a method must be released with a call to - /// release() when no longer needed. -{ -public: - virtual Node* item(unsigned long index) const = 0; - /// Returns the index'th item in the collection. If index is - /// greater than or equal to the number of nodes in the list, - /// this returns null. - - virtual unsigned long length() const = 0; - /// Returns the number of nodes in the list. The range of valid - /// node indices is 0 to length - 1 inclusive. - -protected: - virtual ~NodeList(); -}; - - -} } // namespace Poco::XML - - -#endif // DOM_NodeList_INCLUDED +// +// NodeList.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM NodeList interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_NodeList_INCLUDED +#define DOM_NodeList_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/DOMObject.h" + + +namespace Poco { +namespace XML { + + +class Node; + + +class XML_API NodeList: public DOMObject + /// The NodeList interface provides the abstraction of an ordered + /// collection of nodes, without defining or constraining how this + /// collection is implemented. + /// + /// The items in the NodeList are accessible via an integral index, + /// starting from 0. + /// + /// A NodeList returned from a method must be released with a call to + /// release() when no longer needed. +{ +public: + virtual Node* item(unsigned long index) const = 0; + /// Returns the index'th item in the collection. If index is + /// greater than or equal to the number of nodes in the list, + /// this returns null. + + virtual unsigned long length() const = 0; + /// Returns the number of nodes in the list. The range of valid + /// node indices is 0 to length - 1 inclusive. + +protected: + virtual ~NodeList(); +}; + + +} } // namespace Poco::XML + + +#endif // DOM_NodeList_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/Notation.h b/contrib/libs/poco/XML/include/Poco/DOM/Notation.h index c9824b0e05..4bc823a026 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/Notation.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/Notation.h @@ -1,93 +1,93 @@ -// -// Notation.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM Notation class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_Notation_INCLUDED -#define DOM_Notation_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractNode.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API Notation: public AbstractNode - /// This interface represents a notation declared in the DTD. A notation either - /// declares, by name, the format of an unparsed entity (see section 4.7 of - /// the XML 1.0 specification <http://www.w3.org/TR/2004/REC-xml-20040204/>), - /// or is used for formal declaration of processing - /// instruction targets (see section 2.6 of the XML 1.0 specification). - /// The nodeName attribute inherited from Node is set to the declared name of - /// the notation. - /// - /// The DOM Level 1 does not support editing Notation nodes; they are therefore - /// readonly. - /// - /// A Notation node does not have any parent. -{ -public: - const XMLString& publicId() const; - /// Returns the public identifier of this notation. - /// If not specified, this is an empty string (and not null, - /// as in the DOM specification). - - const XMLString& systemId() const; - /// Returns the system identifier of this notation. - /// If not specified, this is an empty string (and not null, - /// as in the DOM specification). - - // Node - const XMLString& nodeName() const; - unsigned short nodeType() const; - -protected: - Notation(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId); - Notation(Document* pOwnerDocument, const Notation& notation); - ~Notation(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - -private: - XMLString _name; - XMLString _publicId; - XMLString _systemId; - - friend class Document; -}; - - -// -// inlines -// -inline const XMLString& Notation::publicId() const -{ - return _publicId; -} - - -inline const XMLString& Notation::systemId() const -{ - return _systemId; -} - - -} } // namespace Poco::XML - - -#endif // DOM_Notation_INCLUDED +// +// Notation.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM Notation class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_Notation_INCLUDED +#define DOM_Notation_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractNode.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API Notation: public AbstractNode + /// This interface represents a notation declared in the DTD. A notation either + /// declares, by name, the format of an unparsed entity (see section 4.7 of + /// the XML 1.0 specification <http://www.w3.org/TR/2004/REC-xml-20040204/>), + /// or is used for formal declaration of processing + /// instruction targets (see section 2.6 of the XML 1.0 specification). + /// The nodeName attribute inherited from Node is set to the declared name of + /// the notation. + /// + /// The DOM Level 1 does not support editing Notation nodes; they are therefore + /// readonly. + /// + /// A Notation node does not have any parent. +{ +public: + const XMLString& publicId() const; + /// Returns the public identifier of this notation. + /// If not specified, this is an empty string (and not null, + /// as in the DOM specification). + + const XMLString& systemId() const; + /// Returns the system identifier of this notation. + /// If not specified, this is an empty string (and not null, + /// as in the DOM specification). + + // Node + const XMLString& nodeName() const; + unsigned short nodeType() const; + +protected: + Notation(Document* pOwnerDocument, const XMLString& name, const XMLString& publicId, const XMLString& systemId); + Notation(Document* pOwnerDocument, const Notation& notation); + ~Notation(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + +private: + XMLString _name; + XMLString _publicId; + XMLString _systemId; + + friend class Document; +}; + + +// +// inlines +// +inline const XMLString& Notation::publicId() const +{ + return _publicId; +} + + +inline const XMLString& Notation::systemId() const +{ + return _systemId; +} + + +} } // namespace Poco::XML + + +#endif // DOM_Notation_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/ProcessingInstruction.h b/contrib/libs/poco/XML/include/Poco/DOM/ProcessingInstruction.h index ab600ca952..6d5916ee5c 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/ProcessingInstruction.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/ProcessingInstruction.h @@ -1,99 +1,99 @@ -// -// ProcessingInstruction.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM ProcessingInstruction class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_ProcessingInstruction_INCLUDED -#define DOM_ProcessingInstruction_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/AbstractNode.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API ProcessingInstruction: public AbstractNode - /// The ProcessingInstruction interface represents a "processing instruction", - /// used in XML as a way to keep processor-specific information in the text - /// of the document. -{ -public: - const XMLString& target() const; - /// Returns the target of this processing instruction. - /// XML defines this as being the first token following - /// the markup that begins the processing instruction. - - const XMLString& data() const; - /// Returns the content of this processing instruction. This is from the first non - /// white space character after the target to the character immediately preceding - /// the ?>. - - const XMLString& getData() const; - /// Returns the content of this processing instruction. This is from the first non - /// white space character after the target to the character immediately preceding - /// the ?>. - - void setData(const XMLString& data); - /// Sets the content of this processing instruction. - - // Node - const XMLString& nodeName() const; - const XMLString& getNodeValue() const; - void setNodeValue(const XMLString& data); - unsigned short nodeType() const; - -protected: - ProcessingInstruction(Document* pOwnerDocument, const XMLString& target, const XMLString& data); - ProcessingInstruction(Document* pOwnerDocument, const ProcessingInstruction& processingInstruction); - ~ProcessingInstruction(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - -private: - XMLString _target; - XMLString _data; - - friend class Document; -}; - - -// -// inlines -// -inline const XMLString& ProcessingInstruction::target() const -{ - return _target; -} - - -inline const XMLString& ProcessingInstruction::data() const -{ - return _data; -} - - -inline const XMLString& ProcessingInstruction::getData() const -{ - return _data; -} - - -} } // namespace Poco::XML - - -#endif // DOM_ProcessingInstruction_INCLUDED +// +// ProcessingInstruction.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM ProcessingInstruction class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_ProcessingInstruction_INCLUDED +#define DOM_ProcessingInstruction_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/AbstractNode.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API ProcessingInstruction: public AbstractNode + /// The ProcessingInstruction interface represents a "processing instruction", + /// used in XML as a way to keep processor-specific information in the text + /// of the document. +{ +public: + const XMLString& target() const; + /// Returns the target of this processing instruction. + /// XML defines this as being the first token following + /// the markup that begins the processing instruction. + + const XMLString& data() const; + /// Returns the content of this processing instruction. This is from the first non + /// white space character after the target to the character immediately preceding + /// the ?>. + + const XMLString& getData() const; + /// Returns the content of this processing instruction. This is from the first non + /// white space character after the target to the character immediately preceding + /// the ?>. + + void setData(const XMLString& data); + /// Sets the content of this processing instruction. + + // Node + const XMLString& nodeName() const; + const XMLString& getNodeValue() const; + void setNodeValue(const XMLString& data); + unsigned short nodeType() const; + +protected: + ProcessingInstruction(Document* pOwnerDocument, const XMLString& target, const XMLString& data); + ProcessingInstruction(Document* pOwnerDocument, const ProcessingInstruction& processingInstruction); + ~ProcessingInstruction(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + +private: + XMLString _target; + XMLString _data; + + friend class Document; +}; + + +// +// inlines +// +inline const XMLString& ProcessingInstruction::target() const +{ + return _target; +} + + +inline const XMLString& ProcessingInstruction::data() const +{ + return _data; +} + + +inline const XMLString& ProcessingInstruction::getData() const +{ + return _data; +} + + +} } // namespace Poco::XML + + +#endif // DOM_ProcessingInstruction_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/Text.h b/contrib/libs/poco/XML/include/Poco/DOM/Text.h index 3a7931a8b2..5b0084909c 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/Text.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/Text.h @@ -1,79 +1,79 @@ -// -// Text.h -// -// Library: XML -// Package: DOM -// Module: DOM -// -// Definition of the DOM Text class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_Text_INCLUDED -#define DOM_Text_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/DOM/CharacterData.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API Text: public CharacterData - /// The Text interface inherits from CharacterData and represents the textual - /// content (termed character data in XML) of an Element or Attr. If there is - /// no markup inside an element's content, the text is contained in a single - /// object implementing the Text interface that is the only child of the element. - /// If there is markup, it is parsed into the information items (elements, comments, - /// etc.) and Text nodes that form the list of children of the element. - /// - /// When a document is first made available via the DOM, there is only one Text - /// node for each block of text. Users may create adjacent Text nodes that represent - /// the contents of a given element without any intervening markup, but should - /// be aware that there is no way to represent the separations between these - /// nodes in XML or HTML, so they will not (in general) persist between DOM - /// editing sessions. The normalize() method on Element merges any such adjacent - /// Text objects into a single node for each block of text. -{ -public: - Text* splitText(unsigned long offset); - /// Breaks this node into two nodes at the specified offset, keeping both in - /// the tree as siblings. This node then only contains all the content up to - /// the offset point. A new node of the same type, which is inserted as the - /// next sibling of this node, contains all the content at and after the offset - /// point. When the offset is equal to the length of this node, the new node - /// has no data. - - // Node - const XMLString& nodeName() const; - unsigned short nodeType() const; - - // Non-standard extensions - XMLString innerText() const; - -protected: - Text(Document* pOwnerDocument, const XMLString& data); - Text(Document* pOwnerDocument, const Text& text); - ~Text(); - - Node* copyNode(bool deep, Document* pOwnerDocument) const; - -private: - static const XMLString NODE_NAME; - - friend class Document; -}; - - -} } // namespace Poco::XML - - -#endif // DOM_Text_INCLUDED +// +// Text.h +// +// Library: XML +// Package: DOM +// Module: DOM +// +// Definition of the DOM Text class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_Text_INCLUDED +#define DOM_Text_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/DOM/CharacterData.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API Text: public CharacterData + /// The Text interface inherits from CharacterData and represents the textual + /// content (termed character data in XML) of an Element or Attr. If there is + /// no markup inside an element's content, the text is contained in a single + /// object implementing the Text interface that is the only child of the element. + /// If there is markup, it is parsed into the information items (elements, comments, + /// etc.) and Text nodes that form the list of children of the element. + /// + /// When a document is first made available via the DOM, there is only one Text + /// node for each block of text. Users may create adjacent Text nodes that represent + /// the contents of a given element without any intervening markup, but should + /// be aware that there is no way to represent the separations between these + /// nodes in XML or HTML, so they will not (in general) persist between DOM + /// editing sessions. The normalize() method on Element merges any such adjacent + /// Text objects into a single node for each block of text. +{ +public: + Text* splitText(unsigned long offset); + /// Breaks this node into two nodes at the specified offset, keeping both in + /// the tree as siblings. This node then only contains all the content up to + /// the offset point. A new node of the same type, which is inserted as the + /// next sibling of this node, contains all the content at and after the offset + /// point. When the offset is equal to the length of this node, the new node + /// has no data. + + // Node + const XMLString& nodeName() const; + unsigned short nodeType() const; + + // Non-standard extensions + XMLString innerText() const; + +protected: + Text(Document* pOwnerDocument, const XMLString& data); + Text(Document* pOwnerDocument, const Text& text); + ~Text(); + + Node* copyNode(bool deep, Document* pOwnerDocument) const; + +private: + static const XMLString NODE_NAME; + + friend class Document; +}; + + +} } // namespace Poco::XML + + +#endif // DOM_Text_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/DOM/TreeWalker.h b/contrib/libs/poco/XML/include/Poco/DOM/TreeWalker.h index 884b37d3c7..79ec4a12d7 100644 --- a/contrib/libs/poco/XML/include/Poco/DOM/TreeWalker.h +++ b/contrib/libs/poco/XML/include/Poco/DOM/TreeWalker.h @@ -1,211 +1,211 @@ -// -// TreeWalker.h -// -// Library: XML -// Package: DOM -// Module: TreeWalker -// -// Definition of the DOM TreeWalker class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef DOM_TreeWalker_INCLUDED -#define DOM_TreeWalker_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class Node; -class NodeFilter; - - -class XML_API TreeWalker - /// TreeWalker objects are used to navigate a document tree or subtree using - /// the view of the document defined by their whatToShow flags and filter (if - /// any). Any function which performs navigation using a TreeWalker will automatically - /// support any view defined by a TreeWalker. +// +// TreeWalker.h +// +// Library: XML +// Package: DOM +// Module: TreeWalker +// +// Definition of the DOM TreeWalker class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef DOM_TreeWalker_INCLUDED +#define DOM_TreeWalker_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class Node; +class NodeFilter; + + +class XML_API TreeWalker + /// TreeWalker objects are used to navigate a document tree or subtree using + /// the view of the document defined by their whatToShow flags and filter (if + /// any). Any function which performs navigation using a TreeWalker will automatically + /// support any view defined by a TreeWalker. + /// + /// Omitting nodes from the logical view of a subtree can result in a structure + /// that is substantially different from the same subtree in the complete, unfiltered + /// document. Nodes that are siblings in the TreeWalker view may be children + /// of different, widely separated nodes in the original view. For instance, + /// consider a NodeFilter that skips all nodes except for Text nodes and the + /// root node of a document. In the logical view that results, all text nodes + /// will be siblings and appear as direct children of the root node, no matter + /// how deeply nested the structure of the original document. /// - /// Omitting nodes from the logical view of a subtree can result in a structure - /// that is substantially different from the same subtree in the complete, unfiltered - /// document. Nodes that are siblings in the TreeWalker view may be children - /// of different, widely separated nodes in the original view. For instance, - /// consider a NodeFilter that skips all nodes except for Text nodes and the - /// root node of a document. In the logical view that results, all text nodes - /// will be siblings and appear as direct children of the root node, no matter - /// how deeply nested the structure of the original document. - /// - /// A TreeWalker can be directly instantiated using one of its constructors - - /// the DocumentTraversal interface is not needed and therefore not implemented. - /// Unlike most other DOM classes, TreeWalker supports value semantics. - /// - /// If the TreeWalker's current node is removed from the document, the - /// result of calling any of the movement methods is undefined. This behavior - /// does not conform to the DOM Level 2 Traversal specification. -{ -public: - TreeWalker(Node* root, unsigned long whatToShow, NodeFilter* pFilter = 0); - /// Creates a TreeWalker over the subtree rooted at the specified node. - - TreeWalker(const TreeWalker& walker); - /// Creates a TreeWalker by copying another TreeWalker. - - TreeWalker& operator = (const TreeWalker& walker); - /// Assignment operator. - - ~TreeWalker(); - /// Destroys the TreeWalker. - - Node* root() const; - /// The root node of the TreeWalker, as specified when it was created. - - unsigned long whatToShow() const; - /// This attribute determines which node types are presented via the TreeWalker. - /// The available set of constants is defined in the NodeFilter interface. Nodes - /// not accepted by whatToShow will be skipped, but their children may still - /// be considered. Note that this skip takes precedence over the filter, if - /// any. - - NodeFilter* filter() const; - /// The NodeFilter used to screen nodes. - - bool expandEntityReferences() const; - /// The value of this flag determines whether the children of entity reference - /// nodes are visible to the iterator. If false, they and their descendants - /// will be rejected. Note that this rejection takes precedence over whatToShow - /// and the filter. Also note that this is currently the only situation where - /// NodeIterators may reject a complete subtree rather than skipping individual - /// nodes. + /// A TreeWalker can be directly instantiated using one of its constructors - + /// the DocumentTraversal interface is not needed and therefore not implemented. + /// Unlike most other DOM classes, TreeWalker supports value semantics. + /// + /// If the TreeWalker's current node is removed from the document, the + /// result of calling any of the movement methods is undefined. This behavior + /// does not conform to the DOM Level 2 Traversal specification. +{ +public: + TreeWalker(Node* root, unsigned long whatToShow, NodeFilter* pFilter = 0); + /// Creates a TreeWalker over the subtree rooted at the specified node. + + TreeWalker(const TreeWalker& walker); + /// Creates a TreeWalker by copying another TreeWalker. + + TreeWalker& operator = (const TreeWalker& walker); + /// Assignment operator. + + ~TreeWalker(); + /// Destroys the TreeWalker. + + Node* root() const; + /// The root node of the TreeWalker, as specified when it was created. + + unsigned long whatToShow() const; + /// This attribute determines which node types are presented via the TreeWalker. + /// The available set of constants is defined in the NodeFilter interface. Nodes + /// not accepted by whatToShow will be skipped, but their children may still + /// be considered. Note that this skip takes precedence over the filter, if + /// any. + + NodeFilter* filter() const; + /// The NodeFilter used to screen nodes. + + bool expandEntityReferences() const; + /// The value of this flag determines whether the children of entity reference + /// nodes are visible to the iterator. If false, they and their descendants + /// will be rejected. Note that this rejection takes precedence over whatToShow + /// and the filter. Also note that this is currently the only situation where + /// NodeIterators may reject a complete subtree rather than skipping individual + /// nodes. + /// + /// To produce a view of the document that has entity references expanded and + /// does not expose the entity reference node itself, use the whatToShow flags + /// to hide the entity reference node and set expandEntityReferences to true + /// when creating the iterator. To produce a view of the document that has entity + /// reference nodes but no entity expansion, use the whatToShow flags to show + /// the entity reference node and set expandEntityReferences to false. /// - /// To produce a view of the document that has entity references expanded and - /// does not expose the entity reference node itself, use the whatToShow flags - /// to hide the entity reference node and set expandEntityReferences to true - /// when creating the iterator. To produce a view of the document that has entity - /// reference nodes but no entity expansion, use the whatToShow flags to show - /// the entity reference node and set expandEntityReferences to false. - /// - /// This implementation does not support entity reference expansion and - /// thus always returns false. - - Node* currentNode() const; - /// The node at which the TreeWalker is currently positioned. - /// Alterations to the DOM tree may cause the current node to no longer be accepted - /// by the TreeWalker's associated filter. currentNode may also be explicitly - /// set to any node, whether or not it is within the subtree specified by the - /// root node or would be accepted by the filter and whatToShow flags. Further - /// traversal occurs relative to currentNode even if it is not part of the current - /// view, by applying the filters in the requested direction; if no traversal - /// is possible, currentNode is not changed. - - Node* getCurrentNode() const; - /// See currentNode(). - - void setCurrentNode(Node* pNode); - /// Sets the current node. - - Node* parentNode(); - /// Moves to and returns the closest visible ancestor node of the current node. - /// If the search for parentNode attempts to step upward from the TreeWalker's - /// root node, or if it fails to find a visible ancestor node, this method retains - /// the current position and returns null. - - Node* firstChild(); - /// Moves the TreeWalker to the first visible child of the current node, and - /// returns the new node. If the current node has no visible children, returns - /// null, and retains the current node. - - Node* lastChild(); - /// Moves the TreeWalker to the last visible child of the current node, and - /// returns the new node. If the current node has no visible children, returns - /// null, and retains the current node. - - Node* previousSibling(); - /// Moves the TreeWalker to the previous sibling of the current node, and returns - /// the new node. If the current node has no visible previous sibling, returns - /// null, and retains the current node. - - Node* nextSibling(); - /// Moves the TreeWalker to the next sibling of the current node, and returns - /// the new node. If the current node has no visible next sibling, returns null, - /// and retains the current node. - - Node* previousNode(); - /// Moves the TreeWalker to the previous visible node in document order relative - /// to the current node, and returns the new node. If the current node has no - /// previous node, or if the search for previousNode attempts to step upward - /// from the TreeWalker's root node, returns null, and retains the current node. - - Node* nextNode(); - /// Moves the TreeWalker to the next visible node in document order relative - /// to the current node, and returns the new node. If the current node has no - /// next node, or if the search for nextNode attempts to step upward from the - /// TreeWalker's root node, returns null, and retains the current node. - -protected: - int accept(Node* pNode) const; - Node* next(Node* pNode) const; - Node* previous(Node* pNode) const; - -private: - TreeWalker(); - - Node* _pRoot; - unsigned long _whatToShow; - NodeFilter* _pFilter; - Node* _pCurrent; -}; - - -// -// inlines -// -inline Node* TreeWalker::root() const -{ - return _pRoot; -} - - -inline unsigned long TreeWalker::whatToShow() const -{ - return _whatToShow; -} - - -inline NodeFilter* TreeWalker::filter() const -{ - return _pFilter; -} - - -inline bool TreeWalker::expandEntityReferences() const -{ - return false; -} - - -inline Node* TreeWalker::currentNode() const -{ - return _pCurrent; -} - - -inline Node* TreeWalker::getCurrentNode() const -{ - return _pCurrent; -} - - -} } // namespace Poco::XML - - -#endif // DOM_TreeWalker_INCLUDED + /// This implementation does not support entity reference expansion and + /// thus always returns false. + + Node* currentNode() const; + /// The node at which the TreeWalker is currently positioned. + /// Alterations to the DOM tree may cause the current node to no longer be accepted + /// by the TreeWalker's associated filter. currentNode may also be explicitly + /// set to any node, whether or not it is within the subtree specified by the + /// root node or would be accepted by the filter and whatToShow flags. Further + /// traversal occurs relative to currentNode even if it is not part of the current + /// view, by applying the filters in the requested direction; if no traversal + /// is possible, currentNode is not changed. + + Node* getCurrentNode() const; + /// See currentNode(). + + void setCurrentNode(Node* pNode); + /// Sets the current node. + + Node* parentNode(); + /// Moves to and returns the closest visible ancestor node of the current node. + /// If the search for parentNode attempts to step upward from the TreeWalker's + /// root node, or if it fails to find a visible ancestor node, this method retains + /// the current position and returns null. + + Node* firstChild(); + /// Moves the TreeWalker to the first visible child of the current node, and + /// returns the new node. If the current node has no visible children, returns + /// null, and retains the current node. + + Node* lastChild(); + /// Moves the TreeWalker to the last visible child of the current node, and + /// returns the new node. If the current node has no visible children, returns + /// null, and retains the current node. + + Node* previousSibling(); + /// Moves the TreeWalker to the previous sibling of the current node, and returns + /// the new node. If the current node has no visible previous sibling, returns + /// null, and retains the current node. + + Node* nextSibling(); + /// Moves the TreeWalker to the next sibling of the current node, and returns + /// the new node. If the current node has no visible next sibling, returns null, + /// and retains the current node. + + Node* previousNode(); + /// Moves the TreeWalker to the previous visible node in document order relative + /// to the current node, and returns the new node. If the current node has no + /// previous node, or if the search for previousNode attempts to step upward + /// from the TreeWalker's root node, returns null, and retains the current node. + + Node* nextNode(); + /// Moves the TreeWalker to the next visible node in document order relative + /// to the current node, and returns the new node. If the current node has no + /// next node, or if the search for nextNode attempts to step upward from the + /// TreeWalker's root node, returns null, and retains the current node. + +protected: + int accept(Node* pNode) const; + Node* next(Node* pNode) const; + Node* previous(Node* pNode) const; + +private: + TreeWalker(); + + Node* _pRoot; + unsigned long _whatToShow; + NodeFilter* _pFilter; + Node* _pCurrent; +}; + + +// +// inlines +// +inline Node* TreeWalker::root() const +{ + return _pRoot; +} + + +inline unsigned long TreeWalker::whatToShow() const +{ + return _whatToShow; +} + + +inline NodeFilter* TreeWalker::filter() const +{ + return _pFilter; +} + + +inline bool TreeWalker::expandEntityReferences() const +{ + return false; +} + + +inline Node* TreeWalker::currentNode() const +{ + return _pCurrent; +} + + +inline Node* TreeWalker::getCurrentNode() const +{ + return _pCurrent; +} + + +} } // namespace Poco::XML + + +#endif // DOM_TreeWalker_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/Attributes.h b/contrib/libs/poco/XML/include/Poco/SAX/Attributes.h index d7ba9129ed..a62d6383de 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/Attributes.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/Attributes.h @@ -1,120 +1,120 @@ -// -// Attributes.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX2 Attributes Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_Attributes_INCLUDED -#define SAX_Attributes_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API Attributes - /// Interface for a list of XML attributes. - /// This interface allows access to a list of attributes in three different ways: - /// 1.by attribute index; - /// 2.by Namespace-qualified name; or - /// 3.by qualified (prefixed) name. - /// - /// The list will not contain attributes that were declared #IMPLIED but not - /// specified in the start tag. It will also not contain - /// attributes used as Namespace declarations (xmlns*) unless the - /// http://xml.org/sax/features/namespace-prefixes - /// feature is set to true (it is false by default). - /// - /// If the namespace-prefixes feature (see above) is false, access by - /// qualified name may not be available; if the - /// http://xml.org/sax/features/namespaces feature is false, access by - /// Namespace-qualified names may not be available. - /// This interface replaces the now-deprecated SAX1 AttributeList interface, - /// which does not contain Namespace support. In - /// addition to Namespace support, it adds the getIndex methods (below). - /// The order of attributes in the list is unspecified, and will vary from - /// implementation to implementation. -{ -public: - virtual int getIndex(const XMLString& name) const = 0; - /// Look up the index of an attribute by a qualified name. - - virtual int getIndex(const XMLString& namespaceURI, const XMLString& localName) const = 0; - /// Look up the index of an attribute by a namspace name. - - virtual int getLength() const = 0; - /// Return the number of attributes in the list. - /// - /// Once you know the number of attributes, you can iterate through the list. - - virtual const XMLString& getLocalName(int i) const = 0; - /// Look up a local attribute name by index. - - virtual const XMLString& getQName(int i) const = 0; - /// Look up a qualified attribute name by index. - - virtual const XMLString& getType(int i) const = 0; - /// Look up an attribute type by index. - /// - /// The attribute type is one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", - /// "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper case). - /// - /// If the parser has not read a declaration for the attribute, or if the parser does not - /// report attribute types, then it must return the value "CDATA" as stated in the XML 1.0 - /// Recommendation (clause 3.3.3, "Attribute-Value Normalization"). +// +// Attributes.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX2 Attributes Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_Attributes_INCLUDED +#define SAX_Attributes_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API Attributes + /// Interface for a list of XML attributes. + /// This interface allows access to a list of attributes in three different ways: + /// 1.by attribute index; + /// 2.by Namespace-qualified name; or + /// 3.by qualified (prefixed) name. + /// + /// The list will not contain attributes that were declared #IMPLIED but not + /// specified in the start tag. It will also not contain + /// attributes used as Namespace declarations (xmlns*) unless the + /// http://xml.org/sax/features/namespace-prefixes + /// feature is set to true (it is false by default). + /// + /// If the namespace-prefixes feature (see above) is false, access by + /// qualified name may not be available; if the + /// http://xml.org/sax/features/namespaces feature is false, access by + /// Namespace-qualified names may not be available. + /// This interface replaces the now-deprecated SAX1 AttributeList interface, + /// which does not contain Namespace support. In + /// addition to Namespace support, it adds the getIndex methods (below). + /// The order of attributes in the list is unspecified, and will vary from + /// implementation to implementation. +{ +public: + virtual int getIndex(const XMLString& name) const = 0; + /// Look up the index of an attribute by a qualified name. + + virtual int getIndex(const XMLString& namespaceURI, const XMLString& localName) const = 0; + /// Look up the index of an attribute by a namspace name. + + virtual int getLength() const = 0; + /// Return the number of attributes in the list. /// - /// For an enumerated attribute that is not a notation, the parser will report the type - /// as "NMTOKEN". - - virtual const XMLString& getType(const XMLString& qname) const = 0; - /// Look up an attribute type by a qualified name. - /// - /// See getType(int) for a description of the possible types. - - virtual const XMLString& getType(const XMLString& namespaceURI, const XMLString& localName) const = 0; - /// Look up an attribute type by a namespace name. - /// - /// See getType(int) for a description of the possible types. - - virtual const XMLString& getValue(int i) const = 0; - /// Look up an attribute value by index. - /// - /// If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens - /// will be concatenated into a single string with each token separated by a single space. - - virtual const XMLString& getValue(const XMLString& qname) const = 0; - /// Look up an attribute value by a qualified name. - /// - /// See getValue(int) for a description of the possible values. - - virtual const XMLString& getValue(const XMLString& uri, const XMLString& localName) const = 0; - /// Look up an attribute value by a namespace name. - /// - /// See getValue(int) for a description of the possible values. - - virtual const XMLString& getURI(int i) const = 0; - /// Look up a namespace URI by index. - -protected: - virtual ~Attributes(); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_Attributes_INCLUDED + /// Once you know the number of attributes, you can iterate through the list. + + virtual const XMLString& getLocalName(int i) const = 0; + /// Look up a local attribute name by index. + + virtual const XMLString& getQName(int i) const = 0; + /// Look up a qualified attribute name by index. + + virtual const XMLString& getType(int i) const = 0; + /// Look up an attribute type by index. + /// + /// The attribute type is one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN", + /// "NMTOKENS", "ENTITY", "ENTITIES", or "NOTATION" (always in upper case). + /// + /// If the parser has not read a declaration for the attribute, or if the parser does not + /// report attribute types, then it must return the value "CDATA" as stated in the XML 1.0 + /// Recommendation (clause 3.3.3, "Attribute-Value Normalization"). + /// + /// For an enumerated attribute that is not a notation, the parser will report the type + /// as "NMTOKEN". + + virtual const XMLString& getType(const XMLString& qname) const = 0; + /// Look up an attribute type by a qualified name. + /// + /// See getType(int) for a description of the possible types. + + virtual const XMLString& getType(const XMLString& namespaceURI, const XMLString& localName) const = 0; + /// Look up an attribute type by a namespace name. + /// + /// See getType(int) for a description of the possible types. + + virtual const XMLString& getValue(int i) const = 0; + /// Look up an attribute value by index. + /// + /// If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens + /// will be concatenated into a single string with each token separated by a single space. + + virtual const XMLString& getValue(const XMLString& qname) const = 0; + /// Look up an attribute value by a qualified name. + /// + /// See getValue(int) for a description of the possible values. + + virtual const XMLString& getValue(const XMLString& uri, const XMLString& localName) const = 0; + /// Look up an attribute value by a namespace name. + /// + /// See getValue(int) for a description of the possible values. + + virtual const XMLString& getURI(int i) const = 0; + /// Look up a namespace URI by index. + +protected: + virtual ~Attributes(); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_Attributes_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/AttributesImpl.h b/contrib/libs/poco/XML/include/Poco/SAX/AttributesImpl.h index 8ce2d529f1..7281e11dbe 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/AttributesImpl.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/AttributesImpl.h @@ -1,296 +1,296 @@ -// -// AttributesImpl.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// Implementation of the SAX2 Attributes Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_AttributesImpl_INCLUDED -#define SAX_AttributesImpl_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/Attributes.h" -#include <vector> - - -namespace Poco { -namespace XML { - - -class XML_API AttributesImpl: public Attributes - /// This class provides a default implementation of the SAX2 Attributes interface, - /// with the addition of manipulators so that the list can be modified or reused. - /// - /// There are two typical uses of this class: - /// 1. to take a persistent snapshot of an Attributes object in a startElement event; or - /// 2. to construct or modify an Attributes object in a SAX2 driver or filter. -{ -public: - struct Attribute - { - XMLString localName; - XMLString namespaceURI; - XMLString qname; - XMLString value; - XMLString type; - bool specified; - }; - typedef std::vector<Attribute> AttributeVec; - typedef AttributeVec::const_iterator iterator; - - AttributesImpl(); - /// Creates the AttributesImpl. - - AttributesImpl(const Attributes& attributes); - /// Creates the AttributesImpl by copying another one. - - AttributesImpl(const AttributesImpl& attributes); - /// Creates the AttributesImpl by copying another one. - - ~AttributesImpl(); - /// Destroys the AttributesImpl. - - AttributesImpl& operator = (const AttributesImpl& attributes); - /// Assignment operator. - - int getIndex(const XMLString& name) const; - int getIndex(const XMLString& namespaceURI, const XMLString& localName) const; - int getLength() const; - const XMLString& getLocalName(int i) const; - const XMLString& getQName(int i) const; - const XMLString& getType(int i) const; - const XMLString& getType(const XMLString& qname) const; - const XMLString& getType(const XMLString& namespaceURI, const XMLString& localName) const; - const XMLString& getValue(int i) const; - const XMLString& getValue(const XMLString& qname) const; - const XMLString& getValue(const XMLString& namespaceURI, const XMLString& localName) const; - const XMLString& getURI(int i) const; - - bool isSpecified(int i) const; - /// Returns true unless the attribute value was provided by DTD defaulting. - /// Extension from Attributes2 interface. - - bool isSpecified(const XMLString& qname) const; - /// Returns true unless the attribute value was provided by DTD defaulting. - /// Extension from Attributes2 interface. - - bool isSpecified(const XMLString& namespaceURI, const XMLString& localName) const; - /// Returns true unless the attribute value was provided by DTD defaulting. - /// Extension from Attributes2 interface. - - void setValue(int i, const XMLString& value); - /// Sets the value of an attribute. - - void setValue(const XMLString& qname, const XMLString& value); - /// Sets the value of an attribute. - - void setValue(const XMLString& namespaceURI, const XMLString& localName, const XMLString& value); - /// Sets the value of an attribute. - - void setAttributes(const Attributes& attributes); - /// Copies the attributes from another Attributes object. - - void setAttribute(int i, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value); - /// Sets an attribute. - - void addAttribute(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value); - /// Adds an attribute to the end of the list. - - void addAttribute(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value, bool specified); - /// Adds an attribute to the end of the list. - - void addAttribute(const XMLChar* namespaceURI, const XMLChar* localName, const XMLChar* qname, const XMLChar* type, const XMLChar* value, bool specified); - /// Adds an attribute to the end of the list. - - Attribute& addAttribute(); - /// Add an (empty) attribute to the end of the list. - /// For internal use only. - /// The returned Attribute element must be filled by the caller. - - void removeAttribute(int i); - /// Removes an attribute. - - void removeAttribute(const XMLString& qname); - /// Removes an attribute. - - void removeAttribute(const XMLString& namespaceURI, const XMLString& localName); - /// Removes an attribute. - - void clear(); - /// Removes all attributes. - - void reserve(std::size_t capacity); - /// Reserves capacity in the internal vector. - - void setLocalName(int i, const XMLString& localName); - /// Sets the local name of an attribute. - - void setQName(int i, const XMLString& qname); - /// Sets the qualified name of an attribute. - - void setType(int i, const XMLString& type); - /// Sets the type of an attribute. - - void setURI(int i, const XMLString& namespaceURI); - /// Sets the namespace URI of an attribute. - - iterator begin() const; - /// Iterator support. - - iterator end() const; - /// Iterator support. - -protected: - Attribute* find(const XMLString& qname) const; - Attribute* find(const XMLString& namespaceURI, const XMLString& localName) const; - -private: - AttributeVec _attributes; - Attribute _empty; -}; - - -// -// inlines -// -inline AttributesImpl::iterator AttributesImpl::begin() const -{ - return _attributes.begin(); -} - - -inline AttributesImpl::iterator AttributesImpl::end() const -{ - return _attributes.end(); -} - - -inline AttributesImpl::Attribute& AttributesImpl::addAttribute() -{ - _attributes.push_back(_empty); - return _attributes.back(); -} - - -inline int AttributesImpl::getLength() const -{ - return (int) _attributes.size(); -} - - -inline const XMLString& AttributesImpl::getLocalName(int i) const -{ - poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); - return _attributes[i].localName; -} - - -inline const XMLString& AttributesImpl::getQName(int i) const -{ - poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); - return _attributes[i].qname; -} - - -inline const XMLString& AttributesImpl::getType(int i) const -{ - poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); - return _attributes[i].type; -} - - -inline const XMLString& AttributesImpl::getType(const XMLString& qname) const -{ - Attribute* pAttr = find(qname); - if (pAttr) - return pAttr->type; - else - return _empty.type; -} - - -inline const XMLString& AttributesImpl::getType(const XMLString& namespaceURI, const XMLString& localName) const -{ - Attribute* pAttr = find(namespaceURI, localName); - if (pAttr) - return pAttr->type; - else - return _empty.type; -} - - -inline const XMLString& AttributesImpl::getValue(int i) const -{ - poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); - return _attributes[i].value; -} - - -inline const XMLString& AttributesImpl::getValue(const XMLString& qname) const -{ - Attribute* pAttr = find(qname); - if (pAttr) - return pAttr->value; - else - return _empty.value; -} - - -inline const XMLString& AttributesImpl::getValue(const XMLString& namespaceURI, const XMLString& localName) const -{ - Attribute* pAttr = find(namespaceURI, localName); - if (pAttr) - return pAttr->value; - else - return _empty.value; -} - - -inline const XMLString& AttributesImpl::getURI(int i) const -{ - poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); - return _attributes[i].namespaceURI; -} - - -inline bool AttributesImpl::isSpecified(int i) const -{ - poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); - return _attributes[i].specified; -} - - -inline bool AttributesImpl::isSpecified(const XMLString& qname) const -{ - Attribute* pAttr = find(qname); - if (pAttr) - return pAttr->specified; - else - return false; -} - - -inline bool AttributesImpl::isSpecified(const XMLString& namespaceURI, const XMLString& localName) const -{ - Attribute* pAttr = find(namespaceURI, localName); - if (pAttr) - return pAttr->specified; - else - return false; -} - - -} } // namespace Poco::XML - - -#endif // SAX_AttributesImpl_INCLUDED +// +// AttributesImpl.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// Implementation of the SAX2 Attributes Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_AttributesImpl_INCLUDED +#define SAX_AttributesImpl_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/Attributes.h" +#include <vector> + + +namespace Poco { +namespace XML { + + +class XML_API AttributesImpl: public Attributes + /// This class provides a default implementation of the SAX2 Attributes interface, + /// with the addition of manipulators so that the list can be modified or reused. + /// + /// There are two typical uses of this class: + /// 1. to take a persistent snapshot of an Attributes object in a startElement event; or + /// 2. to construct or modify an Attributes object in a SAX2 driver or filter. +{ +public: + struct Attribute + { + XMLString localName; + XMLString namespaceURI; + XMLString qname; + XMLString value; + XMLString type; + bool specified; + }; + typedef std::vector<Attribute> AttributeVec; + typedef AttributeVec::const_iterator iterator; + + AttributesImpl(); + /// Creates the AttributesImpl. + + AttributesImpl(const Attributes& attributes); + /// Creates the AttributesImpl by copying another one. + + AttributesImpl(const AttributesImpl& attributes); + /// Creates the AttributesImpl by copying another one. + + ~AttributesImpl(); + /// Destroys the AttributesImpl. + + AttributesImpl& operator = (const AttributesImpl& attributes); + /// Assignment operator. + + int getIndex(const XMLString& name) const; + int getIndex(const XMLString& namespaceURI, const XMLString& localName) const; + int getLength() const; + const XMLString& getLocalName(int i) const; + const XMLString& getQName(int i) const; + const XMLString& getType(int i) const; + const XMLString& getType(const XMLString& qname) const; + const XMLString& getType(const XMLString& namespaceURI, const XMLString& localName) const; + const XMLString& getValue(int i) const; + const XMLString& getValue(const XMLString& qname) const; + const XMLString& getValue(const XMLString& namespaceURI, const XMLString& localName) const; + const XMLString& getURI(int i) const; + + bool isSpecified(int i) const; + /// Returns true unless the attribute value was provided by DTD defaulting. + /// Extension from Attributes2 interface. + + bool isSpecified(const XMLString& qname) const; + /// Returns true unless the attribute value was provided by DTD defaulting. + /// Extension from Attributes2 interface. + + bool isSpecified(const XMLString& namespaceURI, const XMLString& localName) const; + /// Returns true unless the attribute value was provided by DTD defaulting. + /// Extension from Attributes2 interface. + + void setValue(int i, const XMLString& value); + /// Sets the value of an attribute. + + void setValue(const XMLString& qname, const XMLString& value); + /// Sets the value of an attribute. + + void setValue(const XMLString& namespaceURI, const XMLString& localName, const XMLString& value); + /// Sets the value of an attribute. + + void setAttributes(const Attributes& attributes); + /// Copies the attributes from another Attributes object. + + void setAttribute(int i, const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value); + /// Sets an attribute. + + void addAttribute(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value); + /// Adds an attribute to the end of the list. + + void addAttribute(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& type, const XMLString& value, bool specified); + /// Adds an attribute to the end of the list. + + void addAttribute(const XMLChar* namespaceURI, const XMLChar* localName, const XMLChar* qname, const XMLChar* type, const XMLChar* value, bool specified); + /// Adds an attribute to the end of the list. + + Attribute& addAttribute(); + /// Add an (empty) attribute to the end of the list. + /// For internal use only. + /// The returned Attribute element must be filled by the caller. + + void removeAttribute(int i); + /// Removes an attribute. + + void removeAttribute(const XMLString& qname); + /// Removes an attribute. + + void removeAttribute(const XMLString& namespaceURI, const XMLString& localName); + /// Removes an attribute. + + void clear(); + /// Removes all attributes. + + void reserve(std::size_t capacity); + /// Reserves capacity in the internal vector. + + void setLocalName(int i, const XMLString& localName); + /// Sets the local name of an attribute. + + void setQName(int i, const XMLString& qname); + /// Sets the qualified name of an attribute. + + void setType(int i, const XMLString& type); + /// Sets the type of an attribute. + + void setURI(int i, const XMLString& namespaceURI); + /// Sets the namespace URI of an attribute. + + iterator begin() const; + /// Iterator support. + + iterator end() const; + /// Iterator support. + +protected: + Attribute* find(const XMLString& qname) const; + Attribute* find(const XMLString& namespaceURI, const XMLString& localName) const; + +private: + AttributeVec _attributes; + Attribute _empty; +}; + + +// +// inlines +// +inline AttributesImpl::iterator AttributesImpl::begin() const +{ + return _attributes.begin(); +} + + +inline AttributesImpl::iterator AttributesImpl::end() const +{ + return _attributes.end(); +} + + +inline AttributesImpl::Attribute& AttributesImpl::addAttribute() +{ + _attributes.push_back(_empty); + return _attributes.back(); +} + + +inline int AttributesImpl::getLength() const +{ + return (int) _attributes.size(); +} + + +inline const XMLString& AttributesImpl::getLocalName(int i) const +{ + poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); + return _attributes[i].localName; +} + + +inline const XMLString& AttributesImpl::getQName(int i) const +{ + poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); + return _attributes[i].qname; +} + + +inline const XMLString& AttributesImpl::getType(int i) const +{ + poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); + return _attributes[i].type; +} + + +inline const XMLString& AttributesImpl::getType(const XMLString& qname) const +{ + Attribute* pAttr = find(qname); + if (pAttr) + return pAttr->type; + else + return _empty.type; +} + + +inline const XMLString& AttributesImpl::getType(const XMLString& namespaceURI, const XMLString& localName) const +{ + Attribute* pAttr = find(namespaceURI, localName); + if (pAttr) + return pAttr->type; + else + return _empty.type; +} + + +inline const XMLString& AttributesImpl::getValue(int i) const +{ + poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); + return _attributes[i].value; +} + + +inline const XMLString& AttributesImpl::getValue(const XMLString& qname) const +{ + Attribute* pAttr = find(qname); + if (pAttr) + return pAttr->value; + else + return _empty.value; +} + + +inline const XMLString& AttributesImpl::getValue(const XMLString& namespaceURI, const XMLString& localName) const +{ + Attribute* pAttr = find(namespaceURI, localName); + if (pAttr) + return pAttr->value; + else + return _empty.value; +} + + +inline const XMLString& AttributesImpl::getURI(int i) const +{ + poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); + return _attributes[i].namespaceURI; +} + + +inline bool AttributesImpl::isSpecified(int i) const +{ + poco_assert (0 <= i && i < static_cast<int>(_attributes.size())); + return _attributes[i].specified; +} + + +inline bool AttributesImpl::isSpecified(const XMLString& qname) const +{ + Attribute* pAttr = find(qname); + if (pAttr) + return pAttr->specified; + else + return false; +} + + +inline bool AttributesImpl::isSpecified(const XMLString& namespaceURI, const XMLString& localName) const +{ + Attribute* pAttr = find(namespaceURI, localName); + if (pAttr) + return pAttr->specified; + else + return false; +} + + +} } // namespace Poco::XML + + +#endif // SAX_AttributesImpl_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/ContentHandler.h b/contrib/libs/poco/XML/include/Poco/SAX/ContentHandler.h index 58f2a253ad..0568fee89a 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/ContentHandler.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/ContentHandler.h @@ -1,240 +1,240 @@ -// -// ContentHandler.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX2 ContentHandler Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_ContentHandler_INCLUDED -#define SAX_ContentHandler_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class Locator; -class Attributes; - - -class XML_API ContentHandler - /// Receive notification of the logical content of a document. - /// - /// This is the main interface that most SAX applications implement: if the - /// application needs to be informed of basic parsing events, it implements - /// this interface and registers an instance with the SAX parser using the setContentHandler - /// method. The parser uses the instance to report basic document-related events - /// like the start and end of elements and character data. - /// - /// The order of events in this interface is very important, and mirrors the - /// order of information in the document itself. For example, all of an element's - /// content (character data, processing instructions, and/or subelements) will - /// appear, in order, between the startElement event and the corresponding endElement - /// event. +// +// ContentHandler.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX2 ContentHandler Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_ContentHandler_INCLUDED +#define SAX_ContentHandler_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class Locator; +class Attributes; + + +class XML_API ContentHandler + /// Receive notification of the logical content of a document. /// - /// This interface is similar to the now-deprecated SAX 1.0 DocumentHandler - /// interface, but it adds support for Namespaces and for reporting skipped - /// entities (in non-validating XML processors). - /// Receive notification of the logical content of a document. -{ -public: - virtual void setDocumentLocator(const Locator* loc) = 0; - /// Receive an object for locating the origin of SAX document events. - /// - /// SAX parsers are strongly encouraged (though not absolutely required) to - /// supply a locator: if it does so, it must supply the locator to the application - /// by invoking this method before invoking any of the other methods in the - /// ContentHandler interface. - /// - /// The locator allows the application to determine the end position of any - /// document-related event, even if the parser is not reporting an error. Typically, - /// the application will use this information for reporting its own errors (such - /// as character content that does not match an application's business rules). - /// The information returned by the locator is probably not sufficient for use - /// with a search engine. - /// - /// Note that the locator will return correct information only during the invocation - /// SAX event callbacks after startDocument returns and before endDocument is - /// called. The application should not attempt to use it at any other time. - - virtual void startDocument() = 0; - /// Receive notification of the beginning of a document. - /// - /// The SAX parser calls this function one time before calling all other - /// functions of this class (except SetDocumentLocator). - - virtual void endDocument() = 0; - /// Receive notification of the end of a document. - /// - /// The SAX parser will invoke this method only once, and it will be the last - /// method invoked during the parse. The parser shall not invoke this method - /// until it has either abandoned parsing (because of an unrecoverable error) - /// or reached the end of input. - - virtual void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList) = 0; - /// Receive notification of the beginning of an element. - /// - /// The Parser will invoke this method at the beginning of every element in - /// the XML document; there will be a corresponding endElement event for every - /// startElement event (even when the element is empty). All of the element's - /// content will be reported, in order, before the corresponding endElement - /// event. - /// - /// This event allows up to three name components for each element: - /// 1. the Namespace URI; - /// 2. the local name; and - /// 3. the qualified (prefixed) name. - /// - /// Any or all of these may be provided, depending on the values of the http://xml.org/sax/features/namespaces - /// and the http://xml.org/sax/features/namespace-prefixes properties: - /// * the Namespace URI and local name are required when the namespaces - /// property is true (the default), and are optional when the namespaces property - /// is false (if one is specified, both must be); - /// * the qualified name is required when the namespace-prefixes property - /// is true, and is optional when the namespace-prefixes property is false (the - /// default). - /// - /// Note that the attribute list provided will contain only attributes with - /// explicit values (specified or defaulted): #IMPLIED attributes will be omitted. - /// The attribute list will contain attributes used for Namespace declarations - /// (xmlns* attributes) only if the http://xml.org/sax/features/namespace-prefixes - /// property is true (it is false by default, and support for a true value is - /// optional). - /// - /// Like characters(), attribute values may have characters that need more than - /// one char value. - - virtual void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname) = 0; - /// Receive notification of the end of an element. - /// - /// The SAX parser will invoke this method at the end of every element in the - /// XML document; there will be a corresponding startElement event for every - /// endElement event (even when the element is empty). - /// - /// For information on the names, see startElement. - - virtual void characters(const XMLChar ch[], int start, int length) = 0; - /// Receive notification of character data. - /// - /// The Parser will call this method to report each chunk of character data. - /// SAX parsers may return all contiguous character data in a single chunk, - /// or they may split it into several chunks; however, all of the characters - /// in any single event must come from the same external entity so that the - /// Locator provides useful information. - /// - /// The application must not attempt to read from the array outside of the specified - /// range. - /// - /// Individual characters may consist of more than one XMLChar value. There - /// are three important cases where this happens, because characters can't be - /// represented in just sixteen bits. In one case, characters are represented - /// in a Surrogate Pair, using two special Unicode values. Such characters are - /// in the so-called "Astral Planes", with a code point above U+FFFF. A second - /// case involves composite characters, such as a base character combining with - /// one or more accent characters. And most important, if XMLChar is a plain - /// char, characters are encoded in UTF-8. - /// - /// Your code should not assume that algorithms using char-at-a-time idioms - /// will be working in character units; in some cases they will split characters. - /// This is relevant wherever XML permits arbitrary characters, such as attribute - /// values, processing instruction data, and comments as well as in data reported - /// from this method. It's also generally relevant whenever C++ code manipulates - /// internationalized text; the issue isn't unique to XML. - /// - /// Note that some parsers will report whitespace in element content using the - /// ignorableWhitespace method rather than this one (validating parsers must - /// do so). - - virtual void ignorableWhitespace(const XMLChar ch[], int start, int length) = 0; - /// Receive notification of ignorable whitespace in element content. - /// - /// Validating Parsers must use this method to report each chunk of whitespace - /// in element content (see the W3C XML 1.0 recommendation, section 2.10): non-validating - /// parsers may also use this method if they are capable of parsing and using - /// content models. - /// - /// SAX parsers may return all contiguous whitespace in a single chunk, or they - /// may split it into several chunks; however, all of the characters in any - /// single event must come from the same external entity, so that the Locator - /// provides useful information. - /// - /// The application must not attempt to read from the array outside of the specified - /// range. - - virtual void processingInstruction(const XMLString& target, const XMLString& data) = 0; - /// Receive notification of a processing instruction. - /// - /// The Parser will invoke this method once for each processing instruction - /// found: note that processing instructions may occur before or after the main - /// document element. - /// - /// A SAX parser must never report an XML declaration (XML 1.0, section 2.8) - /// or a text declaration (XML 1.0, section 4.3.1) using this method. - /// - /// Like characters(), processing instruction data may have characters that - /// need more than one char value. - - virtual void startPrefixMapping(const XMLString& prefix, const XMLString& uri) = 0; - /// Begin the scope of a prefix-URI Namespace mapping. - /// - /// The information from this event is not necessary for normal Namespace processing: - /// the SAX XML reader will automatically replace prefixes for element and attribute - /// names when the http://xml.org/sax/features/namespaces feature is true (the - /// default). - /// - /// There are cases, however, when applications need to use prefixes in character - /// data or in attribute values, where they cannot safely be expanded automatically; - /// the start/endPrefixMapping event supplies the information to the application - /// to expand prefixes in those contexts itself, if necessary. - /// - /// Note that start/endPrefixMapping events are not guaranteed to be properly - /// nested relative to each other: all startPrefixMapping events will occur - /// immediately before the corresponding startElement event, and all endPrefixMapping - /// events will occur immediately after the corresponding endElement event, - /// but their order is not otherwise guaranteed. - /// - /// There should never be start/endPrefixMapping events for the "xml" prefix, - /// since it is predeclared and immutable. - - virtual void endPrefixMapping(const XMLString& prefix) = 0; - /// End the scope of a prefix-URI mapping. - /// - /// See startPrefixMapping for details. These events will always occur immediately - /// after the corresponding endElement event, but the order of endPrefixMapping - /// events is not otherwise guaranteed. - - virtual void skippedEntity(const XMLString& name) = 0; - /// Receive notification of a skipped entity. This is not called for entity - /// references within markup constructs such as element start tags or markup - /// declarations. (The XML recommendation requires reporting skipped external - /// entities. SAX also reports internal entity expansion/non-expansion, except - /// within markup constructs.) - /// - /// The Parser will invoke this method each time the entity is skipped. Non-validating - /// processors may skip entities if they have not seen the declarations (because, - /// for example, the entity was declared in an external DTD subset). All processors - /// may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities - /// and the http://xml.org/sax/features/external-parameter-entities properties. - -protected: - virtual ~ContentHandler(); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_ContentHandler_INCLUDED + /// This is the main interface that most SAX applications implement: if the + /// application needs to be informed of basic parsing events, it implements + /// this interface and registers an instance with the SAX parser using the setContentHandler + /// method. The parser uses the instance to report basic document-related events + /// like the start and end of elements and character data. + /// + /// The order of events in this interface is very important, and mirrors the + /// order of information in the document itself. For example, all of an element's + /// content (character data, processing instructions, and/or subelements) will + /// appear, in order, between the startElement event and the corresponding endElement + /// event. + /// + /// This interface is similar to the now-deprecated SAX 1.0 DocumentHandler + /// interface, but it adds support for Namespaces and for reporting skipped + /// entities (in non-validating XML processors). + /// Receive notification of the logical content of a document. +{ +public: + virtual void setDocumentLocator(const Locator* loc) = 0; + /// Receive an object for locating the origin of SAX document events. + /// + /// SAX parsers are strongly encouraged (though not absolutely required) to + /// supply a locator: if it does so, it must supply the locator to the application + /// by invoking this method before invoking any of the other methods in the + /// ContentHandler interface. + /// + /// The locator allows the application to determine the end position of any + /// document-related event, even if the parser is not reporting an error. Typically, + /// the application will use this information for reporting its own errors (such + /// as character content that does not match an application's business rules). + /// The information returned by the locator is probably not sufficient for use + /// with a search engine. + /// + /// Note that the locator will return correct information only during the invocation + /// SAX event callbacks after startDocument returns and before endDocument is + /// called. The application should not attempt to use it at any other time. + + virtual void startDocument() = 0; + /// Receive notification of the beginning of a document. + /// + /// The SAX parser calls this function one time before calling all other + /// functions of this class (except SetDocumentLocator). + + virtual void endDocument() = 0; + /// Receive notification of the end of a document. + /// + /// The SAX parser will invoke this method only once, and it will be the last + /// method invoked during the parse. The parser shall not invoke this method + /// until it has either abandoned parsing (because of an unrecoverable error) + /// or reached the end of input. + + virtual void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList) = 0; + /// Receive notification of the beginning of an element. + /// + /// The Parser will invoke this method at the beginning of every element in + /// the XML document; there will be a corresponding endElement event for every + /// startElement event (even when the element is empty). All of the element's + /// content will be reported, in order, before the corresponding endElement + /// event. + /// + /// This event allows up to three name components for each element: + /// 1. the Namespace URI; + /// 2. the local name; and + /// 3. the qualified (prefixed) name. + /// + /// Any or all of these may be provided, depending on the values of the http://xml.org/sax/features/namespaces + /// and the http://xml.org/sax/features/namespace-prefixes properties: + /// * the Namespace URI and local name are required when the namespaces + /// property is true (the default), and are optional when the namespaces property + /// is false (if one is specified, both must be); + /// * the qualified name is required when the namespace-prefixes property + /// is true, and is optional when the namespace-prefixes property is false (the + /// default). + /// + /// Note that the attribute list provided will contain only attributes with + /// explicit values (specified or defaulted): #IMPLIED attributes will be omitted. + /// The attribute list will contain attributes used for Namespace declarations + /// (xmlns* attributes) only if the http://xml.org/sax/features/namespace-prefixes + /// property is true (it is false by default, and support for a true value is + /// optional). + /// + /// Like characters(), attribute values may have characters that need more than + /// one char value. + + virtual void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname) = 0; + /// Receive notification of the end of an element. + /// + /// The SAX parser will invoke this method at the end of every element in the + /// XML document; there will be a corresponding startElement event for every + /// endElement event (even when the element is empty). + /// + /// For information on the names, see startElement. + + virtual void characters(const XMLChar ch[], int start, int length) = 0; + /// Receive notification of character data. + /// + /// The Parser will call this method to report each chunk of character data. + /// SAX parsers may return all contiguous character data in a single chunk, + /// or they may split it into several chunks; however, all of the characters + /// in any single event must come from the same external entity so that the + /// Locator provides useful information. + /// + /// The application must not attempt to read from the array outside of the specified + /// range. + /// + /// Individual characters may consist of more than one XMLChar value. There + /// are three important cases where this happens, because characters can't be + /// represented in just sixteen bits. In one case, characters are represented + /// in a Surrogate Pair, using two special Unicode values. Such characters are + /// in the so-called "Astral Planes", with a code point above U+FFFF. A second + /// case involves composite characters, such as a base character combining with + /// one or more accent characters. And most important, if XMLChar is a plain + /// char, characters are encoded in UTF-8. + /// + /// Your code should not assume that algorithms using char-at-a-time idioms + /// will be working in character units; in some cases they will split characters. + /// This is relevant wherever XML permits arbitrary characters, such as attribute + /// values, processing instruction data, and comments as well as in data reported + /// from this method. It's also generally relevant whenever C++ code manipulates + /// internationalized text; the issue isn't unique to XML. + /// + /// Note that some parsers will report whitespace in element content using the + /// ignorableWhitespace method rather than this one (validating parsers must + /// do so). + + virtual void ignorableWhitespace(const XMLChar ch[], int start, int length) = 0; + /// Receive notification of ignorable whitespace in element content. + /// + /// Validating Parsers must use this method to report each chunk of whitespace + /// in element content (see the W3C XML 1.0 recommendation, section 2.10): non-validating + /// parsers may also use this method if they are capable of parsing and using + /// content models. + /// + /// SAX parsers may return all contiguous whitespace in a single chunk, or they + /// may split it into several chunks; however, all of the characters in any + /// single event must come from the same external entity, so that the Locator + /// provides useful information. + /// + /// The application must not attempt to read from the array outside of the specified + /// range. + + virtual void processingInstruction(const XMLString& target, const XMLString& data) = 0; + /// Receive notification of a processing instruction. + /// + /// The Parser will invoke this method once for each processing instruction + /// found: note that processing instructions may occur before or after the main + /// document element. + /// + /// A SAX parser must never report an XML declaration (XML 1.0, section 2.8) + /// or a text declaration (XML 1.0, section 4.3.1) using this method. + /// + /// Like characters(), processing instruction data may have characters that + /// need more than one char value. + + virtual void startPrefixMapping(const XMLString& prefix, const XMLString& uri) = 0; + /// Begin the scope of a prefix-URI Namespace mapping. + /// + /// The information from this event is not necessary for normal Namespace processing: + /// the SAX XML reader will automatically replace prefixes for element and attribute + /// names when the http://xml.org/sax/features/namespaces feature is true (the + /// default). + /// + /// There are cases, however, when applications need to use prefixes in character + /// data or in attribute values, where they cannot safely be expanded automatically; + /// the start/endPrefixMapping event supplies the information to the application + /// to expand prefixes in those contexts itself, if necessary. + /// + /// Note that start/endPrefixMapping events are not guaranteed to be properly + /// nested relative to each other: all startPrefixMapping events will occur + /// immediately before the corresponding startElement event, and all endPrefixMapping + /// events will occur immediately after the corresponding endElement event, + /// but their order is not otherwise guaranteed. + /// + /// There should never be start/endPrefixMapping events for the "xml" prefix, + /// since it is predeclared and immutable. + + virtual void endPrefixMapping(const XMLString& prefix) = 0; + /// End the scope of a prefix-URI mapping. + /// + /// See startPrefixMapping for details. These events will always occur immediately + /// after the corresponding endElement event, but the order of endPrefixMapping + /// events is not otherwise guaranteed. + + virtual void skippedEntity(const XMLString& name) = 0; + /// Receive notification of a skipped entity. This is not called for entity + /// references within markup constructs such as element start tags or markup + /// declarations. (The XML recommendation requires reporting skipped external + /// entities. SAX also reports internal entity expansion/non-expansion, except + /// within markup constructs.) + /// + /// The Parser will invoke this method each time the entity is skipped. Non-validating + /// processors may skip entities if they have not seen the declarations (because, + /// for example, the entity was declared in an external DTD subset). All processors + /// may skip external entities, depending on the values of the http://xml.org/sax/features/external-general-entities + /// and the http://xml.org/sax/features/external-parameter-entities properties. + +protected: + virtual ~ContentHandler(); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_ContentHandler_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/DTDHandler.h b/contrib/libs/poco/XML/include/Poco/SAX/DTDHandler.h index f21a299c81..aa1426fa4f 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/DTDHandler.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/DTDHandler.h @@ -1,86 +1,86 @@ -// -// DTDHandler.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX DTDHandler Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_DTDHandler_INCLUDED -#define SAX_DTDHandler_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API DTDHandler - /// If a SAX application needs information about notations and unparsed entities, - /// then the application implements this interface and registers an instance with the - /// SAX parser using the parser's setDTDHandler method. The parser uses the instance - /// to report notation and unparsed entity declarations to the application. - /// - /// Note that this interface includes only those DTD events that the XML recommendation - /// requires processors to report: notation and unparsed entity declarations. - /// - /// The SAX parser may report these events in any order, regardless of the order in - /// which the notations and unparsed entities were declared; however, all DTD events - /// must be reported after the document handler's startDocument event, and before the first - /// startElement event. (If the LexicalHandler is used, these events must also be reported before the endDTD event.) +// +// DTDHandler.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX DTDHandler Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_DTDHandler_INCLUDED +#define SAX_DTDHandler_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API DTDHandler + /// If a SAX application needs information about notations and unparsed entities, + /// then the application implements this interface and registers an instance with the + /// SAX parser using the parser's setDTDHandler method. The parser uses the instance + /// to report notation and unparsed entity declarations to the application. /// - /// It is up to the application to store the information for future use (perhaps in a hash table or - /// object tree). If the application encounters attributes of type "NOTATION", "ENTITY", or "ENTITIES", - /// it can use the information that it obtained through this interface to find the entity and/or notation - /// corresponding with the attribute value. -{ -public: - virtual void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId) = 0; - /// Receive notification of a notation declaration event. - /// - /// It is up to the application to record the notation for later reference, - /// if necessary; notations may appear as attribute values and in unparsed - /// entity declarations, and are sometime used with processing instruction - /// target names. - /// - /// At least one of publicId and systemId must be non-null. If a system identifier - /// is present, and it is a URL, the SAX parser must resolve it fully before passing - /// it to the application through this event. - /// - /// There is no guarantee that the notation declaration will be reported before any - /// unparsed entities that use it. - /// - /// Note that publicId and systemId maybe null, therefore we pass a pointer rather than a reference. - - virtual void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName) = 0; - /// Receive notification of an unparsed entity declaration event. - /// - /// Note that the notation name corresponds to a notation reported by the - /// notationDecl event. It is up to the application to record the entity for - /// later reference, if necessary; unparsed entities may appear as attribute values. - /// - /// If the system identifier is a URL, the parser must resolve it fully before - /// passing it to the application. + /// Note that this interface includes only those DTD events that the XML recommendation + /// requires processors to report: notation and unparsed entity declarations. + /// + /// The SAX parser may report these events in any order, regardless of the order in + /// which the notations and unparsed entities were declared; however, all DTD events + /// must be reported after the document handler's startDocument event, and before the first + /// startElement event. (If the LexicalHandler is used, these events must also be reported before the endDTD event.) + /// + /// It is up to the application to store the information for future use (perhaps in a hash table or + /// object tree). If the application encounters attributes of type "NOTATION", "ENTITY", or "ENTITIES", + /// it can use the information that it obtained through this interface to find the entity and/or notation + /// corresponding with the attribute value. +{ +public: + virtual void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId) = 0; + /// Receive notification of a notation declaration event. + /// + /// It is up to the application to record the notation for later reference, + /// if necessary; notations may appear as attribute values and in unparsed + /// entity declarations, and are sometime used with processing instruction + /// target names. + /// + /// At least one of publicId and systemId must be non-null. If a system identifier + /// is present, and it is a URL, the SAX parser must resolve it fully before passing + /// it to the application through this event. + /// + /// There is no guarantee that the notation declaration will be reported before any + /// unparsed entities that use it. /// - /// Note that publicId maybe null, therefore we pass a pointer rather than a reference. - -protected: - virtual ~DTDHandler(); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_DTDHandler_INCLUDED + /// Note that publicId and systemId maybe null, therefore we pass a pointer rather than a reference. + + virtual void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName) = 0; + /// Receive notification of an unparsed entity declaration event. + /// + /// Note that the notation name corresponds to a notation reported by the + /// notationDecl event. It is up to the application to record the entity for + /// later reference, if necessary; unparsed entities may appear as attribute values. + /// + /// If the system identifier is a URL, the parser must resolve it fully before + /// passing it to the application. + /// + /// Note that publicId maybe null, therefore we pass a pointer rather than a reference. + +protected: + virtual ~DTDHandler(); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_DTDHandler_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/DeclHandler.h b/contrib/libs/poco/XML/include/Poco/SAX/DeclHandler.h index 578f10275d..bef995548b 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/DeclHandler.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/DeclHandler.h @@ -1,91 +1,91 @@ -// -// DeclHandler.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX2-ext DeclHandler Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_DeclHandler_INCLUDED -#define SAX_DeclHandler_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API DeclHandler - /// This is an optional extension handler for SAX2 to provide information - /// about DTD declarations in an XML document. XML - /// readers are not required to support this handler, and this handler is - /// not included in the core SAX2 distribution. - /// - /// Note that data-related DTD declarations (unparsed entities and notations) - /// are already reported through the DTDHandler interface. - /// If you are using the declaration handler together with a lexical handler, - /// all of the events will occur between the startDTD and the endDTD events. - /// To set the DeclHandler for an XML reader, use the setProperty method - /// with the propertyId "http://xml.org/sax/properties/declaration-handler". - /// If the reader does not support declaration events, it will throw a - /// SAXNotRecognizedException or a SAXNotSupportedException when you attempt to - /// register the handler. -{ -public: - virtual void attributeDecl(const XMLString& eName, const XMLString& aName, const XMLString* valueDefault, const XMLString* value) = 0; - /// Report an attribute type declaration. +// +// DeclHandler.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX2-ext DeclHandler Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_DeclHandler_INCLUDED +#define SAX_DeclHandler_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API DeclHandler + /// This is an optional extension handler for SAX2 to provide information + /// about DTD declarations in an XML document. XML + /// readers are not required to support this handler, and this handler is + /// not included in the core SAX2 distribution. + /// + /// Note that data-related DTD declarations (unparsed entities and notations) + /// are already reported through the DTDHandler interface. + /// If you are using the declaration handler together with a lexical handler, + /// all of the events will occur between the startDTD and the endDTD events. + /// To set the DeclHandler for an XML reader, use the setProperty method + /// with the propertyId "http://xml.org/sax/properties/declaration-handler". + /// If the reader does not support declaration events, it will throw a + /// SAXNotRecognizedException or a SAXNotSupportedException when you attempt to + /// register the handler. +{ +public: + virtual void attributeDecl(const XMLString& eName, const XMLString& aName, const XMLString* valueDefault, const XMLString* value) = 0; + /// Report an attribute type declaration. + /// + /// Only the effective (first) declaration for an attribute will be reported. + /// The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", + /// "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", a parenthesized token group + /// with the separator "|" and all whitespace removed, or the word "NOTATION" + /// followed by a space followed by a parenthesized token group with all whitespace + /// removed. /// - /// Only the effective (first) declaration for an attribute will be reported. - /// The type will be one of the strings "CDATA", "ID", "IDREF", "IDREFS", - /// "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", a parenthesized token group - /// with the separator "|" and all whitespace removed, or the word "NOTATION" - /// followed by a space followed by a parenthesized token group with all whitespace - /// removed. - /// - /// The value will be the value as reported to applications, appropriately normalized - /// and with entity and character references expanded. - - virtual void elementDecl(const XMLString& name, const XMLString& model) = 0; - /// Report an element type declaration. - /// - /// The content model will consist of the string "EMPTY", the string "ANY", or a - /// parenthesised group, optionally followed by an occurrence indicator. The model - /// will be normalized so that all parameter entities are fully resolved and all - /// whitespace is removed,and will include the enclosing parentheses. Other - /// normalization (such as removing redundant parentheses or simplifying occurrence - /// indicators) is at the discretion of the parser. - - virtual void externalEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId) = 0; - /// Report an external entity declaration. + /// The value will be the value as reported to applications, appropriately normalized + /// and with entity and character references expanded. + + virtual void elementDecl(const XMLString& name, const XMLString& model) = 0; + /// Report an element type declaration. /// - /// Only the effective (first) declaration for each entity will be reported. + /// The content model will consist of the string "EMPTY", the string "ANY", or a + /// parenthesised group, optionally followed by an occurrence indicator. The model + /// will be normalized so that all parameter entities are fully resolved and all + /// whitespace is removed,and will include the enclosing parentheses. Other + /// normalization (such as removing redundant parentheses or simplifying occurrence + /// indicators) is at the discretion of the parser. + + virtual void externalEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId) = 0; + /// Report an external entity declaration. + /// + /// Only the effective (first) declaration for each entity will be reported. + /// + /// If the system identifier is a URL, the parser must resolve it fully before + /// passing it to the application. + + virtual void internalEntityDecl(const XMLString& name, const XMLString& value) = 0; + /// Report an internal entity declaration. /// - /// If the system identifier is a URL, the parser must resolve it fully before - /// passing it to the application. - - virtual void internalEntityDecl(const XMLString& name, const XMLString& value) = 0; - /// Report an internal entity declaration. - /// - /// Only the effective (first) declaration for each entity will be reported. All - /// parameter entities in the value will be expanded, but general entities will not. - -protected: - virtual ~DeclHandler(); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_DeclHandler_INCLUDED + /// Only the effective (first) declaration for each entity will be reported. All + /// parameter entities in the value will be expanded, but general entities will not. + +protected: + virtual ~DeclHandler(); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_DeclHandler_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/DefaultHandler.h b/contrib/libs/poco/XML/include/Poco/SAX/DefaultHandler.h index 7df1f5479e..8f006dca25 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/DefaultHandler.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/DefaultHandler.h @@ -1,83 +1,83 @@ -// -// DefaultHandler.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX-2 DefaultHandler class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_DefaultHandler_INCLUDED -#define SAX_DefaultHandler_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/EntityResolver.h" -#include "Poco/SAX/DTDHandler.h" -#include "Poco/SAX/ContentHandler.h" -#include "Poco/SAX/ErrorHandler.h" - - -namespace Poco { -namespace XML { - - -class XML_API DefaultHandler: public EntityResolver, public DTDHandler, public ContentHandler, public ErrorHandler - /// Default base class for SAX2 event handlers. - /// This class is available as a convenience base class for SAX2 applications: - /// it provides default implementations for all of the - /// callbacks in the four core SAX2 handler classes: - /// * EntityResolver - /// * DTDHandler - /// * ContentHandler - /// * ErrorHandler - /// Application writers can extend this class when they need to implement only - /// part of an interface; parser writers can instantiate this - /// class to provide default handlers when the application has not supplied its own. -{ -public: - DefaultHandler(); - /// Creates the DefaultHandler. - - ~DefaultHandler(); - /// Destroys the DefaultHandler. - - // EntityResolver - InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId); - void releaseInputSource(InputSource* pSource); - - // DTDHandler - void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId); - void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName); - - // ContentHandler - void setDocumentLocator(const Locator* loc); - void startDocument(); - void endDocument(); - void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attributes); - void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname); - void characters(const XMLChar ch[], int start, int length); - void ignorableWhitespace(const XMLChar ch[], int start, int length); - void processingInstruction(const XMLString& target, const XMLString& data); - void startPrefixMapping(const XMLString& prefix, const XMLString& uri); - void endPrefixMapping(const XMLString& prefix); - void skippedEntity(const XMLString& name); - - // ErrorHandler - void warning(const SAXException& exc); - void error(const SAXException& exc); - void fatalError(const SAXException& exc); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_DefaultHandler_INCLUDED +// +// DefaultHandler.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX-2 DefaultHandler class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_DefaultHandler_INCLUDED +#define SAX_DefaultHandler_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/EntityResolver.h" +#include "Poco/SAX/DTDHandler.h" +#include "Poco/SAX/ContentHandler.h" +#include "Poco/SAX/ErrorHandler.h" + + +namespace Poco { +namespace XML { + + +class XML_API DefaultHandler: public EntityResolver, public DTDHandler, public ContentHandler, public ErrorHandler + /// Default base class for SAX2 event handlers. + /// This class is available as a convenience base class for SAX2 applications: + /// it provides default implementations for all of the + /// callbacks in the four core SAX2 handler classes: + /// * EntityResolver + /// * DTDHandler + /// * ContentHandler + /// * ErrorHandler + /// Application writers can extend this class when they need to implement only + /// part of an interface; parser writers can instantiate this + /// class to provide default handlers when the application has not supplied its own. +{ +public: + DefaultHandler(); + /// Creates the DefaultHandler. + + ~DefaultHandler(); + /// Destroys the DefaultHandler. + + // EntityResolver + InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId); + void releaseInputSource(InputSource* pSource); + + // DTDHandler + void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId); + void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName); + + // ContentHandler + void setDocumentLocator(const Locator* loc); + void startDocument(); + void endDocument(); + void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attributes); + void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname); + void characters(const XMLChar ch[], int start, int length); + void ignorableWhitespace(const XMLChar ch[], int start, int length); + void processingInstruction(const XMLString& target, const XMLString& data); + void startPrefixMapping(const XMLString& prefix, const XMLString& uri); + void endPrefixMapping(const XMLString& prefix); + void skippedEntity(const XMLString& name); + + // ErrorHandler + void warning(const SAXException& exc); + void error(const SAXException& exc); + void fatalError(const SAXException& exc); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_DefaultHandler_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/EntityResolver.h b/contrib/libs/poco/XML/include/Poco/SAX/EntityResolver.h index 3387ecfca6..41e1ad6f6f 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/EntityResolver.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/EntityResolver.h @@ -1,86 +1,86 @@ -// -// EntityResolver.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX EntityResolver Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_EntityResolver_INCLUDED -#define SAX_EntityResolver_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class InputSource; - - -class XML_API EntityResolver - /// If a SAX application needs to implement customized handling for external entities, - /// it must implement this interface and register an instance with the SAX driver using - /// the setEntityResolver method. +// +// EntityResolver.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX EntityResolver Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_EntityResolver_INCLUDED +#define SAX_EntityResolver_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class InputSource; + + +class XML_API EntityResolver + /// If a SAX application needs to implement customized handling for external entities, + /// it must implement this interface and register an instance with the SAX driver using + /// the setEntityResolver method. + /// + /// The XML reader will then allow the application to intercept any external entities + /// (including the external DTD subset and external parameter entities, if any) before + /// including them. + /// + /// Many SAX applications will not need to implement this interface, but it will be + /// especially useful for applications that build XML documents from databases or other + /// specialised input sources, or for applications that use URI types other than URLs. /// - /// The XML reader will then allow the application to intercept any external entities - /// (including the external DTD subset and external parameter entities, if any) before - /// including them. - /// - /// Many SAX applications will not need to implement this interface, but it will be - /// especially useful for applications that build XML documents from databases or other - /// specialised input sources, or for applications that use URI types other than URLs. - /// - /// The application can also use this interface to redirect system identifiers to local - /// URIs or to look up replacements in a catalog (possibly by using the public identifier). -{ -public: - virtual InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId) = 0; - /// Allow the application to resolve external entities. - /// - /// The parser will call this method before opening any external entity except the - /// top-level document entity. Such entities include the external DTD subset and - /// external parameter entities referenced within the DTD (in either case, only - /// if the parser reads external parameter entities), and external general entities - /// referenced within the document element (if the parser reads external general entities). - /// The application may request that the parser locate the entity itself, that it use an - /// alternative URI, or that it use data provided by the application (as a character or - /// byte input stream). - /// - /// Application writers can use this method to redirect external system identifiers to - /// secure and/or local URIs, to look up public identifiers in a catalogue, or to read an - /// entity from a database or other input source (including, for example, a dialog box). - /// Neither XML nor SAX specifies a preferred policy for using public or system IDs to resolve - /// resources. However, SAX specifies how to interpret any InputSource returned by this method, - /// and that if none is returned, then the system ID will be dereferenced as a URL. - /// - /// If the system identifier is a URL, the SAX parser must resolve it fully before reporting it to - /// the application. - /// - /// Note that publicId maybe null, therefore we pass a pointer rather than a reference. - - virtual void releaseInputSource(InputSource* pSource) = 0; - /// This is a non-standard extension to SAX! - /// Called by the parser when the input source returned by ResolveEntity is - /// no longer needed. Should free any resources used by the input source. - -protected: - virtual ~EntityResolver(); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_EntityResolver_INCLUDED + /// The application can also use this interface to redirect system identifiers to local + /// URIs or to look up replacements in a catalog (possibly by using the public identifier). +{ +public: + virtual InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId) = 0; + /// Allow the application to resolve external entities. + /// + /// The parser will call this method before opening any external entity except the + /// top-level document entity. Such entities include the external DTD subset and + /// external parameter entities referenced within the DTD (in either case, only + /// if the parser reads external parameter entities), and external general entities + /// referenced within the document element (if the parser reads external general entities). + /// The application may request that the parser locate the entity itself, that it use an + /// alternative URI, or that it use data provided by the application (as a character or + /// byte input stream). + /// + /// Application writers can use this method to redirect external system identifiers to + /// secure and/or local URIs, to look up public identifiers in a catalogue, or to read an + /// entity from a database or other input source (including, for example, a dialog box). + /// Neither XML nor SAX specifies a preferred policy for using public or system IDs to resolve + /// resources. However, SAX specifies how to interpret any InputSource returned by this method, + /// and that if none is returned, then the system ID will be dereferenced as a URL. + /// + /// If the system identifier is a URL, the SAX parser must resolve it fully before reporting it to + /// the application. + /// + /// Note that publicId maybe null, therefore we pass a pointer rather than a reference. + + virtual void releaseInputSource(InputSource* pSource) = 0; + /// This is a non-standard extension to SAX! + /// Called by the parser when the input source returned by ResolveEntity is + /// no longer needed. Should free any resources used by the input source. + +protected: + virtual ~EntityResolver(); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_EntityResolver_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/EntityResolverImpl.h b/contrib/libs/poco/XML/include/Poco/SAX/EntityResolverImpl.h index de088c64b6..89deb2c60c 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/EntityResolverImpl.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/EntityResolverImpl.h @@ -1,78 +1,78 @@ -// -// EntityResolverImpl.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// An implementation of EntityResolver. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_EntityResolverImpl_INCLUDED -#define SAX_EntityResolverImpl_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" -#include "Poco/SAX/EntityResolver.h" -#include "Poco/URIStreamOpener.h" - - -namespace Poco { -namespace XML { - - -class XML_API EntityResolverImpl: public EntityResolver - /// A default implementation of the EntityResolver interface. - /// - /// The system ID is first interpreted as an URI and the - /// URIStreamOpener is used to create and open an istream - /// for an InputSource. - /// - /// If the system ID is not a valid URI, it is - /// interpreted as a filesystem path and a Poco::FileInputStream - /// is opened for it. -{ -public: - EntityResolverImpl(); - /// Creates an EntityResolverImpl that uses the default - /// URIStreamOpener. - - EntityResolverImpl(const Poco::URIStreamOpener& opener); - /// Creates an EntityResolverImpl that uses the given - /// URIStreamOpener. - - ~EntityResolverImpl(); - /// Destroys the EntityResolverImpl. - - InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId); - /// Tries to use the URIStreamOpener to create and open an istream - /// for the given systemId, which is interpreted as an URI. - /// - /// If the systemId is not a valid URI, it is interpreted as - /// a local filesystem path and a Poco::FileInputStream is opened for it. - - void releaseInputSource(InputSource* pSource); - /// Deletes the InputSource's stream. - -protected: - std::istream* resolveSystemId(const XMLString& systemId); - -private: - EntityResolverImpl(const EntityResolverImpl&); - EntityResolverImpl& operator = (const EntityResolverImpl&); - - const Poco::URIStreamOpener& _opener; -}; - - -} } // namespace Poco::XML - - -#endif // SAX_EntityResolverImpl_INCLUDED +// +// EntityResolverImpl.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// An implementation of EntityResolver. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_EntityResolverImpl_INCLUDED +#define SAX_EntityResolverImpl_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" +#include "Poco/SAX/EntityResolver.h" +#include "Poco/URIStreamOpener.h" + + +namespace Poco { +namespace XML { + + +class XML_API EntityResolverImpl: public EntityResolver + /// A default implementation of the EntityResolver interface. + /// + /// The system ID is first interpreted as an URI and the + /// URIStreamOpener is used to create and open an istream + /// for an InputSource. + /// + /// If the system ID is not a valid URI, it is + /// interpreted as a filesystem path and a Poco::FileInputStream + /// is opened for it. +{ +public: + EntityResolverImpl(); + /// Creates an EntityResolverImpl that uses the default + /// URIStreamOpener. + + EntityResolverImpl(const Poco::URIStreamOpener& opener); + /// Creates an EntityResolverImpl that uses the given + /// URIStreamOpener. + + ~EntityResolverImpl(); + /// Destroys the EntityResolverImpl. + + InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId); + /// Tries to use the URIStreamOpener to create and open an istream + /// for the given systemId, which is interpreted as an URI. + /// + /// If the systemId is not a valid URI, it is interpreted as + /// a local filesystem path and a Poco::FileInputStream is opened for it. + + void releaseInputSource(InputSource* pSource); + /// Deletes the InputSource's stream. + +protected: + std::istream* resolveSystemId(const XMLString& systemId); + +private: + EntityResolverImpl(const EntityResolverImpl&); + EntityResolverImpl& operator = (const EntityResolverImpl&); + + const Poco::URIStreamOpener& _opener; +}; + + +} } // namespace Poco::XML + + +#endif // SAX_EntityResolverImpl_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/ErrorHandler.h b/contrib/libs/poco/XML/include/Poco/SAX/ErrorHandler.h index 3097e20075..ee74712003 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/ErrorHandler.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/ErrorHandler.h @@ -1,92 +1,92 @@ -// -// ErrorHandler.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX ErrorHandler Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_ErrorHandler_INCLUDED -#define SAX_ErrorHandler_INCLUDED - - -#include "Poco/XML/XML.h" - - -namespace Poco { -namespace XML { - - -class SAXException; - - -class XML_API ErrorHandler - /// If a SAX application needs to implement customized error handling, it must - /// implement this interface and then register an instance with the XML reader - /// using the setErrorHandler method. The parser will then report all errors and - /// warnings through this interface. - /// - /// WARNING: If an application does not register an ErrorHandler, XML parsing errors - /// will go unreported, except that SAXParseExceptions will be thrown for fatal errors. - /// In order to detect validity errors, an ErrorHandler that does something with error() - /// calls must be registered. - /// - /// For XML processing errors, a SAX driver must use this interface in preference to - /// throwing an exception: it is up to the application to decide whether to throw an - /// exception for different types of errors and warnings. Note, however, that there is no - /// requirement that the parser continue to report additional errors after a call to - /// fatalError. In other words, a SAX driver class may throw an exception after reporting - /// any fatalError. Also parsers may throw appropriate exceptions for non-XML errors. For - /// example, XMLReader::parse() would throw an IOException for errors accessing entities or - /// the document. -{ -public: - virtual void warning(const SAXException& exc) = 0; - /// Receive notification of a warning. - /// - /// SAX parsers will use this method to report conditions that are not errors or fatal - /// errors as defined by the XML recommendation. The default behaviour is to take no action. - /// - /// The SAX parser must continue to provide normal parsing events after invoking this method: - /// it should still be possible for the application to process the document through to the end. - /// - /// Filters may use this method to report other, non-XML warnings as well. - - virtual void error(const SAXException& exc) = 0; - /// Receive notification of a recoverable error. - /// - /// This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 - /// Recommendation. For example, a validating parser would use this callback to report - /// the violation of a validity constraint. The default behaviour is to take no action. - /// - /// The SAX parser must continue to provide normal parsing events after invoking this - /// method: it should still be possible for the application to process the document through - /// to the end. If the application cannot do so, then the parser should report a fatal error - /// even if the XML recommendation does not require it to do so. - /// - /// Filters may use this method to report other, non-XML errors as well. - - virtual void fatalError(const SAXException& exc) = 0; - /// Receive notification of a non-recoverable error. - /// The application must assume that the document is unusable after the parser has - /// invoked this method, and should continue (if at all) only for the sake of collecting - /// additional error messages: in fact, SAX parsers are free to stop reporting any other - /// events once this method has been invoked. - -protected: - virtual ~ErrorHandler(); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_ErrorHandler_INCLUDED +// +// ErrorHandler.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX ErrorHandler Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_ErrorHandler_INCLUDED +#define SAX_ErrorHandler_INCLUDED + + +#include "Poco/XML/XML.h" + + +namespace Poco { +namespace XML { + + +class SAXException; + + +class XML_API ErrorHandler + /// If a SAX application needs to implement customized error handling, it must + /// implement this interface and then register an instance with the XML reader + /// using the setErrorHandler method. The parser will then report all errors and + /// warnings through this interface. + /// + /// WARNING: If an application does not register an ErrorHandler, XML parsing errors + /// will go unreported, except that SAXParseExceptions will be thrown for fatal errors. + /// In order to detect validity errors, an ErrorHandler that does something with error() + /// calls must be registered. + /// + /// For XML processing errors, a SAX driver must use this interface in preference to + /// throwing an exception: it is up to the application to decide whether to throw an + /// exception for different types of errors and warnings. Note, however, that there is no + /// requirement that the parser continue to report additional errors after a call to + /// fatalError. In other words, a SAX driver class may throw an exception after reporting + /// any fatalError. Also parsers may throw appropriate exceptions for non-XML errors. For + /// example, XMLReader::parse() would throw an IOException for errors accessing entities or + /// the document. +{ +public: + virtual void warning(const SAXException& exc) = 0; + /// Receive notification of a warning. + /// + /// SAX parsers will use this method to report conditions that are not errors or fatal + /// errors as defined by the XML recommendation. The default behaviour is to take no action. + /// + /// The SAX parser must continue to provide normal parsing events after invoking this method: + /// it should still be possible for the application to process the document through to the end. + /// + /// Filters may use this method to report other, non-XML warnings as well. + + virtual void error(const SAXException& exc) = 0; + /// Receive notification of a recoverable error. + /// + /// This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 + /// Recommendation. For example, a validating parser would use this callback to report + /// the violation of a validity constraint. The default behaviour is to take no action. + /// + /// The SAX parser must continue to provide normal parsing events after invoking this + /// method: it should still be possible for the application to process the document through + /// to the end. If the application cannot do so, then the parser should report a fatal error + /// even if the XML recommendation does not require it to do so. + /// + /// Filters may use this method to report other, non-XML errors as well. + + virtual void fatalError(const SAXException& exc) = 0; + /// Receive notification of a non-recoverable error. + /// The application must assume that the document is unusable after the parser has + /// invoked this method, and should continue (if at all) only for the sake of collecting + /// additional error messages: in fact, SAX parsers are free to stop reporting any other + /// events once this method has been invoked. + +protected: + virtual ~ErrorHandler(); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_ErrorHandler_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/InputSource.h b/contrib/libs/poco/XML/include/Poco/SAX/InputSource.h index 7fcecf2589..fb970c80e5 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/InputSource.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/InputSource.h @@ -1,169 +1,169 @@ -// -// InputSource.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX InputSource - A single input source for an XML entity. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_InputSource_INCLUDED -#define SAX_InputSource_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" -#include "Poco/XML/XMLStream.h" - - -namespace Poco { -namespace XML { - - -class XML_API InputSource - /// This class allows a SAX application to encapsulate information about an input - /// source in a single object, which may include a public identifier, a system - /// identifier, a byte stream (possibly with a specified encoding), and/or a character - /// stream. - /// - /// There are two places that the application can deliver an input source to the - /// parser: as the argument to the Parser.parse method, or as the return value of the - /// EntityResolver::resolveEntity() method. - /// - /// The SAX parser will use the InputSource object to determine how to read XML input. - /// If there is a character stream available, the parser will read that stream directly, - /// disregarding any text encoding declaration found in that stream. If there is no character - /// stream, but there is a byte stream, the parser will use that byte stream, using the - /// encoding specified in the InputSource or else (if no encoding is specified) autodetecting - /// the character encoding using an algorithm such as the one in the XML specification. - /// If neither a character stream nor a byte stream is available, the parser will attempt - /// to open a URI connection to the resource identified by the system identifier. - /// - /// An InputSource object belongs to the application: the SAX parser shall never modify it in - /// any way (it may modify a copy if necessary). However, standard processing of both byte and - /// character streams is to close them on as part of end-of-parse cleanup, so applications should - /// not attempt to re-use such streams after they have been handed to a parser. -{ -public: - InputSource(); - /// Zero-argument default constructor. - - InputSource(const XMLString& systemId); - /// Creates a new input source with a system identifier. - /// Applications may use setPublicId to include a public identifier as well, - /// or setEncoding to specify the character encoding, if known. +// +// InputSource.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX InputSource - A single input source for an XML entity. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_InputSource_INCLUDED +#define SAX_InputSource_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" +#include "Poco/XML/XMLStream.h" + + +namespace Poco { +namespace XML { + + +class XML_API InputSource + /// This class allows a SAX application to encapsulate information about an input + /// source in a single object, which may include a public identifier, a system + /// identifier, a byte stream (possibly with a specified encoding), and/or a character + /// stream. + /// + /// There are two places that the application can deliver an input source to the + /// parser: as the argument to the Parser.parse method, or as the return value of the + /// EntityResolver::resolveEntity() method. + /// + /// The SAX parser will use the InputSource object to determine how to read XML input. + /// If there is a character stream available, the parser will read that stream directly, + /// disregarding any text encoding declaration found in that stream. If there is no character + /// stream, but there is a byte stream, the parser will use that byte stream, using the + /// encoding specified in the InputSource or else (if no encoding is specified) autodetecting + /// the character encoding using an algorithm such as the one in the XML specification. + /// If neither a character stream nor a byte stream is available, the parser will attempt + /// to open a URI connection to the resource identified by the system identifier. + /// + /// An InputSource object belongs to the application: the SAX parser shall never modify it in + /// any way (it may modify a copy if necessary). However, standard processing of both byte and + /// character streams is to close them on as part of end-of-parse cleanup, so applications should + /// not attempt to re-use such streams after they have been handed to a parser. +{ +public: + InputSource(); + /// Zero-argument default constructor. + + InputSource(const XMLString& systemId); + /// Creates a new input source with a system identifier. + /// Applications may use setPublicId to include a public identifier as well, + /// or setEncoding to specify the character encoding, if known. + /// + /// If the system identifier is a URL, it must be fully resolved (it may not + /// be a relative URL). + + InputSource(XMLByteInputStream& istr); + /// Creates a new input source with a byte stream. + /// + /// Application writers should use setSystemId() to provide a base for resolving + /// relative URIs, may use setPublicId to include a public identifier, and may use + /// setEncoding to specify the object's character encoding. + + ~InputSource(); + /// Destroys the InputSource. + + void setPublicId(const XMLString& publicId); + /// Set the public identifier for this input source. /// - /// If the system identifier is a URL, it must be fully resolved (it may not - /// be a relative URL). - - InputSource(XMLByteInputStream& istr); - /// Creates a new input source with a byte stream. + /// The public identifier is always optional: if the application writer includes one, + /// it will be provided as part of the location information. + + void setSystemId(const XMLString& systemId); + /// Set the system identifier for this input source. /// - /// Application writers should use setSystemId() to provide a base for resolving - /// relative URIs, may use setPublicId to include a public identifier, and may use - /// setEncoding to specify the object's character encoding. - - ~InputSource(); - /// Destroys the InputSource. - - void setPublicId(const XMLString& publicId); - /// Set the public identifier for this input source. - /// - /// The public identifier is always optional: if the application writer includes one, - /// it will be provided as part of the location information. - - void setSystemId(const XMLString& systemId); - /// Set the system identifier for this input source. - /// - /// The system identifier is optional if there is a byte stream or a character stream, - /// but it is still useful to provide one, since the application can use it to resolve - /// relative URIs and can include it in error messages and warnings (the parser will - /// attempt to open a connection to the URI only if there is no byte stream or character - /// stream specified). - /// - /// If the application knows the character encoding of the object pointed to by the system - /// identifier, it can register the encoding using the setEncoding method. - /// - /// If the system identifier is a URL, it must be fully resolved (it may not be a relative URL). - - const XMLString& getPublicId() const; - /// Get the public identifier for this input source. - - const XMLString& getSystemId() const; - /// Get the system identifier for this input source. - - void setByteStream(XMLByteInputStream& istr); - /// Set the byte stream for this input source. - /// The SAX parser will ignore this if there is also a character stream specified, but it - /// will use a byte stream in preference to opening a URI connection itself. - - XMLByteInputStream* getByteStream() const; - /// Get the byte stream for this input source. - - void setCharacterStream(XMLCharInputStream& istr); - /// Set the character stream for this input source. - - XMLCharInputStream* getCharacterStream() const; - /// Get the character stream for this input source. - - void setEncoding(const XMLString& encoding); - /// Set the character encoding, if known. - /// The encoding must be a string acceptable for an XML encoding declaration - /// (see section 4.3.3 of the XML 1.0 recommendation). - - const XMLString& getEncoding() const; - /// Get the character encoding for a byte stream or URI. - -private: - XMLString _publicId; - XMLString _systemId; - XMLString _encoding; - XMLByteInputStream* _bistr; - XMLCharInputStream* _cistr; -}; - - -// -// inlines -// -inline const XMLString& InputSource::getPublicId() const -{ - return _publicId; -} - - -inline const XMLString& InputSource::getSystemId() const -{ - return _systemId; -} - - -inline const XMLString& InputSource::getEncoding() const -{ - return _encoding; -} - - -inline XMLByteInputStream* InputSource::getByteStream() const -{ - return _bistr; -} - - -inline XMLCharInputStream* InputSource::getCharacterStream() const -{ - return _cistr; -} - - -} } // namespace Poco::XML - - -#endif // SAX_InputSource_INCLUDED + /// The system identifier is optional if there is a byte stream or a character stream, + /// but it is still useful to provide one, since the application can use it to resolve + /// relative URIs and can include it in error messages and warnings (the parser will + /// attempt to open a connection to the URI only if there is no byte stream or character + /// stream specified). + /// + /// If the application knows the character encoding of the object pointed to by the system + /// identifier, it can register the encoding using the setEncoding method. + /// + /// If the system identifier is a URL, it must be fully resolved (it may not be a relative URL). + + const XMLString& getPublicId() const; + /// Get the public identifier for this input source. + + const XMLString& getSystemId() const; + /// Get the system identifier for this input source. + + void setByteStream(XMLByteInputStream& istr); + /// Set the byte stream for this input source. + /// The SAX parser will ignore this if there is also a character stream specified, but it + /// will use a byte stream in preference to opening a URI connection itself. + + XMLByteInputStream* getByteStream() const; + /// Get the byte stream for this input source. + + void setCharacterStream(XMLCharInputStream& istr); + /// Set the character stream for this input source. + + XMLCharInputStream* getCharacterStream() const; + /// Get the character stream for this input source. + + void setEncoding(const XMLString& encoding); + /// Set the character encoding, if known. + /// The encoding must be a string acceptable for an XML encoding declaration + /// (see section 4.3.3 of the XML 1.0 recommendation). + + const XMLString& getEncoding() const; + /// Get the character encoding for a byte stream or URI. + +private: + XMLString _publicId; + XMLString _systemId; + XMLString _encoding; + XMLByteInputStream* _bistr; + XMLCharInputStream* _cistr; +}; + + +// +// inlines +// +inline const XMLString& InputSource::getPublicId() const +{ + return _publicId; +} + + +inline const XMLString& InputSource::getSystemId() const +{ + return _systemId; +} + + +inline const XMLString& InputSource::getEncoding() const +{ + return _encoding; +} + + +inline XMLByteInputStream* InputSource::getByteStream() const +{ + return _bistr; +} + + +inline XMLCharInputStream* InputSource::getCharacterStream() const +{ + return _cistr; +} + + +} } // namespace Poco::XML + + +#endif // SAX_InputSource_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/LexicalHandler.h b/contrib/libs/poco/XML/include/Poco/SAX/LexicalHandler.h index 772bd5c3fb..3f232ee0dc 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/LexicalHandler.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/LexicalHandler.h @@ -1,125 +1,125 @@ -// -// LexicalHandler.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX2-ext LexicalHandler Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_LexicalHandler_INCLUDED -#define SAX_LexicalHandler_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API LexicalHandler - /// This is an optional extension handler for SAX2 to provide lexical information - /// about an XML document, such as comments and CDATA section boundaries. - /// XML readers are not required to recognize this handler, and it is not part of - /// core-only SAX2 distributions. - /// - /// The events in the lexical handler apply to the entire document, not just to the - /// document element, and all lexical handler events must appear between the content - /// handler's startDocument and endDocument events. - /// - /// To set the LexicalHandler for an XML reader, use the setProperty method with the - /// property name http://xml.org/sax/properties/lexical-handler and an object implementing - /// this interface (or null) as the value. If the reader does not report lexical events, - /// it will throw a SAXNotRecognizedException when you attempt to register the handler. -{ -public: - virtual void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId) = 0; - /// Report the start of DTD declarations, if any. +// +// LexicalHandler.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX2-ext LexicalHandler Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_LexicalHandler_INCLUDED +#define SAX_LexicalHandler_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API LexicalHandler + /// This is an optional extension handler for SAX2 to provide lexical information + /// about an XML document, such as comments and CDATA section boundaries. + /// XML readers are not required to recognize this handler, and it is not part of + /// core-only SAX2 distributions. + /// + /// The events in the lexical handler apply to the entire document, not just to the + /// document element, and all lexical handler events must appear between the content + /// handler's startDocument and endDocument events. + /// + /// To set the LexicalHandler for an XML reader, use the setProperty method with the + /// property name http://xml.org/sax/properties/lexical-handler and an object implementing + /// this interface (or null) as the value. If the reader does not report lexical events, + /// it will throw a SAXNotRecognizedException when you attempt to register the handler. +{ +public: + virtual void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId) = 0; + /// Report the start of DTD declarations, if any. + /// + /// This method is intended to report the beginning of the DOCTYPE declaration; + /// if the document has no DOCTYPE declaration, this method will not be invoked. + /// + /// All declarations reported through DTDHandler or DeclHandler events must appear + /// between the startDTD and endDTD events. Declarations are assumed to belong to + /// the internal DTD subset unless they appear between startEntity and endEntity + /// events. Comments and processing instructions from the DTD should also be reported + /// between the startDTD and endDTD events, in their original order of (logical) occurrence; + /// they are not required to appear in their correct locations relative to DTDHandler or + /// DeclHandler events, however. + /// + /// Note that the start/endDTD events will appear within the start/endDocument events from + /// ContentHandler and before the first startElement event. + + virtual void endDTD() = 0; + /// Report the end of DTD declarations. + /// + /// This method is intended to report the end of the DOCTYPE declaration; if the document + /// has no DOCTYPE declaration, this method will not be invoked. + + virtual void startEntity(const XMLString& name) = 0; + /// Report the beginning of some internal and external XML entities. + /// + /// The reporting of parameter entities (including the external DTD subset) is optional, + /// and SAX2 drivers that report LexicalHandler events may not implement it; you can use the + /// http://xml.org/sax/features/lexical-handler/parameter-entities feature to query or control + /// the reporting of parameter entities. + /// + /// General entities are reported with their regular names, parameter entities have '%' + /// prepended to their names, and the external DTD subset has the pseudo-entity name "[dtd]". + /// + /// When a SAX2 driver is providing these events, all other events must be properly nested + /// within start/end entity events. There is no additional requirement that events from + /// DeclHandler or DTDHandler be properly ordered. + /// + /// Note that skipped entities will be reported through the skippedEntity event, which is part of + /// the ContentHandler interface. + /// + /// Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under + /// any circumstances: + /// + /// * general entities within attribute values + /// * parameter entities within declarations /// - /// This method is intended to report the beginning of the DOCTYPE declaration; - /// if the document has no DOCTYPE declaration, this method will not be invoked. + /// These will be silently expanded, with no indication of where the original entity boundaries were. + /// + /// Note also that the boundaries of character references (which are not really entities anyway) are not reported. + /// + /// All start/endEntity events must be properly nested. + + virtual void endEntity(const XMLString& name) = 0; + /// Report the end of an entity. + + virtual void startCDATA() = 0; + /// Report the start of a CDATA section. /// - /// All declarations reported through DTDHandler or DeclHandler events must appear - /// between the startDTD and endDTD events. Declarations are assumed to belong to - /// the internal DTD subset unless they appear between startEntity and endEntity - /// events. Comments and processing instructions from the DTD should also be reported - /// between the startDTD and endDTD events, in their original order of (logical) occurrence; - /// they are not required to appear in their correct locations relative to DTDHandler or - /// DeclHandler events, however. - /// - /// Note that the start/endDTD events will appear within the start/endDocument events from - /// ContentHandler and before the first startElement event. - - virtual void endDTD() = 0; - /// Report the end of DTD declarations. - /// - /// This method is intended to report the end of the DOCTYPE declaration; if the document - /// has no DOCTYPE declaration, this method will not be invoked. - - virtual void startEntity(const XMLString& name) = 0; - /// Report the beginning of some internal and external XML entities. - /// - /// The reporting of parameter entities (including the external DTD subset) is optional, - /// and SAX2 drivers that report LexicalHandler events may not implement it; you can use the - /// http://xml.org/sax/features/lexical-handler/parameter-entities feature to query or control - /// the reporting of parameter entities. - /// - /// General entities are reported with their regular names, parameter entities have '%' - /// prepended to their names, and the external DTD subset has the pseudo-entity name "[dtd]". - /// - /// When a SAX2 driver is providing these events, all other events must be properly nested - /// within start/end entity events. There is no additional requirement that events from - /// DeclHandler or DTDHandler be properly ordered. - /// - /// Note that skipped entities will be reported through the skippedEntity event, which is part of - /// the ContentHandler interface. - /// - /// Because of the streaming event model that SAX uses, some entity boundaries cannot be reported under - /// any circumstances: - /// - /// * general entities within attribute values - /// * parameter entities within declarations - /// - /// These will be silently expanded, with no indication of where the original entity boundaries were. - /// - /// Note also that the boundaries of character references (which are not really entities anyway) are not reported. - /// - /// All start/endEntity events must be properly nested. - - virtual void endEntity(const XMLString& name) = 0; - /// Report the end of an entity. - - virtual void startCDATA() = 0; - /// Report the start of a CDATA section. - /// - /// The contents of the CDATA section will be reported through the regular characters event; - /// this event is intended only to report the boundary. - - virtual void endCDATA() = 0; - /// Report the end of a CDATA section. - - virtual void comment(const XMLChar ch[], int start, int length) = 0; - /// Report an XML comment anywhere in the document. - /// - /// This callback will be used for comments inside or outside the document element, - /// including comments in the external DTD subset (if read). Comments in the DTD must - /// be properly nested inside start/endDTD and start/endEntity events (if used). - -protected: - virtual ~LexicalHandler(); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_LexicalHandler_INCLUDED + /// The contents of the CDATA section will be reported through the regular characters event; + /// this event is intended only to report the boundary. + + virtual void endCDATA() = 0; + /// Report the end of a CDATA section. + + virtual void comment(const XMLChar ch[], int start, int length) = 0; + /// Report an XML comment anywhere in the document. + /// + /// This callback will be used for comments inside or outside the document element, + /// including comments in the external DTD subset (if read). Comments in the DTD must + /// be properly nested inside start/endDTD and start/endEntity events (if used). + +protected: + virtual ~LexicalHandler(); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_LexicalHandler_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/Locator.h b/contrib/libs/poco/XML/include/Poco/SAX/Locator.h index 4f2b47d481..5f9ec395bf 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/Locator.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/Locator.h @@ -1,103 +1,103 @@ -// -// Locator.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX Locator Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_Locator_INCLUDED -#define SAX_Locator_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API Locator - /// Interface for associating a SAX event with a document location. - /// - /// If a SAX parser provides location information to the SAX application, it does so by - /// implementing this interface and then passing an instance to the application using the - /// content handler's setDocumentLocator method. The application can use the object to obtain - /// the location of any other SAX event in the XML source document. - /// - /// Note that the results returned by the object will be valid only during the scope of each - /// callback method: the application will receive unpredictable results if it attempts to use - /// the locator at any other time, or after parsing completes. - /// - /// SAX parsers are not required to supply a locator, but they are very strongly encouraged to - /// do so. If the parser supplies a locator, it must do so before reporting any other document - /// events. If no locator has been set by the time the application receives the startDocument event, - /// the application should assume that a locator is not available. -{ -public: - virtual XMLString getPublicId() const = 0; - /// Return the public identifier for the current document event. - /// - /// The return value is the public identifier of the document entity or of the external - /// parsed entity in which the markup triggering the event appears. - - virtual XMLString getSystemId() const = 0; - /// Return the system identifier for the current document event. - /// - /// The return value is the system identifier of the document entity or of the external - /// parsed entity in which the markup triggering the event appears. - /// - /// If the system identifier is a URL, the parser must resolve it fully before passing - /// it to the application. For example, a file name must always be provided as a - /// file:... URL, and other kinds of relative URI are also resolved against their bases. - - virtual int getLineNumber() const = 0; - /// Return the line number where the current document event ends. - /// Lines are delimited by line ends, which are defined in the XML specification. - /// - /// Warning: The return value from the method is intended only as an approximation for - /// the sake of diagnostics; it is not intended to provide sufficient information to - /// edit the character content of the original XML document. In some cases, these "line" - /// numbers match what would be displayed as columns, and in others they may not match the - /// source text due to internal entity expansion. - /// - /// The return value is an approximation of the line number in the document entity or external - /// parsed entity where the markup triggering the event appears. - /// - /// If possible, the SAX driver should provide the line position of the first character after - /// the text associated with the document event. The first line is line 1. - - virtual int getColumnNumber() const = 0; - /// Return the column number where the current document event ends. - /// This is one-based number of characters since the last line end. - /// - /// Warning: The return value from the method is intended only as an approximation - /// for the sake of diagnostics; it is not intended to provide sufficient information - /// to edit the character content of the original XML document. For example, when lines - /// contain combining character sequences, wide characters, surrogate pairs, or bi-directional - /// text, the value may not correspond to the column in a text editor's display. - /// - /// The return value is an approximation of the column number in the document entity or external - /// parsed entity where the markup triggering the event appears. - /// - /// If possible, the SAX driver should provide the line position of the first character after - /// the text associated with the document event. The first column in each line is column 1. - -protected: - virtual ~Locator(); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_Locator_INCLUDED +// +// Locator.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX Locator Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_Locator_INCLUDED +#define SAX_Locator_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API Locator + /// Interface for associating a SAX event with a document location. + /// + /// If a SAX parser provides location information to the SAX application, it does so by + /// implementing this interface and then passing an instance to the application using the + /// content handler's setDocumentLocator method. The application can use the object to obtain + /// the location of any other SAX event in the XML source document. + /// + /// Note that the results returned by the object will be valid only during the scope of each + /// callback method: the application will receive unpredictable results if it attempts to use + /// the locator at any other time, or after parsing completes. + /// + /// SAX parsers are not required to supply a locator, but they are very strongly encouraged to + /// do so. If the parser supplies a locator, it must do so before reporting any other document + /// events. If no locator has been set by the time the application receives the startDocument event, + /// the application should assume that a locator is not available. +{ +public: + virtual XMLString getPublicId() const = 0; + /// Return the public identifier for the current document event. + /// + /// The return value is the public identifier of the document entity or of the external + /// parsed entity in which the markup triggering the event appears. + + virtual XMLString getSystemId() const = 0; + /// Return the system identifier for the current document event. + /// + /// The return value is the system identifier of the document entity or of the external + /// parsed entity in which the markup triggering the event appears. + /// + /// If the system identifier is a URL, the parser must resolve it fully before passing + /// it to the application. For example, a file name must always be provided as a + /// file:... URL, and other kinds of relative URI are also resolved against their bases. + + virtual int getLineNumber() const = 0; + /// Return the line number where the current document event ends. + /// Lines are delimited by line ends, which are defined in the XML specification. + /// + /// Warning: The return value from the method is intended only as an approximation for + /// the sake of diagnostics; it is not intended to provide sufficient information to + /// edit the character content of the original XML document. In some cases, these "line" + /// numbers match what would be displayed as columns, and in others they may not match the + /// source text due to internal entity expansion. + /// + /// The return value is an approximation of the line number in the document entity or external + /// parsed entity where the markup triggering the event appears. + /// + /// If possible, the SAX driver should provide the line position of the first character after + /// the text associated with the document event. The first line is line 1. + + virtual int getColumnNumber() const = 0; + /// Return the column number where the current document event ends. + /// This is one-based number of characters since the last line end. + /// + /// Warning: The return value from the method is intended only as an approximation + /// for the sake of diagnostics; it is not intended to provide sufficient information + /// to edit the character content of the original XML document. For example, when lines + /// contain combining character sequences, wide characters, surrogate pairs, or bi-directional + /// text, the value may not correspond to the column in a text editor's display. + /// + /// The return value is an approximation of the column number in the document entity or external + /// parsed entity where the markup triggering the event appears. + /// + /// If possible, the SAX driver should provide the line position of the first character after + /// the text associated with the document event. The first column in each line is column 1. + +protected: + virtual ~Locator(); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_Locator_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/LocatorImpl.h b/contrib/libs/poco/XML/include/Poco/SAX/LocatorImpl.h index 2c924b3f88..0f0a584238 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/LocatorImpl.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/LocatorImpl.h @@ -1,88 +1,88 @@ -// -// LocatorImpl.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// An implementation of the SAX Locator interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_LocatorImpl_INCLUDED -#define SAX_LocatorImpl_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/Locator.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API LocatorImpl: public Locator - /// Provide an optional convenience implementation of Locator. -{ -public: - LocatorImpl(); - /// Zero-argument constructor. - /// - /// This will not normally be useful, since the main purpose of this class is - /// to make a snapshot of an existing Locator. - - LocatorImpl(const Locator& loc); - /// Copy constructor. - /// - /// Create a persistent copy of the current state of a locator. When the original - /// locator changes, this copy will still keep the original values (and it can be - /// used outside the scope of DocumentHandler methods). - - ~LocatorImpl(); - /// Destroys the Locator. - - LocatorImpl& operator = (const Locator& loc); - /// Assignment operator. - - XMLString getPublicId() const; - /// Return the saved public identifier. - - XMLString getSystemId() const; - /// Return the saved system identifier. - - int getLineNumber() const; - /// Return the saved line number (1-based). - - int getColumnNumber() const; - /// Return the saved column number (1-based). - - void setPublicId(const XMLString& publicId); - /// Set the public identifier for this locator. - - void setSystemId(const XMLString& systemId); - /// Set the system identifier for this locator. - - void setLineNumber(int lineNumber); - /// Set the line number for this locator (1-based). - - void setColumnNumber(int columnNumber); - /// Set the column number for this locator (1-based). - -private: - XMLString _publicId; - XMLString _systemId; - int _lineNumber; - int _columnNumber; -}; - - -} } // namespace Poco::XML - - -#endif // SAX_LocatorImpl_INCLUDED +// +// LocatorImpl.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// An implementation of the SAX Locator interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_LocatorImpl_INCLUDED +#define SAX_LocatorImpl_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/Locator.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API LocatorImpl: public Locator + /// Provide an optional convenience implementation of Locator. +{ +public: + LocatorImpl(); + /// Zero-argument constructor. + /// + /// This will not normally be useful, since the main purpose of this class is + /// to make a snapshot of an existing Locator. + + LocatorImpl(const Locator& loc); + /// Copy constructor. + /// + /// Create a persistent copy of the current state of a locator. When the original + /// locator changes, this copy will still keep the original values (and it can be + /// used outside the scope of DocumentHandler methods). + + ~LocatorImpl(); + /// Destroys the Locator. + + LocatorImpl& operator = (const Locator& loc); + /// Assignment operator. + + XMLString getPublicId() const; + /// Return the saved public identifier. + + XMLString getSystemId() const; + /// Return the saved system identifier. + + int getLineNumber() const; + /// Return the saved line number (1-based). + + int getColumnNumber() const; + /// Return the saved column number (1-based). + + void setPublicId(const XMLString& publicId); + /// Set the public identifier for this locator. + + void setSystemId(const XMLString& systemId); + /// Set the system identifier for this locator. + + void setLineNumber(int lineNumber); + /// Set the line number for this locator (1-based). + + void setColumnNumber(int columnNumber); + /// Set the column number for this locator (1-based). + +private: + XMLString _publicId; + XMLString _systemId; + int _lineNumber; + int _columnNumber; +}; + + +} } // namespace Poco::XML + + +#endif // SAX_LocatorImpl_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/NamespaceSupport.h b/contrib/libs/poco/XML/include/Poco/SAX/NamespaceSupport.h index 7441649949..48e567b7f2 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/NamespaceSupport.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/NamespaceSupport.h @@ -1,195 +1,195 @@ -// -// NamespaceSupport.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// Namespace support for SAX2. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_NamespaceSupport_INCLUDED -#define SAX_NamespaceSupport_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" -#include <set> -#include <map> -#include <vector> - - -namespace Poco { -namespace XML { - - -class XML_API NamespaceSupport - /// Encapsulate Namespace logic for use by SAX drivers. - /// This class encapsulates the logic of Namespace processing: - /// it tracks the declarations currently in force for each context and - /// automatically processes qualified XML 1.0 names into their Namespace - /// parts; it can also be used in reverse for generating - /// XML 1.0 from Namespaces. - /// Namespace support objects are reusable, but the reset method - /// must be invoked between each session. -{ -public: - typedef std::set<XMLString> PrefixSet; - - NamespaceSupport(); - /// Creates a NamespaceSupport object. - - ~NamespaceSupport(); - /// Destroys a NamespaceSupport object. - - bool declarePrefix(const XMLString& prefix, const XMLString& namespaceURI); - /// Declare a Namespace prefix. All prefixes must be declared before they are - /// referenced. For example, a SAX driver (parser) would scan an element's attributes - /// in two passes: first for namespace declarations, then a second pass using - /// processName() to interpret prefixes against (potentially redefined) prefixes. +// +// NamespaceSupport.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// Namespace support for SAX2. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_NamespaceSupport_INCLUDED +#define SAX_NamespaceSupport_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" +#include <set> +#include <map> +#include <vector> + + +namespace Poco { +namespace XML { + + +class XML_API NamespaceSupport + /// Encapsulate Namespace logic for use by SAX drivers. + /// This class encapsulates the logic of Namespace processing: + /// it tracks the declarations currently in force for each context and + /// automatically processes qualified XML 1.0 names into their Namespace + /// parts; it can also be used in reverse for generating + /// XML 1.0 from Namespaces. + /// Namespace support objects are reusable, but the reset method + /// must be invoked between each session. +{ +public: + typedef std::set<XMLString> PrefixSet; + + NamespaceSupport(); + /// Creates a NamespaceSupport object. + + ~NamespaceSupport(); + /// Destroys a NamespaceSupport object. + + bool declarePrefix(const XMLString& prefix, const XMLString& namespaceURI); + /// Declare a Namespace prefix. All prefixes must be declared before they are + /// referenced. For example, a SAX driver (parser) would scan an element's attributes + /// in two passes: first for namespace declarations, then a second pass using + /// processName() to interpret prefixes against (potentially redefined) prefixes. + /// + /// This method declares a prefix in the current Namespace context; the prefix + /// will remain in force until this context is popped, unless it is shadowed + /// in a descendant context. + /// + /// To declare the default element Namespace, use the empty string as the prefix. + /// + /// Note that you must not declare a prefix after you've pushed and popped another + /// Namespace context, or treated the declarations phase as complete by processing + /// a prefixed name. /// - /// This method declares a prefix in the current Namespace context; the prefix - /// will remain in force until this context is popped, unless it is shadowed - /// in a descendant context. + /// Returns true if the prefix was legal, false otherwise. + + bool undeclarePrefix(const XMLString& prefix); + /// Remove the given namespace prefix. + + void getDeclaredPrefixes(PrefixSet& prefixes) const; + /// Return an enumeration of all prefixes declared in this context. + /// + /// The empty (default) prefix will be included in this enumeration; note that + /// this behaviour differs from that of getPrefix() and getPrefixes(). + + const XMLString& getPrefix(const XMLString& namespaceURI) const; + /// Return one of the prefixes mapped to a Namespace URI. + /// + /// If more than one prefix is currently mapped to the same URI, this method + /// will make an arbitrary selection; if you want all of the prefixes, use the + /// getPrefixes() method instead. + + bool isMapped(const XMLString& namespaceURI) const; + /// Returns true if the given namespaceURI has been mapped to a prefix, + /// false otherwise. + + void getPrefixes(PrefixSet& prefixes) const; + /// Return an enumeration of all prefixes whose declarations are active in the + /// current context. This includes declarations from parent contexts that have + /// not been overridden. + /// + /// Note: if there is a default prefix, it will not be returned in this enumeration; + /// check for the default prefix using the getURI with an argument of "". + + void getPrefixes(const XMLString& namespaceURI, PrefixSet& prefixes) const; + /// Return an enumeration of all prefixes for a given URI whose declarations + /// are active in the current context. This includes declarations from parent + /// contexts that have not been overridden. + /// + /// This method returns prefixes mapped to a specific Namespace URI. The xml: + /// prefix will be included. If you want only one prefix that's mapped to the + /// Namespace URI, and you don't care which one you get, use the getPrefix() method + /// instead. + /// + /// Note: the empty (default) prefix is never included in this enumeration; + /// to check for the presence of a default Namespace, use the getURI() method + /// with an argument of "". + + const XMLString& getURI(const XMLString& prefix) const; + /// Look up a prefix and get the currently-mapped Namespace URI. + /// + /// This method looks up the prefix in the current context. Use the empty string + /// ("") for the default Namespace. + + void pushContext(); + /// Start a new Namespace context. The new context will automatically inherit + /// the declarations of its parent context, but it will also keep track of which + /// declarations were made within this context. + /// + /// Event callback code should start a new context once per element. This means + /// being ready to call this in either of two places. For elements that don't + /// include namespace declarations, the ContentHandler::startElement() callback + /// is the right place. For elements with such a declaration, it'd done in the + /// first ContentHandler::startPrefixMapping() callback. A boolean flag can be + /// used to track whether a context has been started yet. When either of those + /// methods is called, it checks the flag to see if a new context needs to be + /// started. If so, it starts the context and sets the flag. After + /// ContentHandler::startElement() does that, it always clears the flag. + /// + /// Normally, SAX drivers would push a new context at the beginning of each + /// XML element. Then they perform a first pass over the attributes to process + /// all namespace declarations, making ContentHandler::startPrefixMapping() callbacks. + /// Then a second pass is made, to determine the namespace-qualified names for + /// all attributes and for the element name. Finally all the information for + /// the ContentHandler::startElement() callback is available, so it can then + /// be made. + /// + /// The Namespace support object always starts with a base context already in + /// force: in this context, only the "xml" prefix is declared. + + void popContext(); + /// Revert to the previous Namespace context. + /// + /// Normally, you should pop the context at the end of each XML element. After + /// popping the context, all Namespace prefix mappings that were previously + /// in force are restored. + /// + /// You must not attempt to declare additional Namespace prefixes after popping + /// a context, unless you push another context first. + + bool processName(const XMLString& qname, XMLString& namespaceURI, XMLString& localName, bool isAttribute) const; + /// Process a raw XML 1.0 name. + /// This method processes a raw XML 1.0 name in the current context + /// by removing the prefix and looking it up among the + /// prefixes currently declared. The result will be returned in + /// namespaceURI and localName. + /// If the raw name has a prefix that has not been declared, then the return + /// value will be false, otherwise true. /// - /// To declare the default element Namespace, use the empty string as the prefix. - /// - /// Note that you must not declare a prefix after you've pushed and popped another - /// Namespace context, or treated the declarations phase as complete by processing - /// a prefixed name. - /// - /// Returns true if the prefix was legal, false otherwise. - - bool undeclarePrefix(const XMLString& prefix); - /// Remove the given namespace prefix. - - void getDeclaredPrefixes(PrefixSet& prefixes) const; - /// Return an enumeration of all prefixes declared in this context. - /// - /// The empty (default) prefix will be included in this enumeration; note that - /// this behaviour differs from that of getPrefix() and getPrefixes(). - - const XMLString& getPrefix(const XMLString& namespaceURI) const; - /// Return one of the prefixes mapped to a Namespace URI. - /// - /// If more than one prefix is currently mapped to the same URI, this method - /// will make an arbitrary selection; if you want all of the prefixes, use the - /// getPrefixes() method instead. - - bool isMapped(const XMLString& namespaceURI) const; - /// Returns true if the given namespaceURI has been mapped to a prefix, - /// false otherwise. - - void getPrefixes(PrefixSet& prefixes) const; - /// Return an enumeration of all prefixes whose declarations are active in the - /// current context. This includes declarations from parent contexts that have - /// not been overridden. - /// - /// Note: if there is a default prefix, it will not be returned in this enumeration; - /// check for the default prefix using the getURI with an argument of "". - - void getPrefixes(const XMLString& namespaceURI, PrefixSet& prefixes) const; - /// Return an enumeration of all prefixes for a given URI whose declarations - /// are active in the current context. This includes declarations from parent - /// contexts that have not been overridden. - /// - /// This method returns prefixes mapped to a specific Namespace URI. The xml: - /// prefix will be included. If you want only one prefix that's mapped to the - /// Namespace URI, and you don't care which one you get, use the getPrefix() method - /// instead. - /// - /// Note: the empty (default) prefix is never included in this enumeration; - /// to check for the presence of a default Namespace, use the getURI() method - /// with an argument of "". - - const XMLString& getURI(const XMLString& prefix) const; - /// Look up a prefix and get the currently-mapped Namespace URI. - /// - /// This method looks up the prefix in the current context. Use the empty string - /// ("") for the default Namespace. - - void pushContext(); - /// Start a new Namespace context. The new context will automatically inherit - /// the declarations of its parent context, but it will also keep track of which - /// declarations were made within this context. - /// - /// Event callback code should start a new context once per element. This means - /// being ready to call this in either of two places. For elements that don't - /// include namespace declarations, the ContentHandler::startElement() callback - /// is the right place. For elements with such a declaration, it'd done in the - /// first ContentHandler::startPrefixMapping() callback. A boolean flag can be - /// used to track whether a context has been started yet. When either of those - /// methods is called, it checks the flag to see if a new context needs to be - /// started. If so, it starts the context and sets the flag. After - /// ContentHandler::startElement() does that, it always clears the flag. - /// - /// Normally, SAX drivers would push a new context at the beginning of each - /// XML element. Then they perform a first pass over the attributes to process - /// all namespace declarations, making ContentHandler::startPrefixMapping() callbacks. - /// Then a second pass is made, to determine the namespace-qualified names for - /// all attributes and for the element name. Finally all the information for - /// the ContentHandler::startElement() callback is available, so it can then - /// be made. - /// - /// The Namespace support object always starts with a base context already in - /// force: in this context, only the "xml" prefix is declared. - - void popContext(); - /// Revert to the previous Namespace context. - /// - /// Normally, you should pop the context at the end of each XML element. After - /// popping the context, all Namespace prefix mappings that were previously - /// in force are restored. - /// - /// You must not attempt to declare additional Namespace prefixes after popping - /// a context, unless you push another context first. - - bool processName(const XMLString& qname, XMLString& namespaceURI, XMLString& localName, bool isAttribute) const; - /// Process a raw XML 1.0 name. - /// This method processes a raw XML 1.0 name in the current context - /// by removing the prefix and looking it up among the - /// prefixes currently declared. The result will be returned in - /// namespaceURI and localName. - /// If the raw name has a prefix that has not been declared, then the return - /// value will be false, otherwise true. - /// - /// Note that attribute names are processed differently than element names: - /// an unprefixed element name will receive the - /// default Namespace (if any), while an unprefixed attribute name will not. - - void reset(); - /// Reset this Namespace support object for reuse. - /// - /// It is necessary to invoke this method before reusing the Namespace support - /// object for a new session. If namespace declaration URIs are to be supported, - /// that flag must also be set to a non-default value. - /// Reset this Namespace support object for reuse. - - static const XMLString XML_NAMESPACE; - static const XMLString XML_NAMESPACE_PREFIX; - static const XMLString XMLNS_NAMESPACE; - static const XMLString XMLNS_NAMESPACE_PREFIX; - -private: - NamespaceSupport(const NamespaceSupport&); - NamespaceSupport& operator = (const NamespaceSupport&); - - typedef std::map<XMLString, XMLString> Context; - typedef std::vector<Context> ContextVec; - - ContextVec _contexts; - - static const XMLString EMPTY_STRING; -}; - - -} } // namespace Poco::XML - - -#endif // SAX_NamespaceSupport_INCLUDED + /// Note that attribute names are processed differently than element names: + /// an unprefixed element name will receive the + /// default Namespace (if any), while an unprefixed attribute name will not. + + void reset(); + /// Reset this Namespace support object for reuse. + /// + /// It is necessary to invoke this method before reusing the Namespace support + /// object for a new session. If namespace declaration URIs are to be supported, + /// that flag must also be set to a non-default value. + /// Reset this Namespace support object for reuse. + + static const XMLString XML_NAMESPACE; + static const XMLString XML_NAMESPACE_PREFIX; + static const XMLString XMLNS_NAMESPACE; + static const XMLString XMLNS_NAMESPACE_PREFIX; + +private: + NamespaceSupport(const NamespaceSupport&); + NamespaceSupport& operator = (const NamespaceSupport&); + + typedef std::map<XMLString, XMLString> Context; + typedef std::vector<Context> ContextVec; + + ContextVec _contexts; + + static const XMLString EMPTY_STRING; +}; + + +} } // namespace Poco::XML + + +#endif // SAX_NamespaceSupport_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/SAXException.h b/contrib/libs/poco/XML/include/Poco/SAX/SAXException.h index e1f9cae8e4..64b5b20739 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/SAXException.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/SAXException.h @@ -1,176 +1,176 @@ -// -// SAXException.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX exception classes. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_SAXException_INCLUDED -#define SAX_SAXException_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLException.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -POCO_DECLARE_EXCEPTION(XML_API, SAXException, XMLException) - /// The base class for all SAX-related exceptions like SAXParseException, - /// SAXNotRecognizedException or SAXNotSupportedException. +// +// SAXException.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX exception classes. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_SAXException_INCLUDED +#define SAX_SAXException_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLException.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +POCO_DECLARE_EXCEPTION(XML_API, SAXException, XMLException) + /// The base class for all SAX-related exceptions like SAXParseException, + /// SAXNotRecognizedException or SAXNotSupportedException. + /// + /// This class can contain basic error or warning information from either the XML parser + /// or the application: a parser writer or application writer can subclass it to provide + /// additional functionality. SAX handlers may throw this exception or any exception subclassed + /// from it. + /// + /// If the application needs to pass through other types of exceptions, it must wrap those exceptions + /// in a SAXException or an exception derived from a SAXException. + /// + /// If the parser or application needs to include information about a specific location in an XML + /// document, it should use the SAXParseException subclass. + + +POCO_DECLARE_EXCEPTION(XML_API, SAXNotRecognizedException, SAXException) + /// Exception class for an unrecognized identifier. + /// + /// An XMLReader will throw this exception when it finds an unrecognized feature or property + /// identifier; SAX applications and extensions may use this class for other, similar purposes. + + +POCO_DECLARE_EXCEPTION(XML_API, SAXNotSupportedException, SAXException) + /// Exception class for an unsupported operation. + /// + /// An XMLReader will throw this exception when it recognizes a feature or property identifier, + /// but cannot perform the requested operation (setting a state or value). Other SAX2 applications + /// and extensions may use this class for similar purposes. + + +class Locator; + + +class XML_API SAXParseException: public SAXException + /// Encapsulate an XML parse error or warning. /// - /// This class can contain basic error or warning information from either the XML parser - /// or the application: a parser writer or application writer can subclass it to provide - /// additional functionality. SAX handlers may throw this exception or any exception subclassed - /// from it. - /// - /// If the application needs to pass through other types of exceptions, it must wrap those exceptions - /// in a SAXException or an exception derived from a SAXException. - /// - /// If the parser or application needs to include information about a specific location in an XML - /// document, it should use the SAXParseException subclass. - - -POCO_DECLARE_EXCEPTION(XML_API, SAXNotRecognizedException, SAXException) - /// Exception class for an unrecognized identifier. - /// - /// An XMLReader will throw this exception when it finds an unrecognized feature or property - /// identifier; SAX applications and extensions may use this class for other, similar purposes. - - -POCO_DECLARE_EXCEPTION(XML_API, SAXNotSupportedException, SAXException) - /// Exception class for an unsupported operation. - /// - /// An XMLReader will throw this exception when it recognizes a feature or property identifier, - /// but cannot perform the requested operation (setting a state or value). Other SAX2 applications - /// and extensions may use this class for similar purposes. - - -class Locator; - - -class XML_API SAXParseException: public SAXException - /// Encapsulate an XML parse error or warning. - /// - /// This exception may include information for locating the error in the original XML document, - /// as if it came from a Locator object. Note that although the application will receive a - /// SAXParseException as the argument to the handlers in the ErrorHandler interface, the application - /// is not actually required to throw the exception; instead, it can simply read the information in it - /// and take a different action. - /// - /// Since this exception is a subclass of SAXException, it inherits the ability to wrap another exception. -{ -public: - SAXParseException(const std::string& msg, const Locator& loc); - /// Create a new SAXParseException from a message and a Locator. - - SAXParseException(const std::string& msg, const Locator& loc, const Poco::Exception& exc); - /// Wrap an existing exception in a SAXParseException. - - SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber); - /// Create a new SAXParseException with an embedded exception. - /// - /// This constructor is most useful for parser writers. - /// All parameters except the message are as if they were provided by a Locator. - /// For example, if the system identifier is a URL (including relative filename), - /// the caller must resolve it fully before creating the exception. - - SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber, const Poco::Exception& exc); - /// Create a new SAXParseException. - /// - /// This constructor is most useful for parser writers. - /// All parameters except the message are as if they were provided by a Locator. - /// For example, if the system identifier is a URL (including relative filename), - /// the caller must resolve it fully before creating the exception. - - SAXParseException(const SAXParseException& exc); - /// Creates a new SAXParseException from another one. - - ~SAXParseException() noexcept; - /// Destroy the exception. - - SAXParseException& operator = (const SAXParseException& exc); - /// Assignment operator. - + /// This exception may include information for locating the error in the original XML document, + /// as if it came from a Locator object. Note that although the application will receive a + /// SAXParseException as the argument to the handlers in the ErrorHandler interface, the application + /// is not actually required to throw the exception; instead, it can simply read the information in it + /// and take a different action. + /// + /// Since this exception is a subclass of SAXException, it inherits the ability to wrap another exception. +{ +public: + SAXParseException(const std::string& msg, const Locator& loc); + /// Create a new SAXParseException from a message and a Locator. + + SAXParseException(const std::string& msg, const Locator& loc, const Poco::Exception& exc); + /// Wrap an existing exception in a SAXParseException. + + SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber); + /// Create a new SAXParseException with an embedded exception. + /// + /// This constructor is most useful for parser writers. + /// All parameters except the message are as if they were provided by a Locator. + /// For example, if the system identifier is a URL (including relative filename), + /// the caller must resolve it fully before creating the exception. + + SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber, const Poco::Exception& exc); + /// Create a new SAXParseException. + /// + /// This constructor is most useful for parser writers. + /// All parameters except the message are as if they were provided by a Locator. + /// For example, if the system identifier is a URL (including relative filename), + /// the caller must resolve it fully before creating the exception. + + SAXParseException(const SAXParseException& exc); + /// Creates a new SAXParseException from another one. + + ~SAXParseException() noexcept; + /// Destroy the exception. + + SAXParseException& operator = (const SAXParseException& exc); + /// Assignment operator. + const char* name() const noexcept; - /// Returns a static string describing the exception. - + /// Returns a static string describing the exception. + const char* className() const noexcept; - /// Returns the name of the exception class. - - Poco::Exception* clone() const; - /// Creates an exact copy of the exception. - - void rethrow() const; - /// (Re)Throws the exception. - - const XMLString& getPublicId() const; - /// Get the public identifier of the entity where the exception occurred. - - const XMLString& getSystemId() const; - /// Get the system identifier of the entity where the exception occurred. - - int getLineNumber() const; - /// The line number of the end of the text where the exception occurred. - /// The first line is line 1. - - int getColumnNumber() const; - /// The column number of the end of the text where the exception occurred. - /// The first column in a line is position 1. - -protected: - static std::string buildMessage(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber); - -private: - SAXParseException(); - - XMLString _publicId; - XMLString _systemId; - int _lineNumber; - int _columnNumber; -}; - - -// -// inlines -// -inline const XMLString& SAXParseException::getPublicId() const -{ - return _publicId; -} - - -inline const XMLString& SAXParseException::getSystemId() const -{ - return _systemId; -} - - -inline int SAXParseException::getLineNumber() const -{ - return _lineNumber; -} - - -inline int SAXParseException::getColumnNumber() const -{ - return _columnNumber; -} - - -} } // namespace Poco::XML - - -#endif // SAX_SAXException_INCLUDED + /// Returns the name of the exception class. + + Poco::Exception* clone() const; + /// Creates an exact copy of the exception. + + void rethrow() const; + /// (Re)Throws the exception. + + const XMLString& getPublicId() const; + /// Get the public identifier of the entity where the exception occurred. + + const XMLString& getSystemId() const; + /// Get the system identifier of the entity where the exception occurred. + + int getLineNumber() const; + /// The line number of the end of the text where the exception occurred. + /// The first line is line 1. + + int getColumnNumber() const; + /// The column number of the end of the text where the exception occurred. + /// The first column in a line is position 1. + +protected: + static std::string buildMessage(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber); + +private: + SAXParseException(); + + XMLString _publicId; + XMLString _systemId; + int _lineNumber; + int _columnNumber; +}; + + +// +// inlines +// +inline const XMLString& SAXParseException::getPublicId() const +{ + return _publicId; +} + + +inline const XMLString& SAXParseException::getSystemId() const +{ + return _systemId; +} + + +inline int SAXParseException::getLineNumber() const +{ + return _lineNumber; +} + + +inline int SAXParseException::getColumnNumber() const +{ + return _columnNumber; +} + + +} } // namespace Poco::XML + + +#endif // SAX_SAXException_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/SAXParser.h b/contrib/libs/poco/XML/include/Poco/SAX/SAXParser.h index 587e61c597..8cdfd6fa65 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/SAXParser.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/SAXParser.h @@ -1,103 +1,103 @@ -// -// SAXParser.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// Implementation of the XMLReader interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_SAXParser_INCLUDED -#define SAX_SAXParser_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/XMLReader.h" -#include "Poco/XML/ParserEngine.h" - - -namespace Poco { -namespace XML { - - -class XML_API SAXParser: public XMLReader - /// This class provides a SAX2 (Simple API for XML) interface to expat, - /// the XML parser toolkit. - /// The following SAX2 features and properties are supported: - /// * http://xml.org/sax/features/external-general-entities - /// * http://xml.org/sax/features/external-parameter-entities - /// * http://xml.org/sax/features/namespaces - /// * http://xml.org/sax/features/namespace-prefixes - /// * http://xml.org/sax/properties/lexical-handler - /// * http://xml.org/sax/properties/declaration-handler - /// - /// The following proprietary extensions are supported: - /// * http://www.appinf.com/features/enable-partial-reads -- - /// see ParserEngine::setEnablePartialReads() -{ -public: - SAXParser(); - /// Creates an SAXParser. - - SAXParser(const XMLString& encoding); - /// Creates an SAXParser with the given encoding. - - ~SAXParser(); - /// Destroys the SAXParser. - - void setEncoding(const XMLString& encoding); - /// Sets the encoding used by the parser if no - /// encoding is specified in the XML document. - - const XMLString& getEncoding() const; - /// Returns the name of the encoding used by - /// the parser if no encoding is specified in - /// the XML document. - - void addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding); - /// Adds an encoding to the parser. Does not take ownership of the pointer! - - /// XMLReader - void setEntityResolver(EntityResolver* pResolver); - EntityResolver* getEntityResolver() const; - void setDTDHandler(DTDHandler* pDTDHandler); - DTDHandler* getDTDHandler() const; - void setContentHandler(ContentHandler* pContentHandler); - ContentHandler* getContentHandler() const; - void setErrorHandler(ErrorHandler* pErrorHandler); - ErrorHandler* getErrorHandler() const; - void setFeature(const XMLString& featureId, bool state); - bool getFeature(const XMLString& featureId) const; - void setProperty(const XMLString& propertyId, const XMLString& value); - void setProperty(const XMLString& propertyId, void* value); - void* getProperty(const XMLString& propertyId) const; - void parse(InputSource* pSource); - void parse(const XMLString& systemId); - void parseMemoryNP(const char* xml, std::size_t size); - - /// Extensions - void parseString(const std::string& xml); - - static const XMLString FEATURE_PARTIAL_READS; - -protected: - void setupParse(); - -private: - ParserEngine _engine; - bool _namespaces; - bool _namespacePrefixes; -}; - - -} } // namespace Poco::XML - - -#endif // SAX_SAXParser_INCLUDED +// +// SAXParser.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// Implementation of the XMLReader interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_SAXParser_INCLUDED +#define SAX_SAXParser_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/XMLReader.h" +#include "Poco/XML/ParserEngine.h" + + +namespace Poco { +namespace XML { + + +class XML_API SAXParser: public XMLReader + /// This class provides a SAX2 (Simple API for XML) interface to expat, + /// the XML parser toolkit. + /// The following SAX2 features and properties are supported: + /// * http://xml.org/sax/features/external-general-entities + /// * http://xml.org/sax/features/external-parameter-entities + /// * http://xml.org/sax/features/namespaces + /// * http://xml.org/sax/features/namespace-prefixes + /// * http://xml.org/sax/properties/lexical-handler + /// * http://xml.org/sax/properties/declaration-handler + /// + /// The following proprietary extensions are supported: + /// * http://www.appinf.com/features/enable-partial-reads -- + /// see ParserEngine::setEnablePartialReads() +{ +public: + SAXParser(); + /// Creates an SAXParser. + + SAXParser(const XMLString& encoding); + /// Creates an SAXParser with the given encoding. + + ~SAXParser(); + /// Destroys the SAXParser. + + void setEncoding(const XMLString& encoding); + /// Sets the encoding used by the parser if no + /// encoding is specified in the XML document. + + const XMLString& getEncoding() const; + /// Returns the name of the encoding used by + /// the parser if no encoding is specified in + /// the XML document. + + void addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding); + /// Adds an encoding to the parser. Does not take ownership of the pointer! + + /// XMLReader + void setEntityResolver(EntityResolver* pResolver); + EntityResolver* getEntityResolver() const; + void setDTDHandler(DTDHandler* pDTDHandler); + DTDHandler* getDTDHandler() const; + void setContentHandler(ContentHandler* pContentHandler); + ContentHandler* getContentHandler() const; + void setErrorHandler(ErrorHandler* pErrorHandler); + ErrorHandler* getErrorHandler() const; + void setFeature(const XMLString& featureId, bool state); + bool getFeature(const XMLString& featureId) const; + void setProperty(const XMLString& propertyId, const XMLString& value); + void setProperty(const XMLString& propertyId, void* value); + void* getProperty(const XMLString& propertyId) const; + void parse(InputSource* pSource); + void parse(const XMLString& systemId); + void parseMemoryNP(const char* xml, std::size_t size); + + /// Extensions + void parseString(const std::string& xml); + + static const XMLString FEATURE_PARTIAL_READS; + +protected: + void setupParse(); + +private: + ParserEngine _engine; + bool _namespaces; + bool _namespacePrefixes; +}; + + +} } // namespace Poco::XML + + +#endif // SAX_SAXParser_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/WhitespaceFilter.h b/contrib/libs/poco/XML/include/Poco/SAX/WhitespaceFilter.h index f4f08bc0f3..001b74397d 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/WhitespaceFilter.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/WhitespaceFilter.h @@ -1,81 +1,81 @@ -// -// WhitespaceFilter.h -// -// Library: XML -// Package: SAX -// Module: WhitespaceFilter -// -// Definition of the WhitespaceFilter class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_WhitespaceFilter_INCLUDED -#define SAX_WhitespaceFilter_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/XMLFilterImpl.h" -#include "Poco/SAX/LexicalHandler.h" - - -namespace Poco { -namespace XML { - - -class XML_API WhitespaceFilter: public XMLFilterImpl, public LexicalHandler - /// This implementation of the SAX2 XMLFilter interface - /// filters all whitespace-only character data element - /// content. -{ -public: - WhitespaceFilter(); - /// Creates the WhitespaceFilter, with no parent. - - WhitespaceFilter(XMLReader* pReader); - /// Creates the WhitespaceFilter with the specified parent. - - ~WhitespaceFilter(); - /// Destroys the WhitespaceFilter. - - // XMLReader - void setProperty(const XMLString& propertyId, const XMLString& value); - void setProperty(const XMLString& propertyId, void* value); - void* getProperty(const XMLString& propertyId) const; - - // ContentHandler - void startDocument(); - void endDocument(); - void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList); - void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname); - void characters(const XMLChar ch[], int start, int length); - void ignorableWhitespace(const XMLChar ch[], int start, int length); - void processingInstruction(const XMLString& target, const XMLString& data); - - // LexicalHandler - void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId); - void endDTD(); - void startEntity(const XMLString& name); - void endEntity(const XMLString& name); - void startCDATA(); - void endCDATA(); - void comment(const XMLChar ch[], int start, int length); - -protected: - void setupParse(); - -private: - LexicalHandler* _pLexicalHandler; - XMLString _data; - bool _filter; -}; - - -} } // namespace Poco::XML - - -#endif // SAX_WhitespaceFilter_INCLUDED +// +// WhitespaceFilter.h +// +// Library: XML +// Package: SAX +// Module: WhitespaceFilter +// +// Definition of the WhitespaceFilter class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_WhitespaceFilter_INCLUDED +#define SAX_WhitespaceFilter_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/XMLFilterImpl.h" +#include "Poco/SAX/LexicalHandler.h" + + +namespace Poco { +namespace XML { + + +class XML_API WhitespaceFilter: public XMLFilterImpl, public LexicalHandler + /// This implementation of the SAX2 XMLFilter interface + /// filters all whitespace-only character data element + /// content. +{ +public: + WhitespaceFilter(); + /// Creates the WhitespaceFilter, with no parent. + + WhitespaceFilter(XMLReader* pReader); + /// Creates the WhitespaceFilter with the specified parent. + + ~WhitespaceFilter(); + /// Destroys the WhitespaceFilter. + + // XMLReader + void setProperty(const XMLString& propertyId, const XMLString& value); + void setProperty(const XMLString& propertyId, void* value); + void* getProperty(const XMLString& propertyId) const; + + // ContentHandler + void startDocument(); + void endDocument(); + void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList); + void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname); + void characters(const XMLChar ch[], int start, int length); + void ignorableWhitespace(const XMLChar ch[], int start, int length); + void processingInstruction(const XMLString& target, const XMLString& data); + + // LexicalHandler + void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId); + void endDTD(); + void startEntity(const XMLString& name); + void endEntity(const XMLString& name); + void startCDATA(); + void endCDATA(); + void comment(const XMLChar ch[], int start, int length); + +protected: + void setupParse(); + +private: + LexicalHandler* _pLexicalHandler; + XMLString _data; + bool _filter; +}; + + +} } // namespace Poco::XML + + +#endif // SAX_WhitespaceFilter_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/XMLFilter.h b/contrib/libs/poco/XML/include/Poco/SAX/XMLFilter.h index 0bc2e965e9..65ae70f913 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/XMLFilter.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/XMLFilter.h @@ -1,61 +1,61 @@ -// -// XMLFilter.h -// -// Library: XML -// Package: SAX -// Module: SAXFilters -// -// SAX2 XMLFilter Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_XMLFilter_INCLUDED -#define SAX_XMLFilter_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/XMLReader.h" - - -namespace Poco { -namespace XML { - - -class XML_API XMLFilter: public XMLReader - /// Interface for an XML filter. - /// - /// An XML filter is like an XML reader, except that it obtains its events from another XML reader - /// rather than a primary source like an XML document or database. Filters can modify a stream of - /// events as they pass on to the final application. +// +// XMLFilter.h +// +// Library: XML +// Package: SAX +// Module: SAXFilters +// +// SAX2 XMLFilter Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_XMLFilter_INCLUDED +#define SAX_XMLFilter_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/XMLReader.h" + + +namespace Poco { +namespace XML { + + +class XML_API XMLFilter: public XMLReader + /// Interface for an XML filter. /// - /// The XMLFilterImpl helper class provides a convenient base for creating SAX2 filters, by passing on - /// all EntityResolver, DTDHandler, ContentHandler and ErrorHandler events automatically. -{ -public: - virtual XMLReader* getParent() const = 0; - /// Set the parent reader. - /// - /// This method allows the application to link the filter to a parent reader (which may be another - /// filter). The argument may not be null. - - virtual void setParent(XMLReader* pParent) = 0; - /// Get the parent reader. - /// - /// This method allows the application to query the parent reader (which may be another filter). - /// It is generally a bad idea to perform any operations on the parent reader directly: they should - /// all pass through this filter. - -protected: - virtual ~XMLFilter(); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_XMLFilter_INCLUDED + /// An XML filter is like an XML reader, except that it obtains its events from another XML reader + /// rather than a primary source like an XML document or database. Filters can modify a stream of + /// events as they pass on to the final application. + /// + /// The XMLFilterImpl helper class provides a convenient base for creating SAX2 filters, by passing on + /// all EntityResolver, DTDHandler, ContentHandler and ErrorHandler events automatically. +{ +public: + virtual XMLReader* getParent() const = 0; + /// Set the parent reader. + /// + /// This method allows the application to link the filter to a parent reader (which may be another + /// filter). The argument may not be null. + + virtual void setParent(XMLReader* pParent) = 0; + /// Get the parent reader. + /// + /// This method allows the application to query the parent reader (which may be another filter). + /// It is generally a bad idea to perform any operations on the parent reader directly: they should + /// all pass through this filter. + +protected: + virtual ~XMLFilter(); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_XMLFilter_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/XMLFilterImpl.h b/contrib/libs/poco/XML/include/Poco/SAX/XMLFilterImpl.h index 33c049c7b2..d8449df8ce 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/XMLFilterImpl.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/XMLFilterImpl.h @@ -1,132 +1,132 @@ -// -// XMLFilterImpl.h -// -// Library: XML -// Package: SAX -// Module: SAXFilters -// -// SAX2 XMLFilterImpl class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_XMLFilterImpl_INCLUDED -#define SAX_XMLFilterImpl_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/XMLFilter.h" -#include "Poco/SAX/EntityResolver.h" -#include "Poco/SAX/DTDHandler.h" -#include "Poco/SAX/ContentHandler.h" -#include "Poco/SAX/ErrorHandler.h" - - -namespace Poco { -namespace XML { - - -class XML_API XMLFilterImpl: public XMLFilter, public EntityResolver, public DTDHandler, public ContentHandler, public ErrorHandler - /// Base class for deriving an XML filter. - /// - /// This class is designed to sit between an XMLReader and the client application's event - /// handlers. By default, it does nothing but pass requests up to the reader and events on to - /// the handlers unmodified, but subclasses can override specific methods to modify the event - /// stream or the configuration requests as they pass through. -{ -public: - XMLFilterImpl(); - /// Construct an empty XML filter, with no parent. - /// - /// This filter will have no parent: you must assign a parent before you start a parse or do any - /// configuration with setFeature or setProperty, unless you use this as a pure event consumer rather - /// than as an XMLReader. - - XMLFilterImpl(XMLReader* pParent); - /// Construct an XML filter with the specified parent. - - ~XMLFilterImpl(); - /// Destroys the XMLFilterImpl. - - // XMLFilter - XMLReader* getParent() const; - void setParent(XMLReader* pParent); - - // XMLReader - void setEntityResolver(EntityResolver* pResolver); - EntityResolver* getEntityResolver() const; - void setDTDHandler(DTDHandler* pDTDHandler); - DTDHandler* getDTDHandler() const; - void setContentHandler(ContentHandler* pContentHandler); - ContentHandler* getContentHandler() const; - void setErrorHandler(ErrorHandler* pErrorHandler); - ErrorHandler* getErrorHandler() const; - void setFeature(const XMLString& featureId, bool state); - bool getFeature(const XMLString& featureId) const; - void setProperty(const XMLString& propertyId, const XMLString& value); - void setProperty(const XMLString& propertyId, void* value); - void* getProperty(const XMLString& propertyId) const; - void parse(InputSource* pSource); - void parse(const XMLString& systemId); - void parseMemoryNP(const char* xml, std::size_t size); - - // EntityResolver - InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId); - void releaseInputSource(InputSource* pSource); - - // DTDHandler - void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId); - void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName); - - // ContentHandler - void setDocumentLocator(const Locator* loc); - void startDocument(); - void endDocument(); - void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList); - void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname); - void characters(const XMLChar ch[], int start, int length); - void ignorableWhitespace(const XMLChar ch[], int start, int length); - void processingInstruction(const XMLString& target, const XMLString& data); - void startPrefixMapping(const XMLString& prefix, const XMLString& uri); - void endPrefixMapping(const XMLString& prefix); - void skippedEntity(const XMLString& prefix); - void warning(const SAXException& e); - void error(const SAXException& e); - void fatalError(const SAXException& e); - -protected: - XMLReader* parent() const; - /// Return a pointer to the parent reader. - /// Subclasses can use this method instead of - /// getParent() for better performance - this method - /// is non-virtual and implemented as inline. - - virtual void setupParse(); - /// Setup the event handlers in the parent reader. - -private: - XMLReader* _pParent; - EntityResolver* _pEntityResolver; - DTDHandler* _pDTDHandler; - ContentHandler* _pContentHandler; - ErrorHandler* _pErrorHandler; -}; - - -// -// inlines -// -inline XMLReader* XMLFilterImpl::parent() const -{ - return _pParent; -} - - -} } // namespace Poco::XML - - -#endif // SAX_XMLFilterImpl_INCLUDED +// +// XMLFilterImpl.h +// +// Library: XML +// Package: SAX +// Module: SAXFilters +// +// SAX2 XMLFilterImpl class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_XMLFilterImpl_INCLUDED +#define SAX_XMLFilterImpl_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/XMLFilter.h" +#include "Poco/SAX/EntityResolver.h" +#include "Poco/SAX/DTDHandler.h" +#include "Poco/SAX/ContentHandler.h" +#include "Poco/SAX/ErrorHandler.h" + + +namespace Poco { +namespace XML { + + +class XML_API XMLFilterImpl: public XMLFilter, public EntityResolver, public DTDHandler, public ContentHandler, public ErrorHandler + /// Base class for deriving an XML filter. + /// + /// This class is designed to sit between an XMLReader and the client application's event + /// handlers. By default, it does nothing but pass requests up to the reader and events on to + /// the handlers unmodified, but subclasses can override specific methods to modify the event + /// stream or the configuration requests as they pass through. +{ +public: + XMLFilterImpl(); + /// Construct an empty XML filter, with no parent. + /// + /// This filter will have no parent: you must assign a parent before you start a parse or do any + /// configuration with setFeature or setProperty, unless you use this as a pure event consumer rather + /// than as an XMLReader. + + XMLFilterImpl(XMLReader* pParent); + /// Construct an XML filter with the specified parent. + + ~XMLFilterImpl(); + /// Destroys the XMLFilterImpl. + + // XMLFilter + XMLReader* getParent() const; + void setParent(XMLReader* pParent); + + // XMLReader + void setEntityResolver(EntityResolver* pResolver); + EntityResolver* getEntityResolver() const; + void setDTDHandler(DTDHandler* pDTDHandler); + DTDHandler* getDTDHandler() const; + void setContentHandler(ContentHandler* pContentHandler); + ContentHandler* getContentHandler() const; + void setErrorHandler(ErrorHandler* pErrorHandler); + ErrorHandler* getErrorHandler() const; + void setFeature(const XMLString& featureId, bool state); + bool getFeature(const XMLString& featureId) const; + void setProperty(const XMLString& propertyId, const XMLString& value); + void setProperty(const XMLString& propertyId, void* value); + void* getProperty(const XMLString& propertyId) const; + void parse(InputSource* pSource); + void parse(const XMLString& systemId); + void parseMemoryNP(const char* xml, std::size_t size); + + // EntityResolver + InputSource* resolveEntity(const XMLString* publicId, const XMLString& systemId); + void releaseInputSource(InputSource* pSource); + + // DTDHandler + void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId); + void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName); + + // ContentHandler + void setDocumentLocator(const Locator* loc); + void startDocument(); + void endDocument(); + void startElement(const XMLString& uri, const XMLString& localName, const XMLString& qname, const Attributes& attrList); + void endElement(const XMLString& uri, const XMLString& localName, const XMLString& qname); + void characters(const XMLChar ch[], int start, int length); + void ignorableWhitespace(const XMLChar ch[], int start, int length); + void processingInstruction(const XMLString& target, const XMLString& data); + void startPrefixMapping(const XMLString& prefix, const XMLString& uri); + void endPrefixMapping(const XMLString& prefix); + void skippedEntity(const XMLString& prefix); + void warning(const SAXException& e); + void error(const SAXException& e); + void fatalError(const SAXException& e); + +protected: + XMLReader* parent() const; + /// Return a pointer to the parent reader. + /// Subclasses can use this method instead of + /// getParent() for better performance - this method + /// is non-virtual and implemented as inline. + + virtual void setupParse(); + /// Setup the event handlers in the parent reader. + +private: + XMLReader* _pParent; + EntityResolver* _pEntityResolver; + DTDHandler* _pDTDHandler; + ContentHandler* _pContentHandler; + ErrorHandler* _pErrorHandler; +}; + + +// +// inlines +// +inline XMLReader* XMLFilterImpl::parent() const +{ + return _pParent; +} + + +} } // namespace Poco::XML + + +#endif // SAX_XMLFilterImpl_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/SAX/XMLReader.h b/contrib/libs/poco/XML/include/Poco/SAX/XMLReader.h index 0b1d360323..ad077c61e4 100644 --- a/contrib/libs/poco/XML/include/Poco/SAX/XMLReader.h +++ b/contrib/libs/poco/XML/include/Poco/SAX/XMLReader.h @@ -1,205 +1,205 @@ -// -// XMLReader.h -// -// Library: XML -// Package: SAX -// Module: SAX -// -// SAX2 XMLReader Interface. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef SAX_XMLReader_INCLUDED -#define SAX_XMLReader_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class EntityResolver; -class DTDHandler; -class ContentHandler; -class ErrorHandler; -class InputSource; -class LexicalHandler; -class NamespaceHandler; - - -class XML_API XMLReader - /// Interface for reading an XML document using callbacks. - /// XMLReader is the interface that an XML parser's SAX2 driver must - /// implement. This interface allows an application to set and - /// query features and properties in the parser, to register event handlers - /// for document processing, and to initiate a document parse. - /// All SAX interfaces are assumed to be synchronous: the parse methods must not - /// return until parsing is complete, and readers - /// must wait for an event-handler callback to return before reporting the next event. -{ -public: - virtual void setEntityResolver(EntityResolver* pResolver) = 0; - /// Allow an application to register an entity resolver. - /// - /// If the application does not register an entity resolver, the - /// XMLReader will perform its own default resolution. +// +// XMLReader.h +// +// Library: XML +// Package: SAX +// Module: SAX +// +// SAX2 XMLReader Interface. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef SAX_XMLReader_INCLUDED +#define SAX_XMLReader_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class EntityResolver; +class DTDHandler; +class ContentHandler; +class ErrorHandler; +class InputSource; +class LexicalHandler; +class NamespaceHandler; + + +class XML_API XMLReader + /// Interface for reading an XML document using callbacks. + /// XMLReader is the interface that an XML parser's SAX2 driver must + /// implement. This interface allows an application to set and + /// query features and properties in the parser, to register event handlers + /// for document processing, and to initiate a document parse. + /// All SAX interfaces are assumed to be synchronous: the parse methods must not + /// return until parsing is complete, and readers + /// must wait for an event-handler callback to return before reporting the next event. +{ +public: + virtual void setEntityResolver(EntityResolver* pResolver) = 0; + /// Allow an application to register an entity resolver. /// - /// Applications may register a new or different resolver in the middle of a - /// parse, and the SAX parser must begin using the new resolver immediately. - - virtual EntityResolver* getEntityResolver() const = 0; - /// Return the current entity resolver. - - virtual void setDTDHandler(DTDHandler* pDTDHandler) = 0; - /// Allow an application to register a DTD event handler. - /// - /// If the application does not register a DTD handler, all DTD events reported by - /// the SAX parser will be silently ignored. + /// If the application does not register an entity resolver, the + /// XMLReader will perform its own default resolution. + /// + /// Applications may register a new or different resolver in the middle of a + /// parse, and the SAX parser must begin using the new resolver immediately. + + virtual EntityResolver* getEntityResolver() const = 0; + /// Return the current entity resolver. + + virtual void setDTDHandler(DTDHandler* pDTDHandler) = 0; + /// Allow an application to register a DTD event handler. /// - /// Applications may register a new or different handler in the middle of a parse, - /// and the SAX parser must begin using the new handler immediately. - - virtual DTDHandler* getDTDHandler() const = 0; - /// Return the current DTD handler. - - virtual void setContentHandler(ContentHandler* pContentHandler) = 0; - /// Allow an application to register a content event handler. + /// If the application does not register a DTD handler, all DTD events reported by + /// the SAX parser will be silently ignored. + /// + /// Applications may register a new or different handler in the middle of a parse, + /// and the SAX parser must begin using the new handler immediately. + + virtual DTDHandler* getDTDHandler() const = 0; + /// Return the current DTD handler. + + virtual void setContentHandler(ContentHandler* pContentHandler) = 0; + /// Allow an application to register a content event handler. + /// + /// If the application does not register a content handler, all content events + /// reported by the SAX parser will be silently ignored. + /// + /// Applications may register a new or different handler in the middle of a parse, + /// and the SAX parser must begin using the new handler immediately. + + virtual ContentHandler* getContentHandler() const = 0; + /// Return the current content handler. + + virtual void setErrorHandler(ErrorHandler* pErrorHandler) = 0; + /// Allow an application to register an error event handler. /// - /// If the application does not register a content handler, all content events - /// reported by the SAX parser will be silently ignored. + /// If the application does not register an error handler, all error events reported by + /// the SAX parser will be silently ignored; however, normal processing may not continue. + /// It is highly recommended that all SAX applications implement an error handler to avoid + /// unexpected bugs. + /// + /// Applications may register a new or different handler in the middle of a parse, and the + /// SAX parser must begin using the new handler immediately. + + virtual ErrorHandler* getErrorHandler() const = 0; + /// Return the current error handler. + + virtual void setFeature(const XMLString& featureId, bool state) = 0; + /// Set the state of a feature. /// - /// Applications may register a new or different handler in the middle of a parse, - /// and the SAX parser must begin using the new handler immediately. - - virtual ContentHandler* getContentHandler() const = 0; - /// Return the current content handler. - - virtual void setErrorHandler(ErrorHandler* pErrorHandler) = 0; - /// Allow an application to register an error event handler. - /// - /// If the application does not register an error handler, all error events reported by - /// the SAX parser will be silently ignored; however, normal processing may not continue. - /// It is highly recommended that all SAX applications implement an error handler to avoid - /// unexpected bugs. + /// The feature name is any fully-qualified URI. It is possible for an XMLReader to + /// expose a feature value but to be unable to change the current value. Some feature + /// values may be immutable or mutable only in specific contexts, such as before, during, + /// or after a parse. + /// + /// All XMLReaders are required to support setting http://xml.org/sax/features/namespaces + /// to true and http://xml.org/sax/features/namespace-prefixes to false. + + virtual bool getFeature(const XMLString& featureId) const = 0; + /// Look up the value of a feature. /// - /// Applications may register a new or different handler in the middle of a parse, and the - /// SAX parser must begin using the new handler immediately. - - virtual ErrorHandler* getErrorHandler() const = 0; - /// Return the current error handler. - - virtual void setFeature(const XMLString& featureId, bool state) = 0; - /// Set the state of a feature. - /// - /// The feature name is any fully-qualified URI. It is possible for an XMLReader to - /// expose a feature value but to be unable to change the current value. Some feature - /// values may be immutable or mutable only in specific contexts, such as before, during, - /// or after a parse. + /// The feature name is any fully-qualified URI. It is possible for an XMLReader + /// to recognize a feature name but temporarily be unable to return its value. + /// Some feature values may be available only in specific contexts, such as before, + /// during, or after a parse. Also, some feature values may not be programmatically + /// accessible. (In the case of an adapter for SAX1 Parser, there is no + /// implementation-independent way to expose whether the underlying parser is performing + /// validation, expanding external entities, and so forth.) + /// + /// All XMLReaders are required to recognize the + /// http://xml.org/sax/features/namespaces and the + /// http://xml.org/sax/features/namespace-prefixes feature names. + /// Implementors are free (and encouraged) to invent their own features, + /// using names built on their own URIs. + + virtual void setProperty(const XMLString& propertyId, const XMLString& value) = 0; + /// Set the value of a property. + /// + /// The property name is any fully-qualified URI. It is possible for an XMLReader + /// to recognize a property name but to be unable to change the current value. + /// Some property values may be immutable or mutable only in specific contexts, + /// such as before, during, or after a parse. + /// + /// XMLReaders are not required to recognize setting any specific property names, though a + /// core set is defined by SAX2. + /// + /// This method is also the standard mechanism for setting extended handlers. + + virtual void setProperty(const XMLString& propertyId, void* value) = 0; + /// Set the value of a property. + /// See also setProperty(const XMLString&, const XMLString&). + + virtual void* getProperty(const XMLString& propertyId) const = 0; + /// Look up the value of a property. + /// String values are returned as XMLChar* + /// The property name is any fully-qualified URI. It is possible for an XMLReader to + /// recognize a property name but temporarily be unable to return its value. Some property + /// values may be available only in specific contexts, such as before, during, or after a parse. /// - /// All XMLReaders are required to support setting http://xml.org/sax/features/namespaces - /// to true and http://xml.org/sax/features/namespace-prefixes to false. - - virtual bool getFeature(const XMLString& featureId) const = 0; - /// Look up the value of a feature. - /// - /// The feature name is any fully-qualified URI. It is possible for an XMLReader - /// to recognize a feature name but temporarily be unable to return its value. - /// Some feature values may be available only in specific contexts, such as before, - /// during, or after a parse. Also, some feature values may not be programmatically - /// accessible. (In the case of an adapter for SAX1 Parser, there is no - /// implementation-independent way to expose whether the underlying parser is performing - /// validation, expanding external entities, and so forth.) + /// XMLReaders are not required to recognize any specific property names, though an initial + /// core set is documented for SAX2. + /// + /// Implementors are free (and encouraged) to invent their own properties, using names + /// built on their own URIs. + + virtual void parse(InputSource* pSource) = 0; + /// Parse an XML document. + /// + /// The application can use this method to instruct the XML reader to begin parsing an + /// XML document from any valid input source (a character stream, a byte stream, or a URI). + /// + /// Applications may not invoke this method while a parse is in progress (they should create + /// a new XMLReader instead for each nested XML document). Once a parse is complete, an + /// application may reuse the same XMLReader object, possibly with a different input source. + /// Configuration of the XMLReader object (such as handler bindings and values established for + /// feature flags and properties) is unchanged by completion of a parse, unless the definition of that + /// aspect of the configuration explicitly specifies other behavior. (For example, feature flags or + /// properties exposing characteristics of the document being parsed.) + /// + /// During the parse, the XMLReader will provide information about the XML document through the registered + /// event handlers. /// - /// All XMLReaders are required to recognize the - /// http://xml.org/sax/features/namespaces and the - /// http://xml.org/sax/features/namespace-prefixes feature names. - /// Implementors are free (and encouraged) to invent their own features, - /// using names built on their own URIs. - - virtual void setProperty(const XMLString& propertyId, const XMLString& value) = 0; - /// Set the value of a property. - /// - /// The property name is any fully-qualified URI. It is possible for an XMLReader - /// to recognize a property name but to be unable to change the current value. - /// Some property values may be immutable or mutable only in specific contexts, - /// such as before, during, or after a parse. - /// - /// XMLReaders are not required to recognize setting any specific property names, though a - /// core set is defined by SAX2. - /// - /// This method is also the standard mechanism for setting extended handlers. - - virtual void setProperty(const XMLString& propertyId, void* value) = 0; - /// Set the value of a property. - /// See also setProperty(const XMLString&, const XMLString&). - - virtual void* getProperty(const XMLString& propertyId) const = 0; - /// Look up the value of a property. - /// String values are returned as XMLChar* - /// The property name is any fully-qualified URI. It is possible for an XMLReader to - /// recognize a property name but temporarily be unable to return its value. Some property - /// values may be available only in specific contexts, such as before, during, or after a parse. - /// - /// XMLReaders are not required to recognize any specific property names, though an initial - /// core set is documented for SAX2. - /// - /// Implementors are free (and encouraged) to invent their own properties, using names - /// built on their own URIs. - - virtual void parse(InputSource* pSource) = 0; - /// Parse an XML document. - /// - /// The application can use this method to instruct the XML reader to begin parsing an - /// XML document from any valid input source (a character stream, a byte stream, or a URI). - /// - /// Applications may not invoke this method while a parse is in progress (they should create - /// a new XMLReader instead for each nested XML document). Once a parse is complete, an - /// application may reuse the same XMLReader object, possibly with a different input source. - /// Configuration of the XMLReader object (such as handler bindings and values established for - /// feature flags and properties) is unchanged by completion of a parse, unless the definition of that - /// aspect of the configuration explicitly specifies other behavior. (For example, feature flags or - /// properties exposing characteristics of the document being parsed.) - /// - /// During the parse, the XMLReader will provide information about the XML document through the registered - /// event handlers. - /// - /// This method is synchronous: it will not return until parsing has ended. If a client application - /// wants to terminate parsing early, it should throw an exception. - - virtual void parse(const XMLString& systemId) = 0; - /// Parse an XML document from a system identifier. - /// See also parse(InputSource*). - - virtual void parseMemoryNP(const char* xml, std::size_t size) = 0; - /// Parse an XML document from memory. - /// See also parse(InputSource*). - - // SAX Features - static const XMLString FEATURE_VALIDATION; - static const XMLString FEATURE_NAMESPACES; - static const XMLString FEATURE_NAMESPACE_PREFIXES; - static const XMLString FEATURE_EXTERNAL_GENERAL_ENTITIES; - static const XMLString FEATURE_EXTERNAL_PARAMETER_ENTITIES; - static const XMLString FEATURE_STRING_INTERNING; - - // SAX Properties - static const XMLString PROPERTY_DECLARATION_HANDLER; - static const XMLString PROPERTY_LEXICAL_HANDLER; - -protected: - virtual ~XMLReader(); -}; - - -} } // namespace Poco::XML - - -#endif // SAX_XMLReader_INCLUDED + /// This method is synchronous: it will not return until parsing has ended. If a client application + /// wants to terminate parsing early, it should throw an exception. + + virtual void parse(const XMLString& systemId) = 0; + /// Parse an XML document from a system identifier. + /// See also parse(InputSource*). + + virtual void parseMemoryNP(const char* xml, std::size_t size) = 0; + /// Parse an XML document from memory. + /// See also parse(InputSource*). + + // SAX Features + static const XMLString FEATURE_VALIDATION; + static const XMLString FEATURE_NAMESPACES; + static const XMLString FEATURE_NAMESPACE_PREFIXES; + static const XMLString FEATURE_EXTERNAL_GENERAL_ENTITIES; + static const XMLString FEATURE_EXTERNAL_PARAMETER_ENTITIES; + static const XMLString FEATURE_STRING_INTERNING; + + // SAX Properties + static const XMLString PROPERTY_DECLARATION_HANDLER; + static const XMLString PROPERTY_LEXICAL_HANDLER; + +protected: + virtual ~XMLReader(); +}; + + +} } // namespace Poco::XML + + +#endif // SAX_XMLReader_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/Content.h b/contrib/libs/poco/XML/include/Poco/XML/Content.h index 8b2b312344..52ff589376 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/Content.h +++ b/contrib/libs/poco/XML/include/Poco/XML/Content.h @@ -1,63 +1,63 @@ -// -// Content.h -// -// Library: XML -// Package: XML -// Module: Content -// -// Definition of the Content enum. -// -// 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 -// - - -#ifndef XML_Content_INCLUDED -#define XML_Content_INCLUDED - - -namespace Poco { -namespace XML { - - -struct Content - /// XML content model. C++11 enum class emulated for C++98. - /// - /// element characters whitespaces notes - /// Empty no no ignored - /// Simple no yes preserved content accumulated - /// Complex yes no ignored - /// Mixed yes yes preserved -{ - enum value - { - Empty, - Simple, - Complex, - Mixed - }; - - Content(value v) - : _v(v) - { - } - - operator value() const - { - return _v; - } - -private: - value _v; -}; - - -} } // namespace Poco::XML - - -#endif // XML_Content_INCLUDED +// +// Content.h +// +// Library: XML +// Package: XML +// Module: Content +// +// Definition of the Content enum. +// +// 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 +// + + +#ifndef XML_Content_INCLUDED +#define XML_Content_INCLUDED + + +namespace Poco { +namespace XML { + + +struct Content + /// XML content model. C++11 enum class emulated for C++98. + /// + /// element characters whitespaces notes + /// Empty no no ignored + /// Simple no yes preserved content accumulated + /// Complex yes no ignored + /// Mixed yes yes preserved +{ + enum value + { + Empty, + Simple, + Complex, + Mixed + }; + + Content(value v) + : _v(v) + { + } + + operator value() const + { + return _v; + } + +private: + value _v; +}; + + +} } // namespace Poco::XML + + +#endif // XML_Content_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/Name.h b/contrib/libs/poco/XML/include/Poco/XML/Name.h index d21219b14a..0a7ac1ca5c 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/Name.h +++ b/contrib/libs/poco/XML/include/Poco/XML/Name.h @@ -1,138 +1,138 @@ -// -// Name.h -// -// Library: XML -// Package: XML -// Module: Name -// -// Definition of the Name class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef XML_Name_INCLUDED -#define XML_Name_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" - - -namespace Poco { -namespace XML { - - -class XML_API Name - /// An XML element or attribute name, consisting of a - /// qualified name, a namespace URI and a local name. -{ -public: - Name(); - /// Creates an empty Name. - - Name(const XMLString& qname); - /// Creates a Name from a qualified name only. - - Name(const XMLString& qname, const XMLString& namespaceURI); - /// Creates a Name from a qualified name and a namespace URI. - /// The local name is extracted from the qualified name. - - Name(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName); - /// Creates a Name from a qualified name, a namespace URI and a local name. - - Name(const Name& name); - /// Copy constructor. - - ~Name(); - /// Destroys the name. - - Name& operator = (const Name& name); - /// Assignment operator. - - void swap(Name& name); - /// Swaps the name with another one. - - void assign(const XMLString& qname); - /// Assigns a new value to the name. - - void assign(const XMLString& qname, const XMLString& namespaceURI); - /// Assigns new values to the name. - /// The local name is extracted from the qualified name. - - void assign(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName); - /// Assigns new values to the name. - - bool equals(const Name& name) const; - /// Returns true if both names are equal. - - bool equals(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName) const; - /// Returns true if all the name's components are equal to the given ones. - - bool equalsWeakly(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName) const; - /// Returns true if either the qnames are identical or the namespaceURIs and the localNames are identical. - - const XMLString& qname() const; - /// Returns the qualified name. - - const XMLString& namespaceURI() const; - /// Returns the namespace URI. - - const XMLString& localName() const; - /// Returns the local name. - - XMLString prefix() const; - /// Returns the namespace prefix. - - static void split(const XMLString& qname, XMLString& prefix, XMLString& localName); - /// Splits the given qualified name into its prefix and localName parts. - - static XMLString localName(const XMLString& qname); - /// Returns the local name part of the given qualified name. - - static XMLString prefix(const XMLString& qname); - /// Returns the prefix part of the given qualified name. - - static const XMLString EMPTY_NAME; - -private: - XMLString _qname; - XMLString _namespaceURI; - XMLString _localName; -}; - - -// -// inlines -// -inline const XMLString& Name::qname() const -{ - return _qname; -} - - -inline const XMLString& Name::namespaceURI() const -{ - return _namespaceURI; -} - - -inline const XMLString& Name::localName() const -{ - return _localName; -} - - -inline void swap(Name& n1, Name& n2) -{ - n1.swap(n2); -} - - -} } // namespace Poco::XML - - -#endif // XML_Name_INCLUDED +// +// Name.h +// +// Library: XML +// Package: XML +// Module: Name +// +// Definition of the Name class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef XML_Name_INCLUDED +#define XML_Name_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" + + +namespace Poco { +namespace XML { + + +class XML_API Name + /// An XML element or attribute name, consisting of a + /// qualified name, a namespace URI and a local name. +{ +public: + Name(); + /// Creates an empty Name. + + Name(const XMLString& qname); + /// Creates a Name from a qualified name only. + + Name(const XMLString& qname, const XMLString& namespaceURI); + /// Creates a Name from a qualified name and a namespace URI. + /// The local name is extracted from the qualified name. + + Name(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName); + /// Creates a Name from a qualified name, a namespace URI and a local name. + + Name(const Name& name); + /// Copy constructor. + + ~Name(); + /// Destroys the name. + + Name& operator = (const Name& name); + /// Assignment operator. + + void swap(Name& name); + /// Swaps the name with another one. + + void assign(const XMLString& qname); + /// Assigns a new value to the name. + + void assign(const XMLString& qname, const XMLString& namespaceURI); + /// Assigns new values to the name. + /// The local name is extracted from the qualified name. + + void assign(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName); + /// Assigns new values to the name. + + bool equals(const Name& name) const; + /// Returns true if both names are equal. + + bool equals(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName) const; + /// Returns true if all the name's components are equal to the given ones. + + bool equalsWeakly(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName) const; + /// Returns true if either the qnames are identical or the namespaceURIs and the localNames are identical. + + const XMLString& qname() const; + /// Returns the qualified name. + + const XMLString& namespaceURI() const; + /// Returns the namespace URI. + + const XMLString& localName() const; + /// Returns the local name. + + XMLString prefix() const; + /// Returns the namespace prefix. + + static void split(const XMLString& qname, XMLString& prefix, XMLString& localName); + /// Splits the given qualified name into its prefix and localName parts. + + static XMLString localName(const XMLString& qname); + /// Returns the local name part of the given qualified name. + + static XMLString prefix(const XMLString& qname); + /// Returns the prefix part of the given qualified name. + + static const XMLString EMPTY_NAME; + +private: + XMLString _qname; + XMLString _namespaceURI; + XMLString _localName; +}; + + +// +// inlines +// +inline const XMLString& Name::qname() const +{ + return _qname; +} + + +inline const XMLString& Name::namespaceURI() const +{ + return _namespaceURI; +} + + +inline const XMLString& Name::localName() const +{ + return _localName; +} + + +inline void swap(Name& n1, Name& n2) +{ + n1.swap(n2); +} + + +} } // namespace Poco::XML + + +#endif // XML_Name_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/NamePool.h b/contrib/libs/poco/XML/include/Poco/XML/NamePool.h index 9ffadf1af9..a0c34a9ac6 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/NamePool.h +++ b/contrib/libs/poco/XML/include/Poco/XML/NamePool.h @@ -1,83 +1,83 @@ -// -// NamePool.h -// -// Library: XML -// Package: XML -// Module: NamePool -// -// Definition of the NamePool class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef XML_NamePool_INCLUDED -#define XML_NamePool_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" -#include "Poco/XML/Name.h" - - -#ifndef POCO_XML_NAMEPOOL_DEFAULT_SIZE -#define POCO_XML_NAMEPOOL_DEFAULT_SIZE 509 -#endif - - -namespace Poco { -namespace XML { - - -class NamePoolItem; - - -class XML_API NamePool - /// A hashtable that stores XML names consisting of an URI, a - /// local name and a qualified name. -{ -public: - NamePool(unsigned long size = POCO_XML_NAMEPOOL_DEFAULT_SIZE); - /// Creates a name pool with room for up to size strings. - /// - /// The given size should be a suitable prime number, - /// e.g. 251, 509, 1021 or 4093. - - const Name& insert(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName); - /// Returns a const reference to an Name for the given names. - /// Creates the Name if it does not already exist. - /// Throws a PoolOverflowException if the name pool is full. - - const Name& insert(const Name& name); - /// Returns a const reference to an Name for the given name. - /// Creates the Name if it does not already exist. - /// Throws a PoolOverflowException if the name pool is full. - - void duplicate(); - /// Increments the reference count. - - void release(); - /// Decrements the reference count and deletes the object if the reference count reaches zero. - -protected: - unsigned long hash(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName); - ~NamePool(); - -private: - NamePool(const NamePool&); - NamePool& operator = (const NamePool&); - - NamePoolItem* _pItems; - unsigned long _size; - unsigned long _salt; - int _rc; -}; - - -} } // namespace Poco::XML - - -#endif // XML_NamePool_INCLUDED +// +// NamePool.h +// +// Library: XML +// Package: XML +// Module: NamePool +// +// Definition of the NamePool class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef XML_NamePool_INCLUDED +#define XML_NamePool_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" +#include "Poco/XML/Name.h" + + +#ifndef POCO_XML_NAMEPOOL_DEFAULT_SIZE +#define POCO_XML_NAMEPOOL_DEFAULT_SIZE 509 +#endif + + +namespace Poco { +namespace XML { + + +class NamePoolItem; + + +class XML_API NamePool + /// A hashtable that stores XML names consisting of an URI, a + /// local name and a qualified name. +{ +public: + NamePool(unsigned long size = POCO_XML_NAMEPOOL_DEFAULT_SIZE); + /// Creates a name pool with room for up to size strings. + /// + /// The given size should be a suitable prime number, + /// e.g. 251, 509, 1021 or 4093. + + const Name& insert(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName); + /// Returns a const reference to an Name for the given names. + /// Creates the Name if it does not already exist. + /// Throws a PoolOverflowException if the name pool is full. + + const Name& insert(const Name& name); + /// Returns a const reference to an Name for the given name. + /// Creates the Name if it does not already exist. + /// Throws a PoolOverflowException if the name pool is full. + + void duplicate(); + /// Increments the reference count. + + void release(); + /// Decrements the reference count and deletes the object if the reference count reaches zero. + +protected: + unsigned long hash(const XMLString& qname, const XMLString& namespaceURI, const XMLString& localName); + ~NamePool(); + +private: + NamePool(const NamePool&); + NamePool& operator = (const NamePool&); + + NamePoolItem* _pItems; + unsigned long _size; + unsigned long _salt; + int _rc; +}; + + +} } // namespace Poco::XML + + +#endif // XML_NamePool_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/NamespaceStrategy.h b/contrib/libs/poco/XML/include/Poco/XML/NamespaceStrategy.h index 1f27e3c23b..4937c5a5c8 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/NamespaceStrategy.h +++ b/contrib/libs/poco/XML/include/Poco/XML/NamespaceStrategy.h @@ -1,115 +1,115 @@ -// -// NamespaceStrategy.h -// -// Library: XML -// Package: XML -// Module: NamespaceStrategy -// -// Definition of the NamespaceStrategy class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef XML_NamespaceStrategy_INCLUDED -#define XML_NamespaceStrategy_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/XML/XMLString.h" -#include "Poco/SAX/NamespaceSupport.h" -#include "Poco/SAX/AttributesImpl.h" - - -namespace Poco { -namespace XML { - - -class ContentHandler; - - -class XML_API NamespaceStrategy - /// This class is used by ParserEngine to handle the - /// startElement, endElement, startPrefixMapping and - /// endPrefixMapping events. -{ -public: - virtual ~NamespaceStrategy(); - - virtual void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler) = 0; - /// Translate the arguments as delivered by Expat and - /// call the startElement() method of the ContentHandler. - - virtual void endElement(const XMLChar* name, ContentHandler* pContentHandler) = 0; - /// Translate the arguments as delivered by Expat and - /// call the endElement() method of the ContentHandler. - -protected: - static void splitName(const XMLChar* qname, XMLString& uri, XMLString& localName); - static void splitName(const XMLChar* qname, XMLString& uri, XMLString& localName, XMLString& prefix); - - static const XMLString NOTHING; -}; - - -class XML_API NoNamespacesStrategy: public NamespaceStrategy - /// The NamespaceStrategy implementation used if no namespaces - /// processing is requested. -{ -public: - NoNamespacesStrategy(); - ~NoNamespacesStrategy(); - - void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler); - void endElement(const XMLChar* name, ContentHandler* pContentHandler); - -private: - XMLString _name; - AttributesImpl _attrs; -}; - - -class XML_API NoNamespacePrefixesStrategy: public NamespaceStrategy - /// The NamespaceStrategy implementation used if namespaces - /// processing is requested, but prefixes are not reported. -{ -public: - NoNamespacePrefixesStrategy(); - ~NoNamespacePrefixesStrategy(); - - void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler); - void endElement(const XMLChar* name, ContentHandler* pContentHandler); - -private: - XMLString _uri; - XMLString _local; - AttributesImpl _attrs; -}; - - -class XML_API NamespacePrefixesStrategy: public NamespaceStrategy - /// The NamespaceStrategy implementation used if namespaces - /// processing is requested and prefixes are reported. -{ -public: - NamespacePrefixesStrategy(); - ~NamespacePrefixesStrategy(); - - void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler); - void endElement(const XMLChar* name, ContentHandler* pContentHandler); - -private: - XMLString _uri; - XMLString _local; - XMLString _qname; - AttributesImpl _attrs; -}; - - -} } // namespace Poco::XML - - -#endif // XML_NamespaceStrategy_INCLUDED +// +// NamespaceStrategy.h +// +// Library: XML +// Package: XML +// Module: NamespaceStrategy +// +// Definition of the NamespaceStrategy class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef XML_NamespaceStrategy_INCLUDED +#define XML_NamespaceStrategy_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/XML/XMLString.h" +#include "Poco/SAX/NamespaceSupport.h" +#include "Poco/SAX/AttributesImpl.h" + + +namespace Poco { +namespace XML { + + +class ContentHandler; + + +class XML_API NamespaceStrategy + /// This class is used by ParserEngine to handle the + /// startElement, endElement, startPrefixMapping and + /// endPrefixMapping events. +{ +public: + virtual ~NamespaceStrategy(); + + virtual void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler) = 0; + /// Translate the arguments as delivered by Expat and + /// call the startElement() method of the ContentHandler. + + virtual void endElement(const XMLChar* name, ContentHandler* pContentHandler) = 0; + /// Translate the arguments as delivered by Expat and + /// call the endElement() method of the ContentHandler. + +protected: + static void splitName(const XMLChar* qname, XMLString& uri, XMLString& localName); + static void splitName(const XMLChar* qname, XMLString& uri, XMLString& localName, XMLString& prefix); + + static const XMLString NOTHING; +}; + + +class XML_API NoNamespacesStrategy: public NamespaceStrategy + /// The NamespaceStrategy implementation used if no namespaces + /// processing is requested. +{ +public: + NoNamespacesStrategy(); + ~NoNamespacesStrategy(); + + void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler); + void endElement(const XMLChar* name, ContentHandler* pContentHandler); + +private: + XMLString _name; + AttributesImpl _attrs; +}; + + +class XML_API NoNamespacePrefixesStrategy: public NamespaceStrategy + /// The NamespaceStrategy implementation used if namespaces + /// processing is requested, but prefixes are not reported. +{ +public: + NoNamespacePrefixesStrategy(); + ~NoNamespacePrefixesStrategy(); + + void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler); + void endElement(const XMLChar* name, ContentHandler* pContentHandler); + +private: + XMLString _uri; + XMLString _local; + AttributesImpl _attrs; +}; + + +class XML_API NamespacePrefixesStrategy: public NamespaceStrategy + /// The NamespaceStrategy implementation used if namespaces + /// processing is requested and prefixes are reported. +{ +public: + NamespacePrefixesStrategy(); + ~NamespacePrefixesStrategy(); + + void startElement(const XMLChar* name, const XMLChar** atts, int specifiedCount, ContentHandler* pContentHandler); + void endElement(const XMLChar* name, ContentHandler* pContentHandler); + +private: + XMLString _uri; + XMLString _local; + XMLString _qname; + AttributesImpl _attrs; +}; + + +} } // namespace Poco::XML + + +#endif // XML_NamespaceStrategy_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/ParserEngine.h b/contrib/libs/poco/XML/include/Poco/XML/ParserEngine.h index 772f5ea291..5d569dced0 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/ParserEngine.h +++ b/contrib/libs/poco/XML/include/Poco/XML/ParserEngine.h @@ -1,358 +1,358 @@ -// -// ParserEngine.h -// -// Library: XML -// Package: XML -// Module: ParserEngine -// -// Definition of the ParseEngine class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 - - -#ifndef XML_ParserEngine_INCLUDED -#define XML_ParserEngine_INCLUDED - - -#include "Poco/XML/XML.h" -#if defined(POCO_UNBUNDLED) -#include <expat.h> -#else -#error #include "Poco/XML/expat.h" -#endif -#include "Poco/XML/XMLString.h" -#include "Poco/XML/XMLStream.h" -#include "Poco/SAX/Locator.h" -#include "Poco/TextEncoding.h" -#include <map> -#include <vector> - - -namespace Poco { -namespace XML { - - -class InputSource; -class EntityResolver; -class DTDHandler; -class DeclHandler; -class ContentHandler; -class LexicalHandler; -class ErrorHandler; -class NamespaceStrategy; -class ContextLocator; - - -class XML_API ParserEngine: public Locator - /// This class provides an object-oriented, stream-based, - /// low-level interface to the XML Parser Toolkit (expat). - /// It is strongly recommended, that you use the - /// SAX parser classes (which are based on this - /// class) instead of this class, since they provide - /// a standardized, higher-level interface to the parser. -{ -public: - ParserEngine(); - /// Creates the parser engine. - - ParserEngine(const XMLString& encoding); - /// Creates the parser engine and passes the encoding - /// to the underlying parser. - - ~ParserEngine(); - /// Destroys the parser. - - void setEncoding(const XMLString& encoding); - /// Sets the encoding used by expat. The encoding must be - /// set before parsing begins, otherwise it will be ignored. - - const XMLString& getEncoding() const; - /// Returns the encoding used by expat. - - void addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding); - /// Adds an encoding to the parser. - - void setNamespaceStrategy(NamespaceStrategy* pStrategy); - /// Sets the NamespaceStrategy used by the parser. - /// The parser takes ownership of the strategy object - /// and deletes it when it's no longer needed. - /// The default is NoNamespacesStrategy. - - NamespaceStrategy* getNamespaceStrategy() const; - /// Returns the NamespaceStrategy currently in use. - - void setExpandInternalEntities(bool flag = true); - /// Enables/disables expansion of internal entities (enabled by - /// default). If entity expansion is disabled, internal entities - /// are reported via the default handler. - /// Must be set before parsing begins, otherwise it will be - /// ignored. - - bool getExpandInternalEntities() const; - /// Returns true if internal entities will be expanded automatically, - /// which is the default. - - void setExternalGeneralEntities(bool flag = true); - /// Enable or disable processing of external general entities. - - bool getExternalGeneralEntities() const; - /// Returns true if external general entities will be processed; false otherwise. - - void setExternalParameterEntities(bool flag = true); - /// Enable or disable processing of external parameter entities. - - bool getExternalParameterEntities() const; - /// Returns true if external parameter entities will be processed; false otherwise. - - void setEntityResolver(EntityResolver* pResolver); - /// Allow an application to register an entity resolver. - - EntityResolver* getEntityResolver() const; - /// Return the current entity resolver. - - void setDTDHandler(DTDHandler* pDTDHandler); - /// Allow an application to register a DTD event handler. - - DTDHandler* getDTDHandler() const; - /// Return the current DTD handler. - - void setDeclHandler(DeclHandler* pDeclHandler); - /// Allow an application to register a DTD declarations event handler. - - DeclHandler* getDeclHandler() const; - /// Return the current DTD declarations handler. - - void setContentHandler(ContentHandler* pContentHandler); - /// Allow an application to register a content event handler. - - ContentHandler* getContentHandler() const; - /// Return the current content handler. - - void setLexicalHandler(LexicalHandler* pLexicalHandler); - /// Allow an application to register a lexical event handler. - - LexicalHandler* getLexicalHandler() const; - /// Return the current lexical handler. - - void setErrorHandler(ErrorHandler* pErrorHandler); - /// Allow an application to register an error event handler. - - ErrorHandler* getErrorHandler() const; - /// Return the current error handler. - - void setEnablePartialReads(bool flag = true); - /// Enable or disable partial reads from the input source. - /// - /// This is useful for parsing XML from a socket stream for - /// a protocol like XMPP, where basically single elements - /// are read one at a time from the input source's stream, and - /// following elements depend upon responses sent back to - /// the peer. - /// - /// Normally, the parser always reads blocks of PARSE_BUFFER_SIZE - /// at a time, and blocks until a complete block has been read (or - /// the end of the stream has been reached). - /// This allows for efficient parsing of "complete" XML documents, - /// but fails in a case such as XMPP, where only XML fragments - /// are sent at a time. - - bool getEnablePartialReads() const; - /// Returns true if partial reads are enabled (see - /// setEnablePartialReads()), false otherwise. - - void parse(InputSource* pInputSource); - /// Parse an XML document from the given InputSource. - - void parse(const char* pBuffer, std::size_t size); - /// Parses an XML document from the given buffer. - - // Locator - XMLString getPublicId() const; - /// Return the public identifier for the current document event. - - XMLString getSystemId() const; - /// Return the system identifier for the current document event. - - int getLineNumber() const; - /// Return the line number where the current document event ends. - - int getColumnNumber() const; - /// Return the column number where the current document event ends. - -protected: - void init(); - /// initializes expat - - void parseByteInputStream(XMLByteInputStream& istr); - /// Parses an entity from the given stream. - - void parseCharInputStream(XMLCharInputStream& istr); - /// Parses an entity from the given stream. - - std::streamsize readBytes(XMLByteInputStream& istr, char* pBuffer, std::streamsize bufferSize); - /// Reads at most bufferSize bytes from the given stream into the given buffer. - - std::streamsize readChars(XMLCharInputStream& istr, XMLChar* pBuffer, std::streamsize bufferSize); - /// Reads at most bufferSize chars from the given stream into the given buffer. - - void handleError(int errorNo); - /// Throws an XMLException with a message corresponding - /// to the given Expat error code. - - void parseExternal(XML_Parser extParser, InputSource* pInputSource); - /// Parse an XML document from the given InputSource. - - void parseExternalByteInputStream(XML_Parser extParser, XMLByteInputStream& istr); - /// Parses an external entity from the given stream, with a separate parser. - - void parseExternalCharInputStream(XML_Parser extParser, XMLCharInputStream& istr); - /// Parses an external entity from the given stream, with a separate parser. - - void pushContext(XML_Parser parser, InputSource* pInputSource); - /// Pushes a new entry to the context stack. - - void popContext(); - /// Pops the top-most entry from the context stack. - - void resetContext(); - /// Resets and clears the context stack. - - const Locator& locator() const; - /// Returns a locator denoting the current parse location. - - // expat handler procedures - static void handleStartElement(void* userData, const XML_Char* name, const XML_Char** atts); - static void handleEndElement(void* userData, const XML_Char* name); - static void handleCharacterData(void* userData, const XML_Char* s, int len); - static void handleProcessingInstruction(void* userData, const XML_Char* target, const XML_Char* data); - static void handleDefault(void* userData, const XML_Char* s, int len); - static void handleUnparsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId, const XML_Char* notationName); - static void handleNotationDecl(void* userData, const XML_Char* notationName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId); - static int handleExternalEntityRef(XML_Parser parser, const XML_Char* openEntityNames, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId); - static int handleUnknownEncoding(void* encodingHandlerData, const XML_Char* name, XML_Encoding* info); - static void handleComment(void* userData, const XML_Char* data); - static void handleStartCdataSection(void* userData); - static void handleEndCdataSection(void* userData); - static void handleStartNamespaceDecl(void* userData, const XML_Char* prefix, const XML_Char* uri); - static void handleEndNamespaceDecl(void* userData, const XML_Char* prefix); - static void handleStartDoctypeDecl(void* userData, const XML_Char* doctypeName, const XML_Char *systemId, const XML_Char* publicId, int hasInternalSubset); - static void handleEndDoctypeDecl(void* userData); - static void 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); - static void handleExternalParsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId); - static void handleInternalParsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* replacementText, int replacementTextLength); - static void handleSkippedEntity(void* userData, const XML_Char* entityName, int isParameterEntity); - - // encoding support - static int convert(void *data, const char *s); - -private: - typedef std::map<XMLString, Poco::TextEncoding*> EncodingMap; - typedef std::vector<ContextLocator*> ContextStack; - - XML_Parser _parser; - char* _pBuffer; - bool _encodingSpecified; - XMLString _encoding; - bool _expandInternalEntities; - bool _externalGeneralEntities; - bool _externalParameterEntities; - bool _enablePartialReads; - NamespaceStrategy* _pNamespaceStrategy; - EncodingMap _encodings; - ContextStack _context; - - EntityResolver* _pEntityResolver; - DTDHandler* _pDTDHandler; - DeclHandler* _pDeclHandler; - ContentHandler* _pContentHandler; - LexicalHandler* _pLexicalHandler; - ErrorHandler* _pErrorHandler; - - static const int PARSE_BUFFER_SIZE; - static const XMLString EMPTY_STRING; -}; - - -// -// inlines -// -inline const XMLString& ParserEngine::getEncoding() const -{ - return _encoding; -} - - -inline NamespaceStrategy* ParserEngine::getNamespaceStrategy() const -{ - return _pNamespaceStrategy; -} - - -inline bool ParserEngine::getExpandInternalEntities() const -{ - return _expandInternalEntities; -} - - -inline bool ParserEngine::getExternalGeneralEntities() const -{ - return _externalGeneralEntities; -} - - -inline bool ParserEngine::getExternalParameterEntities() const -{ - return _externalParameterEntities; -} - - -inline EntityResolver* ParserEngine::getEntityResolver() const -{ - return _pEntityResolver; -} - - -inline DTDHandler* ParserEngine::getDTDHandler() const -{ - return _pDTDHandler; -} - - -inline DeclHandler* ParserEngine::getDeclHandler() const -{ - return _pDeclHandler; -} - - -inline ContentHandler* ParserEngine::getContentHandler() const -{ - return _pContentHandler; -} - - -inline LexicalHandler* ParserEngine::getLexicalHandler() const -{ - return _pLexicalHandler; -} - - -inline ErrorHandler* ParserEngine::getErrorHandler() const -{ - return _pErrorHandler; -} - - -inline bool ParserEngine::getEnablePartialReads() const -{ - return _enablePartialReads; -} - - -} } // namespace Poco::XML - - -#endif // XML_ParserEngine_INCLUDED +// +// ParserEngine.h +// +// Library: XML +// Package: XML +// Module: ParserEngine +// +// Definition of the ParseEngine class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 + + +#ifndef XML_ParserEngine_INCLUDED +#define XML_ParserEngine_INCLUDED + + +#include "Poco/XML/XML.h" +#if defined(POCO_UNBUNDLED) +#include <expat.h> +#else +#error #include "Poco/XML/expat.h" +#endif +#include "Poco/XML/XMLString.h" +#include "Poco/XML/XMLStream.h" +#include "Poco/SAX/Locator.h" +#include "Poco/TextEncoding.h" +#include <map> +#include <vector> + + +namespace Poco { +namespace XML { + + +class InputSource; +class EntityResolver; +class DTDHandler; +class DeclHandler; +class ContentHandler; +class LexicalHandler; +class ErrorHandler; +class NamespaceStrategy; +class ContextLocator; + + +class XML_API ParserEngine: public Locator + /// This class provides an object-oriented, stream-based, + /// low-level interface to the XML Parser Toolkit (expat). + /// It is strongly recommended, that you use the + /// SAX parser classes (which are based on this + /// class) instead of this class, since they provide + /// a standardized, higher-level interface to the parser. +{ +public: + ParserEngine(); + /// Creates the parser engine. + + ParserEngine(const XMLString& encoding); + /// Creates the parser engine and passes the encoding + /// to the underlying parser. + + ~ParserEngine(); + /// Destroys the parser. + + void setEncoding(const XMLString& encoding); + /// Sets the encoding used by expat. The encoding must be + /// set before parsing begins, otherwise it will be ignored. + + const XMLString& getEncoding() const; + /// Returns the encoding used by expat. + + void addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding); + /// Adds an encoding to the parser. + + void setNamespaceStrategy(NamespaceStrategy* pStrategy); + /// Sets the NamespaceStrategy used by the parser. + /// The parser takes ownership of the strategy object + /// and deletes it when it's no longer needed. + /// The default is NoNamespacesStrategy. + + NamespaceStrategy* getNamespaceStrategy() const; + /// Returns the NamespaceStrategy currently in use. + + void setExpandInternalEntities(bool flag = true); + /// Enables/disables expansion of internal entities (enabled by + /// default). If entity expansion is disabled, internal entities + /// are reported via the default handler. + /// Must be set before parsing begins, otherwise it will be + /// ignored. + + bool getExpandInternalEntities() const; + /// Returns true if internal entities will be expanded automatically, + /// which is the default. + + void setExternalGeneralEntities(bool flag = true); + /// Enable or disable processing of external general entities. + + bool getExternalGeneralEntities() const; + /// Returns true if external general entities will be processed; false otherwise. + + void setExternalParameterEntities(bool flag = true); + /// Enable or disable processing of external parameter entities. + + bool getExternalParameterEntities() const; + /// Returns true if external parameter entities will be processed; false otherwise. + + void setEntityResolver(EntityResolver* pResolver); + /// Allow an application to register an entity resolver. + + EntityResolver* getEntityResolver() const; + /// Return the current entity resolver. + + void setDTDHandler(DTDHandler* pDTDHandler); + /// Allow an application to register a DTD event handler. + + DTDHandler* getDTDHandler() const; + /// Return the current DTD handler. + + void setDeclHandler(DeclHandler* pDeclHandler); + /// Allow an application to register a DTD declarations event handler. + + DeclHandler* getDeclHandler() const; + /// Return the current DTD declarations handler. + + void setContentHandler(ContentHandler* pContentHandler); + /// Allow an application to register a content event handler. + + ContentHandler* getContentHandler() const; + /// Return the current content handler. + + void setLexicalHandler(LexicalHandler* pLexicalHandler); + /// Allow an application to register a lexical event handler. + + LexicalHandler* getLexicalHandler() const; + /// Return the current lexical handler. + + void setErrorHandler(ErrorHandler* pErrorHandler); + /// Allow an application to register an error event handler. + + ErrorHandler* getErrorHandler() const; + /// Return the current error handler. + + void setEnablePartialReads(bool flag = true); + /// Enable or disable partial reads from the input source. + /// + /// This is useful for parsing XML from a socket stream for + /// a protocol like XMPP, where basically single elements + /// are read one at a time from the input source's stream, and + /// following elements depend upon responses sent back to + /// the peer. + /// + /// Normally, the parser always reads blocks of PARSE_BUFFER_SIZE + /// at a time, and blocks until a complete block has been read (or + /// the end of the stream has been reached). + /// This allows for efficient parsing of "complete" XML documents, + /// but fails in a case such as XMPP, where only XML fragments + /// are sent at a time. + + bool getEnablePartialReads() const; + /// Returns true if partial reads are enabled (see + /// setEnablePartialReads()), false otherwise. + + void parse(InputSource* pInputSource); + /// Parse an XML document from the given InputSource. + + void parse(const char* pBuffer, std::size_t size); + /// Parses an XML document from the given buffer. + + // Locator + XMLString getPublicId() const; + /// Return the public identifier for the current document event. + + XMLString getSystemId() const; + /// Return the system identifier for the current document event. + + int getLineNumber() const; + /// Return the line number where the current document event ends. + + int getColumnNumber() const; + /// Return the column number where the current document event ends. + +protected: + void init(); + /// initializes expat + + void parseByteInputStream(XMLByteInputStream& istr); + /// Parses an entity from the given stream. + + void parseCharInputStream(XMLCharInputStream& istr); + /// Parses an entity from the given stream. + + std::streamsize readBytes(XMLByteInputStream& istr, char* pBuffer, std::streamsize bufferSize); + /// Reads at most bufferSize bytes from the given stream into the given buffer. + + std::streamsize readChars(XMLCharInputStream& istr, XMLChar* pBuffer, std::streamsize bufferSize); + /// Reads at most bufferSize chars from the given stream into the given buffer. + + void handleError(int errorNo); + /// Throws an XMLException with a message corresponding + /// to the given Expat error code. + + void parseExternal(XML_Parser extParser, InputSource* pInputSource); + /// Parse an XML document from the given InputSource. + + void parseExternalByteInputStream(XML_Parser extParser, XMLByteInputStream& istr); + /// Parses an external entity from the given stream, with a separate parser. + + void parseExternalCharInputStream(XML_Parser extParser, XMLCharInputStream& istr); + /// Parses an external entity from the given stream, with a separate parser. + + void pushContext(XML_Parser parser, InputSource* pInputSource); + /// Pushes a new entry to the context stack. + + void popContext(); + /// Pops the top-most entry from the context stack. + + void resetContext(); + /// Resets and clears the context stack. + + const Locator& locator() const; + /// Returns a locator denoting the current parse location. + + // expat handler procedures + static void handleStartElement(void* userData, const XML_Char* name, const XML_Char** atts); + static void handleEndElement(void* userData, const XML_Char* name); + static void handleCharacterData(void* userData, const XML_Char* s, int len); + static void handleProcessingInstruction(void* userData, const XML_Char* target, const XML_Char* data); + static void handleDefault(void* userData, const XML_Char* s, int len); + static void handleUnparsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId, const XML_Char* notationName); + static void handleNotationDecl(void* userData, const XML_Char* notationName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId); + static int handleExternalEntityRef(XML_Parser parser, const XML_Char* openEntityNames, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId); + static int handleUnknownEncoding(void* encodingHandlerData, const XML_Char* name, XML_Encoding* info); + static void handleComment(void* userData, const XML_Char* data); + static void handleStartCdataSection(void* userData); + static void handleEndCdataSection(void* userData); + static void handleStartNamespaceDecl(void* userData, const XML_Char* prefix, const XML_Char* uri); + static void handleEndNamespaceDecl(void* userData, const XML_Char* prefix); + static void handleStartDoctypeDecl(void* userData, const XML_Char* doctypeName, const XML_Char *systemId, const XML_Char* publicId, int hasInternalSubset); + static void handleEndDoctypeDecl(void* userData); + static void 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); + static void handleExternalParsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* base, const XML_Char* systemId, const XML_Char* publicId); + static void handleInternalParsedEntityDecl(void* userData, const XML_Char* entityName, const XML_Char* replacementText, int replacementTextLength); + static void handleSkippedEntity(void* userData, const XML_Char* entityName, int isParameterEntity); + + // encoding support + static int convert(void *data, const char *s); + +private: + typedef std::map<XMLString, Poco::TextEncoding*> EncodingMap; + typedef std::vector<ContextLocator*> ContextStack; + + XML_Parser _parser; + char* _pBuffer; + bool _encodingSpecified; + XMLString _encoding; + bool _expandInternalEntities; + bool _externalGeneralEntities; + bool _externalParameterEntities; + bool _enablePartialReads; + NamespaceStrategy* _pNamespaceStrategy; + EncodingMap _encodings; + ContextStack _context; + + EntityResolver* _pEntityResolver; + DTDHandler* _pDTDHandler; + DeclHandler* _pDeclHandler; + ContentHandler* _pContentHandler; + LexicalHandler* _pLexicalHandler; + ErrorHandler* _pErrorHandler; + + static const int PARSE_BUFFER_SIZE; + static const XMLString EMPTY_STRING; +}; + + +// +// inlines +// +inline const XMLString& ParserEngine::getEncoding() const +{ + return _encoding; +} + + +inline NamespaceStrategy* ParserEngine::getNamespaceStrategy() const +{ + return _pNamespaceStrategy; +} + + +inline bool ParserEngine::getExpandInternalEntities() const +{ + return _expandInternalEntities; +} + + +inline bool ParserEngine::getExternalGeneralEntities() const +{ + return _externalGeneralEntities; +} + + +inline bool ParserEngine::getExternalParameterEntities() const +{ + return _externalParameterEntities; +} + + +inline EntityResolver* ParserEngine::getEntityResolver() const +{ + return _pEntityResolver; +} + + +inline DTDHandler* ParserEngine::getDTDHandler() const +{ + return _pDTDHandler; +} + + +inline DeclHandler* ParserEngine::getDeclHandler() const +{ + return _pDeclHandler; +} + + +inline ContentHandler* ParserEngine::getContentHandler() const +{ + return _pContentHandler; +} + + +inline LexicalHandler* ParserEngine::getLexicalHandler() const +{ + return _pLexicalHandler; +} + + +inline ErrorHandler* ParserEngine::getErrorHandler() const +{ + return _pErrorHandler; +} + + +inline bool ParserEngine::getEnablePartialReads() const +{ + return _enablePartialReads; +} + + +} } // namespace Poco::XML + + +#endif // XML_ParserEngine_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/QName.h b/contrib/libs/poco/XML/include/Poco/XML/QName.h index 6a6a246e16..5dc4fe8d14 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/QName.h +++ b/contrib/libs/poco/XML/include/Poco/XML/QName.h @@ -1,135 +1,135 @@ -// -// QName.h -// -// Library: XML -// Package: XML -// Module: QName -// -// Definition of the QName class. -// -// 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 -// - - -#ifndef XML_QName_INCLUDED -#define XML_QName_INCLUDED - - -#include "Poco/XML/XML.h" -#include <string> -#include <iosfwd> - - -namespace Poco { -namespace XML { - - -class XML_API QName - /// This class represents a qualified XML name in the stream parser. - /// - /// Note that the optional prefix is just a "syntactic sugar". In - /// particular, it is ignored by the comparison operators and the - /// std::ostream insertion operator. -{ -public: - QName(); - QName(const std::string& name); - QName(const std::string& ns, const std::string& name); - QName(const std::string& ns, const std::string& name, const std::string& prefix); - - const std::string& namespaceURI() const; - /// Returns the namespace URI part of the name. - - const std::string& localName() const; - /// Returns the local part of the name. - - const std::string& prefix() const; - /// Returns the namespace prefix of the name. - - std::string& namespaceURI(); - /// Returns the namespace URI part of the name. - - std::string& localName(); - /// Returns the local part of the name. - - std::string& prefix(); - /// Returns the namespace prefix of the name. - - std::string toString() const; - /// Returns a printable representation in the [<namespace>#]<name> form. - -public: - friend bool operator < (const QName& x, const QName& y) - { - return x._ns < y._ns || (x._ns == y._ns && x._name < y._name); - } - - friend bool operator == (const QName& x, const QName& y) - { - return x._ns == y._ns && x._name == y._name; - } - - friend bool operator != (const QName& x, const QName& y) - { - return !(x == y); - } - -private: - std::string _ns; - std::string _name; - std::string _prefix; -}; - - -// -// inlines -// -inline const std::string& QName::namespaceURI() const -{ - return _ns; -} - - -inline const std::string& QName::localName() const -{ - return _name; -} - - -inline const std::string& QName::prefix() const -{ - return _prefix; -} - - -inline std::string& QName::namespaceURI() -{ - return _ns; -} - - -inline std::string& QName::localName() -{ - return _name; -} - - -inline std::string& QName::prefix() -{ - return _prefix; -} - - -XML_API std::ostream& operator << (std::ostream&, const QName&); - - -} } // namespace Poco::XML - - -#endif // XML_QName_INCLUDED +// +// QName.h +// +// Library: XML +// Package: XML +// Module: QName +// +// Definition of the QName class. +// +// 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 +// + + +#ifndef XML_QName_INCLUDED +#define XML_QName_INCLUDED + + +#include "Poco/XML/XML.h" +#include <string> +#include <iosfwd> + + +namespace Poco { +namespace XML { + + +class XML_API QName + /// This class represents a qualified XML name in the stream parser. + /// + /// Note that the optional prefix is just a "syntactic sugar". In + /// particular, it is ignored by the comparison operators and the + /// std::ostream insertion operator. +{ +public: + QName(); + QName(const std::string& name); + QName(const std::string& ns, const std::string& name); + QName(const std::string& ns, const std::string& name, const std::string& prefix); + + const std::string& namespaceURI() const; + /// Returns the namespace URI part of the name. + + const std::string& localName() const; + /// Returns the local part of the name. + + const std::string& prefix() const; + /// Returns the namespace prefix of the name. + + std::string& namespaceURI(); + /// Returns the namespace URI part of the name. + + std::string& localName(); + /// Returns the local part of the name. + + std::string& prefix(); + /// Returns the namespace prefix of the name. + + std::string toString() const; + /// Returns a printable representation in the [<namespace>#]<name> form. + +public: + friend bool operator < (const QName& x, const QName& y) + { + return x._ns < y._ns || (x._ns == y._ns && x._name < y._name); + } + + friend bool operator == (const QName& x, const QName& y) + { + return x._ns == y._ns && x._name == y._name; + } + + friend bool operator != (const QName& x, const QName& y) + { + return !(x == y); + } + +private: + std::string _ns; + std::string _name; + std::string _prefix; +}; + + +// +// inlines +// +inline const std::string& QName::namespaceURI() const +{ + return _ns; +} + + +inline const std::string& QName::localName() const +{ + return _name; +} + + +inline const std::string& QName::prefix() const +{ + return _prefix; +} + + +inline std::string& QName::namespaceURI() +{ + return _ns; +} + + +inline std::string& QName::localName() +{ + return _name; +} + + +inline std::string& QName::prefix() +{ + return _prefix; +} + + +XML_API std::ostream& operator << (std::ostream&, const QName&); + + +} } // namespace Poco::XML + + +#endif // XML_QName_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/ValueTraits.h b/contrib/libs/poco/XML/include/Poco/XML/ValueTraits.h index 46631c9398..d8fa26cd13 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/ValueTraits.h +++ b/contrib/libs/poco/XML/include/Poco/XML/ValueTraits.h @@ -1,104 +1,104 @@ -// -// ValueTraits.h -// -// 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 -// - - -#ifndef XML_ValueTraits_INCLUDED -#define XML_ValueTraits_INCLUDED - - -#include "XMLStreamParserException.h" -#include <string> -#include <cstddef> -#include <iostream> -#include <sstream> - - -namespace Poco { -namespace XML { - - -class XMLStreamParser; -class XMLStreamSerializer; - - -template <typename T> -struct DefaultValueTraits -{ - static T - parse(std::string, const XMLStreamParser&); - - static std::string - serialize(const T&, const XMLStreamSerializer&); -}; - - -template <> -struct XML_API DefaultValueTraits<bool> -{ - static bool - parse(std::string, const XMLStreamParser&); - - static std::string serialize(bool v, const XMLStreamSerializer&) - { - return v ? "true" : "false"; - } -}; - - -template <> -struct XML_API DefaultValueTraits<std::string> -{ - static std::string parse(std::string s, const XMLStreamParser&) - { - return s; - } - - static std::string serialize(const std::string& v, const XMLStreamSerializer&) - { - return v; - } -}; - - -template <typename T> -struct ValueTraits: DefaultValueTraits<T> -{ -}; - - -template <typename T, std::size_t N> -struct ValueTraits<T[N]> : DefaultValueTraits<const T*> -{ -}; - - -template <typename T> -T DefaultValueTraits<T>::parse(std::string s, const XMLStreamParser& p) -{ - T r; - std::istringstream is(s); - if (!(is >> r && is.eof())) - throw XMLStreamParserException(p, "invalid value '" + s + "'"); - return r; -} - - -} } // namespace Poco::XML - - -#endif // XML_ValueTraits_INCLUDED +// +// ValueTraits.h +// +// 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 +// + + +#ifndef XML_ValueTraits_INCLUDED +#define XML_ValueTraits_INCLUDED + + +#include "XMLStreamParserException.h" +#include <string> +#include <cstddef> +#include <iostream> +#include <sstream> + + +namespace Poco { +namespace XML { + + +class XMLStreamParser; +class XMLStreamSerializer; + + +template <typename T> +struct DefaultValueTraits +{ + static T + parse(std::string, const XMLStreamParser&); + + static std::string + serialize(const T&, const XMLStreamSerializer&); +}; + + +template <> +struct XML_API DefaultValueTraits<bool> +{ + static bool + parse(std::string, const XMLStreamParser&); + + static std::string serialize(bool v, const XMLStreamSerializer&) + { + return v ? "true" : "false"; + } +}; + + +template <> +struct XML_API DefaultValueTraits<std::string> +{ + static std::string parse(std::string s, const XMLStreamParser&) + { + return s; + } + + static std::string serialize(const std::string& v, const XMLStreamSerializer&) + { + return v; + } +}; + + +template <typename T> +struct ValueTraits: DefaultValueTraits<T> +{ +}; + + +template <typename T, std::size_t N> +struct ValueTraits<T[N]> : DefaultValueTraits<const T*> +{ +}; + + +template <typename T> +T DefaultValueTraits<T>::parse(std::string s, const XMLStreamParser& p) +{ + T r; + std::istringstream is(s); + if (!(is >> r && is.eof())) + throw XMLStreamParserException(p, "invalid value '" + s + "'"); + return r; +} + + +} } // namespace Poco::XML + + +#endif // XML_ValueTraits_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/XML.h b/contrib/libs/poco/XML/include/Poco/XML/XML.h index 19a21a3b47..59cb1a2f97 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/XML.h +++ b/contrib/libs/poco/XML/include/Poco/XML/XML.h @@ -1,62 +1,62 @@ -// -// XML.h -// -// Library: XML -// Package: XML -// Module: XML -// -// Basic definitions for the Poco XML library. -// This file must be the first file included by every other XML -// header file. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef XML_XML_INCLUDED -#define XML_XML_INCLUDED - - -#include "Poco/Foundation.h" - - -// -// The following block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the XML_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// XML_API functions as being imported from a DLL, whereas this DLL sees symbols -// defined with this macro as being exported. -// -#if defined(_WIN32) && defined(POCO_DLL) - #if defined(XML_EXPORTS) - #define XML_API __declspec(dllexport) - #else - #define XML_API __declspec(dllimport) - #endif -#endif - - -#if !defined(XML_API) - #if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4) - #define XML_API __attribute__ ((visibility ("default"))) - #else - #define XML_API - #endif -#endif - - -// -// Automatically link XML library. -// -#if defined(_MSC_VER) - #if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(XML_EXPORTS) - #pragma comment(lib, "PocoXML" POCO_LIB_SUFFIX) - #endif -#endif - - -#endif // XML_XML_INCLUDED +// +// XML.h +// +// Library: XML +// Package: XML +// Module: XML +// +// Basic definitions for the Poco XML library. +// This file must be the first file included by every other XML +// header file. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef XML_XML_INCLUDED +#define XML_XML_INCLUDED + + +#include "Poco/Foundation.h" + + +// +// The following block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the XML_EXPORTS +// symbol defined on the command line. this symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// XML_API functions as being imported from a DLL, whereas this DLL sees symbols +// defined with this macro as being exported. +// +#if defined(_WIN32) && defined(POCO_DLL) + #if defined(XML_EXPORTS) + #define XML_API __declspec(dllexport) + #else + #define XML_API __declspec(dllimport) + #endif +#endif + + +#if !defined(XML_API) + #if !defined(POCO_NO_GCC_API_ATTRIBUTE) && defined (__GNUC__) && (__GNUC__ >= 4) + #define XML_API __attribute__ ((visibility ("default"))) + #else + #define XML_API + #endif +#endif + + +// +// Automatically link XML library. +// +#if defined(_MSC_VER) + #if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(XML_EXPORTS) + #pragma comment(lib, "PocoXML" POCO_LIB_SUFFIX) + #endif +#endif + + +#endif // XML_XML_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/XMLException.h b/contrib/libs/poco/XML/include/Poco/XML/XMLException.h index 9805badf06..d8e255388b 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/XMLException.h +++ b/contrib/libs/poco/XML/include/Poco/XML/XMLException.h @@ -1,37 +1,37 @@ -// -// XMLException.h -// -// Library: XML -// Package: XML -// Module: XMLException -// -// Definition of the XMLException class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef XML_XMLException_INCLUDED -#define XML_XMLException_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/Exception.h" - - -namespace Poco { -namespace XML { - - -POCO_DECLARE_EXCEPTION(XML_API, XMLException, Poco::RuntimeException) - /// The base class for all XML-related exceptions like SAXException - /// and DOMException. - - -} } // namespace Poco::XML - - -#endif // XML_XMLException_INCLUDED +// +// XMLException.h +// +// Library: XML +// Package: XML +// Module: XMLException +// +// Definition of the XMLException class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef XML_XMLException_INCLUDED +#define XML_XMLException_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/Exception.h" + + +namespace Poco { +namespace XML { + + +POCO_DECLARE_EXCEPTION(XML_API, XMLException, Poco::RuntimeException) + /// The base class for all XML-related exceptions like SAXException + /// and DOMException. + + +} } // namespace Poco::XML + + +#endif // XML_XMLException_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/XMLStream.h b/contrib/libs/poco/XML/include/Poco/XML/XMLStream.h index e75705a255..316af26054 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/XMLStream.h +++ b/contrib/libs/poco/XML/include/Poco/XML/XMLStream.h @@ -1,71 +1,71 @@ -// -// XMLStream.h -// -// Library: XML -// Package: XML -// Module: XMLStream -// -// Definition of the XMLByteInputStream and XMLCharInputStream classes. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef XML_XMLStream_INCLUDED -#define XML_XMLStream_INCLUDED - - -#include "Poco/XML/XML.h" -#include <istream> -#include <ostream> - - -namespace Poco { -namespace XML { - - -// The byte input stream is always a narrow stream. -typedef std::istream XMLByteInputStream; -typedef std::ostream XMLByteOutputStream; - - -// -// The XML parser uses the stream classes provided by the C++ -// standard library (based on the basic_stream<> template). -// In Unicode mode, a wide stream is used. -// To turn on Unicode mode, #define XML_UNICODE and -// XML_UNICODE_WCHAR_T when compiling the library. -// -// XML_UNICODE XML_UNICODE_WCHAR_T XMLCharInputStream XMLCharOutputStream -// ------------------------------------------------------------------------- -// N N std::istream std::ostream -// N Y std::wistream std::wostream -// Y Y std::wistream std::wostream -// Y N <not supported> -// -#if defined(XML_UNICODE_WCHAR_T) - - // Unicode - use wide streams - typedef std::wistream XMLCharInputStream; - typedef std::wostream XMLCharOutputStream; - -#elif defined(XML_UNICODE) - - // not supported - leave XMLString undefined - -#else - - // Characters are UTF-8 encoded - typedef std::istream XMLCharInputStream; - typedef std::ostream XMLCharOutputStream; - -#endif - - -} } // namespace Poco::XML - - -#endif // XML_XMLStream_INCLUDED +// +// XMLStream.h +// +// Library: XML +// Package: XML +// Module: XMLStream +// +// Definition of the XMLByteInputStream and XMLCharInputStream classes. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef XML_XMLStream_INCLUDED +#define XML_XMLStream_INCLUDED + + +#include "Poco/XML/XML.h" +#include <istream> +#include <ostream> + + +namespace Poco { +namespace XML { + + +// The byte input stream is always a narrow stream. +typedef std::istream XMLByteInputStream; +typedef std::ostream XMLByteOutputStream; + + +// +// The XML parser uses the stream classes provided by the C++ +// standard library (based on the basic_stream<> template). +// In Unicode mode, a wide stream is used. +// To turn on Unicode mode, #define XML_UNICODE and +// XML_UNICODE_WCHAR_T when compiling the library. +// +// XML_UNICODE XML_UNICODE_WCHAR_T XMLCharInputStream XMLCharOutputStream +// ------------------------------------------------------------------------- +// N N std::istream std::ostream +// N Y std::wistream std::wostream +// Y Y std::wistream std::wostream +// Y N <not supported> +// +#if defined(XML_UNICODE_WCHAR_T) + + // Unicode - use wide streams + typedef std::wistream XMLCharInputStream; + typedef std::wostream XMLCharOutputStream; + +#elif defined(XML_UNICODE) + + // not supported - leave XMLString undefined + +#else + + // Characters are UTF-8 encoded + typedef std::istream XMLCharInputStream; + typedef std::ostream XMLCharOutputStream; + +#endif + + +} } // namespace Poco::XML + + +#endif // XML_XMLStream_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParser.h b/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParser.h index 26ac78d369..f594a961a5 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParser.h +++ b/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParser.h @@ -1,634 +1,634 @@ -// -// XMLStreamParser.h -// -// Library: XML -// Package: XML -// Module: XMLStreamParser -// -// Definition of the XMLStreamParser class. -// -// 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 -// - - -#ifndef XML_XMLStreamParser_INCLUDED -#define XML_XMLStreamParser_INCLUDED - - -// We only support UTF-8 expat. -#ifdef XML_UNICODE -#error UTF-16 expat (XML_UNICODE defined) is not supported -#endif - - -#include "Poco/XML/QName.h" -#include "Poco/XML/ValueTraits.h" -#include "Poco/XML/Content.h" -#if defined(POCO_UNBUNDLED) -#include <expat.h> -#else -#error #include "Poco/XML/expat.h" -#endif -#include <map> -#include <vector> -#include <string> -#include <iosfwd> -#include <cstddef> - - -namespace Poco { -namespace XML { - - -class XML_API XMLStreamParser - /// The streaming XML pull parser and streaming XML serializer. The parser - /// is a conforming, non-validating XML 1.0 implementation (see Implementation Notes - /// for details). The application character encoding (that is, the encoding used - /// in the application's memory) for both parser and serializer is UTF-8. - /// The output encoding of the serializer is UTF-8 as well. The parser supports - /// UTF-8, UTF-16, ISO-8859-1, and US-ASCII input encodings. - /// - /// Attribute map: - /// - /// Attribute map lookup. If attribute is not found, then the version - /// without the default value throws an appropriate parsing exception - /// while the version with the default value returns that value. - /// - /// Note also that there is no attribute(ns, name) version since it - /// would conflict with attribute(name, dv) (qualified attributes - /// are not very common). - /// - /// Attribute map is valid throughout at the "element level" until - /// end_element and not just during EV_START_ELEMENT. As a special case, - /// the map is still valid after peek() that returned end_element until - /// this end_element event is retrieved with next(). - /// - /// Using parser: - /// - /// XMLStreamParser p(ifs, argv[1]); - /// for (XMLStreamParser::EventType e: p) - /// { - /// switch (e) - /// { - /// case XMLStreamParser::EV_START_ELEMENT: - /// cerr << p.line () << ':' << p.column () << ": start " << p.name () << endl; - /// break; - /// case XMLStreamParser::EV_END_ELEMENT: - /// cerr << p.line () << ':' << p.column () << ": end " << p.name () << endl; - /// break; - /// case XMLStreamParser::EV_START_ATTRIBUTE: - /// ... - /// case XMLStreamParser::EV_END_ATTRIBUTE: - /// ... - /// case XMLStreamParser::EV_CHARACTERS: - /// ... - /// } - /// } -{ -public: - enum EventType - /// Parsing events. - { - EV_START_ELEMENT, - EV_END_ELEMENT, - EV_START_ATTRIBUTE, - EV_END_ATTRIBUTE, - EV_CHARACTERS, - EV_START_NAMESPACE_DECL, - EV_END_NAMESPACE_DECL, - EV_EOF - }; - - typedef unsigned short FeatureType; - /// If both receive_attributes_event and RECEIVE_ATTRIBUTE_MAP are - /// specified, then RECEIVE_ATTRIBUTES_EVENT is assumed. - - static const FeatureType RECEIVE_ELEMENTS = 0x0001; - static const FeatureType RECEIVE_CHARACTERS = 0x0002; - static const FeatureType RECEIVE_ATTRIBUTE_MAP = 0x0004; - static const FeatureType RECEIVE_ATTRIBUTES_EVENT = 0x0008; - static const FeatureType RECEIVE_NAMESPACE_DECLS = 0x0010; - static const FeatureType RECEIVE_DEFAULT = RECEIVE_ELEMENTS | RECEIVE_CHARACTERS | RECEIVE_ATTRIBUTE_MAP; - - struct XML_API AttributeValueType - { - std::string value; - mutable bool handled; - }; - - typedef std::map<QName, AttributeValueType> AttributeMapType; - - struct XML_API Iterator - // C++11 range-based for support. Generally, the iterator interface - // doesn't make much sense for the XMLStreamParser so for now we have an - // implementation that is just enough to the range-based for. - { - typedef EventType value_type; - - Iterator(XMLStreamParser* p = 0, EventType e = EV_EOF): - _parser(p), - _e(e) - { - } - - value_type operator * () const - { - return _e; - } - - Iterator& operator ++ () - { - _e = _parser->next(); - return *this; - } - - bool operator == (Iterator y) const - /// Comparison only makes sense when comparing to end (eof). - { - return _e == EV_EOF && y._e == EV_EOF; - } - - bool operator != (Iterator y) const - /// Comparison only makes sense when comparing to end (eof). - { - return !(*this == y); - } - - private: - XMLStreamParser* _parser; - EventType _e; - }; - - Iterator begin() - { - return Iterator(this, next()); - } - - Iterator end() - { - return Iterator(this, EV_EOF); - } - - XMLStreamParser(std::istream&, const std::string& inputName, FeatureType = RECEIVE_DEFAULT); - /// The parser constructor takes three arguments: the stream to parse, - /// input name that is used in diagnostics to identify the document being - /// parsed, and the list of events we want the parser to report. - /// - /// Parse std::istream. Input name is used in diagnostics to identify - /// the document being parsed. - /// - /// If stream exceptions are enabled then std::ios_base::failure - /// exception is used to report io errors (badbit and failbit). - /// Otherwise, those are reported as the parsing exception. - - XMLStreamParser(const void* data, std::size_t size, const std::string& inputName, FeatureType = RECEIVE_DEFAULT); - /// Parse memory buffer that contains the whole document. Input name - /// is used in diagnostics to identify the document being parsed. - - ~XMLStreamParser(); - /// Destroys the XMLStreamParser. - - EventType next(); - /// Call the next() function when we are ready to handle the next piece of XML. - - void nextExpect(EventType); - /// Get the next event and make sure that it's what's expected. If it - /// is not, then throw an appropriate parsing exception. - - void nextExpect(EventType, const std::string& name); - void nextExpect(EventType, const QName& qname); - void nextExpect(EventType, const std::string& ns, const std::string& name); - - EventType peek(); - EventType event(); - /// Return the event that was last returned by the call to next() or peek(). - - const std::string& inputName() const; - const QName& getQName() const; - const std::string& namespaceURI() const; - const std::string& localName() const; - const std::string& prefix() const; - std::string& value(); - const std::string& value() const; - template <typename T> T value() const; - Poco::UInt64 line() const; - Poco::UInt64 column() const; - const std::string& attribute(const std::string& name) const; - template <typename T> - T attribute(const std::string& name) const; - std::string attribute(const std::string& name, const std::string& deflt) const; - template <typename T> - T attribute(const std::string& name, const T& deflt) const; - const std::string& attribute(const QName& qname) const; - template <typename T> - T attribute(const QName& qname) const; - std::string attribute(const QName& qname, const std::string& deflt) const; - template <typename T> - T attribute(const QName& qname, const T& deflt) const; - bool attributePresent(const std::string& name) const; - bool attributePresent(const QName& qname) const; - const AttributeMapType& attributeMap() const; - - void content(Content); - Content content() const; - - void nextExpect(EventType, const std::string& name, Content); - void nextExpect(EventType, const QName& qname, Content); - void nextExpect(EventType, const std::string& ns, const std::string& name, Content); - - // Helpers for parsing elements with simple content. The first two - // functions assume that EV_START_ELEMENT has already been parsed. The - // rest parse the complete element, from start to end. - // - // Note also that as with attribute(), there is no (namespace,name) - // overload since it would conflicts with (namespace,deflt). - std::string element(); - - template <typename T> - T element(); - std::string element(const std::string& name); - std::string element(const QName& qname); - template <typename T> - T element(const std::string& name); - template <typename T> - T element(const QName& qname); - std::string element(const std::string& name, const std::string& deflt); - std::string element(const QName& qname, const std::string& deflt); - template <typename T> - T element(const std::string& name, const T& deflt); - template <typename T> - T element(const QName& qname, const T& deflt); - -private: - XMLStreamParser(const XMLStreamParser&); - XMLStreamParser& operator = (const XMLStreamParser&); - - static void XMLCALL handleStartElement(void*, const XML_Char*, const XML_Char**); - static void XMLCALL handleEndElement(void*, const XML_Char*); - static void XMLCALL handleCharacters(void*, const XML_Char*, int); - static void XMLCALL handleStartNamespaceDecl(void*, const XML_Char*, const XML_Char*); - static void XMLCALL handleEndNamespaceDecl(void*, const XML_Char*); - - void init(); - EventType nextImpl(bool peek); - EventType nextBody(); - void handleError(); - - // If _size is 0, then data is std::istream. Otherwise, it is a buffer. - union - { - std::istream* is; - const void* buf; - } - _data; - - std::size_t _size; - const std::string _inputName; - FeatureType _feature; - XML_Parser _parser; - std::size_t _depth; - bool _accumulateContent; // Whether we are accumulating character content. - enum { state_next, state_peek } _parserState; - EventType _currentEvent; - EventType _queue; - QName _qname; - std::string _value; - const QName* _qualifiedName; - std::string* _pvalue; - Poco::UInt64 _line; - Poco::UInt64 _column; - - struct AttributeType - { - QName qname; - std::string value; - }; - - typedef std::vector<AttributeType> attributes; - attributes _attributes; - attributes::size_type _currentAttributeIndex; // Index of the current attribute. - - typedef std::vector<QName> NamespaceDecls; - NamespaceDecls _startNamespace; - NamespaceDecls::size_type _startNamespaceIndex;// Index of the current decl. - NamespaceDecls _endNamespace; - NamespaceDecls::size_type _endNamespaceIndex;// Index of the current decl. - - struct ElementEntry - { - ElementEntry(std::size_t d, Content c = Content::Mixed): - depth(d), - content(c), - attributesUnhandled(0) - { - } - - std::size_t depth; - Content content; - AttributeMapType attributeMap; - mutable AttributeMapType::size_type attributesUnhandled; - }; - - typedef std::vector<ElementEntry> ElementState; - std::vector<ElementEntry> _elementState; - - const AttributeMapType _emptyAttrMap; - - const ElementEntry* getElement() const; - const ElementEntry* getElementImpl() const; - void popElement(); -}; - - -XML_API std::ostream& operator << (std::ostream&, XMLStreamParser::EventType); - - -// -// inlines -// -inline XMLStreamParser::EventType XMLStreamParser::event() - // Return the even that was last returned by the call to next() or peek(). -{ - return _currentEvent; -} - - -inline const std::string& XMLStreamParser::inputName() const -{ - return _inputName; -} - - -inline const QName& XMLStreamParser::getQName() const -{ - return *_qualifiedName; -} - - -inline const std::string& XMLStreamParser::namespaceURI() const -{ - return _qualifiedName->namespaceURI(); -} - - -inline const std::string& XMLStreamParser::localName() const -{ - return _qualifiedName->localName(); -} - - -inline const std::string& XMLStreamParser::prefix() const -{ - return _qualifiedName->prefix(); -} - - -inline std::string& XMLStreamParser::value() -{ - return *_pvalue; -} - - -inline const std::string& XMLStreamParser::value() const -{ - return *_pvalue; -} - - -inline Poco::UInt64 XMLStreamParser::line() const -{ - return _line; -} - - -inline Poco::UInt64 XMLStreamParser::column() const -{ - return _column; -} - - -inline XMLStreamParser::EventType XMLStreamParser::peek() -{ - if (_parserState == state_peek) - return _currentEvent; - else - { - EventType e(nextImpl(true)); - _parserState = state_peek; // Set it after the call to nextImpl(). - return e; - } -} - - -template <typename T> -inline T XMLStreamParser::value() const -{ - return ValueTraits < T > ::parse(value(), *this); -} - - -inline const std::string& XMLStreamParser::attribute(const std::string& n) const -{ - return attribute(QName(n)); -} - - -template <typename T> -inline T XMLStreamParser::attribute(const std::string& n) const -{ - return attribute < T > (QName(n)); -} - - -inline std::string XMLStreamParser::attribute(const std::string& n, const std::string& dv) const -{ - return attribute(QName(n), dv); -} - - -template <typename T> -inline T XMLStreamParser::attribute(const std::string& n, const T& dv) const -{ - return attribute < T > (QName(n), dv); -} - - -template <typename T> -inline T XMLStreamParser::attribute(const QName& qn) const -{ - return ValueTraits < T > ::parse(attribute(qn), *this); -} - - -inline bool XMLStreamParser::attributePresent(const std::string& n) const -{ - return attributePresent(QName(n)); -} - - -inline const XMLStreamParser::AttributeMapType& XMLStreamParser::attributeMap() const -{ - if (const ElementEntry* e = getElement()) - { - e->attributesUnhandled = 0; // Assume all handled. - return e->attributeMap; - } - - return _emptyAttrMap; -} - - -inline void XMLStreamParser::nextExpect(EventType e, const QName& qn) -{ - nextExpect(e, qn.namespaceURI(), qn.localName()); -} - - -inline void XMLStreamParser::nextExpect(EventType e, const std::string& n) -{ - nextExpect(e, std::string(), n); -} - - -inline void XMLStreamParser::nextExpect(EventType e, const QName& qn, Content c) -{ - nextExpect(e, qn); - poco_assert(e == EV_START_ELEMENT); - content(c); -} - - -inline void XMLStreamParser::nextExpect(EventType e, const std::string& n, Content c) -{ - nextExpect(e, std::string(), n); - poco_assert(e == EV_START_ELEMENT); - content(c); -} - - -inline void XMLStreamParser::nextExpect(EventType e, const std::string& ns, const std::string& n, Content c) -{ - nextExpect(e, ns, n); - poco_assert(e == EV_START_ELEMENT); - content(c); -} - - -template <typename T> -inline T XMLStreamParser::element() -{ - return ValueTraits < T > ::parse(element(), *this); -} - - -inline std::string XMLStreamParser::element(const std::string& n) -{ - nextExpect(EV_START_ELEMENT, n); - return element(); -} - - -inline std::string XMLStreamParser::element(const QName& qn) -{ - nextExpect(EV_START_ELEMENT, qn); - return element(); -} - - -template <typename T> -inline T XMLStreamParser::element(const std::string& n) -{ - return ValueTraits < T > ::parse(element(n), *this); -} - - -template <typename T> -inline T XMLStreamParser::element(const QName& qn) -{ - return ValueTraits < T > ::parse(element(qn), *this); -} - - -inline std::string XMLStreamParser::element(const std::string& n, const std::string& dv) -{ - return element(QName(n), dv); -} - - -template <typename T> -inline T XMLStreamParser::element(const std::string& n, const T& dv) -{ - return element < T > (QName(n), dv); -} - - -inline void XMLStreamParser::content(Content c) -{ - poco_assert(_parserState == state_next); - - if (!_elementState.empty() && _elementState.back().depth == _depth) - _elementState.back().content = c; - else - _elementState.push_back(ElementEntry(_depth, c)); -} - - -inline Content XMLStreamParser::content() const -{ - poco_assert(_parserState == state_next); - - return !_elementState.empty() && _elementState.back().depth == _depth ? _elementState.back().content : Content(Content::Mixed); -} - - -inline const XMLStreamParser::ElementEntry* XMLStreamParser::getElement() const -{ - return _elementState.empty() ? 0 : getElementImpl(); -} - - -template <typename T> -T XMLStreamParser::attribute(const QName& qn, const T& 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 ValueTraits < T > ::parse(i->second.value, *this); - } - } - - return dv; -} - - -template <typename T> -T XMLStreamParser::element(const QName& qn, const T& dv) -{ - if (peek() == EV_START_ELEMENT && getQName() == qn) - { - next(); - return element<T>(); - } - - return dv; -} - - -} } // namespace Poco::XML - - -#endif // XML_XMLStreamParser_INCLUDED +// +// XMLStreamParser.h +// +// Library: XML +// Package: XML +// Module: XMLStreamParser +// +// Definition of the XMLStreamParser class. +// +// 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 +// + + +#ifndef XML_XMLStreamParser_INCLUDED +#define XML_XMLStreamParser_INCLUDED + + +// We only support UTF-8 expat. +#ifdef XML_UNICODE +#error UTF-16 expat (XML_UNICODE defined) is not supported +#endif + + +#include "Poco/XML/QName.h" +#include "Poco/XML/ValueTraits.h" +#include "Poco/XML/Content.h" +#if defined(POCO_UNBUNDLED) +#include <expat.h> +#else +#error #include "Poco/XML/expat.h" +#endif +#include <map> +#include <vector> +#include <string> +#include <iosfwd> +#include <cstddef> + + +namespace Poco { +namespace XML { + + +class XML_API XMLStreamParser + /// The streaming XML pull parser and streaming XML serializer. The parser + /// is a conforming, non-validating XML 1.0 implementation (see Implementation Notes + /// for details). The application character encoding (that is, the encoding used + /// in the application's memory) for both parser and serializer is UTF-8. + /// The output encoding of the serializer is UTF-8 as well. The parser supports + /// UTF-8, UTF-16, ISO-8859-1, and US-ASCII input encodings. + /// + /// Attribute map: + /// + /// Attribute map lookup. If attribute is not found, then the version + /// without the default value throws an appropriate parsing exception + /// while the version with the default value returns that value. + /// + /// Note also that there is no attribute(ns, name) version since it + /// would conflict with attribute(name, dv) (qualified attributes + /// are not very common). + /// + /// Attribute map is valid throughout at the "element level" until + /// end_element and not just during EV_START_ELEMENT. As a special case, + /// the map is still valid after peek() that returned end_element until + /// this end_element event is retrieved with next(). + /// + /// Using parser: + /// + /// XMLStreamParser p(ifs, argv[1]); + /// for (XMLStreamParser::EventType e: p) + /// { + /// switch (e) + /// { + /// case XMLStreamParser::EV_START_ELEMENT: + /// cerr << p.line () << ':' << p.column () << ": start " << p.name () << endl; + /// break; + /// case XMLStreamParser::EV_END_ELEMENT: + /// cerr << p.line () << ':' << p.column () << ": end " << p.name () << endl; + /// break; + /// case XMLStreamParser::EV_START_ATTRIBUTE: + /// ... + /// case XMLStreamParser::EV_END_ATTRIBUTE: + /// ... + /// case XMLStreamParser::EV_CHARACTERS: + /// ... + /// } + /// } +{ +public: + enum EventType + /// Parsing events. + { + EV_START_ELEMENT, + EV_END_ELEMENT, + EV_START_ATTRIBUTE, + EV_END_ATTRIBUTE, + EV_CHARACTERS, + EV_START_NAMESPACE_DECL, + EV_END_NAMESPACE_DECL, + EV_EOF + }; + + typedef unsigned short FeatureType; + /// If both receive_attributes_event and RECEIVE_ATTRIBUTE_MAP are + /// specified, then RECEIVE_ATTRIBUTES_EVENT is assumed. + + static const FeatureType RECEIVE_ELEMENTS = 0x0001; + static const FeatureType RECEIVE_CHARACTERS = 0x0002; + static const FeatureType RECEIVE_ATTRIBUTE_MAP = 0x0004; + static const FeatureType RECEIVE_ATTRIBUTES_EVENT = 0x0008; + static const FeatureType RECEIVE_NAMESPACE_DECLS = 0x0010; + static const FeatureType RECEIVE_DEFAULT = RECEIVE_ELEMENTS | RECEIVE_CHARACTERS | RECEIVE_ATTRIBUTE_MAP; + + struct XML_API AttributeValueType + { + std::string value; + mutable bool handled; + }; + + typedef std::map<QName, AttributeValueType> AttributeMapType; + + struct XML_API Iterator + // C++11 range-based for support. Generally, the iterator interface + // doesn't make much sense for the XMLStreamParser so for now we have an + // implementation that is just enough to the range-based for. + { + typedef EventType value_type; + + Iterator(XMLStreamParser* p = 0, EventType e = EV_EOF): + _parser(p), + _e(e) + { + } + + value_type operator * () const + { + return _e; + } + + Iterator& operator ++ () + { + _e = _parser->next(); + return *this; + } + + bool operator == (Iterator y) const + /// Comparison only makes sense when comparing to end (eof). + { + return _e == EV_EOF && y._e == EV_EOF; + } + + bool operator != (Iterator y) const + /// Comparison only makes sense when comparing to end (eof). + { + return !(*this == y); + } + + private: + XMLStreamParser* _parser; + EventType _e; + }; + + Iterator begin() + { + return Iterator(this, next()); + } + + Iterator end() + { + return Iterator(this, EV_EOF); + } + + XMLStreamParser(std::istream&, const std::string& inputName, FeatureType = RECEIVE_DEFAULT); + /// The parser constructor takes three arguments: the stream to parse, + /// input name that is used in diagnostics to identify the document being + /// parsed, and the list of events we want the parser to report. + /// + /// Parse std::istream. Input name is used in diagnostics to identify + /// the document being parsed. + /// + /// If stream exceptions are enabled then std::ios_base::failure + /// exception is used to report io errors (badbit and failbit). + /// Otherwise, those are reported as the parsing exception. + + XMLStreamParser(const void* data, std::size_t size, const std::string& inputName, FeatureType = RECEIVE_DEFAULT); + /// Parse memory buffer that contains the whole document. Input name + /// is used in diagnostics to identify the document being parsed. + + ~XMLStreamParser(); + /// Destroys the XMLStreamParser. + + EventType next(); + /// Call the next() function when we are ready to handle the next piece of XML. + + void nextExpect(EventType); + /// Get the next event and make sure that it's what's expected. If it + /// is not, then throw an appropriate parsing exception. + + void nextExpect(EventType, const std::string& name); + void nextExpect(EventType, const QName& qname); + void nextExpect(EventType, const std::string& ns, const std::string& name); + + EventType peek(); + EventType event(); + /// Return the event that was last returned by the call to next() or peek(). + + const std::string& inputName() const; + const QName& getQName() const; + const std::string& namespaceURI() const; + const std::string& localName() const; + const std::string& prefix() const; + std::string& value(); + const std::string& value() const; + template <typename T> T value() const; + Poco::UInt64 line() const; + Poco::UInt64 column() const; + const std::string& attribute(const std::string& name) const; + template <typename T> + T attribute(const std::string& name) const; + std::string attribute(const std::string& name, const std::string& deflt) const; + template <typename T> + T attribute(const std::string& name, const T& deflt) const; + const std::string& attribute(const QName& qname) const; + template <typename T> + T attribute(const QName& qname) const; + std::string attribute(const QName& qname, const std::string& deflt) const; + template <typename T> + T attribute(const QName& qname, const T& deflt) const; + bool attributePresent(const std::string& name) const; + bool attributePresent(const QName& qname) const; + const AttributeMapType& attributeMap() const; + + void content(Content); + Content content() const; + + void nextExpect(EventType, const std::string& name, Content); + void nextExpect(EventType, const QName& qname, Content); + void nextExpect(EventType, const std::string& ns, const std::string& name, Content); + + // Helpers for parsing elements with simple content. The first two + // functions assume that EV_START_ELEMENT has already been parsed. The + // rest parse the complete element, from start to end. + // + // Note also that as with attribute(), there is no (namespace,name) + // overload since it would conflicts with (namespace,deflt). + std::string element(); + + template <typename T> + T element(); + std::string element(const std::string& name); + std::string element(const QName& qname); + template <typename T> + T element(const std::string& name); + template <typename T> + T element(const QName& qname); + std::string element(const std::string& name, const std::string& deflt); + std::string element(const QName& qname, const std::string& deflt); + template <typename T> + T element(const std::string& name, const T& deflt); + template <typename T> + T element(const QName& qname, const T& deflt); + +private: + XMLStreamParser(const XMLStreamParser&); + XMLStreamParser& operator = (const XMLStreamParser&); + + static void XMLCALL handleStartElement(void*, const XML_Char*, const XML_Char**); + static void XMLCALL handleEndElement(void*, const XML_Char*); + static void XMLCALL handleCharacters(void*, const XML_Char*, int); + static void XMLCALL handleStartNamespaceDecl(void*, const XML_Char*, const XML_Char*); + static void XMLCALL handleEndNamespaceDecl(void*, const XML_Char*); + + void init(); + EventType nextImpl(bool peek); + EventType nextBody(); + void handleError(); + + // If _size is 0, then data is std::istream. Otherwise, it is a buffer. + union + { + std::istream* is; + const void* buf; + } + _data; + + std::size_t _size; + const std::string _inputName; + FeatureType _feature; + XML_Parser _parser; + std::size_t _depth; + bool _accumulateContent; // Whether we are accumulating character content. + enum { state_next, state_peek } _parserState; + EventType _currentEvent; + EventType _queue; + QName _qname; + std::string _value; + const QName* _qualifiedName; + std::string* _pvalue; + Poco::UInt64 _line; + Poco::UInt64 _column; + + struct AttributeType + { + QName qname; + std::string value; + }; + + typedef std::vector<AttributeType> attributes; + attributes _attributes; + attributes::size_type _currentAttributeIndex; // Index of the current attribute. + + typedef std::vector<QName> NamespaceDecls; + NamespaceDecls _startNamespace; + NamespaceDecls::size_type _startNamespaceIndex;// Index of the current decl. + NamespaceDecls _endNamespace; + NamespaceDecls::size_type _endNamespaceIndex;// Index of the current decl. + + struct ElementEntry + { + ElementEntry(std::size_t d, Content c = Content::Mixed): + depth(d), + content(c), + attributesUnhandled(0) + { + } + + std::size_t depth; + Content content; + AttributeMapType attributeMap; + mutable AttributeMapType::size_type attributesUnhandled; + }; + + typedef std::vector<ElementEntry> ElementState; + std::vector<ElementEntry> _elementState; + + const AttributeMapType _emptyAttrMap; + + const ElementEntry* getElement() const; + const ElementEntry* getElementImpl() const; + void popElement(); +}; + + +XML_API std::ostream& operator << (std::ostream&, XMLStreamParser::EventType); + + +// +// inlines +// +inline XMLStreamParser::EventType XMLStreamParser::event() + // Return the even that was last returned by the call to next() or peek(). +{ + return _currentEvent; +} + + +inline const std::string& XMLStreamParser::inputName() const +{ + return _inputName; +} + + +inline const QName& XMLStreamParser::getQName() const +{ + return *_qualifiedName; +} + + +inline const std::string& XMLStreamParser::namespaceURI() const +{ + return _qualifiedName->namespaceURI(); +} + + +inline const std::string& XMLStreamParser::localName() const +{ + return _qualifiedName->localName(); +} + + +inline const std::string& XMLStreamParser::prefix() const +{ + return _qualifiedName->prefix(); +} + + +inline std::string& XMLStreamParser::value() +{ + return *_pvalue; +} + + +inline const std::string& XMLStreamParser::value() const +{ + return *_pvalue; +} + + +inline Poco::UInt64 XMLStreamParser::line() const +{ + return _line; +} + + +inline Poco::UInt64 XMLStreamParser::column() const +{ + return _column; +} + + +inline XMLStreamParser::EventType XMLStreamParser::peek() +{ + if (_parserState == state_peek) + return _currentEvent; + else + { + EventType e(nextImpl(true)); + _parserState = state_peek; // Set it after the call to nextImpl(). + return e; + } +} + + +template <typename T> +inline T XMLStreamParser::value() const +{ + return ValueTraits < T > ::parse(value(), *this); +} + + +inline const std::string& XMLStreamParser::attribute(const std::string& n) const +{ + return attribute(QName(n)); +} + + +template <typename T> +inline T XMLStreamParser::attribute(const std::string& n) const +{ + return attribute < T > (QName(n)); +} + + +inline std::string XMLStreamParser::attribute(const std::string& n, const std::string& dv) const +{ + return attribute(QName(n), dv); +} + + +template <typename T> +inline T XMLStreamParser::attribute(const std::string& n, const T& dv) const +{ + return attribute < T > (QName(n), dv); +} + + +template <typename T> +inline T XMLStreamParser::attribute(const QName& qn) const +{ + return ValueTraits < T > ::parse(attribute(qn), *this); +} + + +inline bool XMLStreamParser::attributePresent(const std::string& n) const +{ + return attributePresent(QName(n)); +} + + +inline const XMLStreamParser::AttributeMapType& XMLStreamParser::attributeMap() const +{ + if (const ElementEntry* e = getElement()) + { + e->attributesUnhandled = 0; // Assume all handled. + return e->attributeMap; + } + + return _emptyAttrMap; +} + + +inline void XMLStreamParser::nextExpect(EventType e, const QName& qn) +{ + nextExpect(e, qn.namespaceURI(), qn.localName()); +} + + +inline void XMLStreamParser::nextExpect(EventType e, const std::string& n) +{ + nextExpect(e, std::string(), n); +} + + +inline void XMLStreamParser::nextExpect(EventType e, const QName& qn, Content c) +{ + nextExpect(e, qn); + poco_assert(e == EV_START_ELEMENT); + content(c); +} + + +inline void XMLStreamParser::nextExpect(EventType e, const std::string& n, Content c) +{ + nextExpect(e, std::string(), n); + poco_assert(e == EV_START_ELEMENT); + content(c); +} + + +inline void XMLStreamParser::nextExpect(EventType e, const std::string& ns, const std::string& n, Content c) +{ + nextExpect(e, ns, n); + poco_assert(e == EV_START_ELEMENT); + content(c); +} + + +template <typename T> +inline T XMLStreamParser::element() +{ + return ValueTraits < T > ::parse(element(), *this); +} + + +inline std::string XMLStreamParser::element(const std::string& n) +{ + nextExpect(EV_START_ELEMENT, n); + return element(); +} + + +inline std::string XMLStreamParser::element(const QName& qn) +{ + nextExpect(EV_START_ELEMENT, qn); + return element(); +} + + +template <typename T> +inline T XMLStreamParser::element(const std::string& n) +{ + return ValueTraits < T > ::parse(element(n), *this); +} + + +template <typename T> +inline T XMLStreamParser::element(const QName& qn) +{ + return ValueTraits < T > ::parse(element(qn), *this); +} + + +inline std::string XMLStreamParser::element(const std::string& n, const std::string& dv) +{ + return element(QName(n), dv); +} + + +template <typename T> +inline T XMLStreamParser::element(const std::string& n, const T& dv) +{ + return element < T > (QName(n), dv); +} + + +inline void XMLStreamParser::content(Content c) +{ + poco_assert(_parserState == state_next); + + if (!_elementState.empty() && _elementState.back().depth == _depth) + _elementState.back().content = c; + else + _elementState.push_back(ElementEntry(_depth, c)); +} + + +inline Content XMLStreamParser::content() const +{ + poco_assert(_parserState == state_next); + + return !_elementState.empty() && _elementState.back().depth == _depth ? _elementState.back().content : Content(Content::Mixed); +} + + +inline const XMLStreamParser::ElementEntry* XMLStreamParser::getElement() const +{ + return _elementState.empty() ? 0 : getElementImpl(); +} + + +template <typename T> +T XMLStreamParser::attribute(const QName& qn, const T& 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 ValueTraits < T > ::parse(i->second.value, *this); + } + } + + return dv; +} + + +template <typename T> +T XMLStreamParser::element(const QName& qn, const T& dv) +{ + if (peek() == EV_START_ELEMENT && getQName() == qn) + { + next(); + return element<T>(); + } + + return dv; +} + + +} } // namespace Poco::XML + + +#endif // XML_XMLStreamParser_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParserException.h b/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParserException.h index 88e4ff3304..edeca1f44d 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParserException.h +++ b/contrib/libs/poco/XML/include/Poco/XML/XMLStreamParserException.h @@ -1,58 +1,58 @@ -// -// XMLStreamParserException.h -// -// Library: XML -// Package: XML -// Module: XMLStreamParserException -// -// Definition of the XMLStreamParserException class. -// -// Copyright (c) 2015, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef XML_XMLStreamParserException_INCLUDED -#define XML_XMLStreamParserException_INCLUDED - - -#include "Poco/XML/XMLException.h" - - -namespace Poco { -namespace XML { - - -class XMLStreamParser; - - -class XML_API XMLStreamParserException: public Poco::XML::XMLException -{ -public: - XMLStreamParserException(const std::string& name, Poco::UInt64 line, Poco::UInt64 column, const std::string& description); - XMLStreamParserException(const XMLStreamParser&, const std::string& description); - virtual ~XMLStreamParserException() noexcept; - +// +// XMLStreamParserException.h +// +// Library: XML +// Package: XML +// Module: XMLStreamParserException +// +// Definition of the XMLStreamParserException class. +// +// Copyright (c) 2015, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef XML_XMLStreamParserException_INCLUDED +#define XML_XMLStreamParserException_INCLUDED + + +#include "Poco/XML/XMLException.h" + + +namespace Poco { +namespace XML { + + +class XMLStreamParser; + + +class XML_API XMLStreamParserException: public Poco::XML::XMLException +{ +public: + XMLStreamParserException(const std::string& name, Poco::UInt64 line, Poco::UInt64 column, const std::string& description); + XMLStreamParserException(const XMLStreamParser&, const std::string& description); + virtual ~XMLStreamParserException() noexcept; + const char* name() const noexcept; - Poco::UInt64 line() const; - Poco::UInt64 column() const; - const std::string& description() const; + Poco::UInt64 line() const; + Poco::UInt64 column() const; + const std::string& description() const; virtual const char* what() const noexcept; - -private: - void init(); - - std::string _name; - Poco::UInt64 _line; - Poco::UInt64 _column; - std::string _description; - std::string _what; -}; - - -} } // namespace Poco::XML - - -#endif // XML_XMLStreamParserException_INCLUDED + +private: + void init(); + + std::string _name; + Poco::UInt64 _line; + Poco::UInt64 _column; + std::string _description; + std::string _what; +}; + + +} } // namespace Poco::XML + + +#endif // XML_XMLStreamParserException_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/XMLString.h b/contrib/libs/poco/XML/include/Poco/XML/XMLString.h index 4f6d24b418..123d9f4547 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/XMLString.h +++ b/contrib/libs/poco/XML/include/Poco/XML/XMLString.h @@ -1,87 +1,87 @@ -// -// XMLString.h -// -// Library: XML -// Package: XML -// Module: XMLString -// -// Definition of the XMLString class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef XML_XMLString_INCLUDED -#define XML_XMLString_INCLUDED - - -#include "Poco/XML/XML.h" - - -namespace Poco { -namespace XML { - - -// -// The XML parser uses the string classes provided by the C++ -// standard library (based on the basic_string<> template). -// In Unicode mode, a std::wstring is used, otherwise -// a std::string is used. -// To turn on Unicode mode, #define XML_UNICODE and -// XML_UNICODE_WCHAR_T when compiling the library. -// -// XML_UNICODE XML_UNICODE_WCHAR_T XMLChar XMLString -// -------------------------------------------------------------- -// N N char std::string -// N Y wchar_t std::wstring -// Y Y wchar_t std::wstring -// Y N <not supported> -// -#if defined(XML_UNICODE_WCHAR_T) - - // Unicode - use wchar_t - typedef wchar_t XMLChar; - typedef std::wstring XMLString; - - std::string fromXMLString(const XMLString& str); - /// Converts an XMLString into an UTF-8 encoded - /// string. - - XMLString toXMLString(const std::string& str); - /// Converts an UTF-8 encoded string into an - /// XMLString - - #define XML_LIT(lit) L##lit - -#elif defined(XML_UNICODE) - - // not supported - leave XMLString undefined - -#else - - // Characters are UTF-8 encoded - typedef char XMLChar; - typedef std::string XMLString; - - inline const std::string& fromXMLString(const XMLString& str) - { - return str; - } - - inline const XMLString& toXMLString(const std::string& str) - { - return str; - } - - #define XML_LIT(lit) lit - -#endif - - -} } // namespace Poco::XML - - -#endif // XML_XMLString_INCLUDED +// +// XMLString.h +// +// Library: XML +// Package: XML +// Module: XMLString +// +// Definition of the XMLString class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef XML_XMLString_INCLUDED +#define XML_XMLString_INCLUDED + + +#include "Poco/XML/XML.h" + + +namespace Poco { +namespace XML { + + +// +// The XML parser uses the string classes provided by the C++ +// standard library (based on the basic_string<> template). +// In Unicode mode, a std::wstring is used, otherwise +// a std::string is used. +// To turn on Unicode mode, #define XML_UNICODE and +// XML_UNICODE_WCHAR_T when compiling the library. +// +// XML_UNICODE XML_UNICODE_WCHAR_T XMLChar XMLString +// -------------------------------------------------------------- +// N N char std::string +// N Y wchar_t std::wstring +// Y Y wchar_t std::wstring +// Y N <not supported> +// +#if defined(XML_UNICODE_WCHAR_T) + + // Unicode - use wchar_t + typedef wchar_t XMLChar; + typedef std::wstring XMLString; + + std::string fromXMLString(const XMLString& str); + /// Converts an XMLString into an UTF-8 encoded + /// string. + + XMLString toXMLString(const std::string& str); + /// Converts an UTF-8 encoded string into an + /// XMLString + + #define XML_LIT(lit) L##lit + +#elif defined(XML_UNICODE) + + // not supported - leave XMLString undefined + +#else + + // Characters are UTF-8 encoded + typedef char XMLChar; + typedef std::string XMLString; + + inline const std::string& fromXMLString(const XMLString& str) + { + return str; + } + + inline const XMLString& toXMLString(const std::string& str) + { + return str; + } + + #define XML_LIT(lit) lit + +#endif + + +} } // namespace Poco::XML + + +#endif // XML_XMLString_INCLUDED diff --git a/contrib/libs/poco/XML/include/Poco/XML/XMLWriter.h b/contrib/libs/poco/XML/include/Poco/XML/XMLWriter.h index b87fd30c47..d0936c0fdc 100644 --- a/contrib/libs/poco/XML/include/Poco/XML/XMLWriter.h +++ b/contrib/libs/poco/XML/include/Poco/XML/XMLWriter.h @@ -1,375 +1,375 @@ -// -// XMLWriter.h -// -// Library: XML -// Package: XML -// Module: XMLWriter -// -// Definition of the XMLWriter class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef XML_XMLWriter_INCLUDED -#define XML_XMLWriter_INCLUDED - - -#include "Poco/XML/XML.h" -#include "Poco/SAX/ContentHandler.h" -#include "Poco/SAX/LexicalHandler.h" -#include "Poco/SAX/DTDHandler.h" -#include "Poco/SAX/NamespaceSupport.h" -#include "Poco/XML/XMLString.h" -#include "Poco/XML/XMLStream.h" -#include "Poco/XML/Name.h" -#include "Poco/TextEncoding.h" -#include "Poco/StreamConverter.h" -#include <vector> -#include <map> - - -namespace Poco { -namespace XML { - - -class Locator; - - -class XML_API XMLWriter: public ContentHandler, public LexicalHandler, public DTDHandler - /// This class serializes SAX2 ContentHandler, LexicalHandler and - /// DTDHandler events back into a stream. +// +// XMLWriter.h +// +// Library: XML +// Package: XML +// Module: XMLWriter +// +// Definition of the XMLWriter class. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef XML_XMLWriter_INCLUDED +#define XML_XMLWriter_INCLUDED + + +#include "Poco/XML/XML.h" +#include "Poco/SAX/ContentHandler.h" +#include "Poco/SAX/LexicalHandler.h" +#include "Poco/SAX/DTDHandler.h" +#include "Poco/SAX/NamespaceSupport.h" +#include "Poco/XML/XMLString.h" +#include "Poco/XML/XMLStream.h" +#include "Poco/XML/Name.h" +#include "Poco/TextEncoding.h" +#include "Poco/StreamConverter.h" +#include <vector> +#include <map> + + +namespace Poco { +namespace XML { + + +class Locator; + + +class XML_API XMLWriter: public ContentHandler, public LexicalHandler, public DTDHandler + /// This class serializes SAX2 ContentHandler, LexicalHandler and + /// DTDHandler events back into a stream. + /// + /// Various consistency checks are performed on the written data + /// (i.e. there must be exactly one root element and every startElement() + /// must have a matching endElement()). /// - /// Various consistency checks are performed on the written data - /// (i.e. there must be exactly one root element and every startElement() - /// must have a matching endElement()). - /// - /// The XMLWriter supports optional pretty-printing of the serialized XML. - /// Note, however, that pretty-printing XML data alters the - /// information set of the document being written, since in - /// XML all whitespace is potentially relevant to an application. - /// - /// The writer contains extensive support for XML Namespaces, so that a client - /// application does not have to keep track of prefixes and supply xmlns attributes. - /// - /// If the client does not provide namespace prefixes (either by specifying them - /// as part of the qualified name given to startElement(), or by calling - /// startPrefixMapping()), the XMLWriter automatically generates namespace - /// prefixes in the form ns1, ns2, etc. -{ -public: - enum Options - { - CANONICAL = 0x00, - /// Do not write an XML declaration (default). - - CANONICAL_XML = 0x01, - /// Enables basic support for Canonical XML: - /// - do not write an XML declaration - /// - do not use special empty element syntax - /// - set the New Line character to NEWLINE_LF - /// - write namespace declarations and attributes - /// in canonical order - /// - use default namespace as much as possible - - WRITE_XML_DECLARATION = 0x02, - /// Write an XML declaration. - - PRETTY_PRINT = 0x04, - /// Pretty-print XML markup. - - PRETTY_PRINT_ATTRIBUTES = 0x08 - /// Write each attribute on a separate line. - /// PRETTY_PRINT must be specified as well. - }; - - XMLWriter(XMLByteOutputStream& str, int options); - /// Creates the XMLWriter and sets the specified options. - /// - /// The resulting stream will be UTF-8 encoded. - - XMLWriter(XMLByteOutputStream& str, int options, const std::string& encodingName, Poco::TextEncoding& textEncoding); - /// Creates the XMLWriter and sets the specified options. - /// - /// The encoding is reflected in the XML declaration. - /// The caller is responsible for that the given encodingName matches with - /// the given textEncoding. - - XMLWriter(XMLByteOutputStream& str, int options, const std::string& encodingName, Poco::TextEncoding* pTextEncoding); - /// Creates the XMLWriter and sets the specified options. - /// - /// The encoding is reflected in the XML declaration. - /// The caller is responsible for that the given encodingName matches with - /// the given textEncoding. - /// If pTextEncoding is null, the given encodingName is ignored and the - /// default UTF-8 encoding is used. - - ~XMLWriter(); - /// Destroys the XMLWriter. - - void setNewLine(const std::string& newLineCharacters); - /// Sets the line ending for the resulting XML file. - /// - /// Possible values are: - /// * NEWLINE_DEFAULT (whatever is appropriate for the current platform) - /// * NEWLINE_CRLF (Windows), - /// * NEWLINE_LF (Unix), - /// * NEWLINE_CR (Macintosh) - - const std::string& getNewLine() const; - /// Returns the line ending currently in use. - - void setIndent(const std::string& indent); - /// Sets the string used for one indentation step. - /// - /// The default is a single TAB character. - /// The given string should only contain TAB or SPACE - /// characters (e.g., a single TAB character, or - /// two to four SPACE characters). - - const std::string& getIndent() const; - /// Returns the string used for one indentation step. - - // ContentHandler - void setDocumentLocator(const Locator* loc); - /// Currently unused. - - void startDocument(); - /// Writes a generic XML declaration to the stream. - /// If a document type has been set (see SetDocumentType), - /// a DOCTYPE declaration is also written. - - void endDocument(); - /// Checks that all elements are closed and prints a final newline. - - void startFragment(); - /// Use this instead of StartDocument() if you want to write - /// a fragment rather than a document (no XML declaration and - /// more than one "root" element allowed). - - void endFragment(); - /// Checks that all elements are closed and prints a final newline. - - void startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes); - /// Writes an XML start element tag. - /// - /// Namespaces are handled as follows. - /// 1. If a qname, but no namespaceURI and localName are given, the qname is taken as element name. - /// 2. If a namespaceURI and a localName, but no qname is given, and the given namespaceURI has been - /// declared earlier, the namespace prefix for the given namespaceURI together with the localName - /// is taken as element name. If the namespace has not been declared, a prefix in the form - /// "ns1", "ns2", etc. is generated and the namespace is declared with the generated prefix. - /// 3. If all three are given, and the namespace given in namespaceURI has not been declared, it is declared now. - /// Otherwise, see 2. - - void startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname); - /// Writes an XML start element tag with no attributes. - /// See the other startElement() method for more information. - - void endElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname); - /// Writes an XML end element tag. - /// - /// Throws an exception if the name of doesn't match the - /// one of the most recent startElement(). - - void emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname); - /// Writes an empty XML element tag (<elem/>). - - void emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes); - /// Writes an empty XML element tag with the given attributes (<elem attr1="value1"... />). - - void characters(const XMLChar ch[], int start, int length); - /// Writes XML character data. Quotes, ampersand's, less-than and - /// greater-than signs are escaped, unless a CDATA section - /// has been opened by calling startCDATA(). - /// - /// The characters must be encoded in UTF-8 (if XMLChar is char) or - /// UTF-16 (if XMLChar is wchar_t). - - void characters(const XMLString& str); - /// Writes XML character data. Quotes, ampersand's, less-than and - /// greater-than signs are escaped, unless a CDATA section - /// has been opened by calling startCDATA(). - /// - /// The characters must be encoded in UTF-8 (if XMLChar is char) or - /// UTF-16 (if XMLChar is wchar_t). - - void rawCharacters(const XMLString& str); - /// Writes the characters in the given string as they are. - /// The caller is responsible for escaping characters as - /// necessary to produce valid XML. - /// - /// The characters must be encoded in UTF-8 (if XMLChar is char) or - /// UTF-16 (if XMLChar is wchar_t). - - void ignorableWhitespace(const XMLChar ch[], int start, int length); - /// Writes whitespace characters by simply passing them to - /// characters(). - - void processingInstruction(const XMLString& target, const XMLString& data); - /// Writes a processing instruction. - - void startPrefixMapping(const XMLString& prefix, const XMLString& namespaceURI); - /// Begin the scope of a prefix-URI Namespace mapping. - /// A namespace declaration is written with the next element. - - void endPrefixMapping(const XMLString& prefix); - /// End the scope of a prefix-URI mapping. - - void skippedEntity(const XMLString& name); - /// Does nothing. - - void dataElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& data, - const XMLString& attr1 = XMLString(), const XMLString& value1 = XMLString(), - const XMLString& attr2 = XMLString(), const XMLString& value2 = XMLString(), - const XMLString& attr3 = XMLString(), const XMLString& value3 = XMLString()); - /// Writes a data element in the form <name attr1="value1"...>data</name>. - - // LexicalHandler - void startCDATA(); - /// Writes the <![CDATA[ string that begins a CDATA section. - /// Use characters() to write the actual character data. - - void endCDATA(); - /// Writes the ]]> string that ends a CDATA section. - - void comment(const XMLChar ch[], int start, int length); - /// Writes a comment. - - void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId); - /// Writes a DTD declaration. - - void endDTD(); - /// Writes the closing characters of a DTD declaration. - - void startEntity(const XMLString& name); - /// Does nothing. - - void endEntity(const XMLString& name); - /// Does nothing. - - // DTDHandler - void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId); - void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName); - - static const std::string NEWLINE_DEFAULT; - static const std::string NEWLINE_CR; - static const std::string NEWLINE_CRLF; - static const std::string NEWLINE_LF; - - // Namespace support. - XMLString uniquePrefix(); - /// Creates and returns a unique namespace prefix that - /// can be used with startPrefixMapping(). - - bool isNamespaceMapped(const XMLString& namespc) const; - /// Returns true if the given namespace has been mapped - /// to a prefix in the current element or its ancestors. - - // Misc. - int depth() const; - /// Return the number of nested XML elements. - /// - /// Will be -1 if no document or fragment has been started, - /// 0 if the document or fragment has been started, - /// 1 if the document element has been written and - /// > 1 for every element nested within the document element. - -protected: - typedef std::map<XMLString, XMLString> AttributeMap; - typedef std::map<XMLString, std::pair<XMLString, XMLString> > CanonicalAttributeMap; - - void writeStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes); - void writeCanonicalStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes); - void writeEndElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname); - void writeMarkup(const std::string& str) const; - void writeXML(const XMLString& str) const; - void writeXML(XMLChar ch) const; - void writeNewLine() const; - void writeIndent() const; - void writeIndent(int indent) const; - void writeName(const XMLString& prefix, const XMLString& localName); - void writeXMLDeclaration(); - void closeStartTag(); - void declareNamespaces(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes); - void declareAttributeNamespaces(const Attributes& attributes); - void addNamespaceAttributes(AttributeMap& attributeMap); - void addNamespaceAttributes(CanonicalAttributeMap& attributeMap); - void addAttributes(AttributeMap& attributeMap, const Attributes& attributes, const XMLString& elementNamespaceURI); - void addAttributes(CanonicalAttributeMap& attributeMap, const Attributes& attributes, const XMLString& elementNamespaceURI); - void writeAttributes(const AttributeMap& attributeMap); - void writeAttributes(const CanonicalAttributeMap& attributeMap); - void prettyPrint() const; - static std::string nameToString(const XMLString& localName, const XMLString& qname); - -private: - struct Namespace - { - Namespace(const XMLString& thePrefix, const XMLString& theNamespaceURI): - prefix(thePrefix), - namespaceURI(theNamespaceURI) - { - } - - XMLString prefix; - XMLString namespaceURI; - }; - typedef std::vector<Name> ElementStack; - - Poco::OutputStreamConverter* _pTextConverter; - Poco::TextEncoding* _pInEncoding; - Poco::TextEncoding* _pOutEncoding; - int _options; - std::string _encoding; - std::string _newLine; - int _depth; - int _elementCount; - bool _inFragment; - bool _inCDATA; - bool _inDTD; - bool _inInternalDTD; - bool _contentWritten; - bool _unclosedStartTag; - ElementStack _elementStack; - NamespaceSupport _namespaces; - int _prefix; - bool _nsContextPushed; - std::string _indent; - - static const std::string MARKUP_QUOTENC; - static const std::string MARKUP_AMPENC; - static const std::string MARKUP_LTENC; - static const std::string MARKUP_GTENC; - static const std::string MARKUP_TABENC; - static const std::string MARKUP_CRENC; - static const std::string MARKUP_LFENC; - static const std::string MARKUP_LT; - static const std::string MARKUP_GT; - static const std::string MARKUP_SLASHGT; - static const std::string MARKUP_LTSLASH; - static const std::string MARKUP_COLON; - static const std::string MARKUP_EQQUOT; - static const std::string MARKUP_QUOT; - static const std::string MARKUP_SPACE; - static const std::string MARKUP_TAB; - static const std::string MARKUP_BEGIN_CDATA; - static const std::string MARKUP_END_CDATA; -}; - - -// -// inlines -// -inline int XMLWriter::depth() const -{ - return _depth; -} - - -} } // namespace Poco::XML - - -#endif // XML_XMLWriter_INCLUDED + /// The XMLWriter supports optional pretty-printing of the serialized XML. + /// Note, however, that pretty-printing XML data alters the + /// information set of the document being written, since in + /// XML all whitespace is potentially relevant to an application. + /// + /// The writer contains extensive support for XML Namespaces, so that a client + /// application does not have to keep track of prefixes and supply xmlns attributes. + /// + /// If the client does not provide namespace prefixes (either by specifying them + /// as part of the qualified name given to startElement(), or by calling + /// startPrefixMapping()), the XMLWriter automatically generates namespace + /// prefixes in the form ns1, ns2, etc. +{ +public: + enum Options + { + CANONICAL = 0x00, + /// Do not write an XML declaration (default). + + CANONICAL_XML = 0x01, + /// Enables basic support for Canonical XML: + /// - do not write an XML declaration + /// - do not use special empty element syntax + /// - set the New Line character to NEWLINE_LF + /// - write namespace declarations and attributes + /// in canonical order + /// - use default namespace as much as possible + + WRITE_XML_DECLARATION = 0x02, + /// Write an XML declaration. + + PRETTY_PRINT = 0x04, + /// Pretty-print XML markup. + + PRETTY_PRINT_ATTRIBUTES = 0x08 + /// Write each attribute on a separate line. + /// PRETTY_PRINT must be specified as well. + }; + + XMLWriter(XMLByteOutputStream& str, int options); + /// Creates the XMLWriter and sets the specified options. + /// + /// The resulting stream will be UTF-8 encoded. + + XMLWriter(XMLByteOutputStream& str, int options, const std::string& encodingName, Poco::TextEncoding& textEncoding); + /// Creates the XMLWriter and sets the specified options. + /// + /// The encoding is reflected in the XML declaration. + /// The caller is responsible for that the given encodingName matches with + /// the given textEncoding. + + XMLWriter(XMLByteOutputStream& str, int options, const std::string& encodingName, Poco::TextEncoding* pTextEncoding); + /// Creates the XMLWriter and sets the specified options. + /// + /// The encoding is reflected in the XML declaration. + /// The caller is responsible for that the given encodingName matches with + /// the given textEncoding. + /// If pTextEncoding is null, the given encodingName is ignored and the + /// default UTF-8 encoding is used. + + ~XMLWriter(); + /// Destroys the XMLWriter. + + void setNewLine(const std::string& newLineCharacters); + /// Sets the line ending for the resulting XML file. + /// + /// Possible values are: + /// * NEWLINE_DEFAULT (whatever is appropriate for the current platform) + /// * NEWLINE_CRLF (Windows), + /// * NEWLINE_LF (Unix), + /// * NEWLINE_CR (Macintosh) + + const std::string& getNewLine() const; + /// Returns the line ending currently in use. + + void setIndent(const std::string& indent); + /// Sets the string used for one indentation step. + /// + /// The default is a single TAB character. + /// The given string should only contain TAB or SPACE + /// characters (e.g., a single TAB character, or + /// two to four SPACE characters). + + const std::string& getIndent() const; + /// Returns the string used for one indentation step. + + // ContentHandler + void setDocumentLocator(const Locator* loc); + /// Currently unused. + + void startDocument(); + /// Writes a generic XML declaration to the stream. + /// If a document type has been set (see SetDocumentType), + /// a DOCTYPE declaration is also written. + + void endDocument(); + /// Checks that all elements are closed and prints a final newline. + + void startFragment(); + /// Use this instead of StartDocument() if you want to write + /// a fragment rather than a document (no XML declaration and + /// more than one "root" element allowed). + + void endFragment(); + /// Checks that all elements are closed and prints a final newline. + + void startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes); + /// Writes an XML start element tag. + /// + /// Namespaces are handled as follows. + /// 1. If a qname, but no namespaceURI and localName are given, the qname is taken as element name. + /// 2. If a namespaceURI and a localName, but no qname is given, and the given namespaceURI has been + /// declared earlier, the namespace prefix for the given namespaceURI together with the localName + /// is taken as element name. If the namespace has not been declared, a prefix in the form + /// "ns1", "ns2", etc. is generated and the namespace is declared with the generated prefix. + /// 3. If all three are given, and the namespace given in namespaceURI has not been declared, it is declared now. + /// Otherwise, see 2. + + void startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname); + /// Writes an XML start element tag with no attributes. + /// See the other startElement() method for more information. + + void endElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname); + /// Writes an XML end element tag. + /// + /// Throws an exception if the name of doesn't match the + /// one of the most recent startElement(). + + void emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname); + /// Writes an empty XML element tag (<elem/>). + + void emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes); + /// Writes an empty XML element tag with the given attributes (<elem attr1="value1"... />). + + void characters(const XMLChar ch[], int start, int length); + /// Writes XML character data. Quotes, ampersand's, less-than and + /// greater-than signs are escaped, unless a CDATA section + /// has been opened by calling startCDATA(). + /// + /// The characters must be encoded in UTF-8 (if XMLChar is char) or + /// UTF-16 (if XMLChar is wchar_t). + + void characters(const XMLString& str); + /// Writes XML character data. Quotes, ampersand's, less-than and + /// greater-than signs are escaped, unless a CDATA section + /// has been opened by calling startCDATA(). + /// + /// The characters must be encoded in UTF-8 (if XMLChar is char) or + /// UTF-16 (if XMLChar is wchar_t). + + void rawCharacters(const XMLString& str); + /// Writes the characters in the given string as they are. + /// The caller is responsible for escaping characters as + /// necessary to produce valid XML. + /// + /// The characters must be encoded in UTF-8 (if XMLChar is char) or + /// UTF-16 (if XMLChar is wchar_t). + + void ignorableWhitespace(const XMLChar ch[], int start, int length); + /// Writes whitespace characters by simply passing them to + /// characters(). + + void processingInstruction(const XMLString& target, const XMLString& data); + /// Writes a processing instruction. + + void startPrefixMapping(const XMLString& prefix, const XMLString& namespaceURI); + /// Begin the scope of a prefix-URI Namespace mapping. + /// A namespace declaration is written with the next element. + + void endPrefixMapping(const XMLString& prefix); + /// End the scope of a prefix-URI mapping. + + void skippedEntity(const XMLString& name); + /// Does nothing. + + void dataElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const XMLString& data, + const XMLString& attr1 = XMLString(), const XMLString& value1 = XMLString(), + const XMLString& attr2 = XMLString(), const XMLString& value2 = XMLString(), + const XMLString& attr3 = XMLString(), const XMLString& value3 = XMLString()); + /// Writes a data element in the form <name attr1="value1"...>data</name>. + + // LexicalHandler + void startCDATA(); + /// Writes the <![CDATA[ string that begins a CDATA section. + /// Use characters() to write the actual character data. + + void endCDATA(); + /// Writes the ]]> string that ends a CDATA section. + + void comment(const XMLChar ch[], int start, int length); + /// Writes a comment. + + void startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId); + /// Writes a DTD declaration. + + void endDTD(); + /// Writes the closing characters of a DTD declaration. + + void startEntity(const XMLString& name); + /// Does nothing. + + void endEntity(const XMLString& name); + /// Does nothing. + + // DTDHandler + void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId); + void unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName); + + static const std::string NEWLINE_DEFAULT; + static const std::string NEWLINE_CR; + static const std::string NEWLINE_CRLF; + static const std::string NEWLINE_LF; + + // Namespace support. + XMLString uniquePrefix(); + /// Creates and returns a unique namespace prefix that + /// can be used with startPrefixMapping(). + + bool isNamespaceMapped(const XMLString& namespc) const; + /// Returns true if the given namespace has been mapped + /// to a prefix in the current element or its ancestors. + + // Misc. + int depth() const; + /// Return the number of nested XML elements. + /// + /// Will be -1 if no document or fragment has been started, + /// 0 if the document or fragment has been started, + /// 1 if the document element has been written and + /// > 1 for every element nested within the document element. + +protected: + typedef std::map<XMLString, XMLString> AttributeMap; + typedef std::map<XMLString, std::pair<XMLString, XMLString> > CanonicalAttributeMap; + + void writeStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes); + void writeCanonicalStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes); + void writeEndElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname); + void writeMarkup(const std::string& str) const; + void writeXML(const XMLString& str) const; + void writeXML(XMLChar ch) const; + void writeNewLine() const; + void writeIndent() const; + void writeIndent(int indent) const; + void writeName(const XMLString& prefix, const XMLString& localName); + void writeXMLDeclaration(); + void closeStartTag(); + void declareNamespaces(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes); + void declareAttributeNamespaces(const Attributes& attributes); + void addNamespaceAttributes(AttributeMap& attributeMap); + void addNamespaceAttributes(CanonicalAttributeMap& attributeMap); + void addAttributes(AttributeMap& attributeMap, const Attributes& attributes, const XMLString& elementNamespaceURI); + void addAttributes(CanonicalAttributeMap& attributeMap, const Attributes& attributes, const XMLString& elementNamespaceURI); + void writeAttributes(const AttributeMap& attributeMap); + void writeAttributes(const CanonicalAttributeMap& attributeMap); + void prettyPrint() const; + static std::string nameToString(const XMLString& localName, const XMLString& qname); + +private: + struct Namespace + { + Namespace(const XMLString& thePrefix, const XMLString& theNamespaceURI): + prefix(thePrefix), + namespaceURI(theNamespaceURI) + { + } + + XMLString prefix; + XMLString namespaceURI; + }; + typedef std::vector<Name> ElementStack; + + Poco::OutputStreamConverter* _pTextConverter; + Poco::TextEncoding* _pInEncoding; + Poco::TextEncoding* _pOutEncoding; + int _options; + std::string _encoding; + std::string _newLine; + int _depth; + int _elementCount; + bool _inFragment; + bool _inCDATA; + bool _inDTD; + bool _inInternalDTD; + bool _contentWritten; + bool _unclosedStartTag; + ElementStack _elementStack; + NamespaceSupport _namespaces; + int _prefix; + bool _nsContextPushed; + std::string _indent; + + static const std::string MARKUP_QUOTENC; + static const std::string MARKUP_AMPENC; + static const std::string MARKUP_LTENC; + static const std::string MARKUP_GTENC; + static const std::string MARKUP_TABENC; + static const std::string MARKUP_CRENC; + static const std::string MARKUP_LFENC; + static const std::string MARKUP_LT; + static const std::string MARKUP_GT; + static const std::string MARKUP_SLASHGT; + static const std::string MARKUP_LTSLASH; + static const std::string MARKUP_COLON; + static const std::string MARKUP_EQQUOT; + static const std::string MARKUP_QUOT; + static const std::string MARKUP_SPACE; + static const std::string MARKUP_TAB; + static const std::string MARKUP_BEGIN_CDATA; + static const std::string MARKUP_END_CDATA; +}; + + +// +// inlines +// +inline int XMLWriter::depth() const +{ + return _depth; +} + + +} } // namespace Poco::XML + + +#endif // XML_XMLWriter_INCLUDED diff --git a/contrib/libs/poco/XML/src/AbstractContainerNode.cpp b/contrib/libs/poco/XML/src/AbstractContainerNode.cpp index 52134ce09c..c891f155fe 100644 --- a/contrib/libs/poco/XML/src/AbstractContainerNode.cpp +++ b/contrib/libs/poco/XML/src/AbstractContainerNode.cpp @@ -1,573 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/AbstractNode.cpp b/contrib/libs/poco/XML/src/AbstractNode.cpp index 1897d69324..5efa19ed06 100644 --- a/contrib/libs/poco/XML/src/AbstractNode.cpp +++ b/contrib/libs/poco/XML/src/AbstractNode.cpp @@ -1,367 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/Attr.cpp b/contrib/libs/poco/XML/src/Attr.cpp index 2cce620bfd..04a2525437 100644 --- a/contrib/libs/poco/XML/src/Attr.cpp +++ b/contrib/libs/poco/XML/src/Attr.cpp @@ -1,133 +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.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(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 +} + + +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 diff --git a/contrib/libs/poco/XML/src/AttrMap.cpp b/contrib/libs/poco/XML/src/AttrMap.cpp index cb3a24133d..39fae03f88 100644 --- a/contrib/libs/poco/XML/src/AttrMap.cpp +++ b/contrib/libs/poco/XML/src/AttrMap.cpp @@ -1,123 +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 - +// +// 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 + diff --git a/contrib/libs/poco/XML/src/Attributes.cpp b/contrib/libs/poco/XML/src/Attributes.cpp index f2baf9ff20..6bc2751c98 100644 --- a/contrib/libs/poco/XML/src/Attributes.cpp +++ b/contrib/libs/poco/XML/src/Attributes.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/AttributesImpl.cpp b/contrib/libs/poco/XML/src/AttributesImpl.cpp index 0a96c1854f..5c0c9b35a6 100644 --- a/contrib/libs/poco/XML/src/AttributesImpl.cpp +++ b/contrib/libs/poco/XML/src/AttributesImpl.cpp @@ -1,280 +1,280 @@ -// -// 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::AttributesImpl() -{ - _empty.specified = false; - _empty.type = XML_LIT("CDATA"); -} - - -AttributesImpl::AttributesImpl(const Attributes& attributes) -{ - _empty.specified = false; - _empty.type = XML_LIT("CDATA"); - setAttributes(attributes); -} - - -AttributesImpl::AttributesImpl(const AttributesImpl& attributes): - _attributes(attributes._attributes), - _empty(attributes._empty) -{ -} - - -AttributesImpl::~AttributesImpl() -{ -} - - -AttributesImpl& AttributesImpl::operator = (const AttributesImpl& attributes) -{ - if (&attributes != this) - { - _attributes = 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) - { +// +// 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::AttributesImpl() +{ + _empty.specified = false; + _empty.type = XML_LIT("CDATA"); +} + + +AttributesImpl::AttributesImpl(const Attributes& attributes) +{ + _empty.specified = false; + _empty.type = XML_LIT("CDATA"); + setAttributes(attributes); +} + + +AttributesImpl::AttributesImpl(const AttributesImpl& attributes): + _attributes(attributes._attributes), + _empty(attributes._empty) +{ +} + + +AttributesImpl::~AttributesImpl() +{ +} + + +AttributesImpl& AttributesImpl::operator = (const AttributesImpl& attributes) +{ + if (&attributes != this) + { + _attributes = 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) - 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) - { + { + _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) - return const_cast<Attribute*>(&(*it)); - } - return 0; -} - - -} } // namespace Poco::XML + { + _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 diff --git a/contrib/libs/poco/XML/src/CDATASection.cpp b/contrib/libs/poco/XML/src/CDATASection.cpp index 478b590a07..9005623641 100644 --- a/contrib/libs/poco/XML/src/CDATASection.cpp +++ b/contrib/libs/poco/XML/src/CDATASection.cpp @@ -1,74 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/CharacterData.cpp b/contrib/libs/poco/XML/src/CharacterData.cpp index f8a3ec324d..cbd819a2cc 100644 --- a/contrib/libs/poco/XML/src/CharacterData.cpp +++ b/contrib/libs/poco/XML/src/CharacterData.cpp @@ -1,152 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/ChildNodesList.cpp b/contrib/libs/poco/XML/src/ChildNodesList.cpp index aeacaf15ad..388a5f5406 100644 --- a/contrib/libs/poco/XML/src/ChildNodesList.cpp +++ b/contrib/libs/poco/XML/src/ChildNodesList.cpp @@ -1,70 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/Comment.cpp b/contrib/libs/poco/XML/src/Comment.cpp index 20421cabca..647cb4dfb5 100644 --- a/contrib/libs/poco/XML/src/Comment.cpp +++ b/contrib/libs/poco/XML/src/Comment.cpp @@ -1,60 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/ContentHandler.cpp b/contrib/libs/poco/XML/src/ContentHandler.cpp index 03177d11e7..b4ef9b66fa 100644 --- a/contrib/libs/poco/XML/src/ContentHandler.cpp +++ b/contrib/libs/poco/XML/src/ContentHandler.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/DOMBuilder.cpp b/contrib/libs/poco/XML/src/DOMBuilder.cpp index 862d473950..d61701a23d 100644 --- a/contrib/libs/poco/XML/src/DOMBuilder.cpp +++ b/contrib/libs/poco/XML/src/DOMBuilder.cpp @@ -1,312 +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 (AttributesImpl::iterator it = attrs.begin(); it != attrs.end(); ++it) - { - AutoPtr<Attr> pAttr = new Attr(_pDocument, 0, it->namespaceURI, it->localName, it->qname, it->value, it->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 +// +// 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 (AttributesImpl::iterator it = attrs.begin(); it != attrs.end(); ++it) + { + AutoPtr<Attr> pAttr = new Attr(_pDocument, 0, it->namespaceURI, it->localName, it->qname, it->value, it->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 diff --git a/contrib/libs/poco/XML/src/DOMException.cpp b/contrib/libs/poco/XML/src/DOMException.cpp index 546a1e2aae..0b29825344 100644 --- a/contrib/libs/poco/XML/src/DOMException.cpp +++ b/contrib/libs/poco/XML/src/DOMException.cpp @@ -1,107 +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; -} - - +// +// 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"; -} - - +{ + 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 +{ + 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 diff --git a/contrib/libs/poco/XML/src/DOMImplementation.cpp b/contrib/libs/poco/XML/src/DOMImplementation.cpp index b6a138d67e..c78ab20691 100644 --- a/contrib/libs/poco/XML/src/DOMImplementation.cpp +++ b/contrib/libs/poco/XML/src/DOMImplementation.cpp @@ -1,86 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/DOMObject.cpp b/contrib/libs/poco/XML/src/DOMObject.cpp index a82708f0dd..6d3e38dea1 100644 --- a/contrib/libs/poco/XML/src/DOMObject.cpp +++ b/contrib/libs/poco/XML/src/DOMObject.cpp @@ -1,32 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/DOMParser.cpp b/contrib/libs/poco/XML/src/DOMParser.cpp index 5e222c6fd7..9baca1a789 100644 --- a/contrib/libs/poco/XML/src/DOMParser.cpp +++ b/contrib/libs/poco/XML/src/DOMParser.cpp @@ -1,157 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/DOMSerializer.cpp b/contrib/libs/poco/XML/src/DOMSerializer.cpp index 327b3132e0..606a09e075 100644 --- a/contrib/libs/poco/XML/src/DOMSerializer.cpp +++ b/contrib/libs/poco/XML/src/DOMSerializer.cpp @@ -1,323 +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 -{ +// +// 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) - { - 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 + _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 diff --git a/contrib/libs/poco/XML/src/DOMWriter.cpp b/contrib/libs/poco/XML/src/DOMWriter.cpp index 8a087643e8..7d936aaa71 100644 --- a/contrib/libs/poco/XML/src/DOMWriter.cpp +++ b/contrib/libs/poco/XML/src/DOMWriter.cpp @@ -1,102 +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 - +// +// 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 + diff --git a/contrib/libs/poco/XML/src/DTDHandler.cpp b/contrib/libs/poco/XML/src/DTDHandler.cpp index 5c478acc40..50a2b3c620 100644 --- a/contrib/libs/poco/XML/src/DTDHandler.cpp +++ b/contrib/libs/poco/XML/src/DTDHandler.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/DTDMap.cpp b/contrib/libs/poco/XML/src/DTDMap.cpp index 8b7136287a..3ab6f6e0d4 100644 --- a/contrib/libs/poco/XML/src/DTDMap.cpp +++ b/contrib/libs/poco/XML/src/DTDMap.cpp @@ -1,117 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/DeclHandler.cpp b/contrib/libs/poco/XML/src/DeclHandler.cpp index d2164f430f..375304cad3 100644 --- a/contrib/libs/poco/XML/src/DeclHandler.cpp +++ b/contrib/libs/poco/XML/src/DeclHandler.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/DefaultHandler.cpp b/contrib/libs/poco/XML/src/DefaultHandler.cpp index 80be56e1d6..c50075b945 100644 --- a/contrib/libs/poco/XML/src/DefaultHandler.cpp +++ b/contrib/libs/poco/XML/src/DefaultHandler.cpp @@ -1,123 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/Document.cpp b/contrib/libs/poco/XML/src/Document.cpp index a649c0b066..f022993e45 100644 --- a/contrib/libs/poco/XML/src/Document.cpp +++ b/contrib/libs/poco/XML/src/Document.cpp @@ -1,326 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/DocumentEvent.cpp b/contrib/libs/poco/XML/src/DocumentEvent.cpp index 943e69f67d..8196d1da9e 100644 --- a/contrib/libs/poco/XML/src/DocumentEvent.cpp +++ b/contrib/libs/poco/XML/src/DocumentEvent.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/DocumentFragment.cpp b/contrib/libs/poco/XML/src/DocumentFragment.cpp index 462be5292e..4d73f25d5c 100644 --- a/contrib/libs/poco/XML/src/DocumentFragment.cpp +++ b/contrib/libs/poco/XML/src/DocumentFragment.cpp @@ -1,70 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/DocumentType.cpp b/contrib/libs/poco/XML/src/DocumentType.cpp index cc55f59586..970232e108 100644 --- a/contrib/libs/poco/XML/src/DocumentType.cpp +++ b/contrib/libs/poco/XML/src/DocumentType.cpp @@ -1,84 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/Element.cpp b/contrib/libs/poco/XML/src/Element.cpp index e66039ade3..287c8e20a2 100644 --- a/contrib/libs/poco/XML/src/Element.cpp +++ b/contrib/libs/poco/XML/src/Element.cpp @@ -1,444 +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); - +// +// 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(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 + 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 diff --git a/contrib/libs/poco/XML/src/ElementsByTagNameList.cpp b/contrib/libs/poco/XML/src/ElementsByTagNameList.cpp index d6bc382ff6..c50f2cf740 100644 --- a/contrib/libs/poco/XML/src/ElementsByTagNameList.cpp +++ b/contrib/libs/poco/XML/src/ElementsByTagNameList.cpp @@ -1,151 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/Entity.cpp b/contrib/libs/poco/XML/src/Entity.cpp index e90a2497e7..4f8a43a0ee 100644 --- a/contrib/libs/poco/XML/src/Entity.cpp +++ b/contrib/libs/poco/XML/src/Entity.cpp @@ -1,68 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/EntityReference.cpp b/contrib/libs/poco/XML/src/EntityReference.cpp index 86fa052ab5..60a4976c1c 100644 --- a/contrib/libs/poco/XML/src/EntityReference.cpp +++ b/contrib/libs/poco/XML/src/EntityReference.cpp @@ -1,59 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/EntityResolver.cpp b/contrib/libs/poco/XML/src/EntityResolver.cpp index 80e1bde9c2..7d3d1e1d0c 100644 --- a/contrib/libs/poco/XML/src/EntityResolver.cpp +++ b/contrib/libs/poco/XML/src/EntityResolver.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/EntityResolverImpl.cpp b/contrib/libs/poco/XML/src/EntityResolverImpl.cpp index a072df5e52..00aa89ae37 100644 --- a/contrib/libs/poco/XML/src/EntityResolverImpl.cpp +++ b/contrib/libs/poco/XML/src/EntityResolverImpl.cpp @@ -1,78 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/ErrorHandler.cpp b/contrib/libs/poco/XML/src/ErrorHandler.cpp index 6a497a3816..18f2b932a3 100644 --- a/contrib/libs/poco/XML/src/ErrorHandler.cpp +++ b/contrib/libs/poco/XML/src/ErrorHandler.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/Event.cpp b/contrib/libs/poco/XML/src/Event.cpp index ffdff7385e..4b35c48052 100644 --- a/contrib/libs/poco/XML/src/Event.cpp +++ b/contrib/libs/poco/XML/src/Event.cpp @@ -1,102 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/EventDispatcher.cpp b/contrib/libs/poco/XML/src/EventDispatcher.cpp index 4656f9b45f..8270106477 100644 --- a/contrib/libs/poco/XML/src/EventDispatcher.cpp +++ b/contrib/libs/poco/XML/src/EventDispatcher.cpp @@ -1,146 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/EventException.cpp b/contrib/libs/poco/XML/src/EventException.cpp index d2d07bd1c6..6dd4e25fdc 100644 --- a/contrib/libs/poco/XML/src/EventException.cpp +++ b/contrib/libs/poco/XML/src/EventException.cpp @@ -1,65 +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", code) -{ -} - - -EventException::EventException(const EventException& exc): - XMLException(exc) -{ -} - - -EventException::~EventException() noexcept -{ -} - - -EventException& EventException::operator = (const EventException& exc) -{ - XMLException::operator = (exc); - return *this; -} - - +// +// 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", code) +{ +} + + +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"; -} - - +{ + return "EventException"; +} + + const char* EventException::className() const noexcept -{ - return typeid(*this).name(); -} - - -Poco::Exception* EventException::clone() const -{ - return new EventException(*this); -} - - -} } // namespace Poco::XML +{ + return typeid(*this).name(); +} + + +Poco::Exception* EventException::clone() const +{ + return new EventException(*this); +} + + +} } // namespace Poco::XML diff --git a/contrib/libs/poco/XML/src/EventListener.cpp b/contrib/libs/poco/XML/src/EventListener.cpp index b6c3988818..d2511cb6eb 100644 --- a/contrib/libs/poco/XML/src/EventListener.cpp +++ b/contrib/libs/poco/XML/src/EventListener.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/EventTarget.cpp b/contrib/libs/poco/XML/src/EventTarget.cpp index 2aa76a0dad..b933a7042f 100644 --- a/contrib/libs/poco/XML/src/EventTarget.cpp +++ b/contrib/libs/poco/XML/src/EventTarget.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/InputSource.cpp b/contrib/libs/poco/XML/src/InputSource.cpp index 1ec8cfc0be..ecfb3c41da 100644 --- a/contrib/libs/poco/XML/src/InputSource.cpp +++ b/contrib/libs/poco/XML/src/InputSource.cpp @@ -1,80 +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 - +// +// 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 + diff --git a/contrib/libs/poco/XML/src/LexicalHandler.cpp b/contrib/libs/poco/XML/src/LexicalHandler.cpp index 52de41d742..e89b7b0a56 100644 --- a/contrib/libs/poco/XML/src/LexicalHandler.cpp +++ b/contrib/libs/poco/XML/src/LexicalHandler.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/Locator.cpp b/contrib/libs/poco/XML/src/Locator.cpp index 3be93bf795..a412b92b8c 100644 --- a/contrib/libs/poco/XML/src/Locator.cpp +++ b/contrib/libs/poco/XML/src/Locator.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/LocatorImpl.cpp b/contrib/libs/poco/XML/src/LocatorImpl.cpp index a77cc43f60..953fed7ec9 100644 --- a/contrib/libs/poco/XML/src/LocatorImpl.cpp +++ b/contrib/libs/poco/XML/src/LocatorImpl.cpp @@ -1,104 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/MutationEvent.cpp b/contrib/libs/poco/XML/src/MutationEvent.cpp index 485836e6b7..ce1f8a34c9 100644 --- a/contrib/libs/poco/XML/src/MutationEvent.cpp +++ b/contrib/libs/poco/XML/src/MutationEvent.cpp @@ -1,76 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/Name.cpp b/contrib/libs/poco/XML/src/Name.cpp index 832afec8df..89e23dbef4 100644 --- a/contrib/libs/poco/XML/src/Name.cpp +++ b/contrib/libs/poco/XML/src/Name.cpp @@ -1,170 +1,170 @@ -// -// 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::operator = (const Name& name) -{ - if (this != &name) - { - _qname = name._qname; - _namespaceURI = name._namespaceURI; - _localName = 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(':'); +// +// 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::operator = (const Name& name) +{ + if (this != &name) + { + _qname = name._qname; + _namespaceURI = name._namespaceURI; + _localName = 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) - 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 + { + 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 diff --git a/contrib/libs/poco/XML/src/NamePool.cpp b/contrib/libs/poco/XML/src/NamePool.cpp index 4e234eabf9..386aab5eb7 100644 --- a/contrib/libs/poco/XML/src/NamePool.cpp +++ b/contrib/libs/poco/XML/src/NamePool.cpp @@ -1,132 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/NamedNodeMap.cpp b/contrib/libs/poco/XML/src/NamedNodeMap.cpp index 91108bf534..2de1f0b2dc 100644 --- a/contrib/libs/poco/XML/src/NamedNodeMap.cpp +++ b/contrib/libs/poco/XML/src/NamedNodeMap.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/NamespaceStrategy.cpp b/contrib/libs/poco/XML/src/NamespaceStrategy.cpp index cfdccd6eca..805ae8a2c2 100644 --- a/contrib/libs/poco/XML/src/NamespaceStrategy.cpp +++ b/contrib/libs/poco/XML/src/NamespaceStrategy.cpp @@ -1,195 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/NamespaceSupport.cpp b/contrib/libs/poco/XML/src/NamespaceSupport.cpp index cfc752885f..e78621d545 100644 --- a/contrib/libs/poco/XML/src/NamespaceSupport.cpp +++ b/contrib/libs/poco/XML/src/NamespaceSupport.cpp @@ -1,187 +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 (Context::const_iterator it = ctx.begin(); it != ctx.end(); ++it) - prefixes.insert(it->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); +// +// 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()) - return it->second; - } - return EMPTY_STRING; -} - - -void NamespaceSupport::pushContext() -{ - _contexts.push_back(Context()); -} - - -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 + { + rit->erase(it); + return true; + } + } + return false; +} + + +void NamespaceSupport::getDeclaredPrefixes(PrefixSet& prefixes) const +{ + prefixes.clear(); + const Context& ctx = _contexts.back(); + for (Context::const_iterator it = ctx.begin(); it != ctx.end(); ++it) + prefixes.insert(it->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.push_back(Context()); +} + + +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 diff --git a/contrib/libs/poco/XML/src/Node.cpp b/contrib/libs/poco/XML/src/Node.cpp index 4134fcfa29..2e6ef5c1fc 100644 --- a/contrib/libs/poco/XML/src/Node.cpp +++ b/contrib/libs/poco/XML/src/Node.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/NodeAppender.cpp b/contrib/libs/poco/XML/src/NodeAppender.cpp index e0582b89cf..5a936b7124 100644 --- a/contrib/libs/poco/XML/src/NodeAppender.cpp +++ b/contrib/libs/poco/XML/src/NodeAppender.cpp @@ -1,82 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/NodeFilter.cpp b/contrib/libs/poco/XML/src/NodeFilter.cpp index 7239f43407..7f843558ef 100644 --- a/contrib/libs/poco/XML/src/NodeFilter.cpp +++ b/contrib/libs/poco/XML/src/NodeFilter.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/NodeIterator.cpp b/contrib/libs/poco/XML/src/NodeIterator.cpp index 69685f9f4e..40a97acf89 100644 --- a/contrib/libs/poco/XML/src/NodeIterator.cpp +++ b/contrib/libs/poco/XML/src/NodeIterator.cpp @@ -1,176 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/NodeList.cpp b/contrib/libs/poco/XML/src/NodeList.cpp index e56b37ce19..23902a21b5 100644 --- a/contrib/libs/poco/XML/src/NodeList.cpp +++ b/contrib/libs/poco/XML/src/NodeList.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/Notation.cpp b/contrib/libs/poco/XML/src/Notation.cpp index ec38a5ade3..68a5b6df11 100644 --- a/contrib/libs/poco/XML/src/Notation.cpp +++ b/contrib/libs/poco/XML/src/Notation.cpp @@ -1,63 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/ParserEngine.cpp b/contrib/libs/poco/XML/src/ParserEngine.cpp index 95361a4cde..4c1401711a 100644 --- a/contrib/libs/poco/XML/src/ParserEngine.cpp +++ b/contrib/libs/poco/XML/src/ParserEngine.cpp @@ -1,896 +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 (ContextStack::iterator it = _context.begin(); it != _context.end(); ++it) - { - delete *it; - } - _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 +// +// 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 (ContextStack::iterator it = _context.begin(); it != _context.end(); ++it) + { + delete *it; + } + _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 diff --git a/contrib/libs/poco/XML/src/ProcessingInstruction.cpp b/contrib/libs/poco/XML/src/ProcessingInstruction.cpp index ebfc7c158b..4d527f9817 100644 --- a/contrib/libs/poco/XML/src/ProcessingInstruction.cpp +++ b/contrib/libs/poco/XML/src/ProcessingInstruction.cpp @@ -1,79 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/QName.cpp b/contrib/libs/poco/XML/src/QName.cpp index 276b1c3fc4..0ef711ac6b 100644 --- a/contrib/libs/poco/XML/src/QName.cpp +++ b/contrib/libs/poco/XML/src/QName.cpp @@ -1,72 +1,72 @@ -// -// 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) -{ -} - - -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 +// +// 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) +{ +} + + +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 diff --git a/contrib/libs/poco/XML/src/SAXException.cpp b/contrib/libs/poco/XML/src/SAXException.cpp index 112747b08f..d03e583991 100644 --- a/contrib/libs/poco/XML/src/SAXException.cpp +++ b/contrib/libs/poco/XML/src/SAXException.cpp @@ -1,138 +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; -} - - +// +// 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"; -} - - +{ + 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 +{ + 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 diff --git a/contrib/libs/poco/XML/src/SAXParser.cpp b/contrib/libs/poco/XML/src/SAXParser.cpp index e03959a845..1f1a4b1587 100644 --- a/contrib/libs/poco/XML/src/SAXParser.cpp +++ b/contrib/libs/poco/XML/src/SAXParser.cpp @@ -1,238 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/Text.cpp b/contrib/libs/poco/XML/src/Text.cpp index abdff3a4e9..62677623d0 100644 --- a/contrib/libs/poco/XML/src/Text.cpp +++ b/contrib/libs/poco/XML/src/Text.cpp @@ -1,80 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/TreeWalker.cpp b/contrib/libs/poco/XML/src/TreeWalker.cpp index 69c0556cda..54efb7d4cc 100644 --- a/contrib/libs/poco/XML/src/TreeWalker.cpp +++ b/contrib/libs/poco/XML/src/TreeWalker.cpp @@ -1,227 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/ValueTraits.cpp b/contrib/libs/poco/XML/src/ValueTraits.cpp index c9b5b3efb8..d216510544 100644 --- a/contrib/libs/poco/XML/src/ValueTraits.cpp +++ b/contrib/libs/poco/XML/src/ValueTraits.cpp @@ -1,39 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/WhitespaceFilter.cpp b/contrib/libs/poco/XML/src/WhitespaceFilter.cpp index 7aba9f5f7e..4faba920ee 100644 --- a/contrib/libs/poco/XML/src/WhitespaceFilter.cpp +++ b/contrib/libs/poco/XML/src/WhitespaceFilter.cpp @@ -1,212 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/XMLException.cpp b/contrib/libs/poco/XML/src/XMLException.cpp index 62ba990cda..a80338cde1 100644 --- a/contrib/libs/poco/XML/src/XMLException.cpp +++ b/contrib/libs/poco/XML/src/XMLException.cpp @@ -1,29 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/XMLFilter.cpp b/contrib/libs/poco/XML/src/XMLFilter.cpp index a409db1e8b..619c04ae72 100644 --- a/contrib/libs/poco/XML/src/XMLFilter.cpp +++ b/contrib/libs/poco/XML/src/XMLFilter.cpp @@ -1,27 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/XMLFilterImpl.cpp b/contrib/libs/poco/XML/src/XMLFilterImpl.cpp index 2256f24584..a981f48286 100644 --- a/contrib/libs/poco/XML/src/XMLFilterImpl.cpp +++ b/contrib/libs/poco/XML/src/XMLFilterImpl.cpp @@ -1,313 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/XMLReader.cpp b/contrib/libs/poco/XML/src/XMLReader.cpp index d6cd767d7d..d36674541e 100644 --- a/contrib/libs/poco/XML/src/XMLReader.cpp +++ b/contrib/libs/poco/XML/src/XMLReader.cpp @@ -1,37 +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 +// +// 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 diff --git a/contrib/libs/poco/XML/src/XMLStreamParser.cpp b/contrib/libs/poco/XML/src/XMLStreamParser.cpp index 850657d79d..9bbd7089d2 100644 --- a/contrib/libs/poco/XML/src/XMLStreamParser.cpp +++ b/contrib/libs/poco/XML/src/XMLStreamParser.cpp @@ -1,939 +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 (AttributeMapType::const_iterator i(e.attributeMap.begin()); i != e.attributeMap.end(); ++i) - { - if (!i->second.handled) - throw XMLStreamParserException(*this, "unexpected attribute '" + i->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.push_back(ElementEntry(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 value(qn, AttributeValueType()); - value.second.value = *(atts + 1); - value.second.handled = false; - pe->attributeMap.insert(value); - } - else - { - p._attributes.push_back(AttributeType()); - 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.push_back(QName()); - 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.push_back(QName()); - p._endNamespace.back().prefix() = (prefix != 0 ? prefix : ""); -} - - -} } // namespace Poco::XML +// +// 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 (AttributeMapType::const_iterator i(e.attributeMap.begin()); i != e.attributeMap.end(); ++i) + { + if (!i->second.handled) + throw XMLStreamParserException(*this, "unexpected attribute '" + i->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.push_back(ElementEntry(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 value(qn, AttributeValueType()); + value.second.value = *(atts + 1); + value.second.handled = false; + pe->attributeMap.insert(value); + } + else + { + p._attributes.push_back(AttributeType()); + 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.push_back(QName()); + 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.push_back(QName()); + p._endNamespace.back().prefix() = (prefix != 0 ? prefix : ""); +} + + +} } // namespace Poco::XML diff --git a/contrib/libs/poco/XML/src/XMLStreamParserException.cpp b/contrib/libs/poco/XML/src/XMLStreamParserException.cpp index d7b01690ed..540dbb26c9 100644 --- a/contrib/libs/poco/XML/src/XMLStreamParserException.cpp +++ b/contrib/libs/poco/XML/src/XMLStreamParserException.cpp @@ -1,88 +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() noexcept -{ -} - - -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(); -} - - +// +// 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() noexcept +{ +} + + +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; -} - - +{ + 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 noexcept -{ - return _what.c_str(); -} - - -} } // namespace Poco::XML +{ + return _what.c_str(); +} + + +} } // namespace Poco::XML diff --git a/contrib/libs/poco/XML/src/XMLString.cpp b/contrib/libs/poco/XML/src/XMLString.cpp index 732d61f1a5..96de90352c 100644 --- a/contrib/libs/poco/XML/src/XMLString.cpp +++ b/contrib/libs/poco/XML/src/XMLString.cpp @@ -1,64 +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 (XMLString::const_iterator it = str.begin(); it != str.end(); ++it) - { - char c; - wctomb(&c, *it); - 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 +// +// 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 (XMLString::const_iterator it = str.begin(); it != str.end(); ++it) + { + char c; + wctomb(&c, *it); + 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 diff --git a/contrib/libs/poco/XML/src/XMLWriter.cpp b/contrib/libs/poco/XML/src/XMLWriter.cpp index 10833e7b33..49a100db75 100644 --- a/contrib/libs/poco/XML/src/XMLWriter.cpp +++ b/contrib/libs/poco/XML/src/XMLWriter.cpp @@ -1,1072 +1,1072 @@ -// -// XMLWriter.cpp -// -// Library: XML -// Package: XML -// Module: XMLWriter -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/XML/XMLWriter.h" -#include "Poco/XML/XMLString.h" -#include "Poco/XML/XMLException.h" -#include "Poco/SAX/AttributesImpl.h" -#include "Poco/UTF8Encoding.h" -#include "Poco/UTF16Encoding.h" -#include <sstream> - - -namespace Poco { -namespace XML { - - -const std::string XMLWriter::NEWLINE_DEFAULT; -const std::string XMLWriter::NEWLINE_CR = "\r"; -const std::string XMLWriter::NEWLINE_CRLF = "\r\n"; -const std::string XMLWriter::NEWLINE_LF = "\n"; -const std::string XMLWriter::MARKUP_QUOTENC = """; -const std::string XMLWriter::MARKUP_AMPENC = "&"; -const std::string XMLWriter::MARKUP_LTENC = "<"; -const std::string XMLWriter::MARKUP_GTENC = ">"; -const std::string XMLWriter::MARKUP_TABENC = "	"; -const std::string XMLWriter::MARKUP_CRENC = "
"; -const std::string XMLWriter::MARKUP_LFENC = "
"; -const std::string XMLWriter::MARKUP_LT = "<"; -const std::string XMLWriter::MARKUP_GT = ">"; -const std::string XMLWriter::MARKUP_SLASHGT = "/>"; -const std::string XMLWriter::MARKUP_LTSLASH = "</"; -const std::string XMLWriter::MARKUP_COLON = ":"; -const std::string XMLWriter::MARKUP_EQQUOT = "=\""; -const std::string XMLWriter::MARKUP_QUOT = "\""; -const std::string XMLWriter::MARKUP_SPACE = " "; -const std::string XMLWriter::MARKUP_TAB = "\t"; -const std::string XMLWriter::MARKUP_BEGIN_CDATA = "<![CDATA["; -const std::string XMLWriter::MARKUP_END_CDATA = "]]>"; - - -#if defined(XML_UNICODE_WCHAR_T) - #define NATIVE_ENCODING Poco::UTF16Encoding -#else - #define NATIVE_ENCODING Poco::UTF8Encoding -#endif - - -XMLWriter::XMLWriter(XMLByteOutputStream& str, int options): - _pTextConverter(0), - _pInEncoding(new NATIVE_ENCODING), - _pOutEncoding(new Poco::UTF8Encoding), - _options(options), - _encoding("UTF-8"), - _depth(-1), - _elementCount(0), - _inFragment(false), - _inCDATA(false), - _inDTD(false), - _inInternalDTD(false), - _contentWritten(false), - _unclosedStartTag(false), - _prefix(0), - _nsContextPushed(false), - _indent(MARKUP_TAB) -{ - _pTextConverter = new Poco::OutputStreamConverter(str, *_pInEncoding, *_pOutEncoding); - setNewLine((_options & CANONICAL_XML) ? NEWLINE_LF : NEWLINE_DEFAULT); -} - - -XMLWriter::XMLWriter(XMLByteOutputStream& str, int options, const std::string& encodingName, Poco::TextEncoding& textEncoding): - _pTextConverter(0), - _pInEncoding(new NATIVE_ENCODING), - _pOutEncoding(0), - _options(options), - _encoding(encodingName), - _depth(-1), - _elementCount(0), - _inFragment(false), - _inCDATA(false), - _inDTD(false), - _inInternalDTD(false), - _contentWritten(false), - _unclosedStartTag(false), - _prefix(0), - _nsContextPushed(false), - _indent(MARKUP_TAB) -{ - _pTextConverter = new Poco::OutputStreamConverter(str, *_pInEncoding, textEncoding); - setNewLine((_options & CANONICAL_XML) ? NEWLINE_LF : NEWLINE_DEFAULT); -} - - -XMLWriter::XMLWriter(XMLByteOutputStream& str, int options, const std::string& encodingName, Poco::TextEncoding* pTextEncoding): - _pTextConverter(0), - _pInEncoding(new NATIVE_ENCODING), - _pOutEncoding(0), - _options(options), - _encoding(encodingName), - _depth(-1), - _elementCount(0), - _inFragment(false), - _inCDATA(false), - _inDTD(false), - _inInternalDTD(false), - _contentWritten(false), - _unclosedStartTag(false), - _prefix(0), - _nsContextPushed(false), - _indent(MARKUP_TAB) -{ - if (pTextEncoding) - { - _pTextConverter = new Poco::OutputStreamConverter(str, *_pInEncoding, *pTextEncoding); - } - else - { - _encoding = "UTF-8"; - _pOutEncoding = new Poco::UTF8Encoding; - _pTextConverter = new Poco::OutputStreamConverter(str, *_pInEncoding, *_pOutEncoding); - } - setNewLine((_options & CANONICAL_XML) ? NEWLINE_LF : NEWLINE_DEFAULT); -} - - -XMLWriter::~XMLWriter() -{ - delete _pTextConverter; - delete _pInEncoding; - delete _pOutEncoding; -} - - -void XMLWriter::setDocumentLocator(const Locator* /*loc*/) -{ -} - - -void XMLWriter::setNewLine(const std::string& newLineCharacters) -{ - if (newLineCharacters.empty()) - { -#if defined(_WIN32) - _newLine = NEWLINE_CRLF; -#else - _newLine = NEWLINE_LF; -#endif - } - else _newLine = newLineCharacters; -} - - -const std::string& XMLWriter::getNewLine() const -{ - return _newLine; -} - - -void XMLWriter::setIndent(const std::string& indent) -{ - _indent = indent; -} - - -const std::string& XMLWriter::getIndent() const -{ - return _indent; -} - - -void XMLWriter::startDocument() -{ - if (_depth != -1) - throw XMLException("Cannot start a document in another document"); - - _inFragment = false; - _depth = 0; - _elementCount = 0; - _inDTD = false; - _inInternalDTD = false; - _prefix = 0; - - if (_options & WRITE_XML_DECLARATION) - writeXMLDeclaration(); - - _contentWritten = true; - _namespaces.reset(); - _namespaces.pushContext(); -} - - -void XMLWriter::endDocument() -{ - if (_depth > 0) - throw XMLException("Not well-formed (at least one tag has no matching end tag)"); - if (_elementCount == 0) - throw XMLException("No document element"); - - poco_assert_dbg (!_unclosedStartTag); - - _elementCount = 0; - _depth = -1; -} - - -void XMLWriter::startFragment() -{ - if (_depth != -1) - throw XMLException("Cannot start a fragment in another fragment or document"); - - _inFragment = true; - _depth = 0; - _elementCount = 0; - _prefix = 0; - - _contentWritten = true; - _namespaces.reset(); - _namespaces.pushContext(); -} - - -void XMLWriter::endFragment() -{ - if (_depth > 1) - throw XMLException("Not well-formed (at least one tag has no matching end tag)"); - - _inFragment = false; - _elementCount = 0; - _depth = -1; -} - - -void XMLWriter::startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname) -{ - const AttributesImpl attributes; - startElement(namespaceURI, localName, qname, attributes); -} - - -void XMLWriter::startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) -{ - if (_depth == 0 && !_inFragment && _elementCount > 1) - throw XMLException("Not well-formed. Second root element found", nameToString(localName, qname)); - - if (_unclosedStartTag) closeStartTag(); - prettyPrint(); - if (_options & CANONICAL_XML) - writeCanonicalStartElement(namespaceURI, localName, qname, attributes); - else - writeStartElement(namespaceURI, localName, qname, attributes); - _elementStack.push_back(Name(qname, namespaceURI, localName)); - _contentWritten = false; - ++_depth; -} - - -void XMLWriter::endElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname) -{ - if (_depth < 1) - throw XMLException("No unclosed tag"); - - if (!_elementStack.back().equalsWeakly(qname, namespaceURI, localName)) - throw XMLException("End tag does not match start tag", nameToString(localName, qname)); - - _elementStack.pop_back(); - --_depth; - if (!_unclosedStartTag) prettyPrint(); - writeEndElement(namespaceURI, localName, qname); - _contentWritten = false; - if (_depth == 0) - writeNewLine(); -} - - -void XMLWriter::emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname) -{ - const AttributesImpl attributes; - emptyElement(namespaceURI, localName, qname, attributes); -} - - -void XMLWriter::emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) -{ - if (_depth == 0 && _elementCount > 1) - throw XMLException("Not well-formed. Second root element found."); - - if (_unclosedStartTag) closeStartTag(); - prettyPrint(); - if (_options & CANONICAL_XML) - writeCanonicalStartElement(namespaceURI, localName, qname, attributes); - else - writeStartElement(namespaceURI, localName, qname, attributes); - _contentWritten = false; - writeMarkup("/"); - closeStartTag(); - _namespaces.popContext(); -} - - -void XMLWriter::characters(const XMLChar ch[], int start, int length) -{ - if (length == 0) return; - - if (_unclosedStartTag) closeStartTag(); - _contentWritten = _contentWritten || length > 0; - if (_inCDATA) - { - while (length-- > 0) writeXML(ch[start++]); - } - else - { - while (length-- > 0) - { - XMLChar c = ch[start++]; - switch (c) - { - case '"': writeMarkup(MARKUP_QUOTENC); break; - case '&': writeMarkup(MARKUP_AMPENC); break; - case '<': writeMarkup(MARKUP_LTENC); break; - case '>': writeMarkup(MARKUP_GTENC); break; - default: - if (c >= 0 && c < 32) - { - if (c == '\t' || c == '\r' || c == '\n') - writeXML(c); - else - throw XMLException("Invalid character token."); - } - else writeXML(c); - } - } - } -} - - -void XMLWriter::characters(const XMLString& str) -{ - characters(str.data(), 0, (int) str.length()); -} - - -void XMLWriter::rawCharacters(const XMLString& str) -{ - if (_unclosedStartTag) closeStartTag(); - _contentWritten = _contentWritten || !str.empty(); - writeXML(str); -} - - -void XMLWriter::ignorableWhitespace(const XMLChar ch[], int start, int length) -{ - characters(ch, start, length); -} - - -void XMLWriter::processingInstruction(const XMLString& target, const XMLString& data) -{ - if (_unclosedStartTag) closeStartTag(); - prettyPrint(); - writeMarkup("<?"); - writeXML(target); - if (!data.empty()) - { - writeMarkup(MARKUP_SPACE); - writeXML(data); - } - writeMarkup("?>"); - if (_depth == 0) - writeNewLine(); -} - - -namespace -{ - static const XMLString CDATA = toXMLString("CDATA"); -} - - -void XMLWriter::dataElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, - const XMLString& data, - const XMLString& attr1, const XMLString& value1, - const XMLString& attr2, const XMLString& value2, - const XMLString& attr3, const XMLString& value3) -{ - AttributesImpl attributes; - if (!attr1.empty()) attributes.addAttribute(XMLString(), XMLString(), attr1, CDATA, value1); - if (!attr2.empty()) attributes.addAttribute(XMLString(), XMLString(), attr2, CDATA, value2); - if (!attr3.empty()) attributes.addAttribute(XMLString(), XMLString(), attr3, CDATA, value3); - if (data.empty()) - { - emptyElement(namespaceURI, localName, qname, attributes); - } - else - { - startElement(namespaceURI, localName, qname, attributes); - characters(data); - endElement(namespaceURI, localName, qname); - } -} - - -void XMLWriter::startPrefixMapping(const XMLString& prefix, const XMLString& namespaceURI) -{ - if (prefix != NamespaceSupport::XML_NAMESPACE_PREFIX) - { - if (!_nsContextPushed) - { - _namespaces.pushContext(); - _nsContextPushed = true; - } - _namespaces.declarePrefix(prefix, namespaceURI); - } -} - - -void XMLWriter::endPrefixMapping(const XMLString& /*prefix*/) -{ - // Note: prefix removed by popContext() at element closing tag -} - - -void XMLWriter::skippedEntity(const XMLString& /*name*/) -{ -} - - -void XMLWriter::startCDATA() -{ - if (_inCDATA) throw XMLException("Cannot nest CDATA sections"); - if (_unclosedStartTag) closeStartTag(); - _inCDATA = true; - writeMarkup(MARKUP_BEGIN_CDATA); -} - - -void XMLWriter::endCDATA() -{ - poco_assert (_inCDATA); - _inCDATA = false; - writeMarkup(MARKUP_END_CDATA); -} - - -void XMLWriter::comment(const XMLChar ch[], int start, int length) -{ - if (_unclosedStartTag) closeStartTag(); - prettyPrint(); - writeMarkup("<!--"); - while (length-- > 0) writeXML(ch[start++]); - writeMarkup("-->"); - _contentWritten = false; -} - - -void XMLWriter::startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId) -{ - writeMarkup("<!DOCTYPE "); - writeXML(name); - if (!publicId.empty()) - { - writeMarkup(" PUBLIC \""); - writeXML(publicId); - writeMarkup("\""); - } - if (!systemId.empty()) - { - if (publicId.empty()) - { - writeMarkup(" SYSTEM"); - } - writeMarkup(" \""); - writeXML(systemId); - writeMarkup("\""); - } - _inDTD = true; -} - - -void XMLWriter::endDTD() -{ - poco_assert (_inDTD); - if (_inInternalDTD) - { - writeNewLine(); - writeMarkup("]"); - _inInternalDTD = false; - } - writeMarkup(">"); - writeNewLine(); - _inDTD = false; -} - - -void XMLWriter::startEntity(const XMLString& /*name*/) -{ -} - - -void XMLWriter::endEntity(const XMLString& /*name*/) -{ -} - - -void XMLWriter::notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId) -{ - if (!_inDTD) throw XMLException("Notation declaration not within DTD"); - if (!_inInternalDTD) - { - writeMarkup(" ["); - _inInternalDTD = true; - } - if (_options & PRETTY_PRINT) - { - writeNewLine(); - writeMarkup(_indent); - } - writeMarkup("<!NOTATION "); - writeXML(name); - if (systemId && !systemId->empty()) - { - writeMarkup(" SYSTEM \""); - writeXML(*systemId); - writeMarkup("\""); - } - if (publicId && !publicId->empty()) - { - writeMarkup(" PUBLIC \""); - writeXML(*publicId); - writeMarkup("\""); - } - writeMarkup(">"); -} - - -void XMLWriter::unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName) -{ - if (!_inDTD) throw XMLException("Entity declaration not within DTD"); - if (!_inInternalDTD) - { - writeMarkup(" ["); - _inInternalDTD = true; - } - if (_options & PRETTY_PRINT) - { - writeNewLine(); - writeMarkup(_indent); - } - writeMarkup("<!ENTITY "); - writeXML(name); - if (!systemId.empty()) - { - writeMarkup(" SYSTEM \""); - writeXML(systemId); - writeMarkup("\""); - } - if (publicId && !publicId->empty()) - { - writeMarkup(" PUBLIC \""); - writeXML(*publicId); - writeMarkup("\""); - } - if (!notationName.empty()) - { - writeMarkup(" NDATA "); - writeXML(notationName); - } - writeMarkup(">"); -} - - -void XMLWriter::prettyPrint() const -{ - if ((_options & PRETTY_PRINT) && !_contentWritten) - { - writeNewLine(); - writeIndent(); - } -} - - -void XMLWriter::writeStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) -{ - if (!_nsContextPushed) - _namespaces.pushContext(); - _nsContextPushed = false; - ++_elementCount; - - declareAttributeNamespaces(attributes); - - writeMarkup(MARKUP_LT); - if (!localName.empty() && (qname.empty() || localName == qname)) - { - XMLString prefix; - if (!namespaceURI.empty() && !_namespaces.isMapped(namespaceURI)) - { - prefix = uniquePrefix(); - _namespaces.declarePrefix(prefix, namespaceURI); - } - else prefix = _namespaces.getPrefix(namespaceURI); - writeName(prefix, localName); - } - else if (namespaceURI.empty() && localName.empty() && !qname.empty()) - { - writeXML(qname); - } - else if (!localName.empty() && !qname.empty()) - { - XMLString local; - XMLString prefix; - Name::split(qname, prefix, local); - if (prefix.empty()) prefix = _namespaces.getPrefix(namespaceURI); - const XMLString& uri = _namespaces.getURI(prefix); - if ((uri.empty() || uri != namespaceURI) && !namespaceURI.empty()) - { - _namespaces.declarePrefix(prefix, namespaceURI); - } - writeName(prefix, localName); - } - else throw XMLException("Tag mismatch", nameToString(localName, qname)); - - AttributeMap attributeMap; - addNamespaceAttributes(attributeMap); - addAttributes(attributeMap, attributes, namespaceURI); - writeAttributes(attributeMap); - _unclosedStartTag = true; -} - - -void XMLWriter::writeCanonicalStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) -{ - if (!_nsContextPushed) - _namespaces.pushContext(); - _nsContextPushed = false; - ++_elementCount; - - declareNamespaces(namespaceURI, localName, qname, attributes); - - writeMarkup(MARKUP_LT); - if (!localName.empty()) - { - writeName(_namespaces.getPrefix(namespaceURI), localName); - } - else if (namespaceURI.empty() && !qname.empty()) - { - writeXML(qname); - } - else throw XMLException("Tag mismatch", nameToString(localName, qname)); - - CanonicalAttributeMap namespaceAttributeMap; - addNamespaceAttributes(namespaceAttributeMap); - writeAttributes(namespaceAttributeMap); - CanonicalAttributeMap attributeMap; - addAttributes(attributeMap, attributes, namespaceURI); - writeAttributes(attributeMap); - _unclosedStartTag = true; -} - - -void XMLWriter::writeEndElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname) -{ - if (_unclosedStartTag && !(_options & CANONICAL_XML)) - { - writeMarkup(MARKUP_SLASHGT); - _unclosedStartTag = false; - } - else - { - if (_unclosedStartTag) - { - writeMarkup(MARKUP_GT); - _unclosedStartTag = false; - } - writeMarkup(MARKUP_LTSLASH); - if (!localName.empty()) - { - XMLString prefix = _namespaces.getPrefix(namespaceURI); - writeName(prefix, localName); - } - else - { - writeXML(qname); - } - writeMarkup(MARKUP_GT); - } - _namespaces.popContext(); -} - - -void XMLWriter::closeStartTag() -{ - _unclosedStartTag = false; - writeMarkup(MARKUP_GT); -} - - -void XMLWriter::declareNamespaces(const XMLString& namespaceURI, const XMLString& /*localName*/, const XMLString& qname, const Attributes& attributes) -{ - std::map<XMLString, std::set<XMLString> > usedNamespaces; - bool defaultNameSpaceUsed = false; - XMLString defaultNamespaceURI = _namespaces.getURI(XMLString()); - XMLString local; - XMLString prefix; - XMLString elementNamespaceURI = namespaceURI; - Name::split(qname, prefix, local); - if (elementNamespaceURI.empty()) - elementNamespaceURI = _namespaces.getURI(prefix); - if (!elementNamespaceURI.empty()) - { - usedNamespaces[prefix].insert(elementNamespaceURI); - if (!defaultNamespaceURI.empty() && elementNamespaceURI == defaultNamespaceURI) - defaultNameSpaceUsed = true; - } - for (int i = 0; i < attributes.getLength(); i++) - { - XMLString attributeNamespaceURI = attributes.getURI(i); - XMLString attributeLocalName = attributes.getLocalName(i); - XMLString attributeQName = attributes.getQName(i); - - XMLString attributePrefix; - XMLString attributeLocal; - Name::split(attributeQName, attributePrefix, attributeLocal); - if (attributeNamespaceURI.empty()) - attributeNamespaceURI = _namespaces.getURI(prefix); - if (!attributeNamespaceURI.empty()) - { - usedNamespaces[attributePrefix].insert(attributeNamespaceURI); - defaultNameSpaceUsed = defaultNameSpaceUsed || (!defaultNamespaceURI.empty() && attributeNamespaceURI == defaultNamespaceURI); - } - } - for (std::map<XMLString, std::set<XMLString> >::const_iterator it = usedNamespaces.begin(); it != usedNamespaces.end(); ++it) - { - const std::set<XMLString> namespaceURIs = it->second; - for (std::set<XMLString>::const_iterator itURI = namespaceURIs.begin(); itURI != namespaceURIs.end(); ++itURI) - { - XMLString prefix2 = it->first; - if (prefix2.empty()) - prefix2 = _namespaces.getPrefix(*itURI); - if (prefix2.empty() && !_namespaces.isMapped(*itURI)) - { - if (defaultNameSpaceUsed) - { - if (*itURI != defaultNamespaceURI) - prefix2 = uniquePrefix(); - } - else - { - defaultNamespaceURI = *itURI; - defaultNameSpaceUsed = true; - } - - } - const XMLString& uri = _namespaces.getURI(prefix2); - if ((uri.empty() || uri != *itURI) && !itURI->empty()) - { - _namespaces.declarePrefix(prefix2, *itURI); - } - } - } -} - - -void XMLWriter::declareAttributeNamespaces(const Attributes& attributes) -{ - for (int i = 0; i < attributes.getLength(); i++) - { - XMLString namespaceURI = attributes.getURI(i); - XMLString localName = attributes.getLocalName(i); - XMLString qname = attributes.getQName(i); - if (!localName.empty()) - { - XMLString prefix; - XMLString splitLocalName; - Name::split(qname, prefix, splitLocalName); - if (prefix.empty()) prefix = _namespaces.getPrefix(namespaceURI); - if (prefix.empty() && !namespaceURI.empty() && !_namespaces.isMapped(namespaceURI)) - { - prefix = uniquePrefix(); - _namespaces.declarePrefix(prefix, namespaceURI); - } - - const XMLString& uri = _namespaces.getURI(prefix); - if ((uri.empty() || uri != namespaceURI) && !namespaceURI.empty()) - { - _namespaces.declarePrefix(prefix, namespaceURI); - } - } - } -} - - -void XMLWriter::addNamespaceAttributes(AttributeMap& attributeMap) -{ - NamespaceSupport::PrefixSet prefixes; - _namespaces.getDeclaredPrefixes(prefixes); - for (NamespaceSupport::PrefixSet::const_iterator it = prefixes.begin(); it != prefixes.end(); ++it) - { - XMLString prefix = *it; - XMLString uri = _namespaces.getURI(prefix); - XMLString qname = NamespaceSupport::XMLNS_NAMESPACE_PREFIX; - - if (!prefix.empty()) - { - qname.append(toXMLString(MARKUP_COLON)); - qname.append(prefix); - } - attributeMap[qname] = uri; - } -} - - -void XMLWriter::addNamespaceAttributes(CanonicalAttributeMap& attributeMap) -{ - NamespaceSupport::PrefixSet prefixes; - _namespaces.getDeclaredPrefixes(prefixes); - for (NamespaceSupport::PrefixSet::const_iterator it = prefixes.begin(); it != prefixes.end(); ++it) - { - XMLString prefix = *it; - XMLString uri = _namespaces.getURI(prefix); - XMLString qname = NamespaceSupport::XMLNS_NAMESPACE_PREFIX; - - if (!prefix.empty()) - { - qname.append(toXMLString(MARKUP_COLON)); - qname.append(prefix); - } - attributeMap.insert(std::make_pair(qname, std::make_pair(qname, uri))); - } -} - - -void XMLWriter::addAttributes(AttributeMap& attributeMap, const Attributes& attributes, const XMLString& /*elementNamespaceURI*/) -{ - for (int i = 0; i < attributes.getLength(); i++) - { - XMLString namespaceURI = attributes.getURI(i); - XMLString localName = attributes.getLocalName(i); - XMLString qname = attributes.getQName(i); - if (!localName.empty()) - { - XMLString prefix; - if (!namespaceURI.empty()) - prefix = _namespaces.getPrefix(namespaceURI); - if (!prefix.empty()) - { - qname = prefix; - qname.append(toXMLString(MARKUP_COLON)); - } - else qname.clear(); - qname.append(localName); - } - attributeMap[qname] = attributes.getValue(i); - } -} - - -void XMLWriter::addAttributes(CanonicalAttributeMap& attributeMap, const Attributes& attributes, const XMLString& /*elementNamespaceURI*/) -{ - for (int i = 0; i < attributes.getLength(); i++) - { - XMLString namespaceURI = attributes.getURI(i); - XMLString localName = attributes.getLocalName(i); - XMLString qname = attributes.getQName(i); - XMLString fullQName = qname; - if (!localName.empty()) - { - XMLString prefix; - if (!namespaceURI.empty()) - { - prefix = _namespaces.getPrefix(namespaceURI); - fullQName = namespaceURI; - fullQName.append(toXMLString(MARKUP_COLON)); - } - else fullQName.clear(); - if (!prefix.empty()) - { - qname = prefix; - qname.append(toXMLString(MARKUP_COLON)); - } - else qname.clear(); - qname.append(localName); - fullQName.append(localName); - } - attributeMap.insert(std::make_pair(fullQName, std::make_pair(qname, attributes.getValue(i)))); - } -} - - -void XMLWriter::writeAttributes(const AttributeMap& attributeMap) -{ - for (AttributeMap::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it) - { - if ((_options & PRETTY_PRINT) && (_options & PRETTY_PRINT_ATTRIBUTES)) - { - writeNewLine(); - writeIndent(_depth + 1); - } - else - { - writeMarkup(MARKUP_SPACE); - } - writeXML(it->first); - writeMarkup(MARKUP_EQQUOT); - for (XMLString::const_iterator itc = it->second.begin(); itc != it->second.end(); ++itc) - { - XMLChar c = *itc; - switch (c) - { - case '"': writeMarkup(MARKUP_QUOTENC); break; - case '&': writeMarkup(MARKUP_AMPENC); break; - case '<': writeMarkup(MARKUP_LTENC); break; - case '>': writeMarkup(MARKUP_GTENC); break; - case '\t': writeMarkup(MARKUP_TABENC); break; - case '\r': writeMarkup(MARKUP_CRENC); break; - case '\n': writeMarkup(MARKUP_LFENC); break; - default: - if (c >= 0 && c < 32) - throw XMLException("Invalid character token."); +// +// XMLWriter.cpp +// +// Library: XML +// Package: XML +// Module: XMLWriter +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/XML/XMLWriter.h" +#include "Poco/XML/XMLString.h" +#include "Poco/XML/XMLException.h" +#include "Poco/SAX/AttributesImpl.h" +#include "Poco/UTF8Encoding.h" +#include "Poco/UTF16Encoding.h" +#include <sstream> + + +namespace Poco { +namespace XML { + + +const std::string XMLWriter::NEWLINE_DEFAULT; +const std::string XMLWriter::NEWLINE_CR = "\r"; +const std::string XMLWriter::NEWLINE_CRLF = "\r\n"; +const std::string XMLWriter::NEWLINE_LF = "\n"; +const std::string XMLWriter::MARKUP_QUOTENC = """; +const std::string XMLWriter::MARKUP_AMPENC = "&"; +const std::string XMLWriter::MARKUP_LTENC = "<"; +const std::string XMLWriter::MARKUP_GTENC = ">"; +const std::string XMLWriter::MARKUP_TABENC = "	"; +const std::string XMLWriter::MARKUP_CRENC = "
"; +const std::string XMLWriter::MARKUP_LFENC = "
"; +const std::string XMLWriter::MARKUP_LT = "<"; +const std::string XMLWriter::MARKUP_GT = ">"; +const std::string XMLWriter::MARKUP_SLASHGT = "/>"; +const std::string XMLWriter::MARKUP_LTSLASH = "</"; +const std::string XMLWriter::MARKUP_COLON = ":"; +const std::string XMLWriter::MARKUP_EQQUOT = "=\""; +const std::string XMLWriter::MARKUP_QUOT = "\""; +const std::string XMLWriter::MARKUP_SPACE = " "; +const std::string XMLWriter::MARKUP_TAB = "\t"; +const std::string XMLWriter::MARKUP_BEGIN_CDATA = "<![CDATA["; +const std::string XMLWriter::MARKUP_END_CDATA = "]]>"; + + +#if defined(XML_UNICODE_WCHAR_T) + #define NATIVE_ENCODING Poco::UTF16Encoding +#else + #define NATIVE_ENCODING Poco::UTF8Encoding +#endif + + +XMLWriter::XMLWriter(XMLByteOutputStream& str, int options): + _pTextConverter(0), + _pInEncoding(new NATIVE_ENCODING), + _pOutEncoding(new Poco::UTF8Encoding), + _options(options), + _encoding("UTF-8"), + _depth(-1), + _elementCount(0), + _inFragment(false), + _inCDATA(false), + _inDTD(false), + _inInternalDTD(false), + _contentWritten(false), + _unclosedStartTag(false), + _prefix(0), + _nsContextPushed(false), + _indent(MARKUP_TAB) +{ + _pTextConverter = new Poco::OutputStreamConverter(str, *_pInEncoding, *_pOutEncoding); + setNewLine((_options & CANONICAL_XML) ? NEWLINE_LF : NEWLINE_DEFAULT); +} + + +XMLWriter::XMLWriter(XMLByteOutputStream& str, int options, const std::string& encodingName, Poco::TextEncoding& textEncoding): + _pTextConverter(0), + _pInEncoding(new NATIVE_ENCODING), + _pOutEncoding(0), + _options(options), + _encoding(encodingName), + _depth(-1), + _elementCount(0), + _inFragment(false), + _inCDATA(false), + _inDTD(false), + _inInternalDTD(false), + _contentWritten(false), + _unclosedStartTag(false), + _prefix(0), + _nsContextPushed(false), + _indent(MARKUP_TAB) +{ + _pTextConverter = new Poco::OutputStreamConverter(str, *_pInEncoding, textEncoding); + setNewLine((_options & CANONICAL_XML) ? NEWLINE_LF : NEWLINE_DEFAULT); +} + + +XMLWriter::XMLWriter(XMLByteOutputStream& str, int options, const std::string& encodingName, Poco::TextEncoding* pTextEncoding): + _pTextConverter(0), + _pInEncoding(new NATIVE_ENCODING), + _pOutEncoding(0), + _options(options), + _encoding(encodingName), + _depth(-1), + _elementCount(0), + _inFragment(false), + _inCDATA(false), + _inDTD(false), + _inInternalDTD(false), + _contentWritten(false), + _unclosedStartTag(false), + _prefix(0), + _nsContextPushed(false), + _indent(MARKUP_TAB) +{ + if (pTextEncoding) + { + _pTextConverter = new Poco::OutputStreamConverter(str, *_pInEncoding, *pTextEncoding); + } + else + { + _encoding = "UTF-8"; + _pOutEncoding = new Poco::UTF8Encoding; + _pTextConverter = new Poco::OutputStreamConverter(str, *_pInEncoding, *_pOutEncoding); + } + setNewLine((_options & CANONICAL_XML) ? NEWLINE_LF : NEWLINE_DEFAULT); +} + + +XMLWriter::~XMLWriter() +{ + delete _pTextConverter; + delete _pInEncoding; + delete _pOutEncoding; +} + + +void XMLWriter::setDocumentLocator(const Locator* /*loc*/) +{ +} + + +void XMLWriter::setNewLine(const std::string& newLineCharacters) +{ + if (newLineCharacters.empty()) + { +#if defined(_WIN32) + _newLine = NEWLINE_CRLF; +#else + _newLine = NEWLINE_LF; +#endif + } + else _newLine = newLineCharacters; +} + + +const std::string& XMLWriter::getNewLine() const +{ + return _newLine; +} + + +void XMLWriter::setIndent(const std::string& indent) +{ + _indent = indent; +} + + +const std::string& XMLWriter::getIndent() const +{ + return _indent; +} + + +void XMLWriter::startDocument() +{ + if (_depth != -1) + throw XMLException("Cannot start a document in another document"); + + _inFragment = false; + _depth = 0; + _elementCount = 0; + _inDTD = false; + _inInternalDTD = false; + _prefix = 0; + + if (_options & WRITE_XML_DECLARATION) + writeXMLDeclaration(); + + _contentWritten = true; + _namespaces.reset(); + _namespaces.pushContext(); +} + + +void XMLWriter::endDocument() +{ + if (_depth > 0) + throw XMLException("Not well-formed (at least one tag has no matching end tag)"); + if (_elementCount == 0) + throw XMLException("No document element"); + + poco_assert_dbg (!_unclosedStartTag); + + _elementCount = 0; + _depth = -1; +} + + +void XMLWriter::startFragment() +{ + if (_depth != -1) + throw XMLException("Cannot start a fragment in another fragment or document"); + + _inFragment = true; + _depth = 0; + _elementCount = 0; + _prefix = 0; + + _contentWritten = true; + _namespaces.reset(); + _namespaces.pushContext(); +} + + +void XMLWriter::endFragment() +{ + if (_depth > 1) + throw XMLException("Not well-formed (at least one tag has no matching end tag)"); + + _inFragment = false; + _elementCount = 0; + _depth = -1; +} + + +void XMLWriter::startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname) +{ + const AttributesImpl attributes; + startElement(namespaceURI, localName, qname, attributes); +} + + +void XMLWriter::startElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) +{ + if (_depth == 0 && !_inFragment && _elementCount > 1) + throw XMLException("Not well-formed. Second root element found", nameToString(localName, qname)); + + if (_unclosedStartTag) closeStartTag(); + prettyPrint(); + if (_options & CANONICAL_XML) + writeCanonicalStartElement(namespaceURI, localName, qname, attributes); + else + writeStartElement(namespaceURI, localName, qname, attributes); + _elementStack.push_back(Name(qname, namespaceURI, localName)); + _contentWritten = false; + ++_depth; +} + + +void XMLWriter::endElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname) +{ + if (_depth < 1) + throw XMLException("No unclosed tag"); + + if (!_elementStack.back().equalsWeakly(qname, namespaceURI, localName)) + throw XMLException("End tag does not match start tag", nameToString(localName, qname)); + + _elementStack.pop_back(); + --_depth; + if (!_unclosedStartTag) prettyPrint(); + writeEndElement(namespaceURI, localName, qname); + _contentWritten = false; + if (_depth == 0) + writeNewLine(); +} + + +void XMLWriter::emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname) +{ + const AttributesImpl attributes; + emptyElement(namespaceURI, localName, qname, attributes); +} + + +void XMLWriter::emptyElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) +{ + if (_depth == 0 && _elementCount > 1) + throw XMLException("Not well-formed. Second root element found."); + + if (_unclosedStartTag) closeStartTag(); + prettyPrint(); + if (_options & CANONICAL_XML) + writeCanonicalStartElement(namespaceURI, localName, qname, attributes); + else + writeStartElement(namespaceURI, localName, qname, attributes); + _contentWritten = false; + writeMarkup("/"); + closeStartTag(); + _namespaces.popContext(); +} + + +void XMLWriter::characters(const XMLChar ch[], int start, int length) +{ + if (length == 0) return; + + if (_unclosedStartTag) closeStartTag(); + _contentWritten = _contentWritten || length > 0; + if (_inCDATA) + { + while (length-- > 0) writeXML(ch[start++]); + } + else + { + while (length-- > 0) + { + XMLChar c = ch[start++]; + switch (c) + { + case '"': writeMarkup(MARKUP_QUOTENC); break; + case '&': writeMarkup(MARKUP_AMPENC); break; + case '<': writeMarkup(MARKUP_LTENC); break; + case '>': writeMarkup(MARKUP_GTENC); break; + default: + if (c >= 0 && c < 32) + { + if (c == '\t' || c == '\r' || c == '\n') + writeXML(c); + else + throw XMLException("Invalid character token."); + } + else writeXML(c); + } + } + } +} + + +void XMLWriter::characters(const XMLString& str) +{ + characters(str.data(), 0, (int) str.length()); +} + + +void XMLWriter::rawCharacters(const XMLString& str) +{ + if (_unclosedStartTag) closeStartTag(); + _contentWritten = _contentWritten || !str.empty(); + writeXML(str); +} + + +void XMLWriter::ignorableWhitespace(const XMLChar ch[], int start, int length) +{ + characters(ch, start, length); +} + + +void XMLWriter::processingInstruction(const XMLString& target, const XMLString& data) +{ + if (_unclosedStartTag) closeStartTag(); + prettyPrint(); + writeMarkup("<?"); + writeXML(target); + if (!data.empty()) + { + writeMarkup(MARKUP_SPACE); + writeXML(data); + } + writeMarkup("?>"); + if (_depth == 0) + writeNewLine(); +} + + +namespace +{ + static const XMLString CDATA = toXMLString("CDATA"); +} + + +void XMLWriter::dataElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, + const XMLString& data, + const XMLString& attr1, const XMLString& value1, + const XMLString& attr2, const XMLString& value2, + const XMLString& attr3, const XMLString& value3) +{ + AttributesImpl attributes; + if (!attr1.empty()) attributes.addAttribute(XMLString(), XMLString(), attr1, CDATA, value1); + if (!attr2.empty()) attributes.addAttribute(XMLString(), XMLString(), attr2, CDATA, value2); + if (!attr3.empty()) attributes.addAttribute(XMLString(), XMLString(), attr3, CDATA, value3); + if (data.empty()) + { + emptyElement(namespaceURI, localName, qname, attributes); + } + else + { + startElement(namespaceURI, localName, qname, attributes); + characters(data); + endElement(namespaceURI, localName, qname); + } +} + + +void XMLWriter::startPrefixMapping(const XMLString& prefix, const XMLString& namespaceURI) +{ + if (prefix != NamespaceSupport::XML_NAMESPACE_PREFIX) + { + if (!_nsContextPushed) + { + _namespaces.pushContext(); + _nsContextPushed = true; + } + _namespaces.declarePrefix(prefix, namespaceURI); + } +} + + +void XMLWriter::endPrefixMapping(const XMLString& /*prefix*/) +{ + // Note: prefix removed by popContext() at element closing tag +} + + +void XMLWriter::skippedEntity(const XMLString& /*name*/) +{ +} + + +void XMLWriter::startCDATA() +{ + if (_inCDATA) throw XMLException("Cannot nest CDATA sections"); + if (_unclosedStartTag) closeStartTag(); + _inCDATA = true; + writeMarkup(MARKUP_BEGIN_CDATA); +} + + +void XMLWriter::endCDATA() +{ + poco_assert (_inCDATA); + _inCDATA = false; + writeMarkup(MARKUP_END_CDATA); +} + + +void XMLWriter::comment(const XMLChar ch[], int start, int length) +{ + if (_unclosedStartTag) closeStartTag(); + prettyPrint(); + writeMarkup("<!--"); + while (length-- > 0) writeXML(ch[start++]); + writeMarkup("-->"); + _contentWritten = false; +} + + +void XMLWriter::startDTD(const XMLString& name, const XMLString& publicId, const XMLString& systemId) +{ + writeMarkup("<!DOCTYPE "); + writeXML(name); + if (!publicId.empty()) + { + writeMarkup(" PUBLIC \""); + writeXML(publicId); + writeMarkup("\""); + } + if (!systemId.empty()) + { + if (publicId.empty()) + { + writeMarkup(" SYSTEM"); + } + writeMarkup(" \""); + writeXML(systemId); + writeMarkup("\""); + } + _inDTD = true; +} + + +void XMLWriter::endDTD() +{ + poco_assert (_inDTD); + if (_inInternalDTD) + { + writeNewLine(); + writeMarkup("]"); + _inInternalDTD = false; + } + writeMarkup(">"); + writeNewLine(); + _inDTD = false; +} + + +void XMLWriter::startEntity(const XMLString& /*name*/) +{ +} + + +void XMLWriter::endEntity(const XMLString& /*name*/) +{ +} + + +void XMLWriter::notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId) +{ + if (!_inDTD) throw XMLException("Notation declaration not within DTD"); + if (!_inInternalDTD) + { + writeMarkup(" ["); + _inInternalDTD = true; + } + if (_options & PRETTY_PRINT) + { + writeNewLine(); + writeMarkup(_indent); + } + writeMarkup("<!NOTATION "); + writeXML(name); + if (systemId && !systemId->empty()) + { + writeMarkup(" SYSTEM \""); + writeXML(*systemId); + writeMarkup("\""); + } + if (publicId && !publicId->empty()) + { + writeMarkup(" PUBLIC \""); + writeXML(*publicId); + writeMarkup("\""); + } + writeMarkup(">"); +} + + +void XMLWriter::unparsedEntityDecl(const XMLString& name, const XMLString* publicId, const XMLString& systemId, const XMLString& notationName) +{ + if (!_inDTD) throw XMLException("Entity declaration not within DTD"); + if (!_inInternalDTD) + { + writeMarkup(" ["); + _inInternalDTD = true; + } + if (_options & PRETTY_PRINT) + { + writeNewLine(); + writeMarkup(_indent); + } + writeMarkup("<!ENTITY "); + writeXML(name); + if (!systemId.empty()) + { + writeMarkup(" SYSTEM \""); + writeXML(systemId); + writeMarkup("\""); + } + if (publicId && !publicId->empty()) + { + writeMarkup(" PUBLIC \""); + writeXML(*publicId); + writeMarkup("\""); + } + if (!notationName.empty()) + { + writeMarkup(" NDATA "); + writeXML(notationName); + } + writeMarkup(">"); +} + + +void XMLWriter::prettyPrint() const +{ + if ((_options & PRETTY_PRINT) && !_contentWritten) + { + writeNewLine(); + writeIndent(); + } +} + + +void XMLWriter::writeStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) +{ + if (!_nsContextPushed) + _namespaces.pushContext(); + _nsContextPushed = false; + ++_elementCount; + + declareAttributeNamespaces(attributes); + + writeMarkup(MARKUP_LT); + if (!localName.empty() && (qname.empty() || localName == qname)) + { + XMLString prefix; + if (!namespaceURI.empty() && !_namespaces.isMapped(namespaceURI)) + { + prefix = uniquePrefix(); + _namespaces.declarePrefix(prefix, namespaceURI); + } + else prefix = _namespaces.getPrefix(namespaceURI); + writeName(prefix, localName); + } + else if (namespaceURI.empty() && localName.empty() && !qname.empty()) + { + writeXML(qname); + } + else if (!localName.empty() && !qname.empty()) + { + XMLString local; + XMLString prefix; + Name::split(qname, prefix, local); + if (prefix.empty()) prefix = _namespaces.getPrefix(namespaceURI); + const XMLString& uri = _namespaces.getURI(prefix); + if ((uri.empty() || uri != namespaceURI) && !namespaceURI.empty()) + { + _namespaces.declarePrefix(prefix, namespaceURI); + } + writeName(prefix, localName); + } + else throw XMLException("Tag mismatch", nameToString(localName, qname)); + + AttributeMap attributeMap; + addNamespaceAttributes(attributeMap); + addAttributes(attributeMap, attributes, namespaceURI); + writeAttributes(attributeMap); + _unclosedStartTag = true; +} + + +void XMLWriter::writeCanonicalStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) +{ + if (!_nsContextPushed) + _namespaces.pushContext(); + _nsContextPushed = false; + ++_elementCount; + + declareNamespaces(namespaceURI, localName, qname, attributes); + + writeMarkup(MARKUP_LT); + if (!localName.empty()) + { + writeName(_namespaces.getPrefix(namespaceURI), localName); + } + else if (namespaceURI.empty() && !qname.empty()) + { + writeXML(qname); + } + else throw XMLException("Tag mismatch", nameToString(localName, qname)); + + CanonicalAttributeMap namespaceAttributeMap; + addNamespaceAttributes(namespaceAttributeMap); + writeAttributes(namespaceAttributeMap); + CanonicalAttributeMap attributeMap; + addAttributes(attributeMap, attributes, namespaceURI); + writeAttributes(attributeMap); + _unclosedStartTag = true; +} + + +void XMLWriter::writeEndElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname) +{ + if (_unclosedStartTag && !(_options & CANONICAL_XML)) + { + writeMarkup(MARKUP_SLASHGT); + _unclosedStartTag = false; + } + else + { + if (_unclosedStartTag) + { + writeMarkup(MARKUP_GT); + _unclosedStartTag = false; + } + writeMarkup(MARKUP_LTSLASH); + if (!localName.empty()) + { + XMLString prefix = _namespaces.getPrefix(namespaceURI); + writeName(prefix, localName); + } + else + { + writeXML(qname); + } + writeMarkup(MARKUP_GT); + } + _namespaces.popContext(); +} + + +void XMLWriter::closeStartTag() +{ + _unclosedStartTag = false; + writeMarkup(MARKUP_GT); +} + + +void XMLWriter::declareNamespaces(const XMLString& namespaceURI, const XMLString& /*localName*/, const XMLString& qname, const Attributes& attributes) +{ + std::map<XMLString, std::set<XMLString> > usedNamespaces; + bool defaultNameSpaceUsed = false; + XMLString defaultNamespaceURI = _namespaces.getURI(XMLString()); + XMLString local; + XMLString prefix; + XMLString elementNamespaceURI = namespaceURI; + Name::split(qname, prefix, local); + if (elementNamespaceURI.empty()) + elementNamespaceURI = _namespaces.getURI(prefix); + if (!elementNamespaceURI.empty()) + { + usedNamespaces[prefix].insert(elementNamespaceURI); + if (!defaultNamespaceURI.empty() && elementNamespaceURI == defaultNamespaceURI) + defaultNameSpaceUsed = true; + } + for (int i = 0; i < attributes.getLength(); i++) + { + XMLString attributeNamespaceURI = attributes.getURI(i); + XMLString attributeLocalName = attributes.getLocalName(i); + XMLString attributeQName = attributes.getQName(i); + + XMLString attributePrefix; + XMLString attributeLocal; + Name::split(attributeQName, attributePrefix, attributeLocal); + if (attributeNamespaceURI.empty()) + attributeNamespaceURI = _namespaces.getURI(prefix); + if (!attributeNamespaceURI.empty()) + { + usedNamespaces[attributePrefix].insert(attributeNamespaceURI); + defaultNameSpaceUsed = defaultNameSpaceUsed || (!defaultNamespaceURI.empty() && attributeNamespaceURI == defaultNamespaceURI); + } + } + for (std::map<XMLString, std::set<XMLString> >::const_iterator it = usedNamespaces.begin(); it != usedNamespaces.end(); ++it) + { + const std::set<XMLString> namespaceURIs = it->second; + for (std::set<XMLString>::const_iterator itURI = namespaceURIs.begin(); itURI != namespaceURIs.end(); ++itURI) + { + XMLString prefix2 = it->first; + if (prefix2.empty()) + prefix2 = _namespaces.getPrefix(*itURI); + if (prefix2.empty() && !_namespaces.isMapped(*itURI)) + { + if (defaultNameSpaceUsed) + { + if (*itURI != defaultNamespaceURI) + prefix2 = uniquePrefix(); + } else - writeXML(c); - } - } - writeMarkup(MARKUP_QUOT); - } -} - - -void XMLWriter::writeAttributes(const CanonicalAttributeMap& attributeMap) -{ - for (CanonicalAttributeMap::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it) - { - if ((_options & PRETTY_PRINT) && (_options & PRETTY_PRINT_ATTRIBUTES)) - { - writeNewLine(); - writeIndent(_depth + 1); - } - else - { - writeMarkup(MARKUP_SPACE); - } - writeXML(it->second.first); - writeMarkup(MARKUP_EQQUOT); - for (XMLString::const_iterator itc = it->second.second.begin(); itc != it->second.second.end(); ++itc) - { - XMLChar c = *itc; - switch (c) - { - case '"': writeMarkup(MARKUP_QUOTENC); break; - case '&': writeMarkup(MARKUP_AMPENC); break; - case '<': writeMarkup(MARKUP_LTENC); break; - case '>': writeMarkup(MARKUP_GTENC); break; - case '\t': writeMarkup(MARKUP_TABENC); break; - case '\r': writeMarkup(MARKUP_CRENC); break; - case '\n': writeMarkup(MARKUP_LFENC); break; - default: - if (c >= 0 && c < 32) - throw XMLException("Invalid character token."); - else - writeXML(c); - } - } - writeMarkup(MARKUP_QUOT); - } -} - - -void XMLWriter::writeMarkup(const std::string& str) const -{ -#if defined(XML_UNICODE_WCHAR_T) - const XMLString xmlString = toXMLString(str); - writeXML(xmlString); -#else - _pTextConverter->write(str.data(), (int) str.size()); -#endif -} - - -void XMLWriter::writeXML(const XMLString& str) const -{ - _pTextConverter->write((const char*) str.data(), (int) str.size()*sizeof(XMLChar)); -} - - -void XMLWriter::writeXML(XMLChar ch) const -{ - _pTextConverter->write((const char*) &ch, sizeof(ch)); -} - - -void XMLWriter::writeName(const XMLString& prefix, const XMLString& localName) -{ - if (prefix.empty()) - { - writeXML(localName); - } - else - { - writeXML(prefix); - writeMarkup(MARKUP_COLON); - writeXML(localName); - } -} - - -void XMLWriter::writeNewLine() const -{ - if (_options & PRETTY_PRINT) - writeMarkup(_newLine); -} - - -void XMLWriter::writeIndent() const -{ - writeIndent(_depth); -} - - -void XMLWriter::writeIndent(int depth) const -{ - for (int i = 0; i < depth; ++i) - writeMarkup(_indent); -} - - -void XMLWriter::writeXMLDeclaration() -{ - writeMarkup("<?xml version=\"1.0\""); - if (!_encoding.empty()) - { - writeMarkup(" encoding=\""); - writeMarkup(_encoding); - writeMarkup("\""); - } - writeMarkup("?>"); - writeNewLine(); -} - - -std::string XMLWriter::nameToString(const XMLString& localName, const XMLString& qname) -{ - if (qname.empty()) - return fromXMLString(localName); - else - return fromXMLString(qname); -} - - -XMLString XMLWriter::uniquePrefix() -{ - std::ostringstream str; - str << "ns" << ++_prefix; - return toXMLString(str.str()); -} - - -bool XMLWriter::isNamespaceMapped(const XMLString& namespc) const -{ - return _namespaces.isMapped(namespc); -} - - -} } // namespace Poco::XML + { + defaultNamespaceURI = *itURI; + defaultNameSpaceUsed = true; + } + + } + const XMLString& uri = _namespaces.getURI(prefix2); + if ((uri.empty() || uri != *itURI) && !itURI->empty()) + { + _namespaces.declarePrefix(prefix2, *itURI); + } + } + } +} + + +void XMLWriter::declareAttributeNamespaces(const Attributes& attributes) +{ + for (int i = 0; i < attributes.getLength(); i++) + { + XMLString namespaceURI = attributes.getURI(i); + XMLString localName = attributes.getLocalName(i); + XMLString qname = attributes.getQName(i); + if (!localName.empty()) + { + XMLString prefix; + XMLString splitLocalName; + Name::split(qname, prefix, splitLocalName); + if (prefix.empty()) prefix = _namespaces.getPrefix(namespaceURI); + if (prefix.empty() && !namespaceURI.empty() && !_namespaces.isMapped(namespaceURI)) + { + prefix = uniquePrefix(); + _namespaces.declarePrefix(prefix, namespaceURI); + } + + const XMLString& uri = _namespaces.getURI(prefix); + if ((uri.empty() || uri != namespaceURI) && !namespaceURI.empty()) + { + _namespaces.declarePrefix(prefix, namespaceURI); + } + } + } +} + + +void XMLWriter::addNamespaceAttributes(AttributeMap& attributeMap) +{ + NamespaceSupport::PrefixSet prefixes; + _namespaces.getDeclaredPrefixes(prefixes); + for (NamespaceSupport::PrefixSet::const_iterator it = prefixes.begin(); it != prefixes.end(); ++it) + { + XMLString prefix = *it; + XMLString uri = _namespaces.getURI(prefix); + XMLString qname = NamespaceSupport::XMLNS_NAMESPACE_PREFIX; + + if (!prefix.empty()) + { + qname.append(toXMLString(MARKUP_COLON)); + qname.append(prefix); + } + attributeMap[qname] = uri; + } +} + + +void XMLWriter::addNamespaceAttributes(CanonicalAttributeMap& attributeMap) +{ + NamespaceSupport::PrefixSet prefixes; + _namespaces.getDeclaredPrefixes(prefixes); + for (NamespaceSupport::PrefixSet::const_iterator it = prefixes.begin(); it != prefixes.end(); ++it) + { + XMLString prefix = *it; + XMLString uri = _namespaces.getURI(prefix); + XMLString qname = NamespaceSupport::XMLNS_NAMESPACE_PREFIX; + + if (!prefix.empty()) + { + qname.append(toXMLString(MARKUP_COLON)); + qname.append(prefix); + } + attributeMap.insert(std::make_pair(qname, std::make_pair(qname, uri))); + } +} + + +void XMLWriter::addAttributes(AttributeMap& attributeMap, const Attributes& attributes, const XMLString& /*elementNamespaceURI*/) +{ + for (int i = 0; i < attributes.getLength(); i++) + { + XMLString namespaceURI = attributes.getURI(i); + XMLString localName = attributes.getLocalName(i); + XMLString qname = attributes.getQName(i); + if (!localName.empty()) + { + XMLString prefix; + if (!namespaceURI.empty()) + prefix = _namespaces.getPrefix(namespaceURI); + if (!prefix.empty()) + { + qname = prefix; + qname.append(toXMLString(MARKUP_COLON)); + } + else qname.clear(); + qname.append(localName); + } + attributeMap[qname] = attributes.getValue(i); + } +} + + +void XMLWriter::addAttributes(CanonicalAttributeMap& attributeMap, const Attributes& attributes, const XMLString& /*elementNamespaceURI*/) +{ + for (int i = 0; i < attributes.getLength(); i++) + { + XMLString namespaceURI = attributes.getURI(i); + XMLString localName = attributes.getLocalName(i); + XMLString qname = attributes.getQName(i); + XMLString fullQName = qname; + if (!localName.empty()) + { + XMLString prefix; + if (!namespaceURI.empty()) + { + prefix = _namespaces.getPrefix(namespaceURI); + fullQName = namespaceURI; + fullQName.append(toXMLString(MARKUP_COLON)); + } + else fullQName.clear(); + if (!prefix.empty()) + { + qname = prefix; + qname.append(toXMLString(MARKUP_COLON)); + } + else qname.clear(); + qname.append(localName); + fullQName.append(localName); + } + attributeMap.insert(std::make_pair(fullQName, std::make_pair(qname, attributes.getValue(i)))); + } +} + + +void XMLWriter::writeAttributes(const AttributeMap& attributeMap) +{ + for (AttributeMap::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it) + { + if ((_options & PRETTY_PRINT) && (_options & PRETTY_PRINT_ATTRIBUTES)) + { + writeNewLine(); + writeIndent(_depth + 1); + } + else + { + writeMarkup(MARKUP_SPACE); + } + writeXML(it->first); + writeMarkup(MARKUP_EQQUOT); + for (XMLString::const_iterator itc = it->second.begin(); itc != it->second.end(); ++itc) + { + XMLChar c = *itc; + switch (c) + { + case '"': writeMarkup(MARKUP_QUOTENC); break; + case '&': writeMarkup(MARKUP_AMPENC); break; + case '<': writeMarkup(MARKUP_LTENC); break; + case '>': writeMarkup(MARKUP_GTENC); break; + case '\t': writeMarkup(MARKUP_TABENC); break; + case '\r': writeMarkup(MARKUP_CRENC); break; + case '\n': writeMarkup(MARKUP_LFENC); break; + default: + if (c >= 0 && c < 32) + throw XMLException("Invalid character token."); + else + writeXML(c); + } + } + writeMarkup(MARKUP_QUOT); + } +} + + +void XMLWriter::writeAttributes(const CanonicalAttributeMap& attributeMap) +{ + for (CanonicalAttributeMap::const_iterator it = attributeMap.begin(); it != attributeMap.end(); ++it) + { + if ((_options & PRETTY_PRINT) && (_options & PRETTY_PRINT_ATTRIBUTES)) + { + writeNewLine(); + writeIndent(_depth + 1); + } + else + { + writeMarkup(MARKUP_SPACE); + } + writeXML(it->second.first); + writeMarkup(MARKUP_EQQUOT); + for (XMLString::const_iterator itc = it->second.second.begin(); itc != it->second.second.end(); ++itc) + { + XMLChar c = *itc; + switch (c) + { + case '"': writeMarkup(MARKUP_QUOTENC); break; + case '&': writeMarkup(MARKUP_AMPENC); break; + case '<': writeMarkup(MARKUP_LTENC); break; + case '>': writeMarkup(MARKUP_GTENC); break; + case '\t': writeMarkup(MARKUP_TABENC); break; + case '\r': writeMarkup(MARKUP_CRENC); break; + case '\n': writeMarkup(MARKUP_LFENC); break; + default: + if (c >= 0 && c < 32) + throw XMLException("Invalid character token."); + else + writeXML(c); + } + } + writeMarkup(MARKUP_QUOT); + } +} + + +void XMLWriter::writeMarkup(const std::string& str) const +{ +#if defined(XML_UNICODE_WCHAR_T) + const XMLString xmlString = toXMLString(str); + writeXML(xmlString); +#else + _pTextConverter->write(str.data(), (int) str.size()); +#endif +} + + +void XMLWriter::writeXML(const XMLString& str) const +{ + _pTextConverter->write((const char*) str.data(), (int) str.size()*sizeof(XMLChar)); +} + + +void XMLWriter::writeXML(XMLChar ch) const +{ + _pTextConverter->write((const char*) &ch, sizeof(ch)); +} + + +void XMLWriter::writeName(const XMLString& prefix, const XMLString& localName) +{ + if (prefix.empty()) + { + writeXML(localName); + } + else + { + writeXML(prefix); + writeMarkup(MARKUP_COLON); + writeXML(localName); + } +} + + +void XMLWriter::writeNewLine() const +{ + if (_options & PRETTY_PRINT) + writeMarkup(_newLine); +} + + +void XMLWriter::writeIndent() const +{ + writeIndent(_depth); +} + + +void XMLWriter::writeIndent(int depth) const +{ + for (int i = 0; i < depth; ++i) + writeMarkup(_indent); +} + + +void XMLWriter::writeXMLDeclaration() +{ + writeMarkup("<?xml version=\"1.0\""); + if (!_encoding.empty()) + { + writeMarkup(" encoding=\""); + writeMarkup(_encoding); + writeMarkup("\""); + } + writeMarkup("?>"); + writeNewLine(); +} + + +std::string XMLWriter::nameToString(const XMLString& localName, const XMLString& qname) +{ + if (qname.empty()) + return fromXMLString(localName); + else + return fromXMLString(qname); +} + + +XMLString XMLWriter::uniquePrefix() +{ + std::ostringstream str; + str << "ns" << ++_prefix; + return toXMLString(str.str()); +} + + +bool XMLWriter::isNamespaceMapped(const XMLString& namespc) const +{ + return _namespaces.isMapped(namespc); +} + + +} } // namespace Poco::XML diff --git a/contrib/libs/poco/XML/ya.make b/contrib/libs/poco/XML/ya.make index ffa0227a18..1e8cada782 100644 --- a/contrib/libs/poco/XML/ya.make +++ b/contrib/libs/poco/XML/ya.make @@ -1,7 +1,7 @@ -# Generated by devtools/yamaker. - -LIBRARY() - +# Generated by devtools/yamaker. + +LIBRARY() + OWNER( orivej g:cpp-contrib @@ -14,94 +14,94 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -PEERDIR( - contrib/libs/expat - contrib/libs/poco/Foundation -) - -ADDINCL( +PEERDIR( + contrib/libs/expat + contrib/libs/poco/Foundation +) + +ADDINCL( GLOBAL contrib/libs/expat - GLOBAL contrib/libs/poco/XML/include - contrib/libs/poco/Foundation/include - contrib/libs/poco/XML/src -) - -NO_COMPILER_WARNINGS() - -NO_UTIL() - -SRCS( - src/AbstractContainerNode.cpp - src/AbstractNode.cpp - src/Attr.cpp - src/AttrMap.cpp - src/Attributes.cpp - src/AttributesImpl.cpp - src/CDATASection.cpp - src/CharacterData.cpp - src/ChildNodesList.cpp - src/Comment.cpp - src/ContentHandler.cpp - src/DOMBuilder.cpp - src/DOMException.cpp - src/DOMImplementation.cpp - src/DOMObject.cpp - src/DOMParser.cpp - src/DOMSerializer.cpp - src/DOMWriter.cpp - src/DTDHandler.cpp - src/DTDMap.cpp - src/DeclHandler.cpp - src/DefaultHandler.cpp - src/Document.cpp - src/DocumentEvent.cpp - src/DocumentFragment.cpp - src/DocumentType.cpp - src/Element.cpp - src/ElementsByTagNameList.cpp - src/Entity.cpp - src/EntityReference.cpp - src/EntityResolver.cpp - src/EntityResolverImpl.cpp - src/ErrorHandler.cpp - src/Event.cpp - src/EventDispatcher.cpp - src/EventException.cpp - src/EventListener.cpp - src/EventTarget.cpp - src/InputSource.cpp - src/LexicalHandler.cpp - src/Locator.cpp - src/LocatorImpl.cpp - src/MutationEvent.cpp - src/Name.cpp - src/NamePool.cpp - src/NamedNodeMap.cpp - src/NamespaceStrategy.cpp - src/NamespaceSupport.cpp - src/Node.cpp - src/NodeAppender.cpp - src/NodeFilter.cpp - src/NodeIterator.cpp - src/NodeList.cpp - src/Notation.cpp - src/ParserEngine.cpp - src/ProcessingInstruction.cpp - src/QName.cpp - src/SAXException.cpp - src/SAXParser.cpp - src/Text.cpp - src/TreeWalker.cpp - src/ValueTraits.cpp - src/WhitespaceFilter.cpp - src/XMLException.cpp - src/XMLFilter.cpp - src/XMLFilterImpl.cpp - src/XMLReader.cpp - src/XMLStreamParser.cpp - src/XMLStreamParserException.cpp - src/XMLString.cpp - src/XMLWriter.cpp -) - -END() + GLOBAL contrib/libs/poco/XML/include + contrib/libs/poco/Foundation/include + contrib/libs/poco/XML/src +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +SRCS( + src/AbstractContainerNode.cpp + src/AbstractNode.cpp + src/Attr.cpp + src/AttrMap.cpp + src/Attributes.cpp + src/AttributesImpl.cpp + src/CDATASection.cpp + src/CharacterData.cpp + src/ChildNodesList.cpp + src/Comment.cpp + src/ContentHandler.cpp + src/DOMBuilder.cpp + src/DOMException.cpp + src/DOMImplementation.cpp + src/DOMObject.cpp + src/DOMParser.cpp + src/DOMSerializer.cpp + src/DOMWriter.cpp + src/DTDHandler.cpp + src/DTDMap.cpp + src/DeclHandler.cpp + src/DefaultHandler.cpp + src/Document.cpp + src/DocumentEvent.cpp + src/DocumentFragment.cpp + src/DocumentType.cpp + src/Element.cpp + src/ElementsByTagNameList.cpp + src/Entity.cpp + src/EntityReference.cpp + src/EntityResolver.cpp + src/EntityResolverImpl.cpp + src/ErrorHandler.cpp + src/Event.cpp + src/EventDispatcher.cpp + src/EventException.cpp + src/EventListener.cpp + src/EventTarget.cpp + src/InputSource.cpp + src/LexicalHandler.cpp + src/Locator.cpp + src/LocatorImpl.cpp + src/MutationEvent.cpp + src/Name.cpp + src/NamePool.cpp + src/NamedNodeMap.cpp + src/NamespaceStrategy.cpp + src/NamespaceSupport.cpp + src/Node.cpp + src/NodeAppender.cpp + src/NodeFilter.cpp + src/NodeIterator.cpp + src/NodeList.cpp + src/Notation.cpp + src/ParserEngine.cpp + src/ProcessingInstruction.cpp + src/QName.cpp + src/SAXException.cpp + src/SAXParser.cpp + src/Text.cpp + src/TreeWalker.cpp + src/ValueTraits.cpp + src/WhitespaceFilter.cpp + src/XMLException.cpp + src/XMLFilter.cpp + src/XMLFilterImpl.cpp + src/XMLReader.cpp + src/XMLStreamParser.cpp + src/XMLStreamParserException.cpp + src/XMLString.cpp + src/XMLWriter.cpp +) + +END() |