Logo ROOT  
Reference Guide
Go to the documentation of this file.
2 * Project: RooFit
3 * Authors:
4 * Carsten D. Burgard, DESY/ATLAS, Dec 2021
5 *
6 * Copyright (c) 2022, CERN
7 *
8 * Redistribution and use in source and binary forms,
9 * with or without modification, are permitted according to the terms
10 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11 */
13#ifndef JSON_PARSER_H
14#define JSON_PARSER_H
18#include <istream>
19#include <memory>
20#include <list>
25 protected:
27 class Impl;
28 template <class Nd, class NdType, class json_it>
29 class ChildItImpl;
30 friend TJSONTree;
31 std::unique_ptr<Impl> node;
33 const TJSONTree *get_tree() const;
35 const Impl &get_node() const;
36 Impl &get_node();
38 public:
39 void writeJSON(std::ostream &os) const override;
41 Node(TJSONTree *t, std::istream &is);
42 Node(TJSONTree *t, Impl &other);
43 Node(TJSONTree *t);
44 Node(const Node &other);
45 virtual ~Node();
46 Node &operator<<(std::string const &s) override;
47 Node &operator<<(int i) override;
48 Node &operator<<(double d) override;
49 const Node &operator>>(std::string &v) const override;
50 Node &operator[](std::string const &k) override;
51 Node &operator[](size_t pos) override;
52 const Node &operator[](std::string const &k) const override;
53 const Node &operator[](size_t pos) const override;
54 bool is_container() const override;
55 bool is_map() const override;
56 bool is_seq() const override;
57 void set_map() override;
58 void set_seq() override;
59 void clear() override;
60 std::string key() const override;
61 std::string val() const override;
62 int val_int() const override;
63 double val_double() const override;
64 bool val_bool() const override;
65 bool has_key() const override;
66 bool has_val() const override;
67 bool has_child(std::string const &) const override;
68 Node &append_child() override;
69 size_t num_children() const override;
70 Node &child(size_t pos) override;
71 const Node &child(size_t pos) const override;
73 children_view children() override;
74 const_children_view children() const override;
75 };
79 std::list<Node> _nodecache;
80 void clearcache();
83 TJSONTree();
84 ~TJSONTree() override;
85 TJSONTree(std::istream &is);
88 Node &rootnode() override;
#define d(i)
Definition: RSha256.hxx:102
bool is_container() const override
Definition: JSONParser.cxx:181
bool has_child(std::string const &) const override
Definition: JSONParser.cxx:300
bool val_bool() const override
Definition: JSONParser.cxx:274
Node & child(size_t pos) override
Definition: JSONParser.cxx:316
const Node & operator>>(std::string &v) const override
Definition: JSONParser.cxx:155
void set_seq() override
Definition: JSONParser.cxx:229
friend TJSONTree
Definition: JSONParser.h:30
Node & operator[](std::string const &k) override
Definition: JSONParser.cxx:161
Node & append_child() override
Definition: JSONParser.cxx:305
void clear() override
Definition: JSONParser.cxx:242
const TJSONTree * get_tree() const
Definition: JSONParser.cxx:53
size_t num_children() const override
Definition: JSONParser.cxx:311
std::string val() const override
Definition: JSONParser.cxx:252
void writeJSON(std::ostream &os) const override
Definition: JSONParser.cxx:132
bool has_key() const override
Definition: JSONParser.cxx:290
TJSONTree * tree
Definition: JSONParser.h:26
std::string key() const override
Definition: JSONParser.cxx:247
void set_map() override
Definition: JSONParser.cxx:216
double val_double() const override
Definition: JSONParser.cxx:270
bool is_seq() const override
Definition: JSONParser.cxx:191
std::unique_ptr< Impl > node
Definition: JSONParser.h:31
bool has_val() const override
Definition: JSONParser.cxx:295
virtual ~Node()
Definition: JSONParser.cxx:128
Node(TJSONTree *t, std::istream &is)
Definition: JSONParser.cxx:117
const Impl & get_node() const
Definition: JSONParser.cxx:48
bool is_map() const override
Definition: JSONParser.cxx:186
children_view children() override
Definition: JSONParser.cxx:363
Node & operator<<(std::string const &s) override
Definition: JSONParser.cxx:137
int val_int() const override
Definition: JSONParser.cxx:266
TJSONTree::Node & incache(const TJSONTree::Node &n)
Definition: JSONParser.cxx:37
Node root
Definition: JSONParser.h:78
std::list< Node > _nodecache
Definition: JSONParser.h:79
void clearcache()
Definition: JSONParser.cxx:63
~TJSONTree() override
Definition: JSONParser.cxx:32
Node & rootnode() override
Definition: JSONParser.cxx:21
const Int_t n
Definition: legend1.C:16
static constexpr double s