20 #include <ripple/beast/utility/PropertyStream.h>
77 m_map->add (m_key, s);
83 return m_ostream << manip;
98 : m_stream (parent.stream())
104 : m_stream (map.stream())
132 return Proxy (*
this, key);
142 : m_stream (map.stream())
155 m_stream.array_end ();
184 if (parent_ !=
nullptr)
185 parent_->remove (*
this);
200 assert (source.
parent_ ==
nullptr);
201 children_.push_back (source.
item_);
211 assert (child.parent_ ==
this);
213 children_.iterator_to (
215 child.parent_ =
nullptr;
221 for (
auto iter = children_.begin(); iter != children_.end(); )
232 Map map (m_name, stream);
238 Map map (m_name, stream);
243 for (
auto& child : children_)
244 child.source().write (stream);
251 if (result.
first ==
nullptr)
255 result.
first->write (stream);
257 result.
first->write_one (stream);
262 bool const deep (peel_trailing_slashstar (&path));
263 bool const rooted (peel_leading_slash (&path));
270 source = find_one_deep (name);
271 if (source ==
nullptr)
281 if (! path->empty() && path->front() ==
'/')
283 *path =
std::string (path->begin() + 1, path->end());
294 if (path->back() ==
'*')
299 if(! path->empty() && path->back() ==
'/')
309 std::string::const_iterator first = (*path).
begin();
310 std::string::const_iterator last = (*path).end();
311 std::string::const_iterator pos =
std::find (first, last,
'/');
325 Source* found = find_one (name);
326 if (found !=
nullptr)
330 for (
auto& s : children_)
333 if (found !=
nullptr)
351 while (source !=
nullptr);
360 for (
auto& s : children_)
362 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)