Sese Framework
2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
Json.h
Go to the documentation of this file.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
19
20
#pragma once
21
22
#include <
sese/util/Value.h
>
23
#include <
sese/util/NotInstantiable.h
>
24
#include <
sese/io/InputStream.h
>
25
#include <
sese/io/OutputStream.h
>
26
27
#include <stack>
28
#include <queue>
29
30
namespace
simdjson::dom
{
31
class
element;
32
}
33
34
namespace
sese
{
36
class
Json
final :
public
NotInstantiable
{
37
using
Tokens
= std::queue<std::string>;
38
using
ParseStack
= std::stack<Value *>;
39
using
StreamifyStack
= std::stack<std::pair<Value *, unsigned int>>;
40
using
StreamifyIterStack
= std::stack<std::map<std::string, std::shared_ptr<Value>>::iterator>;
41
42
static
Value
parse
(
Tokens
&tokens);
43
44
static
bool
parseObject
(
Tokens
&tokens,
ParseStack
&stack);
45
46
static
bool
parseArray
(
Tokens
&tokens,
ParseStack
&stack);
47
48
static
Value
parseBasic
(
const
std::string &value);
49
50
static
bool
streamifyObject
(
51
io::OutputStream
*out,
52
StreamifyStack
&stack,
53
StreamifyIterStack
&map_iter_stack
54
);
55
56
static
bool
streamifyArray
(
57
io::OutputStream
*out,
58
StreamifyStack
&stack,
59
StreamifyIterStack
&map_iter_stack
60
);
61
62
static
bool
streamifyBasic
(
io::OutputStream
*out,
const
std::shared_ptr<Value> &value);
63
64
static
bool
tokenizer
(
io::InputStream
*input_stream,
Tokens
&tokens)
noexcept
;
65
66
static
Value
parse
(
const
simdjson::dom::element &json);
67
68
public
:
69
Json
() =
delete
;
70
74
static
Value
parse
(
io::InputStream
*input);
75
80
static
bool
streamify
(
io::OutputStream
*out,
Value
&value);
81
85
static
Value
simdParse
(
io::InputStream
*input);
86
};
87
}
// namespace sese
sese
config
Json.h
Generated on Tue Jan 7 2025 15:49:05 for Sese Framework by
1.11.0