Implement Interest Exclude
diff --git a/ndn-cpp/Interest.cpp b/ndn-cpp/Interest.cpp
index d081620..382db2e 100644
--- a/ndn-cpp/Interest.cpp
+++ b/ndn-cpp/Interest.cpp
@@ -3,12 +3,38 @@
* See COPYING for copyright and distribution information.
*/
+#include <stdexcept>
#include "Interest.hpp"
using namespace std;
namespace ndn {
+void Exclude::get(struct ndn_Exclude &excludeStruct) const
+{
+ if (excludeStruct.maxEntries < entries_.size())
+ throw runtime_error("excludeStruct.maxEntries must be >= this exclude getEntryCount()");
+
+ excludeStruct.nEntries = entries_.size();
+ for (unsigned int i = 0; i < excludeStruct.nEntries; ++i)
+ entries_[i].get(excludeStruct.entries[i]);
+}
+
+void Exclude::set(struct ndn_Exclude &excludeStruct)
+{
+ entries_.clear();
+ for (unsigned int i = 0; i < excludeStruct.nEntries; ++i) {
+ ndn_ExcludeEntry *entry = &excludeStruct.entries[i];
+
+ if (entry->type == ndn_Exclude_COMPONENT)
+ addComponent(entry->component, entry->componentLength);
+ else if (entry->type == ndn_Exclude_ANY)
+ addAny();
+ else
+ throw runtime_error("unrecognized ndn_ExcludeType");
+ }
+}
+
void Interest::set(struct ndn_Interest &interestStruct)
{
name_.set(interestStruct.name);
@@ -19,7 +45,8 @@
if (interestStruct.publisherPublicKeyDigest)
publisherPublicKeyDigest_.insert
(publisherPublicKeyDigest_.begin(), interestStruct.publisherPublicKeyDigest, interestStruct.publisherPublicKeyDigest + interestStruct.publisherPublicKeyDigestLength);
- // TODO: implement exclude
+
+ exclude_.set(interestStruct.exclude);
childSelector_ = interestStruct.childSelector;
answerOriginKind_ = interestStruct.answerOriginKind;
scope_ = interestStruct.scope;
@@ -42,8 +69,7 @@
else
interestStruct.publisherPublicKeyDigest = 0;
- // TODO: implement exclude.
-
+ exclude_.get(interestStruct.exclude);
interestStruct.childSelector = childSelector_;
interestStruct.answerOriginKind = answerOriginKind_;
interestStruct.scope = scope_;