AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::codec::Protobuf Struct Reference

#include <protobuf.hpp>

Collaboration diagram for anch::codec::Protobuf:

Static Public Member Functions

static std::string_view mediaType () noexcept
template<anch::codec::ProtobufMessage T>
static void serialize (const T &value, std::ostream &out)
template<anch::codec::ProtobufMessage T>
static void deserialize (T &value, std::istream &input, anch::codec::Side side)
static void write (const google::protobuf::Message &message, std::ostream &out)
static void read (google::protobuf::Message &message, std::istream &input)
static void read (google::protobuf::Message &message, std::string_view data)

Detailed Description

application/x-protobuf codec: Protocol Buffers binary encoding of protoc messages. Invalid messages raise std::invalid_argument ( 400 on server side).

api.post("/pets", [](anch::rest::Body<pets::Pet> pet) { return save(*pet); })
.consumes<anch::codec::Protobuf>().produces<anch::codec::Protobuf>();
pets::Pet pet = client.get("/pets/{id}", 1).accept<anch::codec::Protobuf>().as<pets::Pet>();
Author
Vincent Lachenal
Since
0.2

Member Function Documentation

◆ deserialize()

void anch::codec::Protobuf::deserialize ( T & value,
std::istream & input,
anch::codec::Side side )
static

Read message (body size is bounded by maxBodySize )

Parameters
valuethe message to fill
inputthe input stream
sidethe side
Exceptions
std::invalid_argumentwhen message is invalid
ContentTooLargewhen body is larger than maxBodySize
Here is the call graph for this function:

◆ mediaType()

std::string_view anch::codec::Protobuf::mediaType ( )
staticnoexcept

Media type

Returns
application/x-protobuf

◆ read() [1/2]

void anch::codec::Protobuf::read ( google::protobuf::Message & message,
std::istream & input )
static

Read message (any protoc message)

Parameters
messagethe message to fill
inputthe input stream
Exceptions
std::invalid_argumentwhen message is invalid
Here is the call graph for this function:

◆ read() [2/2]

void anch::codec::Protobuf::read ( google::protobuf::Message & message,
std::string_view data )
static

Read message (any protoc message)

Parameters
messagethe message to fill
datathe serialized message
Exceptions
std::invalid_argumentwhen message is invalid
Since
0.3
Here is the call graph for this function:

◆ serialize()

void anch::codec::Protobuf::serialize ( const T & value,
std::ostream & out )
static

Write message

Parameters
valuethe message
outthe output stream
Exceptions
std::runtime_errorwhen message can not be written
Here is the call graph for this function:

◆ write()

void anch::codec::Protobuf::write ( const google::protobuf::Message & message,
std::ostream & out )
static

Write message (any protoc message)

Parameters
messagethe message
outthe output stream
Exceptions
std::runtime_errorwhen message can not be written
Here is the call graph for this function:

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