json/tree: add const begin/end

This commit is contained in:
Danny Robson 2015-03-18 15:59:29 +11:00
parent 1877767614
commit 9230de8c98
2 changed files with 60 additions and 2 deletions

View File

@ -528,6 +528,58 @@ json::tree::array::operator[] (unsigned int idx) const
}
//-----------------------------------------------------------------------------
json::tree::array::iterator
json::tree::array::begin (void)
{
return iterator (m_values.begin ());
}
//-----------------------------------------------------------------------------
json::tree::array::iterator
json::tree::array::end (void)
{
return iterator (m_values.end ());
}
//-----------------------------------------------------------------------------
json::tree::array::const_iterator
json::tree::array::begin (void) const
{
return const_iterator (m_values.begin ());
}
//-----------------------------------------------------------------------------
json::tree::array::const_iterator
json::tree::array::end (void) const
{
return const_iterator (m_values.end ());
}
//-----------------------------------------------------------------------------
json::tree::array::const_iterator
json::tree::array::cbegin (void) const
{
return const_iterator (m_values.cbegin ());
}
//-----------------------------------------------------------------------------
json::tree::array::const_iterator
json::tree::array::cend (void) const
{
return const_iterator (m_values.cend ());
}
//-----------------------------------------------------------------------------
std::ostream&
json::tree::array::write (std::ostream &os) const {

View File

@ -139,6 +139,8 @@ namespace json { namespace tree {
virtual const_iterator begin (void) const;
virtual const_iterator end (void) const;
virtual const_iterator cbegin (void) const { return begin (); }
virtual const_iterator cend (void) const { return end (); }
virtual std::ostream& write (std::ostream &os) const;
};
@ -175,8 +177,12 @@ namespace json { namespace tree {
virtual node& operator [](unsigned int idx);
virtual const node& operator [](unsigned int idx) const;
virtual const_iterator begin (void) const { return const_iterator (m_values.begin ()); }
virtual const_iterator end (void) const { return const_iterator (m_values.end ()); }
virtual iterator begin (void);
virtual iterator end (void);
virtual const_iterator begin (void) const;
virtual const_iterator end (void) const;
virtual const_iterator cbegin (void) const;
virtual const_iterator cend (void) const;
virtual void insert (std::unique_ptr<json::tree::node> &&_value);