Implement get(struct ndn_Interest &)
diff --git a/ndn-cpp/Interest.cpp b/ndn-cpp/Interest.cpp
index f6abf52..2fda538 100644
--- a/ndn-cpp/Interest.cpp
+++ b/ndn-cpp/Interest.cpp
@@ -29,6 +29,32 @@
nonce_.insert
(nonce_.begin(), interestStruct.nonce, interestStruct.nonce + interestStruct.nonceLength);
}
+
+void Interest::get(struct ndn_Interest &interestStruct)
+{
+ name_.get(interestStruct.name);
+ interestStruct.maxSuffixComponents = maxSuffixComponents_;
+ interestStruct.minSuffixComponents = minSuffixComponents_;
+
+ interestStruct.publisherPublicKeyDigestLength = publisherPublicKeyDigest_.size();
+ if (publisherPublicKeyDigest_.size() > 0)
+ interestStruct.publisherPublicKeyDigest = &publisherPublicKeyDigest_[0];
+ else
+ interestStruct.publisherPublicKeyDigest = 0;
+
+ // TODO: implement exclude.
+
+ interestStruct.childSelector = childSelector_;
+ interestStruct.answerOriginKind = answerOriginKind_;
+ interestStruct.scope = scope_;
+ interestStruct.interestLifetime = interestLifetime_;
+
+ interestStruct.nonceLength = nonce_.size();
+ if (nonce_.size() > 0)
+ interestStruct.nonce = &nonce_[0];
+ else
+ interestStruct.nonce = 0;
+}
}
diff --git a/ndn-cpp/Interest.hpp b/ndn-cpp/Interest.hpp
index a481cca..a776912 100644
--- a/ndn-cpp/Interest.hpp
+++ b/ndn-cpp/Interest.hpp
@@ -38,6 +38,13 @@
{
decode(&input[0], input.size());
}
+
+ /**
+ * Set the interestStruct to point to the components in this interest, without copying any memory.
+ * WARNING: The resulting pointers in interestStruct are invalid after a further use of this object which could reallocate memory.
+ * @param interestStruct a C ndn_Interest struct where the name components array is already allocated.
+ */
+ void get(struct ndn_Interest &interestStruct);
Name &getName() { return name_; }