17#include <c4/yml/std/map.hpp>
18#include <c4/yml/std/string.hpp>
19#include <c4/yml/common.hpp>
27 size_t n = (
src.len > 0);
29 n += (
src.begins_with(
'\n') ||
src.begins_with(
'\r'));
35c4::yml::Tree
makeTree(std::istream &is)
38 throw std::runtime_error(
"invalid input!");
39 std::string s(std::istreambuf_iterator<char>(is), {});
41 auto src = c4::to_csubstr(s.c_str());
43 c4::yml::Tree tree(
nlines, s.size());
45 np.parse_in_place({}, tree.copy_to_arena(
src), &tree);
60 inline ryml::Tree &
get()
65 inline const ryml::Tree &
get()
const
86 inline c4::yml::NodeRef &
get()
91 inline const c4::yml::NodeRef &
get()
const
103 os << c4::yml::as_json(
node->get());
115 node->
get() |= c4::yml::MAP;
122 node->
get() |= c4::yml::SEQ;
128 throw std::logic_error(
"Function not yet implemented");
133 throw std::logic_error(
"Function not yet implemented");
142 : tree(std::make_unique<
Impl>()){
208 return Impl::mkNode(
tree, node->get()[c4::to_csubstr(
tree->incache(k))]);
214 return Impl::mkNode(
tree, node->get()[c4::to_csubstr(
tree->incache(k))]);
220 return node->get().is_container();
226 return node->get().is_map();
232 return node->get().is_seq();
237 return !node->get().has_val() && node->get().num_children() == 0;
243 std::stringstream
ss;
244 ss << node->get().key();
252 std::stringstream
ss;
253 ss << node->get().val();
260 return Impl::mkNode(
tree, node->get().append_child());
266 return node->get().has_key();
272 return node->get().has_val();
278 return node->get().has_child(c4::to_csubstr(s.c_str()));
284 return node->get().num_children();
290 return Impl::mkNode(
tree, node->get().child(pos));
296 return Impl::mkNode(
tree, node->get().child(pos));
306 throw std::runtime_error(
msg);
308 throw std::runtime_error(
"error handler invoked without error message");
315 c4::yml::set_callbacks(c4::yml::Callbacks(c4::yml::get_callbacks().
m_user_data, c4::yml::get_callbacks().
m_allocate,
316 c4::yml::get_callbacks().m_free, &
::error_cb));
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
JSONNode & get(std::string const &key)
const ryml::Tree & get() const
const c4::yml::NodeRef & get() const
static TRYMLTree::Node & mkNode(TRYMLTree *t, c4::yml::NodeRef node)
Impl(const c4::yml::NodeRef &n)
bool is_map() const override
bool has_key() const override
Node & child(size_t pos) override
const Node & operator>>(std::string &v) const override
void writeYML(std::ostream &) const override
bool is_container() const override
std::string key() const override
Node & set_map() override
Node & operator<<(std::string const &s) override
bool is_null() const override
std::unique_ptr< Impl > node
std::string val() const override
Node & operator[](std::string const &k) override
Node & append_child() override
bool is_seq() const override
Node & set_null() override
Node(TRYMLTree *t, const Impl &other)
bool has_val() const override
bool has_child(std::string const &) const override
void writeJSON(std::ostream &os) const override
size_t num_children() const override
Node & set_seq() override
std::unique_ptr< Impl > tree
std::list< std::string > _strcache
Node & incache(const Node &n)
Node & rootnode() override
std::list< Node > _nodecache