Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
JSONParser.h
Go to the documentation of this file.
1/*
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 */
12
13#ifndef JSON_PARSER_H
14#define JSON_PARSER_H
15
17
18#include <istream>
19#include <memory>
20#include <list>
21
22class TJSONTree : public JSONTree {
23public:
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;
32
33 const TJSONTree *get_tree() const;
35 const Impl &get_node() const;
36 Impl &get_node();
37
38 public:
39 virtual void writeJSON(std::ostream &os) const override;
40
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 virtual Node &operator<<(std::string const &s) override;
47 virtual Node &operator<<(int i) override;
48 virtual Node &operator<<(double d) override;
49 virtual const Node &operator>>(std::string &v) const override;
50 virtual Node &operator[](std::string const &k) override;
51 virtual Node &operator[](size_t pos) override;
52 virtual const Node &operator[](std::string const &k) const override;
53 virtual const Node &operator[](size_t pos) const override;
54 virtual bool is_container() const override;
55 virtual bool is_map() const override;
56 virtual bool is_seq() const override;
57 virtual void set_map() override;
58 virtual void set_seq() override;
59 virtual std::string key() const override;
60 virtual std::string val() const override;
61 virtual int val_int() const override;
62 virtual float val_float() const override;
63 virtual bool val_bool() const override;
64 virtual bool has_key() const override;
65 virtual bool has_val() const override;
66 virtual bool has_child(std::string const &) const override;
67 virtual Node &append_child() override;
68 virtual size_t num_children() const override;
69 virtual Node &child(size_t pos) override;
70 virtual const Node &child(size_t pos) const override;
71
72 children_view children() override;
73 const_children_view children() const override;
74 };
75
76protected:
78 std::list<Node> _nodecache;
79 void clearcache();
80
81public:
82 TJSONTree();
83 virtual ~TJSONTree();
84 TJSONTree(std::istream &is);
86
87 virtual Node &rootnode() override;
88};
89#endif
#define d(i)
Definition RSha256.hxx:102
virtual bool is_container() const override
virtual bool has_child(std::string const &) const override
virtual bool val_bool() const override
virtual Node & child(size_t pos) override
virtual const Node & operator>>(std::string &v) const override
virtual void set_seq() override
children_view children() override
virtual Node & operator[](std::string const &k) override
virtual Node & append_child() override
const TJSONTree * get_tree() const
virtual size_t num_children() const override
virtual std::string val() const override
virtual void writeJSON(std::ostream &os) const override
virtual bool has_key() const override
TJSONTree * tree
Definition JSONParser.h:26
virtual std::string key() const override
virtual void set_map() override
virtual bool is_seq() const override
std::unique_ptr< Impl > node
Definition JSONParser.h:31
virtual bool has_val() const override
virtual float val_float() const override
const Impl & get_node() const
virtual bool is_map() const override
virtual Node & operator<<(std::string const &s) override
virtual int val_int() const override
TJSONTree::Node & incache(const TJSONTree::Node &n)
Node root
Definition JSONParser.h:77
std::list< Node > _nodecache
Definition JSONParser.h:78
void clearcache()
virtual ~TJSONTree()
virtual Node & rootnode() override
const Int_t n
Definition legend1.C:16