1#include <xrpl/beast/utility/PropertyStream.h>
2#include <xrpl/beast/utility/instrumentation.h>
47 : m_map(&map), m_key(key)
52 : m_map(other.m_map), m_key(other.m_key)
66 return m_ostream << manip;
85 : m_stream(map.stream())
116 return Proxy(*
this, key);
126 : m_stream(map.stream())
139 m_stream.array_end();
161 : m_name(name), item_(this), parent_(nullptr)
168 if (parent_ !=
nullptr)
169 parent_->remove(*
this);
188 "beast::PropertyStream::Source::add : null source parent");
189 children_.push_back(source.
item_);
201 child.parent_ ==
this,
202 "beast::PropertyStream::Source::remove : child parent match");
203 children_.erase(children_.iterator_to(child.item_));
204 child.parent_ =
nullptr;
211 for (
auto iter = children_.begin(); iter != children_.end();)
223 Map map(m_name, stream);
230 Map map(m_name, stream);
235 for (
auto& child : children_)
236 child.source().write(stream);
244 if (result.
first ==
nullptr)
248 result.
first->write(stream);
250 result.
first->write_one(stream);
256 bool const deep(peel_trailing_slashstar(&path));
257 bool const rooted(peel_leading_slash(&path));
264 source = find_one_deep(name);
265 if (source ==
nullptr)
276 if (!path->empty() && path->front() ==
'/')
278 *path =
std::string(path->begin() + 1, path->end());
290 if (path->back() ==
'*')
295 if (!path->empty() && path->back() ==
'/')
306 std::string::const_iterator first = (*path).
begin();
307 std::string::const_iterator last = (*path).end();
308 std::string::const_iterator pos =
std::find(first, last,
'/');
323 Source* found = find_one(name);
324 if (found !=
nullptr)
328 for (
auto& s : children_)
331 if (found !=
nullptr)
349 }
while (source !=
nullptr);
359 for (
auto& s : children_)
361 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)