libcommonc++  0.7
XDREncoder.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_XDREncoder_hxx
24 #define __ccxx_XDREncoder_hxx
25 
26 #include <commonc++/DataWriter.h++>
27 
28 namespace ccxx {
29 
30 class Variant;
31 
41 {
42  public:
43 
50  XDREncoder(DataWriter& writer);
51 
53  ~XDREncoder();
54 
62  inline XDREncoder& encode(bool v)
63  { return(encode(static_cast<uint32_t>(v))); }
64 
73  { return(encode(static_cast<uint32_t>(v))); }
74 
82  XDREncoder& encode(char v)
83  { return(encode(static_cast<int32_t>(v))); }
84 
92  inline XDREncoder& encode(int16_t v)
93  { return(encode(static_cast<int32_t>(v))); }
94 
102  inline XDREncoder& encode(uint16_t v)
103  { return(encode(static_cast<uint32_t>(v))); }
104 
112  inline XDREncoder& encode(int32_t v)
113  { _writer << v; return(*this); }
114 
122  inline XDREncoder& encode(uint32_t v)
123  { _writer << v; return(*this); }
124 
132  inline XDREncoder& encode(const int64_t& v)
133  { _writer << v; return(*this); }
134 
142  inline XDREncoder& encode(const uint64_t& v)
143  { _writer << v; return(*this); }
144 
152  inline XDREncoder& encode(float v)
153  { _writer << v; return(*this); }
154 
162  inline XDREncoder& encode(const double& v)
163  { _writer << v; return(*this); }
164 
173  XDREncoder& encode(const char* s, size_t maxlen = 0);
174 
183  inline XDREncoder& encode(const String& s, size_t maxlen = 0);
184 
193  XDREncoder& encode(const byte_t* v, size_t len);
194 
202  XDREncoder& encode(const Variant& v);
203 
204  private:
205 
206  DataWriter& _writer;
207 };
208 
209 } // namespace ccxx
210 
211 #endif // __ccxx_XDREncoder_hxx
XDREncoder & encode(uint32_t v)
Encode an unsigned 32-bit integer value.
Definition: XDREncoder.h++:122
XDREncoder & encode(const uint64_t &v)
Encode an unsigned 64-bit integer value.
Definition: XDREncoder.h++:142
XDREncoder & encode(byte_t v)
Encode a byte value.
Definition: XDREncoder.h++:72
XDREncoder & encode(char v)
Encode a char value.
Definition: XDREncoder.h++:82
A general-purpose variant type.
Definition: Variant.h++:46
#define COMMONCPP_API
Definition: Common.h++:126
XDREncoder & encode(bool v)
Encode a boolean value.
Definition: XDREncoder.h++:62
XDREncoder & encode(uint16_t v)
Encode an unsigned 16-bit integer value.
Definition: XDREncoder.h++:102
A flexible, reference counted, copy-on-write, thread-safe, nullable string.
Definition: String.h++:50
XDREncoder & encode(int32_t v)
Encode a signed 32-bit integer value.
Definition: XDREncoder.h++:112
XDREncoder & encode(const double &v)
Encode a double-precision floating point value.
Definition: XDREncoder.h++:162
An encoder for XDR, the eXternal Data Representation format.
Definition: XDREncoder.h++:40
XDREncoder & encode(const int64_t &v)
Encode a signed 64-bit integer value.
Definition: XDREncoder.h++:132
An abstract base class for data writers.
Definition: DataWriter.h++:40
Definition: AllocationMap.c++:25
XDREncoder & encode(int16_t v)
Encode a signed 16-bit integer value.
Definition: XDREncoder.h++:92
XDREncoder & encode(float v)
Encode a floating point value.
Definition: XDREncoder.h++:152
unsigned char byte_t
An unsigned 8-bit value.
Definition: Integers.h++:68