name: Fixes and improvements in Name and name::Component classes

Change-Id: I4695ea252d7cd2de7d68991f5c029bd3f1b39828
diff --git a/src/name-component.hpp b/src/name-component.hpp
index c8ca77e..a74c40c 100644
--- a/src/name-component.hpp
+++ b/src/name-component.hpp
@@ -34,7 +34,17 @@
   {    
   }
 
-  // copy constructor OK
+  /**
+   * @brief Directly create component from wire block
+   *
+   * ATTENTION  wire MUST BE of type Tlv::Component. Any other value would cause an exception
+   */
+  Component(const Block& wire)
+    : Block(wire)
+  {
+    if (type() != Tlv::NameComponent)
+      throw Error("Constructing name component from non name component TLV wire block");
+  }
   
   /**
    * Create a new Name::Component, taking another pointer to the Blob value.
@@ -69,12 +79,19 @@
     : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(begin, end)))
   {
   }
-    
-  Component(const char *string)
-    : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(string, ::strlen(string))))
+
+  explicit
+  Component(const char *str)
+    : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(str, ::strlen(str))))
   {
   }
 
+  explicit
+  Component(const std::string& str)
+    : Block (Tlv::NameComponent, ConstBufferPtr(new Buffer(str.begin(), str.end())))
+  {
+  }
+  
   /**
    * @brief Fast encoding or block size estimation
    */
@@ -142,6 +159,18 @@
     toEscapedString(result);
     return result.str();
   }
+
+  inline void
+  toUri(std::ostream& result) const
+  {
+    return toEscapedString(result);
+  }
+
+  inline std::string
+  toUri() const
+  {
+    return toEscapedString();
+  }
     
   /**
    * Interpret this name component as a network-ordered number and return an integer.