Added support for ContentObject
diff --git a/ndn-cpp/ContentObject.cpp b/ndn-cpp/ContentObject.cpp
new file mode 100644
index 0000000..e675e5a
--- /dev/null
+++ b/ndn-cpp/ContentObject.cpp
@@ -0,0 +1,88 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "common.hpp"
+#include "ContentObject.hpp"
+
+using namespace std;
+
+namespace ndn {
+
+void Signature::get(struct ndn_Signature &signatureStruct) const
+{
+ signatureStruct.digestAlgorithmLength = digestAlgorithm_.size();
+ if (digestAlgorithm_.size() > 0)
+ signatureStruct.digestAlgorithm = (unsigned char *)&digestAlgorithm_[0];
+ else
+ signatureStruct.digestAlgorithm = 0;
+
+ signatureStruct.witnessLength = witness_.size();
+ if (witness_.size() > 0)
+ signatureStruct.witness = (unsigned char *)&witness_[0];
+ else
+ signatureStruct.witness = 0;
+
+ signatureStruct.signatureLength = signature_.size();
+ if (signature_.size() > 0)
+ signatureStruct.signature = (unsigned char *)&signature_[0];
+ else
+ signatureStruct.signature = 0;
+}
+
+void Signature::set(const struct ndn_Signature &signatureStruct)
+{
+ setVector(digestAlgorithm_, signatureStruct.digestAlgorithm, signatureStruct.digestAlgorithmLength);
+ setVector(witness_, signatureStruct.witness, signatureStruct.witnessLength);
+ setVector(signature_, signatureStruct.signature, signatureStruct.signatureLength);
+}
+
+void SignedInfo::get(struct ndn_SignedInfo &signedInfoStruct) const
+{
+ publisherPublicKeyDigest_.get(signedInfoStruct.publisherPublicKeyDigest);
+ // TODO: Implement timestamp
+ signedInfoStruct.type = type_;
+ signedInfoStruct.freshnessSeconds = freshnessSeconds_;
+
+ signedInfoStruct.finalBlockIDLength = finalBlockID_.size();
+ if (finalBlockID_.size() > 0)
+ signedInfoStruct.finalBlockID = (unsigned char *)&finalBlockID_[0];
+ else
+ signedInfoStruct.finalBlockID = 0;
+
+ keyLocator_.get(signedInfoStruct.keyLocator);
+}
+
+void SignedInfo::set(const struct ndn_SignedInfo &signedInfoStruct)
+{
+ publisherPublicKeyDigest_.set(signedInfoStruct.publisherPublicKeyDigest);
+ // TODO: Implement timestamp
+ type_ = signedInfoStruct.type;
+ freshnessSeconds_ = signedInfoStruct.freshnessSeconds;
+ setVector(finalBlockID_, signedInfoStruct.finalBlockID, signedInfoStruct.finalBlockIDLength);
+ keyLocator_.set(signedInfoStruct.keyLocator);
+}
+
+void ContentObject::get(struct ndn_ContentObject &contentObjectStruct) const
+{
+ signature_.get(contentObjectStruct.signature);
+ name_.get(contentObjectStruct.name);
+ signedInfo_.get(contentObjectStruct.signedInfo);
+
+ contentObjectStruct.contentLength = content_.size();
+ if (content_.size() > 0)
+ contentObjectStruct.content = (unsigned char *)&content_[0];
+ else
+ contentObjectStruct.content = 0;
+}
+
+void ContentObject::set(const struct ndn_ContentObject &contentObjectStruct)
+{
+ signature_.set(contentObjectStruct.signature);
+ name_.set(contentObjectStruct.name);
+ signedInfo_.set(contentObjectStruct.signedInfo);
+ setVector(content_, contentObjectStruct.content, contentObjectStruct.contentLength);
+}
+
+}