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