Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / json_spirit / json_spirit_stream_reader.h
1 #ifndef JSON_SPIRIT_READ_STREAM\r
2 #define JSON_SPIRIT_READ_STREAM\r
3 \r
4 //          Copyright John W. Wilkinson 2007 - 2011\r
5 // Distributed under the MIT License, see accompanying file LICENSE.txt\r
6 \r
7 // json spirit version 4.05\r
8 \r
9 #if defined(_MSC_VER) && (_MSC_VER >= 1020)\r
10 # pragma once\r
11 #endif\r
12 \r
13 #include "json_spirit_reader_template.h"\r
14 \r
15 namespace json_spirit\r
16 {\r
17     // these classes allows you to read multiple top level contiguous values from a stream,\r
18     // the normal stream read functions have a bug that prevent multiple top level values \r
19     // from being read unless they are separated by spaces\r
20 \r
21     template< class Istream_type, class Value_type >\r
22     class Stream_reader\r
23     {\r
24     public:\r
25 \r
26         Stream_reader( Istream_type& is )\r
27         :   iters_( is )\r
28         {\r
29         }\r
30 \r
31         bool read_next( Value_type& value )\r
32         {\r
33             return read_range( iters_.begin_, iters_.end_, value );\r
34         }\r
35 \r
36     private:\r
37 \r
38         typedef Multi_pass_iters< Istream_type > Mp_iters;\r
39 \r
40         Mp_iters iters_;\r
41     };\r
42 \r
43     template< class Istream_type, class Value_type >\r
44     class Stream_reader_thrower\r
45     {\r
46     public:\r
47 \r
48         Stream_reader_thrower( Istream_type& is )\r
49         :   iters_( is )\r
50         ,    posn_begin_( iters_.begin_, iters_.end_ )\r
51         ,    posn_end_( iters_.end_, iters_.end_ )\r
52         {\r
53         }\r
54 \r
55         void read_next( Value_type& value )\r
56         {\r
57             posn_begin_ = read_range_or_throw( posn_begin_, posn_end_, value );\r
58         }\r
59 \r
60     private:\r
61 \r
62         typedef Multi_pass_iters< Istream_type > Mp_iters;\r
63         typedef spirit_namespace::position_iterator< typename Mp_iters::Mp_iter > Posn_iter_t;\r
64 \r
65         Mp_iters iters_;\r
66         Posn_iter_t posn_begin_, posn_end_;\r
67     };\r
68 }\r
69 \r
70 #endif\r