NamedNodeMap.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // NamedNodeMap.h
  3. //
  4. // Library: XML
  5. // Package: DOM
  6. // Module: DOM
  7. //
  8. // Definition of the DOM NamedNodeMap interface.
  9. //
  10. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
  11. // and Contributors.
  12. //
  13. // SPDX-License-Identifier: BSL-1.0
  14. //
  15. #ifndef DOM_NamedNodeMap_INCLUDED
  16. #define DOM_NamedNodeMap_INCLUDED
  17. #include "Poco/XML/XML.h"
  18. #include "Poco/DOM/DOMObject.h"
  19. #include "Poco/XML/XMLString.h"
  20. namespace Poco {
  21. namespace XML {
  22. class Node;
  23. class XML_API NamedNodeMap: public DOMObject
  24. /// Objects implementing the NamedNodeMap interface are used to represent collections
  25. /// of nodes that can be accessed by name. Note that NamedNodeMap does not inherit
  26. /// from NodeList; NamedNodeMaps are not maintained in any particular order.
  27. /// Objects contained in an object implementing NamedNodeMap may also be accessed
  28. /// by an ordinal index, but this is simply to allow convenient enumeration
  29. /// of the contents of a NamedNodeMap, and does not imply that the DOM specifies
  30. /// an order to these Nodes.
  31. ///
  32. /// NamedNodeMap objects in the DOM are live.
  33. ///
  34. /// A NamedNodeMap returned from a method must be released with a call to
  35. /// release() when no longer needed.
  36. {
  37. public:
  38. virtual Node* getNamedItem(const XMLString& name) const = 0;
  39. /// Retrieves a node specified by name.
  40. virtual Node* setNamedItem(Node* arg) = 0;
  41. /// Adds a node using its nodeName attribute. If a node with that name is already
  42. /// present in this map, it is replaced by the new one.
  43. /// As the nodeName attribute is used to derive the name which the node must
  44. /// be stored under, multiple nodes of certain types (those that have a "special"
  45. /// string value) cannot be stored as the names would clash. This is seen as
  46. /// preferable to allowing nodes to be aliased.
  47. virtual Node* removeNamedItem(const XMLString& name) = 0;
  48. /// Removes a node specified by name. When this map contains the attributes
  49. /// attached to an element, if the removed attribute is known to have a default
  50. /// value, an attribute immediately appears containing the default value.
  51. virtual Node* item(unsigned long index) const = 0;
  52. /// Returns the index'th item in the map. If index is greater
  53. /// than or equal to the number of nodes in the map, this
  54. /// returns null.
  55. virtual unsigned long length() const = 0;
  56. /// Returns the number of nodes in the map. The range of valid
  57. /// child node indices is 0 to length - 1 inclusive.
  58. // DOM Level 2
  59. virtual Node* getNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) const = 0;
  60. /// Retrieves a node specified by name.
  61. virtual Node* setNamedItemNS(Node* arg) = 0;
  62. /// Adds a node using its nodeName attribute.
  63. /// If a node with that namespace URI and that local name is already
  64. /// present in this map, it is replaced by the new one.
  65. virtual Node* removeNamedItemNS(const XMLString& namespaceURI, const XMLString& localName) = 0;
  66. /// Removes a node specified by name.
  67. protected:
  68. virtual ~NamedNodeMap();
  69. };
  70. } } // namespace Poco::XML
  71. #endif // DOM_NamedNodeMap_INCLUDED