10Duke Enterprise C++ SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
SimpleJSONArray.h
1
#ifndef TENDUKE_JSON_SIMPLEJSONARRAY_H
2
#define TENDUKE_JSON_SIMPLEJSONARRAY_H
3
4
#include "json/JSONArray.h"
5
6
#include "./SimpleJSONElement.h"
7
8
namespace
tenduke
{
namespace
json
{
9
10
class
SimpleJSONArray :
public
virtual
::tenduke::json::JSONArray
,
public
::tenduke::json::SimpleJSONElement
11
{
12
public
:
13
SimpleJSONArray()
14
:
::tenduke::json::SimpleJSONElement
(::tenduke::json::JSONElement::Type::ARRAY),
15
values({})
16
{
17
}
18
19
bool
isEmpty
()
const override
20
{
21
return
values.empty();
22
}
23
24
std::size_t
getSize
()
const override
25
{
26
return
values.size();
27
}
28
29
const
std::vector<std::shared_ptr<::tenduke::json::JSONElement>> &
getValues
()
const override
30
{
31
return
values;
32
}
33
34
std::string
asJSON
()
const override
35
{
36
std::string result =
"["
;
37
bool
first =
true
;
38
for
(
const
auto
& v : values) {
39
if
(!first) {
40
result +=
", "
;
41
}
42
else
{
43
first =
false
;
44
}
45
result += v->asJSON();
46
}
47
return
result +
"]"
;
48
}
49
50
virtual
void
add(
const
std::shared_ptr<::tenduke::json::JSONElement> element)
51
{
52
values.emplace_back(element);
53
}
54
55
private
:
56
std::vector<std::shared_ptr<::tenduke::json::JSONElement>> values;
57
};
58
59
}}
// tenduke
60
61
#endif
//TENDUKE_JSON_SIMPLEJSONARRAY_H
tenduke::json::JSONArray
A JSON array.
Definition
JSONArray.h:16
tenduke::json::SimpleJSONArray::asJSON
std::string asJSON() const override
Serializes the element as JSON.
Definition
SimpleJSONArray.h:34
tenduke::json::SimpleJSONArray::getSize
std::size_t getSize() const override
Returns number of elements in the array.
Definition
SimpleJSONArray.h:24
tenduke::json::SimpleJSONArray::isEmpty
bool isEmpty() const override
Checks if the array is empty.
Definition
SimpleJSONArray.h:19
tenduke::json::SimpleJSONArray::getValues
const std::vector< std::shared_ptr<::tenduke::json::JSONElement > > & getValues() const override
Returns the elements of the array.
Definition
SimpleJSONArray.h:29
tenduke::json::SimpleJSONElement
Definition
SimpleJSONElement.h:11
tenduke::json
JSON support.
Definition
JSONArray.h:10
tenduke
Root for classes, functions and globals of 10Duke C++ Client.
Definition
APIRequest.h:4
core
services
common
src
json
SimpleJSONArray.h
Generated by
1.17.0