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 class StaticElement : public XMLElement
34 bool operator()(const char* s1, const char* s2) const
36 return strcmp(s1, s2) < 0;
40 typedef std::map<const char*, const char*, strless> attrs_t;
42 StaticElement(const char* name)
46 void insertAttribute(const char* name, const char* value)
48 m_attrs.insert(attrs_t::value_type(name, value));
50 const char* name() const
54 const char* attribute(const char* name) const
56 attrs_t::const_iterator i = m_attrs.find(name);
57 if(i != m_attrs.end())
62 void forEachAttribute(XMLAttrVisitor& visitor) const
64 for(attrs_t::const_iterator i = m_attrs.begin(); i != m_attrs.end(); ++i)
66 visitor.visit(i->first, i->second);
74 class DynamicElement : public XMLElement
76 typedef std::map<CopiedString, CopiedString> attrs_t;
78 DynamicElement(const char* name)
81 void insertAttribute(const char* name, const char* value)
83 m_attrs.insert(attrs_t::value_type(name, value));
85 const char* name() const
87 return m_name.c_str();
89 const char* attribute(const char* name) const
91 attrs_t::const_iterator i = m_attrs.find(name);
92 if(i != m_attrs.end())
93 return i->second.c_str();
97 void forEachAttribute(XMLAttrVisitor& visitor) const
99 for(attrs_t::const_iterator i = m_attrs.begin(); i != m_attrs.end(); ++i)
101 visitor.visit(i->first.c_str(), i->second.c_str());