summaryrefslogtreecommitdiff
path: root/libcult/cult/dr/xdr/input-stream.hxx
blob: 653b2280a6dddef783ee3d51968d8748064bfb91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// file      : cult/dr/xdr/input-stream.hxx
// author    : Boris Kolpackov <boris@kolpackov.net>
// copyright : Copyright (c) 2005-2010 Boris Kolpackov
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#ifndef CULT_DR_XDR_INPUT_STREAM_HXX
#define CULT_DR_XDR_INPUT_STREAM_HXX

#include <cult/types.hxx>

#include <cult/eh/exception.hxx>

#include <cult/mm/buffer.hxx>

#include <rpc/xdr.h>

namespace Cult
{
  namespace DR
  {
    namespace XDR
    {
      struct Extraction: virtual EH::Exception {};

      class InputStream: public NonCopyable
      {
      public:
        InputStream (Shptr<Buffer> buffer);

        ~InputStream ();

      public:
        InputStream&
        operator>> (Boolean&);

        InputStream&
        operator>> (Int8&);

        InputStream&
        operator>> (UnsignedInt8&);

        InputStream&
        operator>> (Int16&);

        InputStream&
        operator>> (UnsignedInt16&);

        InputStream&
        operator>> (Int32&);

        InputStream&
        operator>> (UnsignedInt32&);

        InputStream&
        operator>> (Int64&);

        InputStream&
        operator>> (UnsignedInt64&);

        InputStream&
        operator>> (String&);

      public:
        Void
        read (Buffer& buffer, Size size);

        Boolean
        eos () const;

      private:
        ::XDR xdr_;
        Shptr<Buffer> buffer_;
      };
    }
  }
}

#endif  // CULT_DR_XDR_INPUT_STREAM_HXX