EndElement.h
1/*
2 * Copyright (C) 2012 Marc Boris Duerner
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * As a special exception, you may use this file as part of a free
10 * software library without restriction. Specifically, if other files
11 * instantiate templates or use macros or inline functions from this
12 * file, or you compile this file and link it with other files to
13 * produce an executable, this file does not by itself cause the
14 * resulting executable to be covered by the GNU General Public
15 * License. This exception does not however invalidate any other
16 * reasons why the executable file might be covered by the GNU Library
17 * General Public License.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 */
28
29#ifndef Pt_Xml_EndElement_h
30#define Pt_Xml_EndElement_h
31
32#include <Pt/Xml/Api.h>
33#include <Pt/Xml/Node.h>
34#include <Pt/Xml/QName.h>
35#include <Pt/Xml/Namespace.h>
36#include <Pt/NonCopyable.h>
37
38namespace Pt {
39
40namespace Xml {
41
44class EndElement : public Node
45 , private NonCopyable
46{
47 public:
52 , _name(0)
53 , _namespace(0)
54 { }
55
58 void clear()
59 {
60 _name = 0;
61 _namespace = 0;
62 _nsmap.clear();
63 }
64
67 const QName& name() const
68 { return *_name; }
69
72 void setName(const QName& name, const Namespace& ns)
73 {
74 _name = &name;
75 _namespace = &ns;
76 }
77
80 const String& namespaceUri() const
81 { return _namespace->namespaceUri(); }
82
83 NamespaceMapping& namespaceMapping()
84 { return _nsmap; }
85
86 const NamespaceMapping& namespaceMapping() const
87 { return _nsmap; }
88
90 inline static const Node::Type nodeId()
91 { return Node::EndElement; }
92
93 private:
94 const QName* _name;
95 const Namespace* _namespace;
96 NamespaceMapping _nsmap;
97};
98
104{
105 return nodeCast<EndElement>(node);
106}
107
112inline const EndElement* toEndElement(const Node* node)
113{
114 return nodeCast<EndElement>(node);
115}
116
122{
123 return nodeCast<EndElement>(node);
124}
125
130inline const EndElement& toEndElement(const Node& node)
131{
132 return nodeCast<EndElement>(node);
133}
134
135} // namespace Xml
136
137} // namespace Pt
138
139#endif // Pt_Xml_EndElement_h
NonCopyable()
Default constructor.
Definition NonCopyable.h:63
Unicode capable basic_string.
Definition Api-String.h:67
const String & namespaceUri() const
Returns the namespace Uri for this element name.
Definition EndElement.h:80
void setName(const QName &name, const Namespace &ns)
Returns the qualified element name.
Definition EndElement.h:72
EndElement & toEndElement(Node &node)
Casts a generic node to an EndElement node.
Definition EndElement.h:121
const QName & name() const
Returns the qualified element name.
Definition EndElement.h:67
EndElement * toEndElement(Node *node)
Casts a generic node to an EndElement node.
Definition EndElement.h:103
EndElement()
Constructs an empty EndElement.
Definition EndElement.h:50
void clear()
Clears all content.
Definition EndElement.h:58
const EndElement * toEndElement(const Node *node)
Casts a generic node to an EndElement node.
Definition EndElement.h:112
const EndElement & toEndElement(const Node &node)
Casts a generic node to an EndElement node.
Definition EndElement.h:130
A namespace used in an XML document.
Definition Namespace.h:47
Node(Type type)
Constructs a new Node object with the specified node type.
Definition Node.h:80
A qualified XML name.
Definition QName.h:47
Read and write XML ducuments.
Core module.
Definition Allocator.h:33