Incrementally encode the fields of one A11 wire record.
More...
#include <cpp/a11/data/msgpack.h>
|
| | MsgpackWriter () |
| | Encode into a buffer of this writer's own.
|
| |
| | MsgpackWriter (std::string *absl_nonnull target) |
| | Encode into a caller-supplied buffer, appending to what is there.
|
| |
| | MsgpackWriter (const MsgpackWriter &)=delete |
| |
| MsgpackWriter & | operator= (const MsgpackWriter &)=delete |
| |
| absl::Status | Pack (const nlohmann::json &value) |
| | Append a JSON-compatible field to the encoded record.
|
| |
| void | PackNil () |
| | Append a MessagePack nil.
|
| |
| void | PackBool (bool value) |
| | Append a MessagePack boolean.
|
| |
| void | PackUint (std::uint64_t value) |
| | Append an unsigned integer in the narrowest MessagePack form that fits.
|
| |
| void | PackInt (std::int64_t value) |
| | Append a signed integer in the narrowest MessagePack form that fits.
|
| |
| void | PackString (std::string_view value) |
| | Append a string field, copying value once.
|
| |
| void | PackBinary (std::string_view value) |
| | Append a binary field, copying value once.
|
| |
| void | PackArrayHeader (size_t length) |
| | Append an array header; length element fields must follow.
|
| |
| void | PackMapHeader (size_t length) |
| | Append a map header; length key/value field pairs must follow.
|
| |
| absl::Status | PackRecord (absl::FunctionRef< absl::Status(MsgpackWriter *absl_nonnull)> encode) |
| | Append a nested record as one binary field, encoded by encode.
|
| |
| const std::string & | bytes () const |
| | View the encoded bytes without transferring ownership.
|
| |
| std::string | TakeBytes () |
| | Transfer the encoded bytes out of this writer.
|
| |
Incrementally encode the fields of one A11 wire record.
A11 records are sequences of MessagePack objects, not one enclosing array; the matching MsgpackReader therefore also rejects trailing fields.
◆ MsgpackWriter() [1/3]
| a11::data::MsgpackWriter::MsgpackWriter |
( |
| ) |
|
|
inline |
Encode into a buffer of this writer's own.
◆ MsgpackWriter() [2/3]
| a11::data::MsgpackWriter::MsgpackWriter |
( |
std::string *absl_nonnull |
target | ) |
|
|
inlineexplicit |
Encode into a caller-supplied buffer, appending to what is there.
target must outlive the writer. Nested records can use this constructor to append to a parent or reused scratch buffer; see PackRecord().
◆ MsgpackWriter() [3/3]
| a11::data::MsgpackWriter::MsgpackWriter |
( |
const MsgpackWriter & |
| ) |
|
|
delete |
◆ bytes()
| const std::string & a11::data::MsgpackWriter::bytes |
( |
| ) |
const |
|
inline |
View the encoded bytes without transferring ownership.
◆ operator=()
◆ Pack()
| absl::Status a11::data::MsgpackWriter::Pack |
( |
const nlohmann::json & |
value | ) |
|
Append a JSON-compatible field to the encoded record.
◆ PackArrayHeader()
| void a11::data::MsgpackWriter::PackArrayHeader |
( |
size_t |
length | ) |
|
Append an array header; length element fields must follow.
◆ PackBinary()
| void a11::data::MsgpackWriter::PackBinary |
( |
std::string_view |
value | ) |
|
Append a binary field, copying value once.
◆ PackBool()
| void a11::data::MsgpackWriter::PackBool |
( |
bool |
value | ) |
|
Append a MessagePack boolean.
◆ PackInt()
| void a11::data::MsgpackWriter::PackInt |
( |
std::int64_t |
value | ) |
|
Append a signed integer in the narrowest MessagePack form that fits.
◆ PackMapHeader()
| void a11::data::MsgpackWriter::PackMapHeader |
( |
size_t |
length | ) |
|
Append a map header; length key/value field pairs must follow.
◆ PackNil()
| void a11::data::MsgpackWriter::PackNil |
( |
| ) |
|
Append a MessagePack nil.
◆ PackRecord()
| absl::Status a11::data::MsgpackWriter::PackRecord |
( |
absl::FunctionRef< absl::Status(MsgpackWriter *absl_nonnull)> |
encode | ) |
|
Append a nested record as one binary field, encoded by encode.
encode receives a writer over a pooled scratch buffer. The encoded record is appended as one MessagePack binary field.
◆ PackString()
| void a11::data::MsgpackWriter::PackString |
( |
std::string_view |
value | ) |
|
Append a string field, copying value once.
◆ PackUint()
| void a11::data::MsgpackWriter::PackUint |
( |
std::uint64_t |
value | ) |
|
Append an unsigned integer in the narrowest MessagePack form that fits.
◆ TakeBytes()
| std::string a11::data::MsgpackWriter::TakeBytes |
( |
| ) |
|
|
inline |
Transfer the encoded bytes out of this writer.
Only meaningful for a writer that owns its buffer; moving out of a borrowed one would empty the caller's buffer.
The documentation for this class was generated from the following files: