Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 2 | /* |
Junxiao Shi | ebfe4a2 | 2018-04-01 23:53:40 +0000 | [diff] [blame] | 3 | * Copyright (c) 2013-2018 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Jeff Thompson | 56ec9e2 | 2013-08-02 11:34:07 -0700 | [diff] [blame] | 22 | #ifndef NDN_DATA_HPP |
Jeff Thompson | a0d18c9 | 2013-08-06 13:55:32 -0700 | [diff] [blame] | 23 | #define NDN_DATA_HPP |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 24 | |
Alexander Afanasyev | 2ba8f66 | 2014-01-05 22:53:18 -0800 | [diff] [blame] | 25 | #include "meta-info.hpp" |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 26 | #include "name.hpp" |
Eric Newberry | c3a4679 | 2017-09-24 14:54:24 -0700 | [diff] [blame] | 27 | #include "packet-base.hpp" |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 28 | #include "signature.hpp" |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 29 | #include "encoding/block.hpp" |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 30 | |
| 31 | namespace ndn { |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 32 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 33 | /** @brief Represents a Data packet |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 34 | */ |
Eric Newberry | c3a4679 | 2017-09-24 14:54:24 -0700 | [diff] [blame] | 35 | class Data : public PacketBase, public enable_shared_from_this<Data> |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 36 | { |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 37 | public: |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 38 | class Error : public tlv::Error |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 39 | { |
| 40 | public: |
| 41 | explicit |
| 42 | Error(const std::string& what) |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 43 | : tlv::Error(what) |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 44 | { |
| 45 | } |
| 46 | }; |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 47 | |
Junxiao Shi | 7d9039b | 2018-04-14 15:56:28 +0000 | [diff] [blame] | 48 | /** @brief Construct an unsigned Data packet with given @p name and empty Content. |
| 49 | * @warning In certain contexts that use `Data::shared_from_this()`, Data must be created |
| 50 | * using `make_shared`. Otherwise, `shared_from_this()` will trigger undefined behavior. |
Jeff Thompson | 20af073 | 2013-09-12 17:01:45 -0700 | [diff] [blame] | 51 | */ |
Junxiao Shi | 9b84535 | 2017-07-24 05:04:56 +0000 | [diff] [blame] | 52 | explicit |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 53 | Data(const Name& name = Name()); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 54 | |
Junxiao Shi | 7d9039b | 2018-04-14 15:56:28 +0000 | [diff] [blame] | 55 | /** @brief Construct a Data packet by decoding from @p wire. |
| 56 | * @param wire @c tlv::Data element as defined in NDN Packet Format v0.2 or v0.3. |
| 57 | * It may be signed or unsigned. |
| 58 | * @warning In certain contexts that use `Data::shared_from_this()`, Data must be created |
| 59 | * using `make_shared`. Otherwise, `shared_from_this()` will trigger undefined behavior. |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 60 | */ |
| 61 | explicit |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 62 | Data(const Block& wire); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 63 | |
Junxiao Shi | 7d9039b | 2018-04-14 15:56:28 +0000 | [diff] [blame] | 64 | /** @brief Prepend wire encoding to @p encoder in NDN Packet Format v0.2. |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 65 | * @param encoder EncodingEstimator or EncodingBuffer instance |
| 66 | * @param wantUnsignedPortionOnly If true, only prepends Name, MetaInfo, Content, and |
| 67 | * SignatureInfo to @p encoder, but omit SignatureValue and outmost Type-Length of Data |
| 68 | * element. This is intended to be used with wireEncode(encoder, signatureValue). |
| 69 | * @throw Error SignatureBits are not provided and wantUnsignedPortionOnly is false. |
Jeff Thompson | b7aefa00 | 2013-09-16 18:22:00 -0700 | [diff] [blame] | 70 | */ |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 71 | template<encoding::Tag TAG> |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 72 | size_t |
Alexander Afanasyev | d5c48e0 | 2015-06-24 11:58:14 -0700 | [diff] [blame] | 73 | wireEncode(EncodingImpl<TAG>& encoder, bool wantUnsignedPortionOnly = false) const; |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 74 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 75 | /** @brief Finalize Data packet encoding with the specified SignatureValue |
| 76 | * @param encoder EncodingBuffer containing Name, MetaInfo, Content, and SignatureInfo, but |
| 77 | * without SignatureValue or outmost Type-Length of Data element |
| 78 | * @param signatureValue SignatureValue element |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 79 | * |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 80 | * This method is intended to be used in concert with Data::wireEncode(encoder, true) |
| 81 | * @code |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 82 | * Data data; |
| 83 | * ... |
| 84 | * EncodingBuffer encoder; |
| 85 | * data.wireEncode(encoder, true); |
| 86 | * ... |
| 87 | * Block signatureValue = <sign_over_unsigned_portion>(encoder.buf(), encoder.size()); |
| 88 | * data.wireEncode(encoder, signatureValue) |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 89 | * @endcode |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 90 | */ |
| 91 | const Block& |
| 92 | wireEncode(EncodingBuffer& encoder, const Block& signatureValue) const; |
| 93 | |
Junxiao Shi | 7d9039b | 2018-04-14 15:56:28 +0000 | [diff] [blame] | 94 | /** @brief Encode to a @c Block. |
| 95 | * @pre Data is signed. |
| 96 | * |
| 97 | * Normally, this function encodes to NDN Packet Format v0.2. However, if this instance has |
| 98 | * cached wire encoding (\c hasWire() is true), the cached encoding is returned and it might |
| 99 | * be in v0.3 format. |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 100 | */ |
| 101 | const Block& |
| 102 | wireEncode() const; |
| 103 | |
Junxiao Shi | 7d9039b | 2018-04-14 15:56:28 +0000 | [diff] [blame] | 104 | /** @brief Decode from @p wire in NDN Packet Format v0.2 or v0.3. |
Alexander Afanasyev | 809805d | 2014-02-17 17:20:33 -0800 | [diff] [blame] | 105 | */ |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 106 | void |
| 107 | wireDecode(const Block& wire); |
Alexander Afanasyev | fadc97d | 2014-01-03 13:22:10 -0800 | [diff] [blame] | 108 | |
Junxiao Shi | 7d9039b | 2018-04-14 15:56:28 +0000 | [diff] [blame] | 109 | /** @brief Check if this instance has cached wire encoding. |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 110 | */ |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 111 | bool |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 112 | hasWire() const |
| 113 | { |
| 114 | return m_wire.hasWire(); |
| 115 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 116 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 117 | /** @brief Get full name including implicit digest |
| 118 | * @pre hasWire() == true; i.e. wireEncode() must have been called |
| 119 | * @throw Error Data has no wire encoding |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 120 | */ |
| 121 | const Name& |
| 122 | getFullName() const; |
| 123 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 124 | public: // Data fields |
| 125 | /** @brief Get name |
| 126 | */ |
| 127 | const Name& |
| 128 | getName() const |
| 129 | { |
| 130 | return m_name; |
| 131 | } |
| 132 | |
| 133 | /** @brief Set name |
| 134 | * @return a reference to this Data, to allow chaining |
| 135 | */ |
| 136 | Data& |
| 137 | setName(const Name& name); |
| 138 | |
| 139 | /** @brief Get MetaInfo |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 140 | */ |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 141 | const MetaInfo& |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 142 | getMetaInfo() const |
| 143 | { |
| 144 | return m_metaInfo; |
| 145 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 146 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 147 | /** @brief Set MetaInfo |
| 148 | * @return a reference to this Data, to allow chaining |
Jeff Thompson | 0cd8c4a | 2013-09-13 17:46:40 -0700 | [diff] [blame] | 149 | */ |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 150 | Data& |
Alexander Afanasyev | 2ba8f66 | 2014-01-05 22:53:18 -0800 | [diff] [blame] | 151 | setMetaInfo(const MetaInfo& metaInfo); |
Jeff Thompson | 46bd45f | 2013-08-08 16:46:41 -0700 | [diff] [blame] | 152 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 153 | /** @brief Get Content |
Alexander Afanasyev | 2ba8f66 | 2014-01-05 22:53:18 -0800 | [diff] [blame] | 154 | * |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 155 | * The Content value is accessible through value()/value_size() or value_begin()/value_end() |
| 156 | * methods of the Block class. |
Alexander Afanasyev | 2ba8f66 | 2014-01-05 22:53:18 -0800 | [diff] [blame] | 157 | */ |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 158 | const Block& |
Alexander Afanasyev | 2ba8f66 | 2014-01-05 22:53:18 -0800 | [diff] [blame] | 159 | getContent() const; |
Alexander Afanasyev | fadc97d | 2014-01-03 13:22:10 -0800 | [diff] [blame] | 160 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 161 | /** @brief Set Content from a block |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 162 | * |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 163 | * If block's TLV-TYPE is Content, it will be used directly as Data's Content element. |
| 164 | * If block's TLV-TYPE is not Content, it will be nested into a Content element. |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 165 | * |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 166 | * @return a reference to this Data, to allow chaining |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 167 | */ |
| 168 | Data& |
| 169 | setContent(const Block& block); |
Alexander Afanasyev | 2ba8f66 | 2014-01-05 22:53:18 -0800 | [diff] [blame] | 170 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 171 | /** @brief Copy Content value from raw buffer |
| 172 | * @param value pointer to the first octet of the value |
| 173 | * @param valueSize size of the raw buffer |
| 174 | * @return a reference to this Data, to allow chaining |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 175 | */ |
| 176 | Data& |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 177 | setContent(const uint8_t* value, size_t valueSize); |
Alexander Afanasyev | 809805d | 2014-02-17 17:20:33 -0800 | [diff] [blame] | 178 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 179 | /** @brief Set Content from wire buffer |
| 180 | * @param value Content value, which does not need to be a TLV element |
| 181 | * @return a reference to this Data, to allow chaining |
| 182 | */ |
| 183 | Data& |
| 184 | setContent(const ConstBufferPtr& value); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 185 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 186 | /** @brief Get Signature |
| 187 | */ |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 188 | const Signature& |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 189 | getSignature() const |
| 190 | { |
| 191 | return m_signature; |
| 192 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 193 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 194 | /** @brief Set Signature |
| 195 | * @return a reference to this Data, to allow chaining |
Alexander Afanasyev | 2ba8f66 | 2014-01-05 22:53:18 -0800 | [diff] [blame] | 196 | */ |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 197 | Data& |
Alexander Afanasyev | 2ba8f66 | 2014-01-05 22:53:18 -0800 | [diff] [blame] | 198 | setSignature(const Signature& signature); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 199 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 200 | /** @brief Set SignatureValue |
| 201 | * @return a reference to this Data, to allow chaining |
| 202 | */ |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 203 | Data& |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 204 | setSignatureValue(const Block& value); |
Yingdi Yu | a4e5767 | 2014-02-06 11:16:17 -0800 | [diff] [blame] | 205 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 206 | public: // MetaInfo fields |
| 207 | uint32_t |
| 208 | getContentType() const |
| 209 | { |
| 210 | return m_metaInfo.getType(); |
| 211 | } |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 212 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 213 | Data& |
| 214 | setContentType(uint32_t type); |
| 215 | |
Junxiao Shi | ebfe4a2 | 2018-04-01 23:53:40 +0000 | [diff] [blame] | 216 | time::milliseconds |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 217 | getFreshnessPeriod() const |
| 218 | { |
| 219 | return m_metaInfo.getFreshnessPeriod(); |
| 220 | } |
| 221 | |
| 222 | Data& |
Junxiao Shi | ebfe4a2 | 2018-04-01 23:53:40 +0000 | [diff] [blame] | 223 | setFreshnessPeriod(time::milliseconds freshnessPeriod); |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 224 | |
Junxiao Shi | ebfe4a2 | 2018-04-01 23:53:40 +0000 | [diff] [blame] | 225 | const optional<name::Component>& |
| 226 | getFinalBlock() const |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 227 | { |
Junxiao Shi | ebfe4a2 | 2018-04-01 23:53:40 +0000 | [diff] [blame] | 228 | return m_metaInfo.getFinalBlock(); |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | Data& |
Junxiao Shi | ebfe4a2 | 2018-04-01 23:53:40 +0000 | [diff] [blame] | 232 | setFinalBlock(optional<name::Component> finalBlockId); |
| 233 | |
| 234 | /** @deprecated Use @c getFinalBlock |
| 235 | * @sa MetaInfo::getFinalBlockId |
| 236 | */ |
| 237 | NDN_CXX_DEPRECATED |
| 238 | name::Component |
| 239 | getFinalBlockId() const; |
| 240 | |
| 241 | /** @deprecated Use @c setFinalBlock |
| 242 | * @sa MetaInfo::setFinalBlockId |
| 243 | */ |
| 244 | NDN_CXX_DEPRECATED |
| 245 | Data& |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 246 | setFinalBlockId(const name::Component& finalBlockId); |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 247 | |
Spyridon Mastorakis | 3b54e85 | 2015-04-07 08:03:25 -0700 | [diff] [blame] | 248 | protected: |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 249 | /** @brief Clear wire encoding and cached FullName |
| 250 | * @note This does not clear the SignatureValue. |
Jeff Thompson | b7aefa00 | 2013-09-16 18:22:00 -0700 | [diff] [blame] | 251 | */ |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 252 | void |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 253 | resetWire(); |
Alexander Afanasyev | fadc97d | 2014-01-03 13:22:10 -0800 | [diff] [blame] | 254 | |
| 255 | private: |
Alexander Afanasyev | 809805d | 2014-02-17 17:20:33 -0800 | [diff] [blame] | 256 | Name m_name; |
| 257 | MetaInfo m_metaInfo; |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 258 | Block m_content; |
Alexander Afanasyev | 809805d | 2014-02-17 17:20:33 -0800 | [diff] [blame] | 259 | Signature m_signature; |
Alexander Afanasyev | fadc97d | 2014-01-03 13:22:10 -0800 | [diff] [blame] | 260 | |
Alexander Afanasyev | 809805d | 2014-02-17 17:20:33 -0800 | [diff] [blame] | 261 | mutable Block m_wire; |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 262 | mutable Name m_fullName; ///< cached FullName computed from m_wire |
Jeff Thompson | 5cae5e5 | 2013-07-10 19:41:20 -0700 | [diff] [blame] | 263 | }; |
Alexander Afanasyev | fadc97d | 2014-01-03 13:22:10 -0800 | [diff] [blame] | 264 | |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 265 | #ifndef DOXYGEN |
| 266 | extern template size_t |
| 267 | Data::wireEncode<encoding::EncoderTag>(EncodingBuffer&, bool) const; |
| 268 | |
| 269 | extern template size_t |
| 270 | Data::wireEncode<encoding::EstimatorTag>(EncodingEstimator&, bool) const; |
| 271 | #endif |
| 272 | |
Alexander Afanasyev | a0c5f83 | 2014-06-19 13:27:56 -0700 | [diff] [blame] | 273 | std::ostream& |
| 274 | operator<<(std::ostream& os, const Data& data); |
Alexander Afanasyev | 809805d | 2014-02-17 17:20:33 -0800 | [diff] [blame] | 275 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 276 | bool |
| 277 | operator==(const Data& lhs, const Data& rhs); |
| 278 | |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 279 | inline bool |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 280 | operator!=(const Data& lhs, const Data& rhs) |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 281 | { |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 282 | return !(lhs == rhs); |
Alexander Afanasyev | 2ba8f66 | 2014-01-05 22:53:18 -0800 | [diff] [blame] | 283 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 284 | |
Alexander Afanasyev | fadc97d | 2014-01-03 13:22:10 -0800 | [diff] [blame] | 285 | } // namespace ndn |
| 286 | |
Junxiao Shi | 81206d5 | 2017-07-23 12:43:22 +0000 | [diff] [blame] | 287 | #endif // NDN_DATA_HPP |