20#include <xrpl/beast/utility/PropertyStream.h>
21#include <xrpl/beast/utility/instrumentation.h>
66 : m_map(&map), m_key(key)
71 : m_map(other.m_map), m_key(other.m_key)
85 return m_ostream << manip;
104 : m_stream(map.stream())
135 return Proxy(*
this, key);
145 : m_stream(map.stream())
158 m_stream.array_end();
180 : m_name(name), item_(this), parent_(nullptr)
187 if (parent_ !=
nullptr)
188 parent_->remove(*
this);
207 "beast::PropertyStream::Source::add : null source parent");
208 children_.push_back(source.
item_);
220 child.parent_ ==
this,
221 "beast::PropertyStream::Source::remove : child parent match");
222 children_.erase(children_.iterator_to(child.item_));
223 child.parent_ =
nullptr;
230 for (
auto iter = children_.begin(); iter != children_.end();)
242 Map map(m_name, stream);
249 Map map(m_name, stream);
254 for (
auto& child : children_)
255 child.source().write(stream);
263 if (result.
first ==
nullptr)
267 result.
first->write(stream);
269 result.
first->write_one(stream);
275 bool const deep(peel_trailing_slashstar(&path));
276 bool const rooted(peel_leading_slash(&path));
283 source = find_one_deep(name);
284 if (source ==
nullptr)
295 if (!path->empty() && path->front() ==
'/')
297 *path =
std::string(path->begin() + 1, path->end());
309 if (path->back() ==
'*')
314 if (!path->empty() && path->back() ==
'/')
325 std::string::const_iterator first = (*path).
begin();
326 std::string::const_iterator last = (*path).end();
327 std::string::const_iterator pos =
std::find(first, last,
'/');
342 Source* found = find_one(name);
343 if (found !=
nullptr)
347 for (
auto& s : children_)
350 if (found !=
nullptr)
368 }
while (source !=
nullptr);
378 for (
auto& s : children_)
380 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)