30 #ifndef PT_JSON_NODE_H
31 #define PT_JSON_NODE_H
33 #include <Pt/Json/Api.h>
34 #include <Pt/Json/JsonError.h>
93 T* nodeCast(Node* node)
97 if( node->type() == T::nodeId() )
98 e =
static_cast<T*
>(node);
104 template <
typename T>
105 const T* nodeCast(
const Node* node)
109 if( node->type() == T::nodeId() )
110 e =
static_cast<const T*
>(node);
116 template <
typename T>
117 T& nodeCast(Node& node)
119 if( node.type() != T::nodeId() )
120 throw JsonError(
"unexpected node type");
122 return static_cast<T&
>(node);
126 template <
typename T>
127 const T& nodeCast(
const Node& node)
129 if( node.type() != T::nodeId() )
130 throw JsonError(
"unexpected node type");
132 return static_cast<const T&
>(node);
139 #endif // nclude guard
Core module.
Definition: Allocator.h:33
Represents a object member.
Definition: Member.h:43
Node(Type type)
Constructs a new Node object with the specified node type.
Definition: Node.h:83
Represents the end of an JSON document.
Definition: EndDocument.h:47
Represents the end of an array.
Definition: EndArray.h:43
Represents a null value.
Definition: Null.h:43
JSON document node.
Definition: Node.h:52
virtual ~Node()
Destructor.
Definition: Node.h:72
Represents an integer.
Definition: Integer.h:43
Represents a float.
Definition: Float.h:43
Represents the end of an object.
Definition: EndObject.h:43
Represents a string.
Definition: String.h:43
Represents a boolean.
Definition: Boolean.h:43
Type type() const
Returns the type of the node.
Definition: Node.h:77
Represents the start of an array.
Definition: StartArray.h:43
Represents the start of an object.
Definition: StartObject.h:43