Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
Yaml.h
浏览该文件的文档.
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>
24#include <sese/util/Value.h>
25
26#include <queue>
27
28namespace sese {
30class Yaml {
31 using Tokens = std::vector<std::string>;
32 using TokensQueue = std::queue<std::tuple<int, Tokens>>;
35 using Line = std::tuple<int, std::string>;
36
37 static Value parseBasic(const std::string &value);
38
39 static Value parseObject(TokensQueue &tokens_queue, size_t level);
40
41 static Value parseArray(TokensQueue &tokens_queue, size_t level);
42
43 static void streamifyObject(io::OutputStream *output, const Value::Dict &dict, size_t level);
44
45 static void streamifyArray(io::OutputStream *output, const Value::List &list, size_t level);
46
47 static int getSpaceCount(const std::string &line) noexcept;
48
49 static Line getLine(InputStream *input) noexcept;
50
51 static Tokens tokenizer(const std::string &line) noexcept;
52
53 static void writeSpace(size_t count, OutputStream *output) noexcept;
54
55public:
56
61 static Value parse(io::InputStream *input, size_t level);
62
66 static void streamify(io::OutputStream *output, const Value &value);
67};
68} // namespace sese