exclude-lite.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_EXCLUDE_LITE_HPP
23 #define NDN_EXCLUDE_LITE_HPP
24 
25 #include "name-lite.hpp"
26 #include "../c/interest-types.h"
27 
28 namespace ndn {
29 
33 class ExcludeLite : private ndn_Exclude {
34 public:
44 
45  class Entry : private ndn_ExcludeEntry {
46  public:
50  Entry();
51 
58  Entry(const uint8_t *component, size_t componentLength);
59 
65  Entry(const BlobLite& component);
66 
67  ndn_ExcludeType
68  getType() const { return type; }
69 
70  const NameLite::Component&
71  getComponent() const { return NameLite::Component::downCast(component); }
72 
78  static Entry&
79  downCast(ndn_ExcludeEntry& entry) { return *(Entry*)&entry; }
80 
81  static const Entry&
82  downCast(const ndn_ExcludeEntry& entry) { return *(Entry*)&entry; }
83  };
84 
89  size_t
90  size() const { return nEntries; }
91 
97  const ExcludeLite::Entry&
98  get(size_t i) const
99  {
100  // TODO: Range check.
101  return Entry::downCast(entries[i]);
102  }
103 
109  ndn_Error
110  appendAny();
111 
120  ndn_Error
121  appendComponent(const uint8_t* component, size_t componentLength);
122 
131  ndn_Error
132  appendComponent(const NameLite::Component& component);
133 
137  void
138  clear();
139 
146  ndn_Error
147  set(const ExcludeLite& other);
148 
154  static ExcludeLite&
155  downCast(ndn_Exclude& exclude) { return *(ExcludeLite*)&exclude; }
156 
157  static const ExcludeLite&
158  downCast(const ndn_Exclude& exclude) { return *(ExcludeLite*)&exclude; }
159 
160 private:
165  ExcludeLite(const ExcludeLite& other);
166 
171  ExcludeLite& operator=(const ExcludeLite& other);
172 };
173 
174 }
175 
176 #endif
An ndn_ExcludeEntry holds an ndn_ExcludeType, and if it is a COMPONENT, it holds a pointer to the com...
Definition: interest-types.h:39
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:36
size_t nEntries
the number of entries in the exclude, 0 for no exclude
Definition: interest-types.h:50
size_t size() const
Get the number of entries.
Definition: exclude-lite.hpp:90
Entry()
Create an ExcludeLite::Entry of type ndn_Exclude_ANY.
Definition: exclude-lite.cpp:27
void clear()
Clear all the entries.
Definition: exclude-lite.cpp:74
struct ndn_ExcludeEntry * entries
pointer to the array of entries.
Definition: interest-types.h:48
static ExcludeLite & downCast(ndn_Exclude &exclude)
Downcast the reference to the ndn_Exclude struct to an ExcludeLite.
Definition: exclude-lite.hpp:155
An ndn_Exclude holds an array of ndn_ExcludeEntry.
Definition: interest-types.h:47
An ExcludeLite holds an array of ExcludeLite::Entry.
Definition: exclude-lite.hpp:33
static Entry & downCast(ndn_ExcludeEntry &entry)
Downcast the reference to the ndn_ExcludeEntry struct to an ExcludeLite::Entry.
Definition: exclude-lite.hpp:79
A NameLite::Component holds a pointer to the component value.
Definition: name-lite.hpp:41
A BlobLite holds a pointer to an immutable pre-allocated buffer and its length This is like a JavaScr...
Definition: blob-lite.hpp:37
static Component & downCast(ndn_NameComponent &component)
Downcast the reference to the ndn_NameComponent struct to a NameLite::Component.
Definition: name-lite.hpp:390
ExcludeLite(ndn_ExcludeEntry *entries, size_t maxEntries)
Create an ExcludeLite with the entries array.
Definition: exclude-lite.cpp:44
size_t maxEntries
the number of elements in the allocated entries array
Definition: interest-types.h:49
Definition: exclude-lite.hpp:45
ndn_Error appendAny()
Append a new entry of type ndn_Exclude_ANY.
Definition: exclude-lite.cpp:50
ndn_Error appendComponent(const uint8_t *component, size_t componentLength)
Append a new entry of type ndn_Exclude_COMPONENT with the given GENERIC component value...
Definition: exclude-lite.cpp:56
ndn_Error set(const ExcludeLite &other)
Set this exclude object to have the values from the other exclude.
Definition: exclude-lite.cpp:77