20 #include <ripple/beast/utility/PropertyStream.h>
63 : m_map(&map), m_key(key)
68 : m_map(other.m_map), m_key(other.m_key)
82 return m_ostream << manip;
101 : m_stream(map.stream())
132 return Proxy(*
this, key);
142 : m_stream(map.stream())
155 m_stream.array_end();
177 : m_name(name), item_(this), parent_(nullptr)
184 if (parent_ !=
nullptr)
185 parent_->remove(*
this);
202 assert(source.
parent_ ==
nullptr);
203 children_.push_back(source.
item_);
214 assert(child.parent_ ==
this);
215 children_.erase(children_.iterator_to(child.item_));
216 child.parent_ =
nullptr;
223 for (
auto iter = children_.begin(); iter != children_.end();)
235 Map map(m_name, stream);
242 Map map(m_name, stream);
247 for (
auto& child : children_)
248 child.source().write(stream);
256 if (result.
first ==
nullptr)
260 result.
first->write(stream);
262 result.
first->write_one(stream);
268 bool const deep(peel_trailing_slashstar(&path));
269 bool const rooted(peel_leading_slash(&path));
276 source = find_one_deep(name);
277 if (source ==
nullptr)
288 if (!path->empty() && path->front() ==
'/')
290 *path =
std::string(path->begin() + 1, path->end());
302 if (path->back() ==
'*')
307 if (!path->empty() && path->back() ==
'/')
318 std::string::const_iterator first = (*path).
begin();
319 std::string::const_iterator last = (*path).end();
320 std::string::const_iterator pos =
std::find(first, last,
'/');
335 Source* found = find_one(name);
336 if (found !=
nullptr)
340 for (
auto& s : children_)
343 if (found !=
nullptr)
361 }
while (source !=
nullptr);
371 for (
auto& s : children_)
373 if (s.source().m_name == name)
std::string const & name() const
Returns the name of this source.
PropertyStream::Source * find_path(std::string path)
void removeAll()
Remove all child sources from this Source.
void write(PropertyStream &stream)
write this source and all its children recursively to the stream.
std::pair< Source *, bool > find(std::string path)
Parse the dot-delimited Source path and return the result.
PropertyStream & stream()
Subclasses can be called to write to a stream and have children.
virtual void map_begin()=0
Source & operator*() const
virtual void onWrite(Map &)
Subclass override.
Set(std::string const &key, Map &map)
void write_one(PropertyStream &stream)
Write only this Source to the stream.
PropertyStream & m_stream
Source * operator->() const
static bool peel_leading_slash(std::string *path)
std::ostream & operator<<(std::ostream &manip(std::ostream &)) const
virtual void add(std::string const &key, std::string const &value)=0
std::recursive_mutex lock_
void add(Source &source)
Add a child source.
virtual void array_begin()=0
static bool peel_trailing_slashstar(std::string *path)
void remove(Source &child)
Remove a child source from this Source.
PropertyStream::Source * find_one(std::string const &name)
Source * find_one_deep(std::string const &name)
Proxy operator[](std::string const &key)
Source(std::string const &name)
Map(PropertyStream &stream)
static std::string peel_name(std::string *path)
Abstract stream with RAII containers that produce a property tree.
PropertyStream & stream()
PropertyStream & m_stream
Proxy(Map const &map, std::string const &key)
void lexical_add(std::string const &key, Value value)