Orcus
Toggle main menu visibility
Loading...
Searching...
No Matches
include
orcus
json_structure_tree.hpp
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
*/
7
8
#ifndef INCLUDED_ORCUS_JSON_STRUCTURE_TREE_HPP
9
#define INCLUDED_ORCUS_JSON_STRUCTURE_TREE_HPP
10
11
#include "orcus/env.hpp"
12
#include "orcus/types.hpp"
13
14
#include <ostream>
15
#include <memory>
16
#include <vector>
17
#include <functional>
18
#include <any>
19
20
namespace
orcus {
namespace
json {
21
22
struct
ORCUS_DLLPUBLIC
table_range_t
23
{
24
std::vector<std::string> paths;
25
std::vector<std::string> row_groups;
26
};
27
28
class
ORCUS_DLLPUBLIC structure_tree
29
{
30
struct
impl;
31
std::unique_ptr<impl> mp_impl;
32
33
public
:
34
35
enum class
node_type : uint8_t { unknown = 0,
array
= 1,
object
= 2, object_key = 3, value = 4 };
36
40
enum class
callback_type
: uint8_t
41
{
43
unknown = 0,
44
51
on_repeat_node
52
};
53
59
using
callback_handler_type
= std::function<void(std::any)>;
60
61
using
range_handler_type = std::function<void(
table_range_t
&&)>;
62
63
struct
node_properties
64
{
65
node_type type;
66
bool
repeat;
67
};
68
69
class
ORCUS_DLLPUBLIC walker
70
{
71
friend
class
structure_tree;
72
73
struct
impl;
74
std::unique_ptr<impl> mp_impl;
75
76
walker(
const
structure_tree::impl* parent_impl);
77
public
:
78
walker();
79
walker(
const
walker& other);
80
~walker();
81
86
void
root
();
87
96
void
descend
(
size_t
child_pos);
97
101
void
ascend
();
102
108
size_t
child_count
()
const
;
109
113
node_properties
get_node
()
const
;
114
123
std::vector<std::string>
build_field_paths
()
const
;
124
132
std::string
build_row_group_path
()
const
;
133
};
134
135
structure_tree(
const
structure_tree&) =
delete
;
136
structure_tree& operator= (
const
structure_tree&) =
delete
;
137
138
structure_tree();
139
~structure_tree();
140
148
void
set_callback
(
callback_type
type,
callback_handler_type
callback);
149
150
void
parse(std::string_view stream);
151
156
void
normalize_tree
();
157
158
void
dump_compact(std::ostream& os)
const
;
159
160
walker
get_walker()
const
;
161
162
void
process_ranges(range_handler_type rh)
const
;
163
};
164
165
ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, structure_tree::node_type nt);
166
167
}}
168
169
#endif
170
171
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
orcus::json::array
Definition
json_document_tree.hpp:387
orcus::json::structure_tree::walker
Definition
json_structure_tree.hpp:70
orcus::json::structure_tree::walker::ascend
void ascend()
orcus::json::structure_tree::walker::child_count
size_t child_count() const
orcus::json::structure_tree::walker::descend
void descend(size_t child_pos)
orcus::json::structure_tree::walker::build_field_paths
std::vector< std::string > build_field_paths() const
orcus::json::structure_tree::walker::build_row_group_path
std::string build_row_group_path() const
orcus::json::structure_tree::walker::get_node
node_properties get_node() const
orcus::json::structure_tree::walker::root
void root()
orcus::json::structure_tree::callback_type
callback_type
Definition
json_structure_tree.hpp:41
orcus::json::structure_tree::set_callback
void set_callback(callback_type type, callback_handler_type callback)
orcus::json::structure_tree::callback_handler_type
std::function< void(std::any)> callback_handler_type
Definition
json_structure_tree.hpp:59
orcus::json::structure_tree::normalize_tree
void normalize_tree()
orcus::json::structure_tree::node_properties
Definition
json_structure_tree.hpp:64
orcus::json::table_range_t
Definition
json_structure_tree.hpp:23
Generated on
for Orcus by
1.17.0