Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

dom_named_node_map.cpp

Go to the documentation of this file.
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 
00029 #include "precomp.h"
00030 #include "exception.h"
00031 #include "dom_named_node_map_generic.h"
00032 #include "dom_named_node_map.h"
00033 #include "dom_attr.h"
00034 #include "dom_node.h"
00035 
00037 // CL_DomNamedNodeMap construction:
00038 
00039 CL_DomNamedNodeMap::CL_DomNamedNodeMap()
00040 : impl(new CL_DomNamedNodeMap_Generic())
00041 {
00042 }
00043 
00044 CL_DomNamedNodeMap::CL_DomNamedNodeMap(CL_DomNode &node)
00045 {
00046         // FIXME: Not sure what this should do
00047         throw CL_Exception(TEXT("CL_DomNamedNodeMap not implemented!"));
00048 }
00049 
00050 CL_DomNamedNodeMap::~CL_DomNamedNodeMap()
00051 {
00052 }
00053 
00055 // CL_DomNamedNodeMap attributes:
00056 
00057 int CL_DomNamedNodeMap::get_length() const
00058 {
00059         return impl->attributes.size();
00060 }
00061 
00063 // CL_DomNamedNodeMap operations:
00064 
00065 CL_DomNode CL_DomNamedNodeMap::get_named_item(const std::string &name) const
00066 {
00067         int size = impl->attributes.size();
00068         for (int i=0; i<size; i++)
00069         {
00070                 if (impl->attributes[i].first == name)
00071                 {
00072                         return CL_DomNode(impl->attributes[i].second);
00073                 }
00074         }
00075         return CL_DomNode();
00076 }
00077 
00078 CL_DomNode CL_DomNamedNodeMap::set_named_item(const CL_DomNode &node)
00079 {
00080         int size = impl->attributes.size();
00081         for (int i=0; i<size; i++)
00082         {
00083                 if (impl->attributes[i].first == node.to_attr().get_name())
00084                 {
00085                         CL_DomNode oldnode(impl->attributes[i].second);
00086                         impl->attributes[i].second = node;
00087                         return oldnode;
00088                 }
00089         }
00090         
00091         impl->attributes.push_back(std::pair<std::string, CL_DomNode>(node.to_attr().get_name(), node));
00092 
00093         return CL_DomNode();
00094 }
00095 
00096 CL_DomNode CL_DomNamedNodeMap::remove_named_item(const std::string &name)
00097 {
00098         // FIXME: Implement me
00099         throw CL_Exception(TEXT("CL_DomNamedNodeMap::remove_named_item not implemented!"));
00100         return CL_DomNode();
00101 }
00102 
00103 CL_DomNode CL_DomNamedNodeMap::item(unsigned long index) const
00104 {
00105         return CL_DomNode(impl->attributes[index].second);
00106 }
00107 
00109 // CL_DomNamedNodeMap implementation:

Generated on Sat Feb 19 22:51:15 2005 for npcore by  doxygen 1.4.1