2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined(INCLUDED_XML_XMLELEMENT_H)
23 #define INCLUDED_XML_XMLELEMENT_H
26 #include "string/string.h"
30 ///\brief All string pointers passed to an instance of this class are not
31 /// copied and must stay valid for the lifetime of the instance.
32 class StaticElement : public XMLElement
34 typedef std::map<const char*, const char*, RawStringLess> attrs_t;
36 StaticElement(const char* name)
40 void insertAttribute(const char* name, const char* value)
42 m_attrs.insert(attrs_t::value_type(name, value));
44 const char* name() const
48 const char* attribute(const char* name) const
50 attrs_t::const_iterator i = m_attrs.find(name);
51 if(i != m_attrs.end())
56 void forEachAttribute(XMLAttrVisitor& visitor) const
58 for(attrs_t::const_iterator i = m_attrs.begin(); i != m_attrs.end(); ++i)
60 visitor.visit(i->first, i->second);
68 ///\brief All string pointers passed to an instance of this class are copied.
69 class DynamicElement : public XMLElement
71 typedef std::map<CopiedString, CopiedString> attrs_t;
73 DynamicElement(const char* name)
77 void insertAttribute(const char* name, const char* value)
79 m_attrs.insert(attrs_t::value_type(name, value));
81 const char* name() const
83 return m_name.c_str();
85 const char* attribute(const char* name) const
87 attrs_t::const_iterator i = m_attrs.find(name);
88 if(i != m_attrs.end())
89 return i->second.c_str();
93 void forEachAttribute(XMLAttrVisitor& visitor) const
95 for(attrs_t::const_iterator i = m_attrs.begin(); i != m_attrs.end(); ++i)
97 visitor.visit(i->first.c_str(), i->second.c_str());