10Duke Enterprise C++ SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
JSONElement.h
1
#ifndef TENDUKE_JSON_JSONELEMENT_H
2
#define TENDUKE_JSON_JSONELEMENT_H
3
4
#include <string>
5
6
namespace
tenduke
{
namespace
json
{
7
11
class
JSONElement
12
{
13
public
:
17
enum
Type
{
18
UNDEFINED,
19
NULLISH,
20
OBJECT,
21
ARRAY,
22
NUMBER,
23
STRING,
24
BOOLEAN
25
};
26
27
public
:
28
virtual
~JSONElement
() =
default
;
29
34
virtual
enum
Type
getType
()
const
= 0;
35
40
virtual
std::string
asJSON
()
const
= 0;
41
48
virtual
std::string
asString
()
const
= 0;
49
54
bool
isArray
()
const
{
return
(
getType
() == Type::ARRAY);}
55
60
bool
isBoolean
()
const
{
return
(
getType
() == Type::BOOLEAN);}
61
66
bool
isNull
()
const
{
return
(
getType
() == Type::NULLISH);}
67
72
bool
isNumber
()
const
{
return
(
getType
() == Type::NUMBER);}
73
78
bool
isObject
()
const
{
return
(
getType
() == Type::OBJECT);}
79
84
bool
isString
()
const
{
return
(
getType
() == Type::STRING);}
85
90
bool
isUndefined
()
const
{
return
(
getType
() == Type::UNDEFINED);}
91
92
98
static
std::string
typeToString
(
const
enum
Type
type) {
99
switch
(type) {
100
case
UNDEFINED:
101
return
"UNDEFINED"
;
102
case
NULLISH:
103
return
"NULLISH"
;
104
case
OBJECT:
105
return
"OBJECT"
;
106
case
ARRAY:
107
return
"ARRAY"
;
108
case
NUMBER:
109
return
"NUMBER"
;
110
case
STRING:
111
return
"STRING"
;
112
case
BOOLEAN:
113
return
"BOOLEAN"
;
114
default
:
115
return
"(INVALID TYPE)"
;
116
}
117
}
118
119
};
120
121
}}
122
123
#endif
// TENDUKE_JSON_JSONELEMENT_H
tenduke::json::JSONElement
Superclass of JSON elements.
Definition
JSONElement.h:12
tenduke::json::JSONElement::isObject
bool isObject() const
Utility to check if this element is JSONObject.
Definition
JSONElement.h:78
tenduke::json::JSONElement::isNull
bool isNull() const
Utility to check if this element is null.
Definition
JSONElement.h:66
tenduke::json::JSONElement::getType
virtual enum Type getType() const =0
Returns type of this element.
tenduke::json::JSONElement::isUndefined
bool isUndefined() const
Utility to check if this element is undefined.
Definition
JSONElement.h:90
tenduke::json::JSONElement::isNumber
bool isNumber() const
Utility to check if this element is JSONNumber.
Definition
JSONElement.h:72
tenduke::json::JSONElement::typeToString
static std::string typeToString(const enum Type type)
Converts the type to string.
Definition
JSONElement.h:98
tenduke::json::JSONElement::isArray
bool isArray() const
Utility to check if this element is JSONArray.
Definition
JSONElement.h:54
tenduke::json::JSONElement::asString
virtual std::string asString() const =0
Gets the value of the element as a string.
tenduke::json::JSONElement::asJSON
virtual std::string asJSON() const =0
Serializes the element as JSON.
tenduke::json::JSONElement::Type
Type
Type of the element.
Definition
JSONElement.h:17
tenduke::json::JSONElement::isString
bool isString() const
Utility to check if this element is JSONString.
Definition
JSONElement.h:84
tenduke::json::JSONElement::isBoolean
bool isBoolean() const
Utility to check if this element is JSONBoolean.
Definition
JSONElement.h:60
tenduke::json
JSON support.
Definition
JSONArray.h:10
tenduke
Root for classes, functions and globals of 10Duke C++ Client.
Definition
APIRequest.h:4
core
core
src
json
JSONElement.h
Generated by
1.17.0