Back to home page

Bitcoin sources

 
 

    


File indexing completed on 2020-06-25 15:43:19

0001 #ifndef JSON_SPIRIT_READ_STREAM
0002 #define JSON_SPIRIT_READ_STREAM
0003 
0004 //          Copyright John W. Wilkinson 2007 - 2009.
0005 // Distributed under the MIT License, see accompanying file LICENSE.txt
0006 
0007 // json spirit version 4.03
0008 
0009 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
0010 # pragma once
0011 #endif
0012 
0013 #include "json_spirit_reader_template.h"
0014 
0015 namespace json_spirit
0016 {
0017     // these classes allows you to read multiple top level contiguous values from a stream,
0018     // the normal stream read functions have a bug that prevent multiple top level values 
0019     // from being read unless they are separated by spaces
0020 
0021     template< class Istream_type, class Value_type >
0022     class Stream_reader
0023     {
0024     public:
0025 
0026         Stream_reader( Istream_type& is )
0027         :   iters_( is )
0028         {
0029         }
0030 
0031         bool read_next( Value_type& value )
0032         {
0033             return read_range( iters_.begin_, iters_.end_, value );
0034         }
0035 
0036     private:
0037 
0038         typedef Multi_pass_iters< Istream_type > Mp_iters;
0039 
0040         Mp_iters iters_;
0041     };
0042 
0043     template< class Istream_type, class Value_type >
0044     class Stream_reader_thrower
0045     {
0046     public:
0047 
0048         Stream_reader_thrower( Istream_type& is )
0049         :   iters_( is )
0050         ,    posn_begin_( iters_.begin_, iters_.end_ )
0051         ,    posn_end_( iters_.end_, iters_.end_ )
0052         {
0053         }
0054 
0055         void read_next( Value_type& value )
0056         {
0057             posn_begin_ = read_range_or_throw( posn_begin_, posn_end_, value );
0058         }
0059 
0060     private:
0061 
0062         typedef Multi_pass_iters< Istream_type > Mp_iters;
0063         typedef spirit_namespace::position_iterator< typename Mp_iters::Mp_iter > Posn_iter_t;
0064 
0065         Mp_iters iters_;
0066         Posn_iter_t posn_begin_, posn_end_;
0067     };
0068 }
0069 
0070 #endif