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;
diff --git a/ndn-cpp/name.hpp b/ndn-cpp/name.hpp
index 5d707a3..2baee7d 100644
--- a/ndn-cpp/name.hpp
+++ b/ndn-cpp/name.hpp
@@ -65,6 +65,12 @@
     bool setFromEscapedString(const char *first, const char *last);
   
     const std::vector<unsigned char> &getValue() const { return value_; }
+    
+    /**
+     * Set this component to the encoded segment number.
+     * @param segment The segment number.
+     */
+    void setSegment(unsigned long segment);
   
   private:
     std::vector<unsigned char> value_;
@@ -141,6 +147,16 @@
   {
     return toUri();
   }
+  
+  /**
+   * Append a component with the encoded segment number.
+   * @param segment The segment number.
+   */
+  void appendSegment(unsigned long segment)
+  {
+    components_.push_back(Component());
+    components_.back().setSegment(segment);
+  }
 
 private:
   std::vector<Component> components_;