protozero::pbf_writer Class Reference

`#include <pbf_writer.hpp>`

Inheritance diagram for protozero::pbf_writer:
[legend]

## Public Member Functions

| pbf_writer (std::string &data) noexcept
| pbf_writer () noexcept
| pbf_writer (pbf_writer &parent_writer, pbf_tag_type tag)
| pbf_writer (const pbf_writer &) noexcept=default
| A pbf_writer object can be copied.
pbf_writer & | operator= (const pbf_writer &) noexcept=default
| A pbf_writer object can be copied.
| pbf_writer (pbf_writer &&) noexcept=default
| A pbf_writer object can be moved.
pbf_writer & | operator= (pbf_writer &&) noexcept=default
| A pbf_writer object can be moved.
Scalar field writer functions
void | add_bool (pbf_tag_type tag, bool value)
void | add_enum (pbf_tag_type tag, int32_t value)
void | add_int32 (pbf_tag_type tag, int32_t value)
void | add_sint32 (pbf_tag_type tag, int32_t value)
void | add_uint32 (pbf_tag_type tag, uint32_t value)
void | add_int64 (pbf_tag_type tag, int64_t value)
void | add_sint64 (pbf_tag_type tag, int64_t value)
void | add_uint64 (pbf_tag_type tag, uint64_t value)
void | add_fixed32 (pbf_tag_type tag, uint32_t value)
void | add_sfixed32 (pbf_tag_type tag, int32_t value)
void | add_fixed64 (pbf_tag_type tag, uint64_t value)
void | add_sfixed64 (pbf_tag_type tag, int64_t value)
void | add_float (pbf_tag_type tag, float value)
void | add_double (pbf_tag_type tag, double value)
void | add_bytes (pbf_tag_type tag, const char *value, size_t size)
void | add_bytes (pbf_tag_type tag, const std::string &value)
void | add_string (pbf_tag_type tag, const char *value, size_t size)
void | add_string (pbf_tag_type tag, const std::string &value)
void | add_string (pbf_tag_type tag, const char *value)
void | add_message (pbf_tag_type tag, const char *value, size_t size)
void | add_message (pbf_tag_type tag, const std::string &value)
Repeated packed field writer functions
template<typename InputIterator >
void | add_packed_bool (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_enum (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_int32 (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_sint32 (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_uint32 (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_int64 (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_sint64 (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_uint64 (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_fixed32 (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_sfixed32 (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_fixed64 (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_sfixed64 (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_float (pbf_tag_type tag, InputIterator first, InputIterator last)
template<typename InputIterator >
void | add_packed_double (pbf_tag_type tag, InputIterator first, InputIterator last)

## Detailed Description

The pbf_writer is used to write PBF formatted messages into a buffer.

Almost all methods in this class can throw an std::bad_alloc exception if the std::string used as a buffer wants to resize.

## Constructor & Destructor Documentation

protozero::pbf_writer::pbf_writer | ( | std::string & | data | ) |

inline explicit noexcept

Create a writer using the given string as a data store. The pbf_writer stores a reference to that string and adds all data to it.

protozero::pbf_writer::pbf_writer | ( |  | ) |

inline noexcept

Create a writer without a data store. In this form the writer can not be used!

protozero::pbf_writer::pbf_writer | ( | pbf_writer & | parent_writer,
|  | pbf_tag_type | tag
| ) |  |

inline

Construct a pbf_writer for a submessage from the pbf_writer of the parent message.

Parameters

  parent_writer | The pbf_writer
  tag | Tag (field number) of the field that will be written

## Member Function Documentation

void protozero::pbf_writer::add_bool | ( | pbf_tag_type | tag,
|  | bool | value
| ) |  |

inline

Add "bool" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_bytes | ( | pbf_tag_type | tag,
|  | const char * | value,
|  | size_t | size
| ) |  |

inline

Add "bytes" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Pointer to value to be written
  size | Number of bytes to be written

void protozero::pbf_writer::add_bytes | ( | pbf_tag_type | tag,
|  | const std::string & | value
| ) |  |

inline

Add "bytes" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_double | ( | pbf_tag_type | tag,
|  | double | value
| ) |  |

inline

Add "double" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_enum | ( | pbf_tag_type | tag,
|  | int32_t | value
| ) |  |

inline

Add "enum" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_fixed32 | ( | pbf_tag_type | tag,
|  | uint32_t | value
| ) |  |

inline

Add "fixed32" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_fixed64 | ( | pbf_tag_type | tag,
|  | uint64_t | value
| ) |  |

inline

Add "fixed64" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_float | ( | pbf_tag_type | tag,
|  | float | value
| ) |  |

inline

Add "float" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_int32 | ( | pbf_tag_type | tag,
|  | int32_t | value
| ) |  |

inline

Add "int32" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_int64 | ( | pbf_tag_type | tag,
|  | int64_t | value
| ) |  |

inline

Add "int64" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_message | ( | pbf_tag_type | tag,
|  | const char * | value,
|  | size_t | size
| ) |  |

inline

Add "message" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Pointer to message to be written
  size | Length of the message

void protozero::pbf_writer::add_message | ( | pbf_tag_type | tag,
|  | const std::string & | value
| ) |  |

inline

Add "message" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written. The value must be a complete message.

template<typename InputIterator >

void protozero::pbf_writer::add_packed_bool | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed bool" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to bool.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_double | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed double" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to double.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_enum | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed enum" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int32_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_fixed32 | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed fixed32" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to uint32_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_fixed64 | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed fixed64" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to uint64_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_float | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed float" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to float.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_int32 | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed int32" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int32_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_int64 | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed int64" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int64_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_sfixed32 | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed sfixed32" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int32_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_sfixed64 | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed sfixed64" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int64_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_sint32 | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed sint32" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int32_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_sint64 | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed sint64" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to int64_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_uint32 | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed uint32" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to uint32_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

template<typename InputIterator >

void protozero::pbf_writer::add_packed_uint64 | ( | pbf_tag_type | tag,
|  | InputIterator | first,
|  | InputIterator | last
| ) |  |

inline

Add "repeated packed uint64" field to data.

Template Parameters

  InputIterator | An type satisfying the InputIterator concept. Dereferencing the iterator must yield a type assignable to uint64_t.

Parameters

  tag | Tag (field number) of the field
  first | Iterator pointing to the beginning of the data
  last | Iterator pointing one past the end of data

void protozero::pbf_writer::add_sfixed32 | ( | pbf_tag_type | tag,
|  | int32_t | value
| ) |  |

inline

Add "sfixed32" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_sfixed64 | ( | pbf_tag_type | tag,
|  | int64_t | value
| ) |  |

inline

Add "sfixed64" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_sint32 | ( | pbf_tag_type | tag,
|  | int32_t | value
| ) |  |

inline

Add "sint32" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_sint64 | ( | pbf_tag_type | tag,
|  | int64_t | value
| ) |  |

inline

Add "sint64" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_string | ( | pbf_tag_type | tag,
|  | const char * | value,
|  | size_t | size
| ) |  |

inline

Add "string" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Pointer to value to be written
  size | Number of bytes to be written

void protozero::pbf_writer::add_string | ( | pbf_tag_type | tag,
|  | const std::string & | value
| ) |  |

inline

Add "string" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_string | ( | pbf_tag_type | tag,
|  | const char * | value
| ) |  |

inline

Add "string" field to data. Bytes from the value are written until a null byte is encountered. The null byte is not added.

Parameters

  tag | Tag (field number) of the field
  value | Pointer to value to be written

void protozero::pbf_writer::add_uint32 | ( | pbf_tag_type | tag,
|  | uint32_t | value
| ) |  |

inline

Add "uint32" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

void protozero::pbf_writer::add_uint64 | ( | pbf_tag_type | tag,
|  | uint64_t | value
| ) |  |

inline

Add "uint64" field to data.

Parameters

  tag | Tag (field number) of the field
  value | Value to be written

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

- include/protozero/pbf_writer.hpp