00001 /* 00002 ** ClanLib SDK 00003 ** Copyright (c) 1997-2005 The ClanLib Team 00004 ** 00005 ** This software is provided 'as-is', without any express or implied 00006 ** warranty. In no event will the authors be held liable for any damages 00007 ** arising from the use of this software. 00008 ** 00009 ** Permission is granted to anyone to use this software for any purpose, 00010 ** including commercial applications, and to alter it and redistribute it 00011 ** freely, subject to the following restrictions: 00012 ** 00013 ** 1. The origin of this software must not be misrepresented; you must not 00014 ** claim that you wrote the original software. If you use this software 00015 ** in a product, an acknowledgment in the product documentation would be 00016 ** appreciated but is not required. 00017 ** 2. Altered source versions must be plainly marked as such, and must not be 00018 ** misrepresented as being the original software. 00019 ** 3. This notice may not be removed or altered from any source distribution. 00020 ** 00021 ** Note: Some of the libraries ClanLib link to may have additional 00022 ** requirements or restrictions. 00023 ** 00024 ** File Author(s): 00025 ** 00026 ** Magnus Norddahl 00027 */ 00028 00031 00032 #ifndef header_dom_named_node_map 00033 #define header_dom_named_node_map 00034 00035 #if _MSC_VER > 1000 00036 #pragma once 00037 #endif 00038 00039 #include "sharedptr.h" 00040 00041 class CL_DomNode; 00042 class CL_DomNamedNodeMap_Generic; 00043 00044 //: DOM Named Node Map class. 00045 //- !group=Core/XML! 00046 //- !header=core.h! 00047 //- <p>Objects implementing the NamedNodeMap interface are used to represent collections of nodes 00048 //- that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; 00049 //- NamedNodeMaps are not maintained in any particular order. Objects contained in an object 00050 //- implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to 00051 //- allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the 00052 //- DOM specifies an order to these Nodes.</p> 00053 class CL_DomNamedNodeMap 00054 { 00056 public: 00057 //: Constructs a DOM NamedNodeMap handle. 00058 CL_DomNamedNodeMap(); 00059 00060 CL_DomNamedNodeMap(CL_DomNode &node); 00061 00062 ~CL_DomNamedNodeMap(); 00063 00065 public: 00066 //: The number of nodes in the map. 00067 int get_length() const; 00068 00070 public: 00071 //: Retrieves a node specified by name. 00072 CL_DomNode get_named_item(const std::string &name) const; 00073 00074 //: Adds a node using its node name attribute. 00075 //- <p>As the node name attribute is used to derive the name which the node must be stored 00076 //- under, multiple nodes of certain types (those that have a "special" string value) cannot 00077 //- be stored as the names would clash. This is seen as preferable to allowing nodes to be 00078 //- aliased.</p> 00079 //param arg: A node to store in a named node map. The node will later be accessible using the value of the node name attribute of the node. If a node with that name is already present in the map, it is replaced by the new one. 00080 //retval: If the new Node replaces an existing node with the same name the previously existing Node is returned, otherwise null is returned. 00081 CL_DomNode set_named_item(const CL_DomNode &node); 00082 00083 //: Removes a node specified by name. 00084 //- <p>If the removed node is an Attr with a default value it is immediately replaced.</p> 00085 //param name: The name of a node to remove. 00086 //retval: The node removed from the map or null if no node with such a name exists. 00087 CL_DomNode remove_named_item(const std::string &name); 00088 00089 //: Returns the indexth item in the map. 00090 //- <p>If index is greater than or equal to the number of nodes in the map, this returns null.</p> 00091 CL_DomNode item(unsigned long index) const; 00092 00094 private: 00095 CL_SharedPtr<CL_DomNamedNodeMap_Generic> impl; 00096 }; 00097 00098 #endif
1.4.1