13#ifndef RooFit_Detail_JSONInterface_h
14#define RooFit_Detail_JSONInterface_h
33 virtual std::unique_ptr<Impl>
clone()
const = 0;
58 return !lhs.
it->equal(*rhs.
it);
62 return lhs.
it->equal(*rhs.
it);
66 std::unique_ptr<Impl>
it;
85 virtual void writeYML(std::ostream &)
const {
throw std::runtime_error(
"YML not supported"); }
103 virtual std::string
key()
const = 0;
104 virtual std::string
val()
const = 0;
105 virtual int val_int()
const {
return atoi(this->
val().c_str()); }
107 virtual bool val_bool()
const {
return atoi(this->
val().c_str()); }
124 template <
typename Collection>
128 for (
auto const &item : coll) {
133 template <
typename Collection>
138 for (
auto const &item : coll) {
146 template <
typename Collection,
typename TransformationFunc>
147 void fill_seq(Collection
const &coll, TransformationFunc func)
150 for (
auto const &item : coll) {
155 template <
typename Matrix>
159 for (
int i = 0; i < mat.
GetNrows(); ++i) {
162 for (
int j = 0; j < mat.
GetNcols(); ++j) {
163 row.append_child() << mat(i, j);
174 template <
typename... Keys_t>
188 template <
typename... Keys_t>
193 return next.get(keys...);
203 static std::unique_ptr<JSONTree>
create();
204 static std::unique_ptr<JSONTree>
create(std::istream &is);
205 static std::unique_ptr<JSONTree>
create(std::string
const &str);
218 template <
typename... Args>
219 static std::unique_ptr<JSONTree>
createImpl(Args &&...args);
227 for (
const auto &
e : cv) {
228 v.push_back(
e.val_t<T>());
236 for (
const auto &
e : cv) {
237 v.push_back(
e.val_t<T>());
246 throw std::runtime_error(
"node " +
n.key() +
" is not of sequence type!");
253inline int JSONNode::val_t<int>()
const
258inline double JSONNode::val_t<double>()
const
263inline bool JSONNode::val_t<bool>()
const
268inline 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
void fill_seq(Collection const &coll, size_t nmax)
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...