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 )
39 void insertAttribute( const char* name, const char* value ){
40 m_attrs.insert( attrs_t::value_type( name, value ) );
42 const char* name() const {
45 const char* attribute( const char* name ) const {
46 attrs_t::const_iterator i = m_attrs.find( name );
47 if ( i != m_attrs.end() ) {
54 void forEachAttribute( XMLAttrVisitor& visitor ) const {
55 for ( attrs_t::const_iterator i = m_attrs.begin(); i != m_attrs.end(); ++i )
57 visitor.visit( i->first, i->second );
65 ///\brief All string pointers passed to an instance of this class are copied.
66 class DynamicElement : public XMLElement
68 typedef std::map<CopiedString, CopiedString> attrs_t;
70 DynamicElement( const char* name )
73 void insertAttribute( const char* name, const char* value ){
74 m_attrs.insert( attrs_t::value_type( name, value ) );
76 const char* name() const {
77 return m_name.c_str();
79 const char* attribute( const char* name ) const {
80 attrs_t::const_iterator i = m_attrs.find( name );
81 if ( i != m_attrs.end() ) {
82 return i->second.c_str();
88 void forEachAttribute( XMLAttrVisitor& visitor ) const {
89 for ( attrs_t::const_iterator i = m_attrs.begin(); i != m_attrs.end(); ++i )
91 visitor.visit( i->first.c_str(), i->second.c_str() );