Orcus
Loading...
Searching...
No Matches
orcus::json::node Class Reference

#include <json_document_tree.hpp>

Inheritance diagram for orcus::json::node:
orcus::json::const_node

Public Member Functions

 node (const node &other)
 node (node &&rhs)
nodeoperator= (const node &other)
nodeoperator= (const detail::init::node &v)
node operator[] (std::string_view key)
node child (size_t index)
node child (std::string_view key)
node parent ()
node back ()
void push_back (const detail::init::node &v)
Public Member Functions inherited from orcus::json::const_node
 const_node (const const_node &other)
 const_node (const_node &&rhs)
node_t type () const
size_t child_count () const
std::vector< std::string_view > keys () const
std::string_view key (size_t index) const
bool has_key (std::string_view key) const
const_node child (size_t index) const
const_node child (std::string_view key) const
const_node parent () const
const_node back () const
std::string_view string_value () const
double numeric_value () const
const_nodeoperator= (const const_node &other)
const_nodeoperator= (const_node &&other)
uintptr_t identity () const
const_node_iterator begin () const
const_node_iterator end () const
std::string dump (std::size_t indent) const

Friends

class document_tree

Additional Inherited Members

Protected Member Functions inherited from orcus::json::const_node
 const_node (const document_tree *doc, json_value *jv)
 const_node (std::unique_ptr< impl > &&p)
Protected Attributes inherited from orcus::json::const_node
std::unique_ptr< impl > mp_impl

Detailed Description

Each node instance represents a JSON value stored in the document tree. This class allows mutable operations.

Member Function Documentation

◆ back()

node orcus::json::node::back ( )

Get the last child node.

Exceptions
orcus::json::document_errorif the node is not of array type or node has no children.
Returns
last child node instance.

◆ child() [1/2]

node orcus::json::node::child ( size_t index)

Get a child node by index.

Parameters
index0-based index of a child node.
Exceptions
orcus::json::document_errorif the node is not one of the object or array types.
std::out_of_rangeif the index is equal to or greater than the number of child nodes that the node has.
Returns
child node instance.

◆ child() [2/2]

node orcus::json::node::child ( std::string_view key)

Get a child node by textural key value.

Parameters
keytextural key value to get a child node by.
Exceptions
orcus::json::document_errorif the node is not of the object type, or the node doesn't have the specified key.
Returns
child node instance.

◆ parent()

node orcus::json::node::parent ( )

Get the parent node.

Exceptions
orcus::json::document_errorif the node doesn't have a parent node which implies that the node is a root node.
Returns
parent node instance.

◆ push_back()

void orcus::json::node::push_back ( const detail::init::node & v)

Append a new node value to the end of the array.

Exceptions
orcus::json::document_errorif the node is not of array type.
Parameters
vnew node value to append to the end of the array.