-
+ 42337F7690B2BD5E7267707385097A8D3B9358EC7650157E350994BED86613C6E39338C4CA50F8A145DE430DF19BC00890459F24B82EF703DEF7A21897D85269
bitcoin/src/json/json_spirit_stream_reader.h
(0 . 0)(1 . 70)
7475 #ifndef JSON_SPIRIT_READ_STREAM
7476 #define JSON_SPIRIT_READ_STREAM
7477
7478 // Copyright John W. Wilkinson 2007 - 2009.
7479 // Distributed under the MIT License, see accompanying file LICENSE.txt
7480
7481 // json spirit version 4.03
7482
7483 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
7484 # pragma once
7485 #endif
7486
7487 #include "json_spirit_reader_template.h"
7488
7489 namespace json_spirit
7490 {
7491 // these classes allows you to read multiple top level contiguous values from a stream,
7492 // the normal stream read functions have a bug that prevent multiple top level values
7493 // from being read unless they are separated by spaces
7494
7495 template< class Istream_type, class Value_type >
7496 class Stream_reader
7497 {
7498 public:
7499
7500 Stream_reader( Istream_type& is )
7501 : iters_( is )
7502 {
7503 }
7504
7505 bool read_next( Value_type& value )
7506 {
7507 return read_range( iters_.begin_, iters_.end_, value );
7508 }
7509
7510 private:
7511
7512 typedef Multi_pass_iters< Istream_type > Mp_iters;
7513
7514 Mp_iters iters_;
7515 };
7516
7517 template< class Istream_type, class Value_type >
7518 class Stream_reader_thrower
7519 {
7520 public:
7521
7522 Stream_reader_thrower( Istream_type& is )
7523 : iters_( is )
7524 , posn_begin_( iters_.begin_, iters_.end_ )
7525 , posn_end_( iters_.end_, iters_.end_ )
7526 {
7527 }
7528
7529 void read_next( Value_type& value )
7530 {
7531 posn_begin_ = read_range_or_throw( posn_begin_, posn_end_, value );
7532 }
7533
7534 private:
7535
7536 typedef Multi_pass_iters< Istream_type > Mp_iters;
7537 typedef spirit_namespace::position_iterator< typename Mp_iters::Mp_iter > Posn_iter_t;
7538
7539 Mp_iters iters_;
7540 Posn_iter_t posn_begin_, posn_end_;
7541 };
7542 }
7543
7544 #endif