Added appendSegment
diff --git a/ndn-cpp/name.cpp b/ndn-cpp/name.cpp
index 226626f..74df146 100644
--- a/ndn-cpp/name.cpp
+++ b/ndn-cpp/name.cpp
@@ -172,6 +172,23 @@
return true;
}
+void Name::Component::setSegment(unsigned long segment)
+{
+ value_.clear();
+
+ // First encode in little endian.
+ while (segment != 0) {
+ value_.push_back(segment & 0xff);
+ segment >>= 8;
+ }
+
+ // Append a zero which will become the leading zero when we reverse.
+ value_.push_back(0);
+
+ // Make it big endian.
+ reverse(value_.begin(), value_.end());
+}
+
Name::Name(const char *uri_cstr)
{
string uri = uri_cstr;