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();
161 if (parent_ !=
nullptr)
162 parent_->remove(*
this);
179 XRPL_ASSERT(source.
parent_ ==
nullptr,
"beast::PropertyStream::Source::add : null source parent");
180 children_.push_back(source.
item_);
191 XRPL_ASSERT(child.parent_ ==
this,
"beast::PropertyStream::Source::remove : child parent match");
192 children_.erase(children_.iterator_to(child.item_));
193 child.parent_ =
nullptr;
200 for (
auto iter = children_.begin(); iter != children_.end();)
212 Map map(m_name, stream);
219 Map map(m_name, stream);
224 for (
auto& child : children_)
225 child.source().write(stream);
233 if (result.
first ==
nullptr)
237 result.
first->write(stream);
239 result.
first->write_one(stream);
245 bool const deep(peel_trailing_slashstar(&path));
246 bool const rooted(peel_leading_slash(&path));
253 source = find_one_deep(name);
254 if (source ==
nullptr)
279 if (path->
back() ==
'*')
284 if (!path->
empty() && path->
back() ==
'/')
295 std::string::const_iterator first = (*path).
begin();
296 std::string::const_iterator last = (*path).end();
297 std::string::const_iterator pos =
std::find(first, last,
'/');
312 Source* found = find_one(name);
313 if (found !=
nullptr)
317 for (
auto& s : children_)
320 if (found !=
nullptr)
338 }
while (source !=
nullptr);
348 for (
auto& s : children_)
350 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)