Static Public Member Functions | List of all members
ndn::ProtobufTlv Class Reference

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...
 

Detailed Description

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.

Member Function Documentation

static void ndn::ProtobufTlv::decode ( google::protobuf::Message &  message,
const uint8_t *  input,
size_t  inputLength 
)
static

Decode the input as NDN-TLV and update the fields of the Protobuf Message object.

Parameters
messageThe Protobuf Message object. This does not first clear the object.
inputA pointer to the input buffer to decode.
inputLengthThe number of bytes in input.
static void ndn::ProtobufTlv::decode ( google::protobuf::Message &  message,
const std::vector< uint8_t > &  input 
)
inlinestatic

Decode the input as NDN-TLV and update the fields of the Protobuf Message object.

Parameters
messageThe Protobuf Message object. This does not first clear the object.
inputThe input byte array to be decoded.
static void ndn::ProtobufTlv::decode ( google::protobuf::Message &  message,
const Blob input 
)
inlinestatic

Decode the input as NDN-TLV and update the fields of the Protobuf Message object.

Parameters
messageThe Protobuf Message object. This does not first clear the object.
inputThe Blob with the input to be decoded.
static Blob ndn::ProtobufTlv::encode ( const google::protobuf::Message &  message)
static

Encode the Protobuf Message object as NDN-TLV.

Parameters
messageThe Protobuf Message object. This calls message.CheckInitialized() to ensure that all required fields are present.
Returns
The encoded byte array as a Blob.

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