Data and IdentityCertificate: Make Data::setName virtual so that IdentityCertificate::setName is sure to validate the name.
diff --git a/include/ndn-cpp/data.hpp b/include/ndn-cpp/data.hpp
index d9b8fc1..a99e410 100644
--- a/include/ndn-cpp/data.hpp
+++ b/include/ndn-cpp/data.hpp
@@ -243,59 +243,64 @@
/**
* Set the signature to a copy of the given signature.
* @param signature The signature object which is cloned.
+ * @return This Data so that you can chain calls to update values.
*/
- void
+ Data&
setSignature(const Signature& signature)
{
signature_ = signature.clone();
onChanged();
+ return *this;
}
/**
- * Set name to a copy of the given Name.
+ * Set name to a copy of the given Name. This is virtual so that a subclass can override to validate the name.
* @param name The Name which is copied.
+ * @return This Data so that you can chain calls to update values.
*/
- void
- setName(const Name& name)
- {
- name_ = name;
- onChanged();
- }
+ virtual Data&
+ setName(const Name& name);
/**
* Set metaInfo to a copy of the given MetaInfo.
* @param metaInfo The MetaInfo which is copied.
+ * @return This Data so that you can chain calls to update values.
*/
- void
+ Data&
setMetainfo(const MetaInfo& metaInfo)
{
metaInfo_ = metaInfo;
onChanged();
+ return *this;
}
/**
* Set the content to a copy of the data in the vector.
* @param content A vector whose contents are copied.
+ * @return This Data so that you can chain calls to update values.
*/
- void
+ Data&
setContent(const std::vector<uint8_t>& content)
{
content_ = content;
onChanged();
+ return *this;
}
- void
+ Data&
setContent(const uint8_t* content, size_t contentLength)
{
content_ = Blob(content, contentLength);
onChanged();
+ return *this;
}
- void
+ Data&
setContent(const Blob& content)
{
content_ = content;
onChanged();
+ return *this;
}
private:
diff --git a/include/ndn-cpp/security/certificate/identity-certificate.hpp b/include/ndn-cpp/security/certificate/identity-certificate.hpp
index 8cb244d..0319774 100644
--- a/include/ndn-cpp/security/certificate/identity-certificate.hpp
+++ b/include/ndn-cpp/security/certificate/identity-certificate.hpp
@@ -35,7 +35,12 @@
virtual
~IdentityCertificate();
- Data &
+ /**
+ * Override the base class method to check that the name is a valid identity certificate name.
+ * @param name The identity certificate name which is copied.
+ * @return This Data so that you can chain calls to update values.
+ */
+ virtual Data &
setName(const Name& name);
virtual Name