tetengo 1.9.2
A multipurpose library set
Loading...
Searching...
No Matches
json_grammar.hpp
Go to the documentation of this file.
1
6
7#if !defined(TETENGO_JSON_JSONGRAMMAR_HPP)
8#define TETENGO_JSON_JSONGRAMMAR_HPP
9
10#include <functional>
11#include <memory>
12#include <string_view>
13#include <unordered_map>
14
15#include <boost/core/noncopyable.hpp>
16
17
18namespace tetengo::json
19{
20 class reader;
21
22
28 class json_grammar : private boost::noncopyable
29 {
30 public:
31 // types
32
41
52 using primitive_handler_type = std::function<bool(primitive_type_type type, const std::string_view& value)>;
53
61
68
80 using structure_handler_type = std::function<bool(
83 const std::unordered_map<std::string_view, std::string_view>& attributes)>;
84
85
86 // constructors and destructor
87
94 json_grammar(primitive_handler_type primitive_handler, structure_handler_type structure_handler);
95
100
101
102 // functions
103
112 [[nodiscard]] bool parse(reader& reader_) const;
113
114
115 private:
116 // types
117
118 class impl;
119
120
121 // variables
122
123 std::unique_ptr<impl> m_p_impl;
124 };
125
126
127}
128
129
130#endif
bool parse(reader &reader_) const
Parses a text.
~json_grammar()
Destroys the JSON grammar.
std::function< bool( structure_type_type type, structure_open_close_type open_close, const std::unordered_map< std::string_view, std::string_view > &attributes)> structure_handler_type
The structure handler type.
Definition json_grammar.hpp:80
std::function< bool(primitive_type_type type, const std::string_view &value)> primitive_handler_type
The primitive handler type.
Definition json_grammar.hpp:52
structure_type_type
The structure type type.
Definition json_grammar.hpp:56
@ object
An object.
Definition json_grammar.hpp:57
@ member
A member.
Definition json_grammar.hpp:58
@ array
An array.
Definition json_grammar.hpp:59
primitive_type_type
The primitive type type.
Definition json_grammar.hpp:35
@ null
A null.
Definition json_grammar.hpp:39
@ boolean
A boolean.
Definition json_grammar.hpp:38
@ number
A number.
Definition json_grammar.hpp:37
@ string
A string.
Definition json_grammar.hpp:36
json_grammar(primitive_handler_type primitive_handler, structure_handler_type structure_handler)
Creates a JSON grammar.
structure_open_close_type
The structure open-close type.
Definition json_grammar.hpp:64
@ close
Closing.
Definition json_grammar.hpp:66
@ open
Opening.
Definition json_grammar.hpp:65
A reader.
Definition reader.hpp:19
A JSON library.