Comment.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_Comment_h
30#define Pt_Xml_Comment_h
31
32#include <Pt/Xml/Api.h>
33#include <Pt/Xml/Node.h>
34#include <Pt/String.h>
35
36namespace Pt {
37
38namespace Xml {
39
44class Comment : public Node
45{
46 public:
49 explicit Comment()
50 : Node(Node::Comment)
51 , _content()
52 { }
53
56 bool empty() const
57 { return _content.empty(); }
58
61 void clear()
62 { _content.clear(); }
63
67 { return _content; }
68
71 const String& content() const
72 { return _content; }
73
76 void setContent(const String& text)
77 { _content = text; }
78
80 inline static const Node::Type nodeId()
81 { return Node::Comment; }
82
83 private:
84 String _content;
85};
86
91inline Comment* toComment(Node* node)
92{
93 return nodeCast<Comment>(node);
94}
95
100inline const Comment* toComment(const Node* node)
101{
102 return nodeCast<Comment>(node);
103}
104
109inline Comment& toComment(Node& node)
110{
111 return nodeCast<Comment>(node);
112}
113
118inline const Comment& toComment(const Node& node)
119{
120 return nodeCast<Comment>(node);
121}
122
123} // namespace Xml
124
125} // namespace Pt
126
127#endif // Pt_Xml_Comment_h
Unicode capable basic_string.
Definition Api-String.h:67
Comment()
Constructs an empty Comment node.
Definition Comment.h:49
void setContent(const String &text)
Sets the text of the comment.
Definition Comment.h:76
Comment & toComment(Node &node)
Casts a generic node to a Comment node.
Definition Comment.h:109
const Comment & toComment(const Node &node)
Casts a generic node to a Comment node.
Definition Comment.h:118
String & content()
Returns the text of the comment.
Definition Comment.h:66
bool empty() const
Returns true if is empty.
Definition Comment.h:56
Comment * toComment(Node *node)
Casts a generic node to a Comment node.
Definition Comment.h:91
void clear()
Clears all content.
Definition Comment.h:61
const Comment * toComment(const Node *node)
Casts a generic node to a Comment node.
Definition Comment.h:100
const String & content() const
Returns the text of the comment.
Definition Comment.h:71
Node(Type type)
Constructs a new Node object with the specified node type.
Definition Node.h:80
Read and write XML ducuments.
Core module.
Definition Allocator.h:33