~ubuntu-branches/ubuntu/raring/ceph/raring

« back to all changes in this revision

Viewing changes to src/json_spirit/json_spirit_stream_reader.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-08 15:54:37 UTC
  • mfrom: (1.1.8) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20120608155437-gy3j9k6wzv7w4gn9
Tags: 0.44.1-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - d/control: Switch from libcryptopp to libnss as libcryptopp
    is not seeded.
  - d/control,d/rules: Move from python-support to dh_python2.
  - d/patches/manpage_updates*.patch: cherry picked upstream manpage
    updates warning about lack of encryption, per MIR review.
  - d/rules,d/control: Drop radosgw since libfcgi is not in main and
    the code may not be suitable for LTS.
  - d/rules,d/control: Drop tcmalloc since google perftools is not
    in main yet.
  - d/rules,d/control: Drop ceph-fuse entirely per MIR review
    recommendation.
* d/patches/fix-radosgw-tests.patch: Cherry picked patch from upstream
  VCS to fixup tests to conditionally use radosgw if enabled.

Show diffs side-by-side

added added

removed removed

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