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