structure_tree¶
Defined in header: <orcus/json_structure_tree.hpp>
-
class structure_tree¶
Public Types
-
enum class node_type : uint8_t¶
Values:
-
enumerator unknown¶
-
enumerator array¶
-
enumerator object¶
-
enumerator object_key¶
-
enumerator value¶
-
enumerator unknown¶
-
enum class callback_type : uint8_t¶
Location of a callback function.
Values:
-
enumerator unknown¶
Location not specified or unknown.
-
enumerator on_repeat_node¶
Callback function is called when a repeat node is encountered. A repeat node can be either an object or an array. The argument passed to the callback function contains the type of the repeat node and its type is
node_type.
-
enumerator unknown¶
-
using callback_handler_type = std::function<void(std::any)>¶
Callback function type. It must take one argument. What value is assigned and what the type of a value is depends on the location of the callback. Refer to
callback_typefor details.
-
using range_handler_type = std::function<void(table_range_t&&)>¶
Public Functions
-
structure_tree(const structure_tree&) = delete¶
-
structure_tree &operator=(const structure_tree&) = delete¶
-
structure_tree()¶
-
~structure_tree()¶
-
void set_callback(callback_type type, callback_handler_type callback)¶
Assign a user-defined callback function in a specified point of execution during parsing.
- Parameters:
type – Location where the callback function will be called.
callback – Callback function.
-
void parse(std::string_view stream)¶
-
void normalize_tree()¶
For now, normalizing a tree just means sorting child nodes. We may add other normalization stuff later.
-
void dump_compact(std::ostream &os) const¶
-
void process_ranges(range_handler_type rh) const¶
-
struct node_properties¶
-
class walker¶
Public Functions
-
walker()¶
-
~walker()¶
-
void root()¶
Set the current position to the root node, and return its properties.
-
void descend(size_t child_pos)¶
Move down to a child node at specified position. Call child_count() to get the number of child nodes the current node has. A child node position is 0-based and must be less than the child count.
- Parameters:
child_pos – 0-based index of the child node to move down to.
-
void ascend()¶
Move up to the parent node of the current node.
-
size_t child_count() const¶
Return the number of child nodes the current node has.
- Returns:
number of child nodes of the current node.
-
node_properties get_node() const¶
Get the properties of the current node.
-
std::vector<std::string> build_field_paths() const¶
Build one or more field paths for the current value node. For a value node that is a child of an object, you’ll always get one path, whereas a value node that is a chlid of an array, you may get more than one field paths.
- Returns:
one or more field paths built for the current value node.
-
std::string build_row_group_path() const¶
Build a path for the parent of the current repeating node. A row group is an anchor to which repeating nodes get anchored to. It is used to determine when to increment row position during mapping.
- Returns:
path for the row group of the current repeating node.
-
walker()¶
-
enum class node_type : uint8_t¶