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
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 { return tree; }
34 TJSONTree *get_tree() { return tree; }
35 const Impl &get_node() const;
36 Impl &get_node();
37
38 public:
39 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() = default;
46 Node &operator<<(std::string const &s) override;
47 Node &operator<<(int i) override;
48 Node &operator<<(double d) override;
49 Node &operator<<(bool b) override;
50 const Node &operator>>(std::string &v) const override;
51 Node &operator[](std::string const &k) override;
52 const Node &operator[](std::string const &k) const override;
53 bool is_container() const override;
54 bool is_map() const override;
55 bool is_seq() const override;
56 Node &set_map() override;
57 Node &set_seq() override;
58 void clear() override;
59 std::string key() const override;
60 std::string val() const override;
61 int val_int() const override;
62 double val_double() const override;
63 bool val_bool() const override;
64 bool has_key() const override;
65 bool has_val() const override;
66 bool has_child(std::string const &) const override;
67 Node &append_child() override;
68 size_t num_children() const override;
69 Node &child(size_t pos) override;
70 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 ~TJSONTree() override;
84 TJSONTree(std::istream &is);
86
87 Node &rootnode() override { return root; }
88};
89#endif
#define d(i)
Definition RSha256.hxx:102
#define b(i)
Definition RSha256.hxx:100
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
bool is_container() const override
bool has_child(std::string const &) const override
bool val_bool() const override
const Node & operator>>(std::string &v) const override
TJSONTree * get_tree()
Definition JSONParser.h:34
Node & operator[](std::string const &k) override
Node & append_child() override
void clear() override
const TJSONTree * get_tree() const
Definition JSONParser.h:33
size_t num_children() const override
virtual ~Node()=default
std::string val() const override
void writeJSON(std::ostream &os) const override
bool has_key() const override
TJSONTree * tree
Definition JSONParser.h:26
std::string key() const override
Node & set_map() override
double val_double() const override
bool is_seq() const override
std::unique_ptr< Impl > node
Definition JSONParser.h:31
Node & set_seq() override
bool has_val() const override
const Impl & get_node() const
bool is_map() const override
children_view children() override
Node & operator<<(std::string const &s) override
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()
Node & rootnode() override
Definition JSONParser.h:87
~TJSONTree() override
const Int_t n
Definition legend1.C:16