libcommonc++  0.7
XDRDecoder.h++
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------------
2  commonc++ - A C++ Common Class Library
3  Copyright (C) 2005-2014 Mark A Lindner
4 
5  This file is part of commonc++.
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public
18  License along with this library; if not, write to the Free
19  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  ---------------------------------------------------------------------------
21 */
22 
23 #ifndef __ccxx_XDRDecoder_hxx
24 #define __ccxx_XDRDecoder_hxx
25 
26 #include <commonc++/DataReader.h++>
27 
28 namespace ccxx {
29 
30 class Variant;
31 
41 {
42  public:
43 
50  XDRDecoder(DataReader& reader);
51 
53  ~XDRDecoder();
54 
62  inline XDRDecoder& decode(bool& v)
63  { int vv; decode(vv); v = static_cast<bool>(vv); return(*this); }
64 
72  inline XDRDecoder& decode(byte_t& v)
73  { uint32_t vv; decode(vv); v = static_cast<byte_t>(vv); return(*this); }
74 
82  inline XDRDecoder& decode(char& v)
83  { uint32_t vv; decode(vv); v = static_cast<bool>(vv); return(*this); }
84 
92  inline XDRDecoder& decode(int16_t& v)
93  { uint32_t vv; decode(vv); v = static_cast<int16_t>(vv); return(*this); }
94 
102  inline XDRDecoder& decode(uint16_t& v)
103  { uint32_t vv; decode(vv); v = static_cast<uint16_t>(vv); return(*this); }
104 
112  inline XDRDecoder& decode(int32_t& v)
113  { _reader >> v; return(*this); }
114 
122  inline XDRDecoder& decode(uint32_t& v)
123  { _reader >> v; return(*this); }
124 
132  inline XDRDecoder& decode(int64_t& v)
133  { _reader >> v; return(*this); }
134 
142  inline XDRDecoder& decode(uint64_t& v)
143  { _reader >> v; return(*this); }
144 
152  inline XDRDecoder& decode(float& v)
153  { _reader >> v; return(*this); }
154 
162  inline XDRDecoder& decode(double& v)
163  { _reader >> v; return(*this); }
164 
175  XDRDecoder& decode(char* s, size_t maxlen = 0);
176 
187  XDRDecoder& decode(String& s, size_t maxlen = 0);
188 
197  XDRDecoder& decode(byte_t* v, size_t len);
198 
206  XDRDecoder& decode(Variant& v);
207 
208  private:
209 
210  DataReader& _reader;
211 };
212 
213 } // namespace ccxx
214 
215 #endif // __ccxx_XDRDecoder_hxx
XDRDecoder & decode(byte_t &v)
Decode a byte value.
Definition: XDRDecoder.h++:72
XDRDecoder & decode(uint64_t &v)
Decode an unsigned 64-bit integer value.
Definition: XDRDecoder.h++:142
A decoder for XDR, the eXternal Data Representation format.
Definition: XDRDecoder.h++:40
XDRDecoder & decode(uint16_t &v)
Decode an unsigned 16-bit integer value.
Definition: XDRDecoder.h++:102
XDRDecoder & decode(bool &v)
Decode a boolean value.
Definition: XDRDecoder.h++:62
XDRDecoder & decode(int16_t &v)
Decode a signed 16-bit integer value.
Definition: XDRDecoder.h++:92
XDRDecoder & decode(int64_t &v)
Decode a signed 64-bit integer value.
Definition: XDRDecoder.h++:132
An abstract base class for data readers.
Definition: DataReader.h++:40
XDRDecoder & decode(char &v)
Decode a char value.
Definition: XDRDecoder.h++:82
XDRDecoder & decode(int32_t &v)
Decode a signed 32-bit integer value.
Definition: XDRDecoder.h++:112
A general-purpose variant type.
Definition: Variant.h++:46
#define COMMONCPP_API
Definition: Common.h++:126
A flexible, reference counted, copy-on-write, thread-safe, nullable string.
Definition: String.h++:50
XDRDecoder & decode(double &v)
Decode a double precision floating point value.
Definition: XDRDecoder.h++:162
XDRDecoder & decode(uint32_t &v)
Decode an unsigned 32-bit integer value.
Definition: XDRDecoder.h++:122
XDRDecoder & decode(float &v)
Decode a floating point value.
Definition: XDRDecoder.h++:152
Definition: AllocationMap.c++:25
unsigned char byte_t
An unsigned 8-bit value.
Definition: Integers.h++:68