Sese Framework
2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
Yaml.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/io/InputStream.h
>
23
#include <
sese/io/OutputStream.h
>
24
#include <
sese/util/Value.h
>
25
26
#include <queue>
27
#include <stack>
28
#include <tuple>
29
30
namespace
sese
{
32
class
Yaml
final :
public
NotInstantiable
{
33
using
Tokens
= std::vector<std::string>;
34
using
TokensQueue
= std::queue<std::tuple<int, Tokens>>;
35
using
InputStream
=
io::InputStream
;
36
using
OutputStream
=
io::OutputStream
;
37
using
Line
= std::tuple<int, std::string>;
38
39
using
ParseStack
= std::stack<std::pair<Value *, int>>;
40
using
StreamifyStack
= std::stack<std::tuple<Value *, unsigned int, unsigned int, bool>>;
41
using
StreamifyIterStack
= std::stack<std::map<std::string, std::shared_ptr<Value>>::iterator>;
42
43
static
Value
parseBasic
(
const
std::string &value);
44
45
static
bool
parseObject
(
46
TokensQueue
&tokens_queue,
47
ParseStack
&stack
48
);
49
50
static
bool
parseArray
(
51
TokensQueue
&tokens_queue,
52
ParseStack
&stack
53
);
54
55
static
bool
streamifyObject
(
56
OutputStream
*output,
57
StreamifyStack
&stack,
58
StreamifyIterStack
&map_iter_stack
59
);
60
61
static
bool
streamifyArray
(
62
OutputStream
*output,
63
StreamifyStack
&stack,
64
StreamifyIterStack
&map_iter_stack
65
);
66
67
static
bool
streamifyBasic
(
OutputStream
*output,
const
std::shared_ptr<Value> &value);
68
69
static
int
getSpaceCount
(
const
std::string &line)
noexcept
;
70
71
static
Line
getLine
(
InputStream
*input)
noexcept
;
72
73
static
Tokens
tokenizer
(
const
std::string &line)
noexcept
;
74
75
static
bool
writeSpace
(
OutputStream
*output,
size_t
count
)
noexcept
;
76
77
public
:
78
Yaml
() =
delete
;
79
83
static
Value
parse
(
io::InputStream
*input);
84
89
static
bool
streamify
(
io::OutputStream
*output,
Value
&value);
90
};
91
}
// namespace sese
sese
config
Yaml.h
Generated on Tue Jan 7 2025 15:49:05 for Sese Framework by
1.11.0