exclude.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_EXCLUDE_HPP
23 #define NDN_EXCLUDE_HPP
24 
25 #include "name.hpp"
26 #include "lite/exclude-lite.hpp"
27 
28 namespace ndn {
29 
33 class Exclude {
34 public:
39  : changeCount_(0)
40  {
41  }
42 
46  class Entry {
47  public:
52  : type_(ndn_Exclude_ANY)
53  {
54  }
55 
59  Entry(const uint8_t *component, size_t componentLen)
60  : type_(ndn_Exclude_COMPONENT), component_(component, componentLen)
61  {
62  }
63 
67  Entry(const Name::Component& component)
68  : type_(ndn_Exclude_COMPONENT), component_(component)
69  {
70  }
71 
72  ndn_ExcludeType
73  getType() const { return type_; }
74 
75  const Name::Component&
76  getComponent() const { return component_; }
77 
78  private:
79  ndn_ExcludeType type_;
80  Name::Component component_;
81  };
82 
87  size_t
88  size() const { return entries_.size(); }
89 
95  const Exclude::Entry&
96  get(size_t i) const { return entries_[i]; }
97 
101  size_t
102  DEPRECATED_IN_NDN_CPP getEntryCount() const { return entries_.size(); }
103 
107  const Exclude::Entry&
108  DEPRECATED_IN_NDN_CPP getEntry(size_t i) const { return entries_[i]; }
109 
118  void
119  get(ExcludeLite& excludeLite) const;
120 
125  void
126  set(const ExcludeLite& excludeLite);
127 
132  Exclude&
134  {
135  entries_.push_back(Entry());
136  ++changeCount_;
137  return *this;
138  }
139 
146  Exclude&
147  appendComponent(const uint8_t *component, size_t componentLength)
148  {
149  entries_.push_back(Entry(component, componentLength));
150  ++changeCount_;
151  return *this;
152  }
153 
159  Exclude&
161  {
162  entries_.push_back(Entry(component));
163  ++changeCount_;
164  return *this;
165  }
166 
170  Exclude&
171  DEPRECATED_IN_NDN_CPP addAny() { return appendAny(); }
172 
176  Exclude&
177  DEPRECATED_IN_NDN_CPP addComponent(uint8_t *component, size_t componentLength)
178  {
179  return appendComponent(component, componentLength);
180  }
181 
185  void
187  {
188  entries_.clear();
189  ++changeCount_;
190  }
191 
198  bool
199  matches(const Name::Component& component) const;
200 
205  std::string
206  toUri() const;
207 
213  const Exclude::Entry&
214  operator [] (int i) const
215  {
216  return get(i);
217  }
218 
223  uint64_t
224  getChangeCount() const { return changeCount_; }
225 
226 private:
227  std::vector<Entry> entries_;
228  uint64_t changeCount_;
229 };
230 
231 }
232 
233 #endif
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
Exclude()
Create a new Exclude with no entries.
Definition: exclude.hpp:38
Exclude & appendAny()
Append a new entry of type ndn_Exclude_ANY.
Definition: exclude.hpp:133
size_t size() const
Get the number of entries.
Definition: exclude.hpp:88
Entry()
Create an Exclude::Entry of type ndn_Exclude_ANY.
Definition: exclude.hpp:51
Entry(const Name::Component &component)
Create an Exclude::Entry of type ndn_Exclude_COMPONENT.
Definition: exclude.hpp:67
An Exclude::Entry holds an ndn_ExcludeType, and if it is a COMPONENT, it holds the component value...
Definition: exclude.hpp:46
const Exclude::Entry & operator[](int i) const
The same as get(i), get the entry at the given index.
Definition: exclude.hpp:214
An Exclude holds a vector of Exclude::Entry.
Definition: exclude.hpp:33
void clear()
Clear all the entries.
Definition: exclude.hpp:186
uint64_t getChangeCount() const
Get the change count, which is incremented each time this object is changed.
Definition: exclude.hpp:224
A Name::Component holds a read-only name component value.
Definition: name.hpp:45
Exclude & appendComponent(const uint8_t *component, size_t componentLength)
Append a new entry of type ndn_Exclude_COMPONENT, copying from component of length componentLength...
Definition: exclude.hpp:147
An ExcludeLite holds an array of ExcludeLite::Entry.
Definition: exclude-lite.hpp:33
Entry(const uint8_t *component, size_t componentLen)
Create an Exclude::Entry of type ndn_Exclude_COMPONENT.
Definition: exclude.hpp:59
Exclude &DEPRECATED_IN_NDN_CPP addComponent(uint8_t *component, size_t componentLength)
Definition: exclude.hpp:177
size_t DEPRECATED_IN_NDN_CPP getEntryCount() const
Definition: exclude.hpp:102
bool matches(const Name::Component &component) const
Check if the component matches any of the exclude criteria.
Definition: exclude.cpp:65
Exclude &DEPRECATED_IN_NDN_CPP addAny()
Definition: exclude.hpp:171
void set(const ExcludeLite &excludeLite)
Clear this Exclude, and set the entries by copying from excludeLite.
Definition: exclude.cpp:49
Exclude & appendComponent(const Name::Component &component)
Append a new entry of type ndn_Exclude_COMPONENT, taking another pointer to the Blob value...
Definition: exclude.hpp:160
const Exclude::Entry &DEPRECATED_IN_NDN_CPP getEntry(size_t i) const
Definition: exclude.hpp:108
std::string toUri() const
Encode this Exclude with elements separated by "," and ndn_Exclude_ANY shown as "*".
Definition: exclude.cpp:120