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 | 4f75690 | 2017-07-18 03:05:02 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2013-2017 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 | |
Junxiao Shi | 4f75690 | 2017-07-18 03:05:02 +0000 | [diff] [blame] | 24 | #ifndef NDN_EXCLUDE_HPP |
| 25 | #define NDN_EXCLUDE_HPP |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 26 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 27 | #include "name-component.hpp" |
Alexander Afanasyev | 15f6731 | 2014-07-22 15:11:09 -0700 | [diff] [blame] | 28 | #include "encoding/encoding-buffer.hpp" |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 29 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 30 | #include <map> |
| 31 | |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 32 | namespace ndn { |
| 33 | |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 34 | /** |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 35 | * @brief Represents Exclude selector in NDN Interest |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 36 | */ |
| 37 | class Exclude |
| 38 | { |
| 39 | public: |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 40 | class Error : public tlv::Error |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 41 | { |
| 42 | public: |
| 43 | explicit |
| 44 | Error(const std::string& what) |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 45 | : tlv::Error(what) |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 46 | { |
| 47 | } |
| 48 | }; |
Alexander Afanasyev | 993a0e1 | 2014-01-03 13:51:37 -0800 | [diff] [blame] | 49 | |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 50 | /** |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 51 | * @brief Constructs an empty Exclude |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 52 | */ |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 53 | Exclude(); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 54 | |
| 55 | /** |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 56 | * @brief Create from wire encoding |
| 57 | */ |
| 58 | explicit |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 59 | Exclude(const Block& wire); |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 60 | |
| 61 | /** |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 62 | * @brief Fast encoding or block size estimation |
| 63 | */ |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 64 | template<encoding::Tag TAG> |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 65 | size_t |
Alexander Afanasyev | d5c48e0 | 2015-06-24 11:58:14 -0700 | [diff] [blame] | 66 | wireEncode(EncodingImpl<TAG>& encoder) const; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 67 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 68 | /** |
| 69 | * @brief Encode to a wire format |
| 70 | */ |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 71 | const Block& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 72 | wireEncode() const; |
| 73 | |
| 74 | /** |
| 75 | * @brief Decode from the wire format |
| 76 | */ |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 77 | void |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 78 | wireDecode(const Block& wire); |
| 79 | |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 80 | /** |
| 81 | * @brief Get escaped string representation (e.g., for use in URI) of the exclude filter |
| 82 | */ |
| 83 | std::string |
| 84 | toUri() const; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 85 | |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 86 | public: // high-level API |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 87 | /** |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 88 | * @brief Check if name component is excluded |
| 89 | * @param comp Name component to check against exclude filter |
| 90 | */ |
| 91 | bool |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 92 | isExcluded(const name::Component& comp) const; |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 93 | |
| 94 | /** |
| 95 | * @brief Exclude specific name component |
| 96 | * @param comp component to exclude |
| 97 | * @returns *this to allow chaining |
| 98 | */ |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 99 | Exclude& |
| 100 | excludeOne(const name::Component& comp); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 101 | |
| 102 | /** |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 103 | * @brief Exclude components in range [from, to] |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 104 | * @param from first element of the range |
| 105 | * @param to last element of the range |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 106 | * @throw Error \p from equals or comes after \p to in canonical ordering |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 107 | * @returns *this to allow chaining |
| 108 | */ |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 109 | Exclude& |
| 110 | excludeRange(const name::Component& from, const name::Component& to); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 111 | |
| 112 | /** |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 113 | * @brief Exclude all components in range (-Inf, to] |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 114 | * @param to last element of the range |
| 115 | * @returns *this to allow chaining |
| 116 | */ |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 117 | Exclude& |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 118 | excludeBefore(const name::Component& to); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 119 | |
| 120 | /** |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 121 | * @brief Exclude all components in range [from, +Inf) |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 122 | * @param from the first element of the range |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 123 | * @returns *this to allow chaining |
| 124 | */ |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 125 | Exclude& |
| 126 | excludeAfter(const name::Component& from); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 127 | |
Alexander Afanasyev | ba09605 | 2014-09-19 15:36:37 -0700 | [diff] [blame] | 128 | public: // EqualityComparable concept |
| 129 | bool |
| 130 | operator==(const Exclude& other) const; |
| 131 | |
| 132 | bool |
| 133 | operator!=(const Exclude& other) const; |
| 134 | |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame^] | 135 | public: // internal storage |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 136 | /** |
| 137 | * @brief either a name::Component or "negative infinity" |
| 138 | */ |
| 139 | class ExcludeComponent |
| 140 | { |
| 141 | public: |
| 142 | /** |
| 143 | * @brief implicitly construct a regular infinity ExcludeComponent |
| 144 | * @param component a name component which is excluded |
| 145 | */ |
| 146 | ExcludeComponent(const name::Component& component); |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 147 | |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 148 | /** |
| 149 | * @brief construct a negative infinity ExcludeComponent |
| 150 | * @param isNegInf must be true |
| 151 | */ |
| 152 | explicit |
| 153 | ExcludeComponent(bool isNegInf); |
| 154 | |
| 155 | public: |
| 156 | bool isNegInf; |
| 157 | name::Component component; |
| 158 | }; |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 159 | |
| 160 | /** |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 161 | * @brief a map of exclude entries |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 162 | * |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 163 | * Each key, except "negative infinity", is a name component that is excluded. |
| 164 | * The mapped boolean indicates whether the range between a key and the next greater key |
| 165 | * is also excluded. If true, the wire encoding shall have an ANY element. |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 166 | * |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 167 | * The map is ordered in descending order to simplify \p isExcluded. |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 168 | */ |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 169 | typedef std::map<ExcludeComponent, bool, std::greater<ExcludeComponent>> ExcludeMap; |
| 170 | typedef ExcludeMap::value_type Entry; |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 171 | |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 172 | public: // enumeration API |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 173 | /** |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 174 | * @brief represent an excluded component or range |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 175 | */ |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 176 | class Range |
| 177 | { |
| 178 | public: |
Junxiao Shi | 4f75690 | 2017-07-18 03:05:02 +0000 | [diff] [blame] | 179 | Range(); |
| 180 | |
| 181 | Range(bool fromInfinity, const name::Component& from, bool toInfinity, const name::Component& to); |
| 182 | |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 183 | /** |
| 184 | * @retval true A single component is excluded |
| 185 | * @retval false A range of more than one components are excluded |
| 186 | */ |
| 187 | bool |
| 188 | isSingular() const; |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 189 | |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 190 | bool |
| 191 | operator==(const Exclude::Range& other) const; |
| 192 | |
| 193 | bool |
| 194 | operator!=(const Exclude::Range& other) const; |
| 195 | |
| 196 | public: |
| 197 | /** |
| 198 | * @brief from negative infinity? |
| 199 | */ |
| 200 | bool fromInfinity; |
| 201 | |
| 202 | /** |
| 203 | * @brief from component (inclusive) |
| 204 | * @pre valid only if !fromInfinity |
| 205 | */ |
| 206 | name::Component from; |
| 207 | |
| 208 | /** |
| 209 | * @brief to positive infinity? |
| 210 | */ |
| 211 | bool toInfinity; |
| 212 | |
| 213 | /** |
| 214 | * @brief to component (inclusive) |
| 215 | * @pre valid only if !toInfinity |
| 216 | */ |
| 217 | name::Component to; |
| 218 | }; |
| 219 | |
| 220 | class const_iterator : public std::iterator<std::forward_iterator_tag, const Range> |
| 221 | { |
| 222 | public: |
| 223 | const_iterator() = default; |
| 224 | |
| 225 | const_iterator(ExcludeMap::const_reverse_iterator it, ExcludeMap::const_reverse_iterator rend); |
| 226 | |
| 227 | const Range& |
| 228 | operator*() const; |
| 229 | |
| 230 | const Range* |
| 231 | operator->() const; |
| 232 | |
| 233 | const_iterator& |
| 234 | operator++(); |
| 235 | |
| 236 | const_iterator |
| 237 | operator++(int); |
| 238 | |
| 239 | bool |
| 240 | operator==(const const_iterator& other) const; |
| 241 | |
| 242 | bool |
| 243 | operator!=(const const_iterator& other) const; |
| 244 | |
| 245 | private: |
| 246 | void |
| 247 | update(); |
| 248 | |
| 249 | private: |
| 250 | ExcludeMap::const_reverse_iterator m_it; |
| 251 | ExcludeMap::const_reverse_iterator m_rend; |
| 252 | Range m_range; |
| 253 | friend class Exclude; |
| 254 | }; |
| 255 | |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 256 | const_iterator |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 257 | begin() const; |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 258 | |
Junxiao Shi | 7520302 | 2014-09-11 10:01:50 -0700 | [diff] [blame] | 259 | const_iterator |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 260 | end() const; |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 261 | |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 262 | bool |
| 263 | empty() const; |
| 264 | |
| 265 | size_t |
| 266 | size() const; |
| 267 | |
| 268 | /// \todo const_iterator erase(const_iterator i); |
| 269 | |
| 270 | void |
| 271 | clear(); |
| 272 | |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 273 | private: |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 274 | /** |
| 275 | * @brief directly append exclude element |
| 276 | * @tparam T either name::Component or bool |
| 277 | * |
| 278 | * This method is used during conversion from wire format of exclude filter |
| 279 | */ |
| 280 | template<typename T> |
| 281 | void |
| 282 | appendEntry(const T& component, bool hasAny); |
| 283 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 284 | Exclude& |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 285 | excludeRange(const ExcludeComponent& from, const name::Component& to); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 286 | |
| 287 | private: |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 288 | ExcludeMap m_entries; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 289 | mutable Block m_wire; |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 290 | |
| 291 | friend std::ostream& |
| 292 | operator<<(std::ostream& os, const Exclude& name); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 293 | }; |
| 294 | |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame^] | 295 | NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Exclude); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 296 | |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 297 | bool |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 298 | operator==(const Exclude::ExcludeComponent& a, const Exclude::ExcludeComponent& b); |
| 299 | |
| 300 | bool |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 301 | operator>(const Exclude::ExcludeComponent& a, const Exclude::ExcludeComponent& b); |
Alexander Afanasyev | 993a0e1 | 2014-01-03 13:51:37 -0800 | [diff] [blame] | 302 | |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 303 | std::ostream& |
| 304 | operator<<(std::ostream& os, const Exclude::Range& range); |
| 305 | |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame^] | 306 | std::ostream& |
| 307 | operator<<(std::ostream& os, const Exclude& name); |
| 308 | |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 309 | inline Exclude::const_iterator |
| 310 | Exclude::begin() const |
| 311 | { |
| 312 | return const_iterator(m_entries.rbegin(), m_entries.rend()); |
| 313 | } |
| 314 | |
| 315 | inline Exclude::const_iterator |
| 316 | Exclude::end() const |
| 317 | { |
| 318 | return const_iterator(m_entries.rend(), m_entries.rend()); |
| 319 | } |
| 320 | |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 321 | inline bool |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 322 | Exclude::empty() const |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 323 | { |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 324 | return m_entries.empty(); |
Alexander Afanasyev | 8548084 | 2014-01-06 14:46:54 -0800 | [diff] [blame] | 325 | } |
| 326 | |
Alexander Afanasyev | ba09605 | 2014-09-19 15:36:37 -0700 | [diff] [blame] | 327 | inline bool |
| 328 | Exclude::operator!=(const Exclude& other) const |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 329 | { |
Alexander Afanasyev | ba09605 | 2014-09-19 15:36:37 -0700 | [diff] [blame] | 330 | return !(*this == other); |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 331 | } |
| 332 | |
Junxiao Shi | b80e947 | 2016-07-20 13:45:24 +0000 | [diff] [blame] | 333 | inline bool |
| 334 | Exclude::Range::isSingular() const |
| 335 | { |
| 336 | return !this->fromInfinity && !this->toInfinity && this->from == this->to; |
| 337 | } |
| 338 | |
| 339 | inline bool |
| 340 | Exclude::Range::operator!=(const Exclude::Range& other) const |
| 341 | { |
| 342 | return !this->operator==(other); |
| 343 | } |
| 344 | |
| 345 | inline const Exclude::Range& |
| 346 | Exclude::const_iterator::operator*() const |
| 347 | { |
| 348 | BOOST_ASSERT(m_it != m_rend); |
| 349 | return m_range; |
| 350 | } |
| 351 | |
| 352 | inline const Exclude::Range* |
| 353 | Exclude::const_iterator::operator->() const |
| 354 | { |
| 355 | BOOST_ASSERT(m_it != m_rend); |
| 356 | return &m_range; |
| 357 | } |
| 358 | |
| 359 | inline bool |
| 360 | Exclude::const_iterator::operator==(const const_iterator& other) const |
| 361 | { |
| 362 | return m_it == other.m_it; |
| 363 | } |
| 364 | |
| 365 | inline bool |
| 366 | Exclude::const_iterator::operator!=(const const_iterator& other) const |
| 367 | { |
| 368 | return !this->operator==(other); |
| 369 | } |
| 370 | |
Junxiao Shi | df4b24e | 2016-07-14 21:41:43 +0000 | [diff] [blame] | 371 | } // namespace ndn |
Alexander Afanasyev | b3a6af4 | 2014-01-03 13:08:28 -0800 | [diff] [blame] | 372 | |
Junxiao Shi | 4f75690 | 2017-07-18 03:05:02 +0000 | [diff] [blame] | 373 | #endif // NDN_EXCLUDE_HPP |