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 #include <ndn-cpp/name.hpp>
27 
28 namespace google { namespace protobuf { class Message; } }
29 
30 namespace ndn {
31 
45 class ProtobufTlv {
46 public:
53  static Blob
54  encode(const google::protobuf::Message& message);
55 
64  static void
65  decode
66  (google::protobuf::Message& message, const uint8_t *input, size_t inputLength);
67 
75  static void
76  decode(google::protobuf::Message& message, const std::vector<uint8_t>& input)
77  {
78  decode(message, &input[0], input.size());
79  }
80 
88  static void
89  decode(google::protobuf::Message& message, const Blob& input)
90  {
91  decode(message, input.buf(), input.size());
92  }
93 
105  static Name
106  toName(const google::protobuf::Message& nameMessage);
107 };
108 
109 }
110 
111 #endif
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:36
ProtobufTlv has static methods to encode and decode an Protobuf Message object as NDN-TLV...
Definition: protobuf-tlv.hpp:45
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
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
static Name toName(const google::protobuf::Message &nameMessage)
Return a Name made from the component array in a Protobuf message object, assuming that it was define...
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:76
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:89
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. ...