Interest exclude: Added appendAny and appendComponent and deprecated addAny and addComponent (to be consistent with Name append).
diff --git a/include/ndn-cpp/interest.hpp b/include/ndn-cpp/interest.hpp
index 2c9688a..36a3859 100644
--- a/include/ndn-cpp/interest.hpp
+++ b/include/ndn-cpp/interest.hpp
@@ -33,7 +33,7 @@
}
/**
- * Create an ExcludeEntry of type ndn_Exclude_COMPONENT
+ * Create an ExcludeEntry of type ndn_Exclude_COMPONENT.
*/
ExcludeEntry(uint8_t *component, size_t componentLen)
: type_(ndn_Exclude_COMPONENT), component_(component, componentLen)
@@ -41,6 +41,14 @@
}
/**
+ * Create an ExcludeEntry of type ndn_Exclude_COMPONENT.
+ */
+ ExcludeEntry(const Blob& component)
+ : type_(ndn_Exclude_COMPONENT), component_(component)
+ {
+ }
+
+ /**
* Set the type in the excludeEntryStruct and to point to this component, without copying any memory.
* WARNING: The resulting pointer in excludeEntryStruct is invalid after a further use of this object which could reallocate memory.
* @param excludeEntryStruct the C ndn_NameComponent struct to receive the pointer
@@ -92,22 +100,52 @@
set(const struct ndn_Exclude& excludeStruct);
/**
- * Add a new entry of type ndn_Exclude_ANY
+ * Append a new entry of type ndn_Exclude_ANY.
+ * @return This Exclude so that you can chain calls to append.
*/
- void
- addAny()
+ Exclude&
+ appendAny()
{
entries_.push_back(ExcludeEntry());
+ return *this;
}
/**
- * Add a new entry of type ndn_Exclude_COMPONENT, copying from component of length compnentLength
+ * Append a new entry of type ndn_Exclude_COMPONENT, copying from component of length compnentLength.
+ * @param component A pointer to the component byte array.
+ * @param componentLength The length of component.
+ * @return This Exclude so that you can chain calls to append.
*/
- void
- addComponent(uint8_t *component, size_t componentLen)
+ Exclude&
+ appendComponent(uint8_t *component, size_t componentLength)
{
- entries_.push_back(ExcludeEntry(component, componentLen));
+ entries_.push_back(ExcludeEntry(component, componentLength));
+ return *this;
}
+
+ /**
+ * Append a new entry of type ndn_Exclude_COMPONENT, copying from component of length compnentLength.
+ * @param component A blob with a pointer to an immutable array. The pointer is copied.
+ * @return This Exclude so that you can chain calls to append.
+ */
+ Exclude&
+ appendComponent(const Blob &component)
+ {
+ entries_.push_back(ExcludeEntry(component));
+ return *this;
+ }
+
+ /**
+ * @deprecated Use appendAny.
+ */
+ Exclude&
+ addAny() { return appendAny(); }
+
+ /**
+ * @deprecated Use appendComponent.
+ */
+ Exclude&
+ addComponent(uint8_t *component, size_t componentLength) { return appendComponent(component, componentLength); }
/**
* Clear all the entries.