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
19
namespace
orcus {
namespace
json {
20
21
struct
ORCUS_DLLPUBLIC
table_range_t
22
{
23
std::vector<std::string> paths;
24
std::vector<std::string> row_groups;
25
};
26
27
class
ORCUS_DLLPUBLIC structure_tree
28
{
29
struct
impl;
30
std::unique_ptr<impl> mp_impl;
31
32
public
:
33
34
enum class
node_type :
short
{ unknown = 0,
array
= 1,
object
= 2, object_key = 3, value = 4 };
35
36
struct
node_properties
37
{
38
node_type type;
39
bool
repeat;
40
};
41
42
class
ORCUS_DLLPUBLIC walker
43
{
44
friend
class
structure_tree;
45
46
struct
impl;
47
std::unique_ptr<impl> mp_impl;
48
49
walker(
const
structure_tree::impl* parent_impl);
50
public
:
51
walker();
52
walker(
const
walker& other);
53
~walker();
54
59
void
root
();
60
69
void
descend
(
size_t
child_pos);
70
74
void
ascend
();
75
81
size_t
child_count
()
const
;
82
86
node_properties
get_node
()
const
;
87
96
std::vector<std::string>
build_field_paths
()
const
;
97
105
std::string
build_row_group_path
()
const
;
106
};
107
108
structure_tree(
const
structure_tree&) =
delete
;
109
structure_tree& operator= (
const
structure_tree&) =
delete
;
110
111
structure_tree();
112
~structure_tree();
113
114
void
parse(std::string_view stream);
115
120
void
normalize_tree
();
121
122
void
dump_compact(std::ostream& os)
const
;
123
124
walker
get_walker()
const
;
125
126
using
range_handler_type = std::function<void(
table_range_t
&&)>;
127
128
void
process_ranges(range_handler_type rh)
const
;
129
};
130
131
ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, structure_tree::node_type nt);
132
133
}}
134
135
#endif
136
137
/* 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:43
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::normalize_tree
void normalize_tree()
orcus::json::structure_tree::node_properties
Definition
json_structure_tree.hpp:37
orcus::json::table_range_t
Definition
json_structure_tree.hpp:22
Generated on
for Orcus by
1.17.0