1#ifndef MSTL_CORE_FILE_TOML_TOML_PARSER_HPP__
2#define MSTL_CORE_FILE_TOML_TOML_PARSER_HPP__
4#include "toml_value.hpp"
7class MSTL_API toml_parser {
14 vector<context> context_stack_;
15 bool is_in_array_table_ =
false;
23 unique_ptr<toml_table> root_;
24 toml_table* ctb_ =
nullptr;
27 void skip_whitespace() noexcept;
28 void skip_comment() noexcept;
29 void skip_whitespace_and_comments() noexcept;
30 void skip_newlines() noexcept;
31 void skip_whitespace_no_newline() noexcept;
33 char current() const noexcept;
34 char peek(
size_t offset = 1) const noexcept;
35 bool eof() const noexcept;
38 bool match(
char ch) noexcept;
40 unique_ptr<toml_string> parse_string();
41 unique_ptr<toml_string> parse_basic_string();
42 unique_ptr<toml_string> parse_literal_string();
43 unique_ptr<toml_string> parse_multiline_basic_string();
44 unique_ptr<toml_string> parse_multiline_literal_string();
46 char32_t parse_unicode_escape(
size_t digits);
48 unique_ptr<toml_value> parse_number();
49 unique_ptr<toml_integer> parse_integer(
int base = 10);
51 unique_ptr<toml_boolean> parse_boolean();
52 unique_ptr<toml_datetime> parse_datetime();
54 unique_ptr<toml_array> parse_array();
55 unique_ptr<toml_table> parse_inline_table();
58 string parse_bare_key();
59 string parse_quoted_key();
60 vector<
string> parse_dotted_key();
62 unique_ptr<toml_value> parse_value();
63 void parse_key_value();
65 void parse_table_header();
66 void parse_array_table_header();
68 toml_table* get_or_create_table(const vector<
string>& path) const;
69 toml_table* navigate_to_table(const vector<
string>& path) const;
70 void set_current_table(const vector<
string>& path);
72 void throw_parse_error(
string message) const;
75 explicit toml_parser(
string toml_str) noexcept
81 unique_ptr<toml_table> parse();
82 optional<unique_ptr<toml_table>> try_parse();
MSTL_CONSTEXPR20 pointer get() const noexcept
获取原始指针
constexpr void advance(Iterator &i, Distance n)
将迭代器前进指定距离
#define _MSTL
全局命名空间MSTL前缀
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result)
移动范围元素
MSTL_NODISCARD MSTL_ALWAYS_INLINE constexpr decltype(auto) size(const Container &cont) noexcept(noexcept(cont.size()))
获取容器的大小
MSTL_CONSTEXPR20 unique_ptr< T > make_unique(Args &&... args)
创建unique_ptr