Avro C++

Public Member Functions | List of all members
avro::Encoder Class Referenceabstract

The abstract base class for all Avro encoders. More...

`#include <Encoder.hh>`

## Public Member Functions
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() or the encoder is destructed.
virtual void | flush ()=0
| Flushes any data in internal buffers.
virtual int64_t | byteCount () const =0
| Returns the number of bytes produced so far. More...
virtual void | encodeNull ()=0
| Encodes a null to the current stream.
virtual void | encodeBool (bool b)=0
| Encodes a bool to the current stream.
virtual void | encodeInt (int32_t i)=0
| Encodes a 32-bit int to the current stream.
virtual void | encodeLong (int64_t l)=0
| Encodes a 64-bit signed int to the current stream.
virtual void | encodeFloat (float f)=0
| Encodes a single-precision floating point number to the current stream.
virtual void | encodeDouble (double d)=0
| Encodes a double-precision floating point number to the current stream.
virtual void | encodeString (const std::string &s)=0
| Encodes a UTF-8 string 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. More...
void | encodeBytes (const std::vector< uint8_t > &bytes)
| Encodes arbitrary binary data into the current stream as Avro "bytes" data type. More...
virtual void | encodeFixed (const uint8_t *bytes, size_t len)=0
| Encodes fixed length binary to the current stream.
void | encodeFixed (const std::vector< uint8_t > &bytes)
| Encodes an Avro data type Fixed. More...
virtual void | encodeEnum (size_t e)=0
| Encodes enum to the current stream.
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.
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 | setItemCount (size_t count)=0
| Indicates that count number of items are to follow in the current array or map.
virtual void | startItem ()=0
| Marks a beginning of an item in the current array or map.
virtual void | encodeUnionIndex (size_t e)=0
| Encodes a branch of a union. The actual value is to follow.

## Detailed Description

The abstract base class for all Avro encoders.

The implementations differ in the method of encoding (binary versus JSON) or in capabilities such as ability to verify the order of invocation of different functions.

## Member Function Documentation

## ◆ byteCount()

virtual int64_t avro::Encoder::byteCount | ( |  | ) | const
| pure virtual

Returns the number of bytes produced so far.

For a meaningful value, do a flush() before invoking this function.

## ◆ encodeBytes() [1/2]

void avro::Encoder::encodeBytes | ( | const std::vector< uint8_t > & | bytes | ) |
| inline

Encodes arbitrary binary data into the current stream as Avro "bytes" data type.

Parameters

  bytes | The data.

## ◆ encodeBytes() [2/2]

virtual void avro::Encoder::encodeBytes | ( | const uint8_t * | bytes,
|  | size_t | len
| ) |  |
| pure virtual

Encodes arbitrary binary data into the current stream as Avro "bytes" data type.

Parameters

  bytes | Where the data is
  len | Number of bytes at `bytes`.

Referenced by avro::codec_traits< std::vector< uint8_t > >::encode().

## ◆ encodeFixed()

void avro::Encoder::encodeFixed | ( | const std::vector< uint8_t > & | bytes | ) |
| inline

Encodes an Avro data type Fixed.

Parameters

  bytes | The fixed, the length of which is taken as the size of fixed.

The documentation for this class was generated from the following file:

- api/Encoder.hh