8#ifndef INCLUDED_ORCUS_JSON_DOCUMENT_TREE_HPP
9#define INCLUDED_ORCUS_JSON_DOCUMENT_TREE_HPP
12#include "exception.hpp"
26struct document_resource;
32class ORCUS_DLLPUBLIC document_error :
public general_error
35 document_error(
const std::string& msg);
36 virtual ~document_error();
44class ORCUS_DLLPUBLIC key_value_error :
public document_error
47 key_value_error(
const std::string& msg);
48 virtual ~key_value_error();
51enum class node_t : uint8_t
82namespace detail {
namespace init {
class node; }}
87class ORCUS_DLLPUBLIC const_node_iterator
89 friend class const_node;
92 std::unique_ptr<impl> mp_impl;
94 const_node_iterator(
const document_tree* doc,
const const_node& v,
bool begin);
97 const_node_iterator();
98 const_node_iterator(
const const_node_iterator& other);
99 ~const_node_iterator();
101 const const_node& operator*()
const;
102 const const_node* operator->()
const;
104 const_node_iterator& operator++();
105 const_node_iterator operator++(
int);
107 const_node_iterator& operator--();
108 const_node_iterator operator--(
int);
110 bool operator== (
const const_node_iterator& other)
const;
111 bool operator!= (
const const_node_iterator& other)
const;
113 const_node_iterator& operator= (
const const_node_iterator& other);
120class ORCUS_DLLPUBLIC const_node
122 friend class document_tree;
123 friend class const_node_iterator;
124 friend class subtree;
126 json_value* get_json_value();
130 std::unique_ptr<impl> mp_impl;
132 const_node(
const document_tree* doc, json_value* jv);
133 const_node(std::unique_ptr<impl>&& p);
136 const_node(
const const_node& other);
137 const_node(const_node&& rhs);
161 std::vector<std::string_view>
keys()
const;
177 std::string_view
key(
size_t index)
const;
202 const_node
child(
size_t index)
const;
256 const_node& operator=(
const const_node& other);
257 const_node& operator=(const_node&& other);
288 const_node_iterator
end()
const;
300 std::string
dump(std::size_t indent)
const;
307class ORCUS_DLLPUBLIC node :
public const_node
309 friend class document_tree;
311 node(
const document_tree* doc, json_value* jv);
312 node(const_node&& rhs);
317 node(
const node& other);
321 node& operator=(
const node& other);
323 node operator[](std::string_view
key);
386class ORCUS_DLLPUBLIC array
389 friend class document_tree;
391 std::vector<detail::init::node> m_vs;
394 array(
const array&) =
delete;
395 array(array&& other);
396 array(std::initializer_list<detail::init::node> vs);
404class ORCUS_DLLPUBLIC object
408 object(
const object&) =
delete;
409 object(
object&& other);
413namespace detail {
namespace init {
420class ORCUS_DLLPUBLIC node
422 friend class ::orcus::json::document_tree;
423 friend class ::orcus::json::node;
426 std::unique_ptr<impl> mp_impl;
432 node(std::nullptr_t);
434 node(
const std::string& s);
435 node(std::initializer_list<detail::init::node> vs);
439 node(
const node& other) =
delete;
443 node& operator= (node other) =
delete;
447 json_value* to_json_value(document_resource& res)
const;
448 void store_to_node(document_resource& res, json_value* parent)
const;
458class ORCUS_DLLPUBLIC document_tree
460 friend class const_node;
464 std::unique_ptr<impl> mp_impl;
466 const document_resource& get_resource()
const;
470 document_tree(
const document_tree&) =
delete;
471 document_tree(document_tree&& other);
472 document_tree(document_resource& res);
473 document_tree(std::initializer_list<detail::init::node> vs);
474 document_tree(
array vs);
475 document_tree(
object obj);
478 document_tree& operator= (std::initializer_list<detail::init::node> vs);
479 document_tree& operator= (
array vs);
480 document_tree& operator= (
object obj);
514 std::string
dump(std::size_t indent)
const;
537 void swap(document_tree& other);
548class ORCUS_DLLPUBLIC subtree
551 std::unique_ptr<impl> mp_impl;
564 subtree(
const subtree&) =
delete;
565 subtree(subtree&& other);
568 subtree& operator=(subtree&& other);
579 std::string
dump(std::size_t indent)
const;
Definition json_document_tree.hpp:387
Definition json_document_tree.hpp:121
bool has_key(std::string_view key) const
std::vector< std::string_view > keys() const
const_node_iterator begin() const
std::string_view key(size_t index) const
const_node child(size_t index) const
std::string_view string_value() const
const_node_iterator end() const
double numeric_value() const
std::string dump(std::size_t indent) const
size_t child_count() const
uintptr_t identity() const
const_node parent() const
const_node child(std::string_view key) const
Definition json_document_tree.hpp:421
Definition json_document_tree.hpp:459
json::node get_document_root()
std::string dump(std::size_t indent) const
std::string dump_yaml() const
void swap(document_tree &other)
json::const_node get_document_root() const
void load(std::string_view stream, const json_config &config)
std::string dump_xml() const
Definition json_document_tree.hpp:308
void push_back(const detail::init::node &v)
node child(std::string_view key)
Definition json_document_tree.hpp:405
std::string dump(std::size_t indent) const
subtree(const document_tree &src, std::string_view path)