Orcus
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
orcus::json::structure_tree Class Reference

Classes

struct  node_properties
 
class  walker
 

Public Types

enum class  node_type : uint8_t {
  unknown = 0 , array = 1 , object = 2 , object_key = 3 ,
  value = 4
}
 
enum class  callback_type : uint8_t { unknown = 0 , on_repeat_node }
 
using callback_handler_type = std::function< void(std::any)>
 
using range_handler_type = std::function< void(table_range_t &&)>
 

Public Member Functions

 structure_tree (const structure_tree &)=delete
 
structure_treeoperator= (const structure_tree &)=delete
 
void set_callback (callback_type type, callback_handler_type callback)
 
void parse (std::string_view stream)
 
void normalize_tree ()
 
void dump_compact (std::ostream &os) const
 
walker get_walker () const
 
void process_ranges (range_handler_type rh) const
 

Member Typedef Documentation

◆ callback_handler_type

using orcus::json::structure_tree::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_type for details.

Member Enumeration Documentation

◆ callback_type

enum class orcus::json::structure_tree::callback_type : uint8_t
strong

Location of a callback function.

Enumerator
unknown 

Location not specified or unknown.

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.

Member Function Documentation

◆ normalize_tree()

void orcus::json::structure_tree::normalize_tree ( )

For now, normalizing a tree just means sorting child nodes. We may add other normalization stuff later.

◆ set_callback()

void orcus::json::structure_tree::set_callback ( callback_type  type,
callback_handler_type  callback 
)

Assign a user-defined callback function in a specified point of execution during parsing.

Parameters
typeLocation where the callback function will be called.
callbackCallback function.