ProtobufTlv has static methods to encode and decode an Protobuf Message object as NDN-TLV. More...
#include <protobuf-tlv.hpp>
Static Public Member Functions | |
static Blob | encode (const google::protobuf::Message &message) |
Encode the Protobuf Message object as NDN-TLV. More... | |
static void | decode (google::protobuf::Message &message, const uint8_t *input, size_t inputLength) |
Decode the input as NDN-TLV and update the fields of the Protobuf Message object. More... | |
static void | decode (google::protobuf::Message &message, const std::vector< uint8_t > &input) |
Decode the input as NDN-TLV and update the fields of the Protobuf Message object. More... | |
static void | decode (google::protobuf::Message &message, const Blob &input) |
Decode the input as NDN-TLV and update the fields of the Protobuf Message object. More... | |
ProtobufTlv has static methods to encode and decode an Protobuf Message object as NDN-TLV.
The Protobuf tag value is used as the TLV type code. A Protobuf message is encoded/decoded as a nested TLV encoding. Protobuf types uint32, uint64 and enum are encoded/decoded as TLV nonNegativeInteger. (It is an error if an enum value is negative.) Protobuf types bytes and string are encoded/decoded as TLV bytes. The Protobuf type bool is encoded/decoded as a TLV boolean (a zero length value for True, omitted for False). Other Protobuf types are an error.
Protobuf has no "outer" message type, so you need to put your TLV message inside an outer "typeless" message.
|
static |
Decode the input as NDN-TLV and update the fields of the Protobuf Message object.
message | The Protobuf Message object. This does not first clear the object. |
input | A pointer to the input buffer to decode. |
inputLength | The number of bytes in input. |
|
inlinestatic |
Decode the input as NDN-TLV and update the fields of the Protobuf Message object.
message | The Protobuf Message object. This does not first clear the object. |
input | The input byte array to be decoded. |
|
inlinestatic |
Decode the input as NDN-TLV and update the fields of the Protobuf Message object.
message | The Protobuf Message object. This does not first clear the object. |
input | The Blob with the input to be decoded. |
|
static |
Encode the Protobuf Message object as NDN-TLV.
message | The Protobuf Message object. This calls message.CheckInitialized() to ensure that all required fields are present. |