1#include <xrpl/beast/utility/PropertyStream.h>
2#include <xrpl/beast/utility/instrumentation.h>
64 return m_ostream << manip;
112 return Proxy(*
this, key);
133 m_stream.array_end();
155 : m_name(name), item_(this), parent_(nullptr)
162 if (parent_ !=
nullptr)
163 parent_->remove(*
this);
181 source.
parent_ ==
nullptr,
"beast::PropertyStream::Source::add : null source parent");
182 children_.push_back(source.
item_);
194 child.parent_ ==
this,
"beast::PropertyStream::Source::remove : child parent match");
195 children_.erase(children_.iterator_to(child.item_));
196 child.parent_ =
nullptr;
203 for (
auto iter = children_.begin(); iter != children_.end();)
215 Map map(m_name, stream);
222 Map map(m_name, stream);
227 for (
auto& child : children_)
228 child.source().write(stream);
236 if (result.
first ==
nullptr)
240 result.
first->write(stream);
242 result.
first->write_one(stream);
248 bool const deep(peel_trailing_slashstar(&path));
249 bool const rooted(peel_leading_slash(&path));
256 source = find_one_deep(name);
257 if (source ==
nullptr)
282 if (path->
back() ==
'*')
287 if (!path->
empty() && path->
back() ==
'/')
298 std::string::const_iterator first = (*path).
begin();
299 std::string::const_iterator last = (*path).end();
300 std::string::const_iterator pos =
std::find(first, last,
'/');
315 Source* found = find_one(name);
316 if (found !=
nullptr)
320 for (
auto& s : children_)
323 if (found !=
nullptr)
341 }
while (source !=
nullptr);
351 for (
auto& s : children_)
353 if (s.source().m_name == name)
Source & operator*() const
Source * operator->() const
PropertyStream & m_stream
Map(PropertyStream &stream)
Proxy operator[](std::string const &key)
PropertyStream & stream()
Proxy(Map const &map, std::string const &key)
std::ostream & operator<<(std::ostream &manip(std::ostream &)) const
PropertyStream & stream()
PropertyStream & m_stream
Set(std::string const &key, Map &map)
Subclasses can be called to write to a stream and have children.
static bool peel_leading_slash(std::string *path)
PropertyStream::Source * find_one(std::string const &name)
void removeAll()
Remove all child sources from this Source.
Source(std::string const &name)
std::recursive_mutex lock_
std::pair< Source *, bool > find(std::string path)
Parse the dot-delimited Source path and return the result.
void remove(Source &child)
Remove a child source from this Source.
std::string const & name() const
Returns the name of this source.
void add(Source &source)
Add a child source.
PropertyStream::Source * find_path(std::string path)
void write_one(PropertyStream &stream)
Write only this Source to the stream.
Source * find_one_deep(std::string const &name)
void write(PropertyStream &stream)
write this source and all its children recursively to the stream.
static std::string peel_name(std::string *path)
static bool peel_trailing_slashstar(std::string *path)
virtual void onWrite(Map &)
Subclass override.
Abstract stream with RAII containers that produce a property tree.
virtual void add(std::string const &key, std::string const &value)=0
virtual void map_begin()=0
virtual void array_begin()=0
void lexical_add(std::string const &key, Value value)