Subject: [Boost-bugs] [Boost C++ Libraries] #9495: property_tree json_read should accept iterators instead of just streams
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-12-15 11:57:20
#9495: property_tree json_read should accept iterators instead of just streams
-----------------------------------------+---------------------------
Reporter: Egbert van der Wal <ewal@â¦> | Owner: cornedbee
Type: Patches | Status: new
Milestone: To Be Determined | Component: property_tree
Version: Boost Development Trunk | Severity: Optimization
Keywords: |
-----------------------------------------+---------------------------
For a project I am using boost::property_tree abundantly. The trees need
to be transfered across all kinds of interfaces and I have ran the limited
function call several times.
It requires a istream to read from. To make matters worse, as soon as it
enters the function, a complete copy is made to a vector. And that happens
when I already had to make a copy because the read_json method expects to
consume all input data, which rarely happens for me. I know the exact
beginning and ending position in the stream, but there is no way to
specify this.
The following function signature would be prefered:
{{{#!cpp
template<typename Iterator, class Ptree>
void read_json_internal(Iterator begin,
Iterator end,
Ptree &pt,
const std::string &filename)
}}}
This signature could still be used by the existing read_json_internal,
which first converts this to a vector and then passed the vector iterators
begin and and to this function, to avoid code duplication.
Of course, the proper front-end in json_parser.hpp needs to be added to.
The benefit is that this method can operate directly on my input sequence
where I can specify exactly where the JSON states and where the JSON ends,
avoiding all copies completely.
I will attach a patch based on SVN Trunk that will accomplish this.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9495> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC