13#ifndef RooFit_Detail_JSONInterface_h
14#define RooFit_Detail_JSONInterface_h
33 virtual std::unique_ptr<Impl>
clone()
const = 0;
41 std::unique_ptr<Impl>
it;
62 return !lhs.
it->equal(*rhs.
it);
66 return lhs.
it->equal(*rhs.
it);
86 virtual void writeYML(std::ostream &)
const {
throw std::runtime_error(
"YML not supported"); }
104 virtual std::string
key()
const = 0;
105 virtual std::string
val()
const = 0;
106 virtual int val_int()
const {
return atoi(this->
val().c_str()); }
108 virtual bool val_bool()
const {
return atoi(this->
val().c_str()); }
125 template <
typename Collection>
129 for (
auto const &item : coll) {
134 template <
typename Collection,
typename TransformationFunc>
135 void fill_seq(Collection
const &coll, TransformationFunc func)
138 for (
auto const &item : coll) {
143 template <
typename Matrix>
147 for (
int i = 0; i < mat.
GetNrows(); ++i) {
150 for (
int j = 0; j < mat.
GetNcols(); ++j) {
151 row.append_child() << mat(i, j);
162 template <
typename... Keys_t>
176 template <
typename... Keys_t>
181 return next.get(keys...);
191 static std::unique_ptr<JSONTree>
create();
192 static std::unique_ptr<JSONTree>
create(std::istream &is);
193 static std::unique_ptr<JSONTree>
create(std::string
const &str);
206 template <
typename... Args>
207 static std::unique_ptr<JSONTree>
createImpl(Args &&...args);
215 for (
const auto &
e : cv) {
216 v.push_back(
e.val_t<T>());
224 for (
const auto &
e : cv) {
225 v.push_back(
e.val_t<T>());
234 throw std::runtime_error(
"node " +
n.key() +
" is not of sequence type!");
241inline int JSONNode::val_t<int>()
const
246inline double JSONNode::val_t<double>()
const
251inline bool JSONNode::val_t<bool>()
const
256inline std::string JSONNode::val_t<std::string>()
const
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
virtual std::unique_ptr< Impl > clone() const =0
virtual bool equal(const Impl &other) const =0
virtual void backward()=0
child_iterator_t & operator--()
child_iterator_t & operator++()
child_iterator_t(std::unique_ptr< Impl > impl)
child_iterator_t(const child_iterator_t &other)
friend bool operator==(child_iterator_t const &lhs, child_iterator_t const &rhs)
std::unique_ptr< Impl > it
friend bool operator!=(child_iterator_t const &lhs, child_iterator_t const &rhs)
child_iterator_t< Nd > begin() const
children_view_t(child_iterator_t< Nd > const &b_, child_iterator_t< Nd > const &e_)
child_iterator_t< Nd > end() const
virtual JSONNode & operator<<(std::string const &s)=0
virtual bool val_bool() const
JSONNode & get(std::string const &key)
virtual std::string val() const =0
virtual const JSONNode & operator>>(std::string &v) const =0
JSONNode & get(std::string const &key, Keys_t const &...keys)
void fill_seq(Collection const &coll)
virtual JSONNode & set_map()=0
virtual JSONNode & append_child()=0
JSONNode const * find(std::string const &key, Keys_t const &...keys) const
virtual JSONNode & operator<<(double d)=0
virtual children_view children()
virtual size_t num_children() const =0
virtual JSONNode & child(size_t pos)=0
virtual JSONNode & set_seq()=0
virtual bool is_container() const =0
virtual void writeJSON(std::ostream &os) const =0
virtual bool is_seq() const =0
virtual const JSONNode & operator[](std::string const &k) const =0
virtual JSONNode & operator<<(bool b)=0
virtual void writeYML(std::ostream &) const
virtual bool is_map() const =0
virtual bool has_child(std::string const &) const =0
virtual std::string key() const =0
JSONNode & operator<<(const char *s)
void fill_seq(Collection const &coll, TransformationFunc func)
virtual JSONNode & operator[](std::string const &k)=0
void fill_mat(Matrix const &mat)
virtual bool has_key() const =0
virtual const JSONNode & child(size_t pos) const =0
virtual double val_double() const
JSONNode const * find(std::string const &key) const
virtual bool has_val() const =0
virtual int val_int() const
virtual JSONNode & operator<<(int i)=0
static void setBackend(std::string const &name)
Set the library that serves as the backend for the JSON interface.
static Backend & getBackendEnum()
static std::unique_ptr< JSONTree > create()
static bool hasBackend(std::string const &name)
Check if ROOT was compiled with support for a certain JSON backend library.
static std::string getBackend()
Returns the name of the library that serves as the backend for the JSON interface,...
static std::unique_ptr< JSONTree > createImpl(Args &&...args)
virtual ~JSONTree()=default
virtual JSONNode & rootnode()=0
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...