diff options
author | Jeff Garzik <jgarzik@bitpay.com> | 2013-10-22 05:43:46 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@bitpay.com> | 2013-10-22 05:43:46 -0400 |
commit | 406b1f05f61a7bba7ef6860c031a7a7c3e019100 (patch) | |
tree | d64672cb2dac9d7bd5a6eeaea21b4f336903cfed /src/json/json_spirit_reader_template.h | |
parent | 0db9a805bde5050060913462299690020ff798a0 (diff) |
Revert "JSON Spirit updated to v4.06"
This reverts commit 2227389fa8fa1b9ff19234838fc7b641e935125b.
Diffstat (limited to 'src/json/json_spirit_reader_template.h')
-rw-r--r-- | src/json/json_spirit_reader_template.h | 114 |
1 files changed, 38 insertions, 76 deletions
diff --git a/src/json/json_spirit_reader_template.h b/src/json/json_spirit_reader_template.h index d3d0cecaa5..4dec00e6c9 100644 --- a/src/json/json_spirit_reader_template.h +++ b/src/json/json_spirit_reader_template.h @@ -1,14 +1,10 @@ #ifndef JSON_SPIRIT_READER_TEMPLATE #define JSON_SPIRIT_READER_TEMPLATE -// Copyright John W. Wilkinson 2007 - 2013 +// Copyright John W. Wilkinson 2007 - 2009. // Distributed under the MIT License, see accompanying file LICENSE.txt -// json spirit version 4.06 - -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -# pragma once -#endif +// json spirit version 4.03 #include "json_spirit_value.h" #include "json_spirit_error_position.h" @@ -488,7 +484,7 @@ namespace json_spirit ; string_ - = lexeme_d // this causes white space and what would appear to be comments inside a string to be retained + = lexeme_d // this causes white space inside a string to be retained [ confix_p ( @@ -519,44 +515,6 @@ namespace json_spirit }; template< class Iter_type, class Value_type > - void add_posn_iter_and_read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value ) - { - typedef spirit_namespace::position_iterator< Iter_type > Posn_iter_t; - - const Posn_iter_t posn_begin( begin, end ); - const Posn_iter_t posn_end( end, end ); - - read_range_or_throw( posn_begin, posn_end, value ); - } - - template< class Istream_type > - struct Multi_pass_iters - { - typedef typename Istream_type::char_type Char_type; - typedef std::istream_iterator< Char_type, Char_type > istream_iter; - typedef spirit_namespace::multi_pass< istream_iter > Mp_iter; - - Multi_pass_iters( Istream_type& is ) - { - is.unsetf( std::ios::skipws ); - - begin_ = spirit_namespace::make_multi_pass( istream_iter( is ) ); - end_ = spirit_namespace::make_multi_pass( istream_iter() ); - } - - Mp_iter begin_; - Mp_iter end_; - }; - - // reads a JSON Value from a pair of input iterators throwing an exception on invalid input, e.g. - // - // string::const_iterator start = str.begin(); - // const string::const_iterator next = read_range_or_throw( str.begin(), str.end(), value ); - // - // The iterator 'next' will point to the character past the - // last one read. - // - template< class Iter_type, class Value_type > Iter_type read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value ) { Semantic_actions< Value_type, Iter_type > semantic_actions( value ); @@ -564,9 +522,7 @@ namespace json_spirit const spirit_namespace::parse_info< Iter_type > info = spirit_namespace::parse( begin, end, Json_grammer< Value_type, Iter_type >( semantic_actions ), - spirit_namespace::space_p | - spirit_namespace::comment_p("//") | - spirit_namespace::comment_p("/*", "*/") ); + spirit_namespace::space_p ); if( !info.hit ) { @@ -577,14 +533,17 @@ namespace json_spirit return info.stop; } - // reads a JSON Value from a pair of input iterators, e.g. - // - // string::const_iterator start = str.begin(); - // const bool success = read_string( start, str.end(), value ); - // - // The iterator 'start' will point to the character past the - // last one read. - // + template< class Iter_type, class Value_type > + void add_posn_iter_and_read_range_or_throw( Iter_type begin, Iter_type end, Value_type& value ) + { + typedef spirit_namespace::position_iterator< Iter_type > Posn_iter_t; + + const Posn_iter_t posn_begin( begin, end ); + const Posn_iter_t posn_end( end, end ); + + read_range_or_throw( posn_begin, posn_end, value ); + } + template< class Iter_type, class Value_type > bool read_range( Iter_type& begin, Iter_type end, Value_type& value ) { @@ -600,10 +559,12 @@ namespace json_spirit } } - // reads a JSON Value from a string, e.g. - // - // const bool success = read_string( str, value ); - // + template< class String_type, class Value_type > + void read_string_or_throw( const String_type& s, Value_type& value ) + { + add_posn_iter_and_read_range_or_throw( s.begin(), s.end(), value ); + } + template< class String_type, class Value_type > bool read_string( const String_type& s, Value_type& value ) { @@ -612,20 +573,25 @@ namespace json_spirit return read_range( begin, s.end(), value ); } - // reads a JSON Value from a string throwing an exception on invalid input, e.g. - // - // read_string_or_throw( is, value ); - // - template< class String_type, class Value_type > - void read_string_or_throw( const String_type& s, Value_type& value ) + template< class Istream_type > + struct Multi_pass_iters { - add_posn_iter_and_read_range_or_throw( s.begin(), s.end(), value ); - } + typedef typename Istream_type::char_type Char_type; + typedef std::istream_iterator< Char_type, Char_type > istream_iter; + typedef spirit_namespace::multi_pass< istream_iter > Mp_iter; + + Multi_pass_iters( Istream_type& is ) + { + is.unsetf( std::ios::skipws ); + + begin_ = spirit_namespace::make_multi_pass( istream_iter( is ) ); + end_ = spirit_namespace::make_multi_pass( istream_iter() ); + } + + Mp_iter begin_; + Mp_iter end_; + }; - // reads a JSON Value from a stream, e.g. - // - // const bool success = read_stream( is, value ); - // template< class Istream_type, class Value_type > bool read_stream( Istream_type& is, Value_type& value ) { @@ -634,10 +600,6 @@ namespace json_spirit return read_range( mp_iters.begin_, mp_iters.end_, value ); } - // reads a JSON Value from a stream throwing an exception on invalid input, e.g. - // - // read_stream_or_throw( is, value ); - // template< class Istream_type, class Value_type > void read_stream_or_throw( Istream_type& is, Value_type& value ) { |