13#ifndef RooFit_Detail_JSONInterface_h
14#define RooFit_Detail_JSONInterface_h
18#include <unordered_map>
97 std::string
key()
const;
98 std::string
val()
const;
108 bool has_child(std::string
const &)
const;
120 template <
typename Collection>
124 for (
auto const &item : coll) {
129 template <
typename Collection>
134 for (
auto const &item : coll) {
142 template <
typename Collection,
typename TransformationFunc>
143 void fill_seq(Collection
const &coll, TransformationFunc func)
146 for (
auto const &item : coll) {
151 template <
typename Matrix>
155 for (
int i = 0; i < mat.
GetNrows(); ++i) {
158 for (
int j = 0; j < mat.
GetNcols(); ++j) {
159 row.append_child() << mat(i, j);
170 template <
typename... Keys_t>
184 template <
typename... Keys_t>
189 return next.get(keys...);
212 static std::unique_ptr<JSONTree>
create();
213 static std::unique_ptr<JSONTree>
create(std::istream &is);
214 static std::unique_ptr<JSONTree>
create(std::string
const &str);
217 explicit JSONTree(std::unique_ptr<JSONNode::Storage> storage);
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!");
252template <
class Key,
class T,
class Hash,
class KeyEqual,
class Allocator>
257 for (
const auto &it :
m) {
258 n[it.first] << it.second;
263template <
class Key,
class T,
class Compare,
class Allocator>
267 for (
const auto &it :
m) {
268 n[it.first] << it.second;
274inline int JSONNode::val_t<int>()
const
279inline double JSONNode::val_t<double>()
const
284inline bool JSONNode::val_t<bool>()
const
289inline std::string JSONNode::val_t<std::string>()
const
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
child_iterator_t(Nd *const *pos)
child_iterator_t & operator--()
child_iterator_t & operator++()
friend bool operator==(child_iterator_t const &lhs, child_iterator_t const &rhs)
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
JSONNode & operator[](std::string const &k)
JSONNode & get(std::string const &key)
double val_double() const
void erase(std::string const &key)
Remove a child of a map, if it exists.
bool is_container() const
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)
JSONNode const * find(std::string const &key, Keys_t const &...keys) const
void writeJSON(std::ostream &os) const
JSONNode & append_child()
JSONNode & operator<<(std::string const &s)
JSONNode & operator=(JSONNode const &)=delete
JSONNode & operator<<(const char *s)
size_t num_children() const
void fill_seq(Collection const &coll, TransformationFunc func)
void fill_mat(Matrix const &mat)
JSONNode const * find(std::string const &key) const
JSONNode(JSONNode const &)=delete
const JSONNode & operator>>(std::string &v) const
bool has_child(std::string const &) const
std::optional< bool > try_val_bool() const
The value as a boolean, or std::nullopt if it is none. Like val_bool(), the integers 0 and 1 are acce...
Records which components of a JSON map are read while it is alive, through any node of the tree.
static std::unique_ptr< JSONTree > create()
JSONTree(std::unique_ptr< JSONNode::Storage > storage)
std::unique_ptr< JSONNode::Storage > _storage
std::ostream & operator<<(std::ostream &os, RooFit::Detail::JSONNode const &s)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...