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