19 #ifndef avro_Encoder_hh__
20 #define avro_Encoder_hh__
29 #include "ValidSchema.hh"
94 virtual void encodeBytes(
const uint8_t *bytes,
size_t len) = 0;
103 encodeBytes(bytes.empty() ? &b : bytes.data(), bytes.size());
115 encodeFixed(bytes.data(), bytes.size());
The abstract base class for all Avro encoders.
Definition: Encoder.hh:52
virtual void encodeInt(int32_t i)=0
Encodes a 32-bit int to the current stream.
virtual void encodeNull()=0
Encodes a null to the current stream.
virtual void arrayStart()=0
Indicates that an array of items is being encoded.
virtual void flush()=0
Flushes any data in internal buffers.
virtual void setItemCount(size_t count)=0
Indicates that count number of items are to follow in the current array or map.
virtual void arrayEnd()=0
Indicates that the current array of items have ended.
virtual int64_t byteCount() const =0
Returns the number of bytes produced so far.
virtual void init(OutputStream &os)=0
All future encodings will go to os, which should be valid until it is reset with another call to init...
virtual void encodeString(const std::string &s)=0
Encodes a UTF-8 string to the current stream.
virtual void encodeFixed(const uint8_t *bytes, size_t len)=0
Encodes fixed length binary to the current stream.
virtual void startItem()=0
Marks a beginning of an item in the current array or map.
void encodeFixed(const std::vector< uint8_t > &bytes)
Encodes an Avro data type Fixed.
Definition: Encoder.hh:114
virtual void encodeBool(bool b)=0
Encodes a bool to the current stream.
virtual void mapStart()=0
Indicates that a map of items is being encoded.
virtual void mapEnd()=0
Indicates that the current map of items have ended.
virtual void encodeDouble(double d)=0
Encodes a double-precision floating point number 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.
virtual void encodeLong(int64_t l)=0
Encodes a 64-bit signed int to the current stream.
virtual void encodeEnum(size_t e)=0
Encodes enum to the current stream.
void encodeBytes(const std::vector< uint8_t > &bytes)
Encodes arbitrary binary data into the current stream as Avro "bytes" data type.
Definition: Encoder.hh:101
virtual void encodeFloat(float f)=0
Encodes a single-precision floating point number to the current stream.
virtual void encodeUnionIndex(size_t e)=0
Encodes a branch of a union. The actual value is to follow.
A no-copy output stream.
Definition: Stream.hh:108
A ValidSchema is basically a non-mutable Schema that has passed some minimum of sanity checks.
Definition: ValidSchema.hh:40
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
AVRO_DECL EncoderPtr jsonEncoder(const ValidSchema &schema)
Returns an encoder that encodes Avro standard for JSON.
AVRO_DECL EncoderPtr validatingEncoder(const ValidSchema &schema, const EncoderPtr &base)
Returns an encoder that validates sequence of calls to an underlying Encoder against the given schema...
std::shared_ptr< Encoder > EncoderPtr
Shared pointer to Encoder.
Definition: Encoder.hh:147
AVRO_DECL EncoderPtr jsonPrettyEncoder(const ValidSchema &schema)
Returns an encoder that encodes Avro standard for pretty printed JSON.
AVRO_DECL EncoderPtr binaryEncoder()
Returns an encoder that can encode binary Avro standard.