name: delete deprecated Name::set method
refs #2506
Change-Id: Iea44dcd8f39db4841d95ae62f79de0c8b642db38
diff --git a/src/name.cpp b/src/name.cpp
index ba6c146..f8b9a8c 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -55,13 +55,57 @@
}
Name::Name(const char* uri)
+ : Name(std::string(uri))
{
- construct(uri);
}
-Name::Name(const std::string& uri)
+Name::Name(std::string uri)
{
- construct(uri.c_str());
+ trim(uri);
+ if (uri.empty())
+ return;
+
+ size_t iColon = uri.find(':');
+ if (iColon != std::string::npos) {
+ // Make sure the colon came before a '/'.
+ size_t iFirstSlash = uri.find('/');
+ if (iFirstSlash == std::string::npos || iColon < iFirstSlash) {
+ // Omit the leading protocol such as ndn:
+ uri.erase(0, iColon + 1);
+ trim(uri);
+ }
+ }
+
+ // Trim the leading slash and possibly the authority.
+ if (uri[0] == '/') {
+ if (uri.size() >= 2 && uri[1] == '/') {
+ // Strip the authority following "//".
+ size_t iAfterAuthority = uri.find('/', 2);
+ if (iAfterAuthority == std::string::npos)
+ // Unusual case: there was only an authority.
+ return;
+ else {
+ uri.erase(0, iAfterAuthority + 1);
+ trim(uri);
+ }
+ }
+ else {
+ uri.erase(0, 1);
+ trim(uri);
+ }
+ }
+
+ size_t iComponentStart = 0;
+
+ // Unescape the components.
+ while (iComponentStart < uri.size()) {
+ size_t iComponentEnd = uri.find("/", iComponentStart);
+ if (iComponentEnd == std::string::npos)
+ iComponentEnd = uri.size();
+
+ append(Component::fromEscapedString(&uri[0], iComponentStart, iComponentEnd));
+ iComponentStart = iComponentEnd + 1;
+ }
}
Name
@@ -123,71 +167,6 @@
m_nameBlock.parse();
}
-void
-Name::construct(const char* uriOrig)
-{
- clear();
-
- std::string uri = uriOrig;
- trim(uri);
- if (uri.size() == 0)
- return;
-
- size_t iColon = uri.find(':');
- if (iColon != std::string::npos) {
- // Make sure the colon came before a '/'.
- size_t iFirstSlash = uri.find('/');
- if (iFirstSlash == std::string::npos || iColon < iFirstSlash) {
- // Omit the leading protocol such as ndn:
- uri.erase(0, iColon + 1);
- trim(uri);
- }
- }
-
- // Trim the leading slash and possibly the authority.
- if (uri[0] == '/') {
- if (uri.size() >= 2 && uri[1] == '/') {
- // Strip the authority following "//".
- size_t iAfterAuthority = uri.find('/', 2);
- if (iAfterAuthority == std::string::npos)
- // Unusual case: there was only an authority.
- return;
- else {
- uri.erase(0, iAfterAuthority + 1);
- trim(uri);
- }
- }
- else {
- uri.erase(0, 1);
- trim(uri);
- }
- }
-
- size_t iComponentStart = 0;
-
- // Unescape the components.
- while (iComponentStart < uri.size()) {
- size_t iComponentEnd = uri.find("/", iComponentStart);
- if (iComponentEnd == std::string::npos)
- iComponentEnd = uri.size();
-
- append(Component::fromEscapedString(&uri[0], iComponentStart, iComponentEnd));
- iComponentStart = iComponentEnd + 1;
- }
-}
-
-void
-Name::set(const char* uri)
-{
- *this = Name(uri);
-}
-
-void
-Name::set(const std::string& uri)
-{
- *this = Name(uri);
-}
-
std::string
Name::toUri() const
{
diff --git a/src/name.hpp b/src/name.hpp
index 986ef8f..3817947 100644
--- a/src/name.hpp
+++ b/src/name.hpp
@@ -105,7 +105,7 @@
* @brief Create name from @p uri (NDN URI scheme)
* @param uri The URI string
*/
- Name(const std::string& uri);
+ Name(std::string uri);
/**
* @brief Make a deep copy of the name, reallocating the underlying memory buffer
@@ -133,20 +133,6 @@
hasWire() const;
/**
- * @deprecated Use appropriate constructor
- */
- DEPRECATED(
- void
- set(const char* uri));
-
- /**
- * @deprecated Use appropriate constructor
- */
- DEPRECATED(
- void
- set(const std::string& uri));
-
- /**
* @brief Append a new component, copying from value of length valueLength.
* @return This name so that you can chain calls to append.
*/
@@ -613,10 +599,6 @@
return const_reverse_iterator(begin());
}
-private:
- void
- construct(const char* uri);
-
public:
/** \brief indicates "until the end" in getSubName and compare
*/