19 #ifndef avro_Codec_hh__
20 #define avro_Codec_hh__
28 #include "boost/blank.hpp"
51 typedef boost::blank
null;
54 void encode(Encoder &e,
const T &t);
56 void decode(Decoder &d, T &t);
225 std::vector<uint8_t> v(N);
227 std::copy(v.data(), v.data() + N, s.data());
243 for (
typename std::vector<T>::const_iterator it = b.begin();
244 it != b.end(); ++it) {
258 for (
size_t i = 0; i < n; ++i) {
261 s.push_back(std::move(t));
267 typedef codec_traits<std::vector<bool>::const_reference> bool_codec_traits;
270 struct codec_traits<std::conditional<avro::is_not_defined<bool_codec_traits>::value,
271 std::vector<bool>::const_reference, void>::type> {
292 for (
typename std::map<std::string, T>::const_iterator
294 it != b.end(); ++it) {
309 for (
size_t i = 0; i < n; ++i) {
312 T &t = s[std::move(k)];
357 #endif // avro_Codec_hh__
static void decode(Decoder &d, std::vector< uint8_t > &s)
Decodes into a given value.
Definition: Specific.hh:204
virtual void encodeNull()=0
Encodes a null to the current stream.
static void encode(Encoder &e, const std::vector< T > &b)
Encodes a given value.
Definition: Specific.hh:239
virtual void setItemCount(size_t count)=0
Indicates that count number of items are to follow in the current array or map.
static void encode(Encoder &e, int32_t i)
Encodes a given value.
Definition: Specific.hh:97
virtual size_t arrayNext()=0
Returns the number of entries in next chunk. 0 if last.
virtual void encodeLong(int64_t l)=0
Encodes a 64-bit signed int to the current stream.
Codec_traits tells avro how to encode and decode an object of given type.
Definition: Generic.hh:114
static void decode(Decoder &d, std::string &s)
Decodes into a given value.
Definition: Specific.hh:184
static void decode(Decoder &d, float &f)
Decodes into a given value.
Definition: Specific.hh:144
The abstract base class for all Avro encoders.
Definition: Encoder.hh:52
static void decode(Decoder &d, std::vector< T > &s)
Decodes into a given value.
Definition: Specific.hh:255
virtual void arrayStart()=0
Indicates that an array of items is being encoded.
virtual void arrayEnd()=0
Indicates that the current array of items have ended.
static void encode(Encoder &e, const std::vector< uint8_t > &b)
Encodes a given value.
Definition: Specific.hh:197
static void decode(Decoder &d, std::array< uint8_t, N > &s)
Decodes into a given value.
Definition: Specific.hh:224
Decoder is an interface implemented by every decoder capable of decoding Avro data.
Definition: Decoder.hh:48
virtual size_t arrayStart()=0
Start decoding an array. Returns the number of entries in first chunk.
virtual int32_t decodeInt()=0
Decodes a 32-bit int from the current stream.
virtual void mapEnd()=0
Indicates that the current map of items have ended.
static void decode(Decoder &d, avro::null &)
Decodes into a given value.
Definition: Specific.hh:334
virtual int64_t decodeLong()=0
Decodes a 64-bit signed int from the current stream.
static void encode(Encoder &e, const std::string &s)
Encodes a given value.
Definition: Specific.hh:177
virtual bool decodeBool()=0
Decodes a bool from the current stream.
static void encode(Encoder &e, const std::map< std::string, T > &b)
Encodes a given value.
Definition: Specific.hh:288
virtual void startItem()=0
Marks a beginning of an item in the current array or map.
virtual void mapStart()=0
Indicates that a map of items is being encoded.
virtual float decodeFloat()=0
Decodes a single-precision floating point number from current stream.
static void decode(Decoder &d, bool &b)
Decodes into a given value.
Definition: Specific.hh:84
std::vector< uint8_t > decodeFixed(size_t n)
Decodes fixed length binary from the current stream.
Definition: Decoder.hh:109
virtual void encodeString(const std::string &s)=0
Encodes a UTF-8 string to the current stream.
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
virtual size_t mapNext()=0
Returns the number of entries in next chunk. 0 if last.
static void encode(Encoder &e, bool b)
Encodes a given value.
Definition: Specific.hh:77
static void encode(Encoder &e, int64_t l)
Encodes a given value.
Definition: Specific.hh:117
void encode(Encoder &e, const T &t)
Generic encoder function that makes use of the codec_traits.
Definition: Specific.hh:343
static void encode(Encoder &e, const avro::null &)
Encodes a given value.
Definition: Specific.hh:327
void decode(Decoder &d, T &t)
Generic decoder function that makes use of the codec_traits.
Definition: Specific.hh:351
virtual void encodeInt(int32_t i)=0
Encodes a 32-bit int to the current stream.
virtual void decodeNull()=0
Decodes a null from the current stream.
virtual void encodeFixed(const uint8_t *bytes, size_t len)=0
Encodes fixed length binary to the current stream.
virtual void encodeBytes(const uint8_t *bytes, size_t len)=0
Encodes arbitrary binary data into the current stream as Avro "bytes" data type.
static void decode(Decoder &d, double &dbl)
Decodes into a given value.
Definition: Specific.hh:164
virtual double decodeDouble()=0
Decodes a double-precision floating point number from current stream.
std::string decodeString()
Decodes a UTF-8 string from the current stream.
Definition: Decoder.hh:75
static void encode(Encoder &e, double d)
Encodes a given value.
Definition: Specific.hh:157
static void encode(Encoder &e, float f)
Encodes a given value.
Definition: Specific.hh:137
virtual void encodeFloat(float f)=0
Encodes a single-precision floating point number to the current stream.
virtual void encodeBool(bool b)=0
Encodes a bool to the current stream.
static void decode(Decoder &d, int32_t &i)
Decodes into a given value.
Definition: Specific.hh:104
static void encode(Encoder &e, std::vector< bool >::const_reference b)
Encodes a given value.
Definition: Specific.hh:275
std::vector< uint8_t > decodeBytes()
Decodes arbitrary binary data from the current stream.
Definition: Decoder.hh:90
static void decode(Decoder &d, int64_t &l)
Decodes into a given value.
Definition: Specific.hh:124
static void encode(Encoder &e, const std::array< uint8_t, N > &b)
Encodes a given value.
Definition: Specific.hh:217
virtual void encodeDouble(double d)=0
Encodes a double-precision floating point number to the current stream.
static void decode(Decoder &d, std::map< std::string, T > &s)
Decodes into a given value.
Definition: Specific.hh:306
virtual size_t mapStart()=0
Start decoding a map. Returns the number of entries in first chunk.