protobuf-tlv.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_PROTOBUF_TLV_HPP
23 #define NDN_PROTOBUF_TLV_HPP
24 
25 #include <ndn-cpp/util/blob.hpp>
26 
27 namespace google { namespace protobuf { class Message; } }
28 
29 namespace ndn {
30 
44 class ProtobufTlv {
45 public:
52  static Blob
53  encode(const google::protobuf::Message& message);
54 
63  static void
64  decode
65  (google::protobuf::Message& message, const uint8_t *input, size_t inputLength);
66 
74  static void
75  decode(google::protobuf::Message& message, const std::vector<uint8_t>& input)
76  {
77  decode(message, &input[0], input.size());
78  }
79 
87  static void
88  decode(google::protobuf::Message& message, const Blob& input)
89  {
90  decode(message, input.buf(), input.size());
91  }
92 };
93 
94 }
95 
96 #endif
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
ProtobufTlv has static methods to encode and decode an Protobuf Message object as NDN-TLV...
Definition: protobuf-tlv.hpp:44
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
const uint8_t * buf() const
Return a const pointer to the first byte of the immutable byte array, or 0 if the pointer is null...
Definition: blob.hpp:159
size_t size() const
Return the length of the immutable byte array.
Definition: blob.hpp:147
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. ...
Definition: protobuf-tlv.hpp:75
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. ...
Definition: protobuf-tlv.hpp:88
Copyright (C) 2014-2016 Regents of the University of California.
Definition: channel-status.pb.h:315
static Blob encode(const google::protobuf::Message &message)
Encode the Protobuf Message object as NDN-TLV.
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. ...