Make MetaInfo.finalBlockID a Name::Component.
diff --git a/ndn-cpp/data.cpp b/ndn-cpp/data.cpp
index 629ff37..0c5e7f3 100644
--- a/ndn-cpp/data.cpp
+++ b/ndn-cpp/data.cpp
@@ -49,9 +49,9 @@
metaInfoStruct.type = type_;
metaInfoStruct.freshnessSeconds = freshnessSeconds_;
- metaInfoStruct.finalBlockIDLength = finalBlockID_.size();
- if (finalBlockID_.size() > 0)
- metaInfoStruct.finalBlockID = (unsigned char *)&finalBlockID_[0];
+ metaInfoStruct.finalBlockIDLength = finalBlockID_.getValue().size();
+ if (metaInfoStruct.finalBlockIDLength > 0)
+ metaInfoStruct.finalBlockID = (unsigned char *)finalBlockID_.getValue().buf();
else
metaInfoStruct.finalBlockID = 0;
}
@@ -61,7 +61,7 @@
timestampMilliseconds_ = metaInfoStruct.timestampMilliseconds;
type_ = metaInfoStruct.type;
freshnessSeconds_ = metaInfoStruct.freshnessSeconds;
- setVector(finalBlockID_, metaInfoStruct.finalBlockID, metaInfoStruct.finalBlockIDLength);
+ finalBlockID_.setValue(Blob(metaInfoStruct.finalBlockID, metaInfoStruct.finalBlockIDLength));
}
void Data::get(struct ndn_Data& dataStruct) const
diff --git a/ndn-cpp/data.hpp b/ndn-cpp/data.hpp
index e1ad290..ab4de84 100644
--- a/ndn-cpp/data.hpp
+++ b/ndn-cpp/data.hpp
@@ -119,8 +119,7 @@
int getFreshnessSeconds() const { return freshnessSeconds_; }
- const std::vector<unsigned char>& getFinalBlockID() const { return finalBlockID_; }
- std::vector<unsigned char>& getFinalBlockID() { return finalBlockID_; }
+ const Name::Component& getFinalBlockID() const { return finalBlockID_; }
void setTimestampMilliseconds(double timestampMilliseconds) { timestampMilliseconds_ = timestampMilliseconds; }
@@ -128,17 +127,17 @@
void setFreshnessSeconds(int freshnessSeconds) { freshnessSeconds_ = freshnessSeconds; }
- void setFinalBlockID(const std::vector<unsigned char>& finalBlockID) { finalBlockID_ = finalBlockID; }
+ void setFinalBlockID(const std::vector<unsigned char>& finalBlockID) { finalBlockID_ = Name::Component(finalBlockID); }
void setFinalBlockID(const unsigned char *finalBlockID, unsigned int finalBlockIdLength)
{
- setVector(finalBlockID_, finalBlockID, finalBlockIdLength);
+ finalBlockID_ = Name::Component(finalBlockID, finalBlockIdLength);
}
private:
double timestampMilliseconds_; /**< milliseconds since 1/1/1970. -1 for none */
ndn_ContentType type_; /**< default is ndn_ContentType_DATA. -1 for none */
int freshnessSeconds_; /**< -1 for none */
- std::vector<unsigned char> finalBlockID_; /** size 0 for none */
+ Name::Component finalBlockID_; /** size 0 for none */
};
class Data {