content-meta-info.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_CONTENT_META_INFO_HPP
23 #define NDN_CONTENT_META_INFO_HPP
24 
25 #include <ndn-cpp/util/blob.hpp>
26 
27 namespace ndntools {
28 
30 public:
35  {
36  clear();
37  }
38 
43  const std::string&
44  getContentType() const { return contentType_; }
45 
52  getTimestamp() const { return timestamp_; }
53 
58  bool
59  getHasSegments() const { return hasSegments_; }
60 
65  const ndn::Blob&
66  getOther() const { return other_; }
67 
74  setContentType(const std::string& contentType)
75  {
76  contentType_ = contentType;
77  return *this;
78  }
79 
87  {
88  timestamp_ = timestamp;
89  return *this;
90  }
91 
98  setHasSegments(bool hasSegments)
99  {
100  hasSegments_ = hasSegments;
101  return *this;
102  }
103 
110  setOther(const ndn::Blob& other)
111  {
112  other_ = other;
113  return *this;
114  }
115 
119  void
120  clear();
121 
126  ndn::Blob
127  wireEncode() const;
128 
134  void
135  wireDecode(const uint8_t *input, size_t inputLength);
136 
141  void
142  wireDecode(const std::vector<uint8_t>& input)
143  {
144  wireDecode(&input[0], input.size());
145  }
146 
151  void
152  wireDecode(const ndn::Blob& input)
153  {
154  wireDecode(input.buf(), input.size());
155  }
156 
157 private:
158  std::string contentType_;
159  ndn::MillisecondsSince1970 timestamp_;
160  bool hasSegments_;
161  ndn::Blob other_;
162 };
163 
164 }
165 
166 #endif
ContentMetaInfo()
Create a ContentMetaInfo where all the fields have default unspecified values.
Definition: content-meta-info.hpp:34
void wireDecode(const ndn::Blob &input)
Decode the input and update this Schedule.
Definition: content-meta-info.hpp:152
ContentMetaInfo & setContentType(const std::string &contentType)
Set the content type.
Definition: content-meta-info.hpp:74
void wireDecode(const std::vector< uint8_t > &input)
Decode the input and update this Schedule.
Definition: content-meta-info.hpp:142
ContentMetaInfo & setTimestamp(ndn::MillisecondsSince1970 timestamp)
Set the time stamp.
Definition: content-meta-info.hpp:86
ndn::Blob wireEncode() const
Encode this ContentMetaInfo.
Definition: content-meta-info.hpp:29
const ndn::Blob & getOther() const
Get the Blob containing the optional other info.
Definition: content-meta-info.hpp:66
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
double MillisecondsSince1970
The calendar time represented as the number of milliseconds since 1/1/1970.
Definition: common.hpp:117
ndn::MillisecondsSince1970 getTimestamp() const
Get the time stamp.
Definition: content-meta-info.hpp:52
ContentMetaInfo & setHasSegments(bool hasSegments)
Set the hasSegments flag.
Definition: content-meta-info.hpp:98
void wireDecode(const uint8_t *input, size_t inputLength)
Decode the input and update this ContentMetaInfo.
ContentMetaInfo & setOther(const ndn::Blob &other)
Set the Blob containing the optional other info.
Definition: content-meta-info.hpp:110
void clear()
Set all the fields to their default unspecified values.
Copyright (C) 2017 Regents of the University of California.
Definition: channel-discovery.hpp:28
bool getHasSegments() const
Get the hasSegments flag.
Definition: content-meta-info.hpp:59
const std::string & getContentType() const
Get the content type.
Definition: content-meta-info.hpp:44