Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2015 Regents of the University of California. |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [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. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 20 | * |
| 21 | * @author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html> |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 22 | */ |
| 23 | |
Alexander Afanasyev | 09c613f | 2014-01-29 00:23:58 -0800 | [diff] [blame] | 24 | #include "exclude.hpp" |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 25 | #include "util/concepts.hpp" |
Junxiao Shi | 7284a40 | 2014-09-12 13:42:16 -0700 | [diff] [blame] | 26 | |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 27 | #include <boost/range/adaptors.hpp> |
| 28 | |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 29 | namespace ndn { |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 30 | |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 31 | BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Exclude>)); |
| 32 | BOOST_CONCEPT_ASSERT((WireEncodable<Exclude>)); |
| 33 | BOOST_CONCEPT_ASSERT((WireDecodable<Exclude>)); |
| 34 | static_assert(std::is_base_of<tlv::Error, Exclude::Error>::value, |
| 35 | "Exclude::Error must inherit from tlv::Error"); |
Junxiao Shi | 7284a40 | 2014-09-12 13:42:16 -0700 | [diff] [blame] | 36 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 37 | Exclude::Exclude() |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 38 | { |
| 39 | } |
| 40 | |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 41 | Exclude::Exclude(const Block& wire) |
| 42 | { |
| 43 | wireDecode(wire); |
| 44 | } |
| 45 | |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 46 | template<encoding::Tag TAG> |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 47 | size_t |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 48 | Exclude::wireEncode(EncodingImpl<TAG>& block) const |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 49 | { |
Junxiao Shi | 7284a40 | 2014-09-12 13:42:16 -0700 | [diff] [blame] | 50 | if (m_exclude.empty()) { |
| 51 | throw Error("Exclude filter cannot be empty"); |
| 52 | } |
| 53 | |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 54 | size_t totalLength = 0; |
| 55 | |
| 56 | // Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+ |
| 57 | // Any ::= ANY-TYPE TLV-LENGTH(=0) |
| 58 | |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 59 | for (const auto& item : m_exclude) { |
| 60 | if (item.second) { |
| 61 | totalLength += prependBooleanBlock(block, tlv::Any); |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 62 | } |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 63 | if (!item.first.empty() || !item.second) { |
| 64 | totalLength += item.first.wireEncode(block); |
| 65 | } |
| 66 | } |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 67 | |
| 68 | totalLength += block.prependVarNumber(totalLength); |
| 69 | totalLength += block.prependVarNumber(tlv::Exclude); |
| 70 | return totalLength; |
| 71 | } |
| 72 | |
| 73 | template size_t |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 74 | Exclude::wireEncode<encoding::EncoderTag>(EncodingImpl<encoding::EncoderTag>& block) const; |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 75 | |
| 76 | template size_t |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 77 | Exclude::wireEncode<encoding::EstimatorTag>(EncodingImpl<encoding::EstimatorTag>& block) const; |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 78 | |
| 79 | const Block& |
| 80 | Exclude::wireEncode() const |
| 81 | { |
| 82 | if (m_wire.hasWire()) |
| 83 | return m_wire; |
| 84 | |
| 85 | EncodingEstimator estimator; |
| 86 | size_t estimatedSize = wireEncode(estimator); |
| 87 | |
| 88 | EncodingBuffer buffer(estimatedSize, 0); |
| 89 | wireEncode(buffer); |
| 90 | |
| 91 | m_wire = buffer.block(); |
| 92 | return m_wire; |
| 93 | } |
| 94 | |
| 95 | void |
| 96 | Exclude::wireDecode(const Block& wire) |
| 97 | { |
Alexander Afanasyev | ba09605 | 2014-09-19 15:36:37 -0700 | [diff] [blame] | 98 | clear(); |
| 99 | |
Junxiao Shi | 7284a40 | 2014-09-12 13:42:16 -0700 | [diff] [blame] | 100 | if (wire.type() != tlv::Exclude) |
| 101 | throw tlv::Error("Unexpected TLV type when decoding Exclude"); |
| 102 | |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 103 | m_wire = wire; |
| 104 | m_wire.parse(); |
| 105 | |
Junxiao Shi | 7284a40 | 2014-09-12 13:42:16 -0700 | [diff] [blame] | 106 | if (m_wire.elements_size() == 0) { |
| 107 | throw Error("Exclude element cannot be empty"); |
| 108 | } |
| 109 | |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 110 | // Exclude ::= EXCLUDE-TYPE TLV-LENGTH Any? (NameComponent (Any)?)+ |
| 111 | // Any ::= ANY-TYPE TLV-LENGTH(=0) |
| 112 | |
| 113 | Block::element_const_iterator i = m_wire.elements_begin(); |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 114 | if (i->type() == tlv::Any) { |
| 115 | appendExclude(name::Component(), true); |
| 116 | ++i; |
| 117 | } |
| 118 | |
| 119 | while (i != m_wire.elements_end()) { |
| 120 | name::Component excludedComponent; |
| 121 | try { |
| 122 | excludedComponent = std::move(name::Component(*i)); |
| 123 | } |
| 124 | catch (const name::Component::Error&) { |
| 125 | throw Error("Incorrect format of Exclude filter"); |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 128 | ++i; |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 129 | |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 130 | if (i != m_wire.elements_end()) { |
| 131 | if (i->type() == tlv::Any) { |
| 132 | appendExclude(excludedComponent, true); |
| 133 | ++i; |
| 134 | } |
| 135 | else { |
| 136 | appendExclude(excludedComponent, false); |
| 137 | } |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 138 | } |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 139 | else { |
| 140 | appendExclude(excludedComponent, false); |
| 141 | } |
| 142 | } |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 145 | // example: ANY /b /d ANY /f |
| 146 | // |
| 147 | // ordered in map as: |
| 148 | // |
| 149 | // /f (false); /d (true); /b (false); / (true) |
| 150 | // |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 151 | // lower_bound(/) -> / (true) <-- excluded (equal) |
| 152 | // lower_bound(/a) -> / (true) <-- excluded (any) |
| 153 | // lower_bound(/b) -> /b (false) <--- excluded (equal) |
| 154 | // lower_bound(/c) -> /b (false) <--- not excluded (not equal and no ANY) |
| 155 | // lower_bound(/d) -> /d (true) <- excluded |
| 156 | // lower_bound(/e) -> /d (true) <- excluded |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 157 | bool |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 158 | Exclude::isExcluded(const name::Component& comp) const |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 159 | { |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 160 | const_iterator lowerBound = m_exclude.lower_bound(comp); |
| 161 | if (lowerBound == end()) |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 162 | return false; |
| 163 | |
| 164 | if (lowerBound->second) |
| 165 | return true; |
| 166 | else |
| 167 | return lowerBound->first == comp; |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 168 | } |
| 169 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 170 | Exclude& |
| 171 | Exclude::excludeOne(const name::Component& comp) |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 172 | { |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 173 | if (!isExcluded(comp)) { |
| 174 | m_exclude.insert(std::make_pair(comp, false)); |
| 175 | m_wire.reset(); |
| 176 | } |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 177 | return *this; |
| 178 | } |
| 179 | |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 180 | // example: ANY /b0 /d0 ANY /f0 |
| 181 | // |
| 182 | // ordered in map as: |
| 183 | // |
| 184 | // /f0 (false); /d0 (true); /b0 (false); / (true) |
| 185 | // |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 186 | // lower_bound(/) -> / (true) <-- excluded (equal) |
| 187 | // lower_bound(/a0) -> / (true) <-- excluded (any) |
| 188 | // lower_bound(/b0) -> /b0 (false) <--- excluded (equal) |
| 189 | // lower_bound(/c0) -> /b0 (false) <--- not excluded (not equal and no ANY) |
| 190 | // lower_bound(/d0) -> /d0 (true) <- excluded |
| 191 | // lower_bound(/e0) -> /d0 (true) <- excluded |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 192 | |
| 193 | |
| 194 | // examples with desired outcomes |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 195 | // excludeRange(/, /f0) -> ANY /f0 |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 196 | // /f0 (false); / (true) |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 197 | // excludeRange(/, /f1) -> ANY /f1 |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 198 | // /f1 (false); / (true) |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 199 | // excludeRange(/a0, /e0) -> ANY /f0 |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 200 | // /f0 (false); / (true) |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 201 | // excludeRange(/a0, /e0) -> ANY /f0 |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 202 | // /f0 (false); / (true) |
| 203 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 204 | // excludeRange(/b1, /c0) -> ANY /b0 /b1 ANY /c0 /d0 ANY /f0 |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 205 | // /f0 (false); /d0 (true); /c0 (false); /b1 (true); /b0 (false); / (true) |
| 206 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 207 | Exclude& |
| 208 | Exclude::excludeRange(const name::Component& from, const name::Component& to) |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 209 | { |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 210 | if (from >= to) { |
Alexander Afanasyev | 9c57818 | 2014-05-14 17:28:28 -0700 | [diff] [blame] | 211 | throw Error("Invalid exclude range [" + from.toUri() + ", " + to.toUri() + "] " |
| 212 | "(for single name exclude use Exclude::excludeOne)"); |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 213 | } |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 214 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 215 | iterator newFrom = m_exclude.lower_bound(from); |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 216 | if (newFrom == end() || !newFrom->second /*without ANY*/) { |
| 217 | std::pair<iterator, bool> fromResult = m_exclude.insert(std::make_pair(from, true)); |
| 218 | newFrom = fromResult.first; |
| 219 | if (!fromResult.second) { |
| 220 | // this means that the lower bound is equal to the item itself. So, just update ANY flag |
| 221 | newFrom->second = true; |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 222 | } |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 223 | } |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 224 | // else |
| 225 | // nothing special if start of the range already exists with ANY flag set |
| 226 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 227 | iterator newTo = m_exclude.lower_bound(to); // !newTo cannot be end() |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 228 | if (newTo == newFrom || !newTo->second) { |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 229 | std::pair<iterator, bool> toResult = m_exclude.insert(std::make_pair(to, false)); |
| 230 | newTo = toResult.first; |
| 231 | ++ newTo; |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 232 | } |
| 233 | // else |
| 234 | // nothing to do really |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 235 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 236 | m_exclude.erase(newTo, newFrom); // remove any intermediate node, since all of the are excluded |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 237 | |
Alexander Afanasyev | ba09605 | 2014-09-19 15:36:37 -0700 | [diff] [blame] | 238 | m_wire.reset(); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 239 | return *this; |
| 240 | } |
| 241 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 242 | Exclude& |
| 243 | Exclude::excludeAfter(const name::Component& from) |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 244 | { |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 245 | iterator newFrom = m_exclude.lower_bound(from); |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 246 | if (newFrom == end() || !newFrom->second /*without ANY*/) { |
| 247 | std::pair<iterator, bool> fromResult = m_exclude.insert(std::make_pair(from, true)); |
| 248 | newFrom = fromResult.first; |
| 249 | if (!fromResult.second) { |
| 250 | // this means that the lower bound is equal to the item itself. So, just update ANY flag |
| 251 | newFrom->second = true; |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 252 | } |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 253 | } |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 254 | // else |
| 255 | // nothing special if start of the range already exists with ANY flag set |
| 256 | |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 257 | if (newFrom != m_exclude.begin()) { |
| 258 | // remove any intermediate node, since all of the are excluded |
| 259 | m_exclude.erase(m_exclude.begin(), newFrom); |
| 260 | } |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 261 | |
Alexander Afanasyev | ba09605 | 2014-09-19 15:36:37 -0700 | [diff] [blame] | 262 | m_wire.reset(); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 263 | return *this; |
| 264 | } |
| 265 | |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 266 | std::ostream& |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 267 | operator<<(std::ostream& os, const Exclude& exclude) |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 268 | { |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 269 | bool isFirst = true; |
| 270 | for (const auto& item : exclude | boost::adaptors::reversed) { |
| 271 | if (!item.first.empty() || !item.second) { |
| 272 | if (!isFirst) |
| 273 | os << ","; |
| 274 | os << item.first.toUri(); |
| 275 | isFirst = false; |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 276 | } |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 277 | if (item.second) { |
| 278 | if (!isFirst) |
| 279 | os << ","; |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 280 | os << "*"; |
Alexander Afanasyev | c076e6d | 2015-04-02 20:07:13 -0700 | [diff] [blame^] | 281 | isFirst = false; |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 282 | } |
| 283 | } |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 284 | return os; |
| 285 | } |
| 286 | |
Alexander Afanasyev | ba09605 | 2014-09-19 15:36:37 -0700 | [diff] [blame] | 287 | std::string |
| 288 | Exclude::toUri() const |
| 289 | { |
| 290 | std::ostringstream os; |
| 291 | os << *this; |
| 292 | return os.str(); |
| 293 | } |
| 294 | |
| 295 | bool |
| 296 | Exclude::operator==(const Exclude& other) const |
| 297 | { |
| 298 | if (empty() && other.empty()) |
| 299 | return true; |
| 300 | if (empty() || other.empty()) |
| 301 | return false; |
| 302 | |
| 303 | return wireEncode() == other.wireEncode(); |
| 304 | } |
| 305 | |
Alexander Afanasyev | 3aeeaeb | 2014-04-22 23:34:23 -0700 | [diff] [blame] | 306 | } // namespace ndn |