startelement.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * As a special exception, you may use this file as part of a free
8  * software library without restriction. Specifically, if other files
9  * instantiate templates or use macros or inline functions from this
10  * file, or you compile this file and link it with other files to
11  * produce an executable, this file does not by itself cause the
12  * resulting executable to be covered by the GNU General Public
13  * License. This exception does not however invalidate any other
14  * reasons why the executable file might be covered by the GNU Library
15  * General Public License.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25  */
26 #ifndef cxxtools_xml_StartElement_h
27 #define cxxtools_xml_StartElement_h
28 
29 #include <cxxtools/xml/node.h>
30 #include <cxxtools/xml/namespace.h>
32 #include <cxxtools/xml/attribute.h>
33 #include <cxxtools/string.h>
34 
35 namespace cxxtools {
36 
37 namespace xml {
38 
57  class StartElement : public Node
58  {
59  public:
63  { }
64 
73  _name(name)
74  { }
75 
81  {return new StartElement(*this);}
82 
83 
84  void clear()
85  {
86  _name.clear();
87  _attributes.clear();
88  }
89 
99  String& name() {return _name;}
100 
110  const String& name() const
111  {return _name;}
112 
117  void setName(const String& name)
118  {_name = name;}
119 
129  {_attributes.push_back(attribute);}
130 
141  const Attributes& attributes() const
142  { return _attributes; }
143 
157  const String& attribute(const String& attributeName) const;
158 
168  bool hasAttribute(const String& attributeName) const;
169 
177  {return _namespaceContext;}
178 
186  {_namespaceContext = conText;}
187 
198  const String& namespaceUri(const String& prefix) const
199  {return _namespaceContext.namespaceUri(prefix);}
200 
210  virtual bool operator==(const Node& node) const;
211 
212  private:
214  String _name;
215 
217  Attributes _attributes;
218 
220  NamespaceContext _namespaceContext;
221  };
222 
223 }
224 
225 }
226 
227 #endif