Added set(const char *uri)
diff --git a/ndn-cpp/name.cpp b/ndn-cpp/name.cpp
index 92d5234..8f8a161 100644
--- a/ndn-cpp/name.cpp
+++ b/ndn-cpp/name.cpp
@@ -190,8 +190,10 @@
reverse(value_.begin() + 1, value_.end());
}
-Name::Name(const char *uri_cstr)
+void Name::set(const char *uri_cstr)
{
+ components_.clear();
+
string uri = uri_cstr;
trim(uri);
if (uri.size() == 0)
diff --git a/ndn-cpp/name.hpp b/ndn-cpp/name.hpp
index 5d6fb19..e02d293 100644
--- a/ndn-cpp/name.hpp
+++ b/ndn-cpp/name.hpp
@@ -96,7 +96,10 @@
* Parse the uri according to the NDN URI Scheme and create the name with the components.
* @param uri The URI string.
*/
- Name(const char *uri);
+ Name(const char *uri)
+ {
+ set(uri);
+ }
/**
* Set the nameStruct to point to the components in this name, without copying any memory.
@@ -112,6 +115,12 @@
void set(const struct ndn_Name &nameStruct);
/**
+ * Parse the uri according to the NDN URI Scheme and set the name with the components.
+ * @param uri The URI string.
+ */
+ void set(const char *uri);
+
+ /**
* Add a new component, copying from value of length valueLength.
*/
void addComponent(unsigned char *value, unsigned int valueLength) {