name: Deprecation of Name::set methods, move constructors to .cpp, and documentation update
Change-Id: Icc68cad2854130fbf99c7af3378516dce0585279
Refs: #2505
diff --git a/src/name.cpp b/src/name.cpp
index 9b49fc8..c388064 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -43,6 +43,27 @@
const size_t Name::npos = std::numeric_limits<size_t>::max();
+Name::Name()
+ : m_nameBlock(tlv::Name)
+{
+}
+
+Name::Name(const Block& wire)
+{
+ m_nameBlock = wire;
+ m_nameBlock.parse();
+}
+
+Name::Name(const char* uri)
+{
+ construct(uri);
+}
+
+Name::Name(const std::string& uri)
+{
+ construct(uri.c_str());
+}
+
template<encoding::Tag TAG>
size_t
Name::wireEncode(EncodingImpl<TAG>& encoder) const
@@ -94,7 +115,7 @@
}
void
-Name::set(const char* uriOrig)
+Name::construct(const char* uriOrig)
{
clear();
@@ -150,6 +171,18 @@
}
}
+void
+Name::set(const char* uri)
+{
+ *this = std::move(Name(uri));
+}
+
+void
+Name::set(const std::string& uri)
+{
+ *this = std::move(Name(uri));
+}
+
std::string
Name::toUri() const
{
@@ -338,7 +371,7 @@
{
std::string inputString;
is >> inputString;
- name.set(inputString);
+ name = std::move(Name(inputString));
return is;
}