util: remove unnecessary trim/trimLeft/trimRight wrappers
When needed, use boost::algorithm::trim/trim_left/trim_right directly.
Change-Id: I854d89e553c70ab20679a38922cec306fc57824d
Refs: #3006
diff --git a/src/name-component.cpp b/src/name-component.cpp
index b491f2e..13005dd 100644
--- a/src/name-component.cpp
+++ b/src/name-component.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -30,7 +30,7 @@
#include "util/string-helper.hpp"
#include "util/crypto.hpp"
-#include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string/trim.hpp>
namespace ndn {
namespace name {
@@ -92,7 +92,7 @@
Component::fromEscapedString(const char* escapedString, size_t beginOffset, size_t endOffset)
{
std::string trimmedString(escapedString + beginOffset, escapedString + endOffset);
- trim(trimmedString);
+ boost::algorithm::trim(trimmedString);
if (trimmedString.compare(0, getSha256DigestUriPrefix().size(),
getSha256DigestUriPrefix()) == 0) {
diff --git a/src/name.cpp b/src/name.cpp
index f8b9a8c..ad15d08 100644
--- a/src/name.cpp
+++ b/src/name.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -26,10 +26,10 @@
#include "name.hpp"
#include "util/time.hpp"
-#include "util/string-helper.hpp"
#include "encoding/block.hpp"
#include "encoding/encoding-buffer.hpp"
+#include <boost/algorithm/string/trim.hpp>
#include <boost/functional/hash.hpp>
namespace ndn {
@@ -61,7 +61,7 @@
Name::Name(std::string uri)
{
- trim(uri);
+ boost::algorithm::trim(uri);
if (uri.empty())
return;
@@ -72,7 +72,7 @@
if (iFirstSlash == std::string::npos || iColon < iFirstSlash) {
// Omit the leading protocol such as ndn:
uri.erase(0, iColon + 1);
- trim(uri);
+ boost::algorithm::trim(uri);
}
}
@@ -86,12 +86,12 @@
return;
else {
uri.erase(0, iAfterAuthority + 1);
- trim(uri);
+ boost::algorithm::trim(uri);
}
}
else {
uri.erase(0, 1);
- trim(uri);
+ boost::algorithm::trim(uri);
}
}
diff --git a/src/util/string-helper.cpp b/src/util/string-helper.cpp
index 44083b3..4a4808f 100644
--- a/src/util/string-helper.cpp
+++ b/src/util/string-helper.cpp
@@ -20,14 +20,13 @@
*/
#include "string-helper.hpp"
+#include "../encoding/buffer.hpp"
#include "../encoding/buffer-stream.hpp"
#include "../security/transform/buffer-source.hpp"
#include "../security/transform/hex-decode.hpp"
#include "../security/transform/hex-encode.hpp"
#include "../security/transform/stream-sink.hpp"
-#include <boost/algorithm/string/trim.hpp>
-
#include <sstream>
#include <iomanip>
@@ -109,24 +108,6 @@
return os.buf();
}
-void
-trimLeft(std::string& str)
-{
- boost::algorithm::trim_left(str);
-}
-
-void
-trimRight(std::string& str)
-{
- boost::algorithm::trim_right(str);
-}
-
-void
-trim(std::string& str)
-{
- boost::algorithm::trim(str);
-}
-
std::string
unescape(const std::string& str)
{
diff --git a/src/util/string-helper.hpp b/src/util/string-helper.hpp
index 7785f69..3f1a303 100644
--- a/src/util/string-helper.hpp
+++ b/src/util/string-helper.hpp
@@ -23,10 +23,11 @@
#define NDN_UTIL_STRING_HELPER_HPP
#include "../common.hpp"
-#include "../encoding/buffer.hpp"
namespace ndn {
+class Buffer;
+
class StringHelperError : public std::invalid_argument
{
public:
@@ -111,24 +112,6 @@
fromHex(const std::string& hexString);
/**
- * @brief Modify str in place to erase whitespace on the left
- */
-void
-trimLeft(std::string& str);
-
-/**
- * @brief Modify str in place to erase whitespace on the right
- */
-void
-trimRight(std::string& str);
-
-/**
- * @brief Modify str in place to erase whitespace on the left and right
- */
-void
-trim(std::string& str);
-
-/**
* @brief Decode a percent-encoded string
* @see RFC 3986 section 2
*