From ccddf4c9f5830d5c7b9e35d000f9e6eec5b0fdec Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 8 Nov 2018 15:32:13 -0800 Subject: C++17: use android::base::Trim instead of std::not1/std::ptr_fun. These were deprecated in C++14 and removed in C++17. (Sadly we don't give deprecation warnings.) This code is already using libbase, so just switch over. Bug: http://b/111067277 Test: builds Change-Id: I5f884aa4d8d6b5d559e14323b1a647cc45cdad9f --- .../vr/performanced/performance_service_tests.cpp | 4 +- services/vr/performanced/string_trim.h | 46 ---------------------- services/vr/performanced/task.cpp | 8 ++-- 3 files changed, 6 insertions(+), 52 deletions(-) delete mode 100644 services/vr/performanced/string_trim.h diff --git a/services/vr/performanced/performance_service_tests.cpp b/services/vr/performanced/performance_service_tests.cpp index 4065785426..a24c88979a 100644 --- a/services/vr/performanced/performance_service_tests.cpp +++ b/services/vr/performanced/performance_service_tests.cpp @@ -12,16 +12,16 @@ #include #include +#include #include #include #include #include #include "stdio_filebuf.h" -#include "string_trim.h" #include "unique_file.h" -using android::dvr::Trim; +using android::base::Trim; using android::dvr::UniqueFile; using android::dvr::stdio_filebuf; diff --git a/services/vr/performanced/string_trim.h b/services/vr/performanced/string_trim.h deleted file mode 100644 index 7094e9fdf8..0000000000 --- a/services/vr/performanced/string_trim.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef ANDROID_DVR_PERFORMANCED_STRING_TRIM_H_ -#define ANDROID_DVR_PERFORMANCED_STRING_TRIM_H_ - -#include -#include -#include - -namespace android { -namespace dvr { - -// Trims whitespace from the left side of |subject| and returns the result as a -// new string. -inline std::string LeftTrim(std::string subject) { - subject.erase(subject.begin(), - std::find_if(subject.begin(), subject.end(), - std::not1(std::ptr_fun(std::isspace)))); - return subject; -} - -// Trims whitespace from the right side of |subject| and returns the result as a -// new string. -inline std::string RightTrim(std::string subject) { - subject.erase(std::find_if(subject.rbegin(), subject.rend(), - std::not1(std::ptr_fun(std::isspace))) - .base(), - subject.end()); - return subject; -} - -// Trims whitespace from the both sides of |subject| and returns the result as a -// new string. -inline std::string Trim(std::string subject) { - subject.erase(subject.begin(), - std::find_if(subject.begin(), subject.end(), - std::not1(std::ptr_fun(std::isspace)))); - subject.erase(std::find_if(subject.rbegin(), subject.rend(), - std::not1(std::ptr_fun(std::isspace))) - .base(), - subject.end()); - return subject; -} - -} // namespace dvr -} // namespace android - -#endif // ANDROID_DVR_PERFORMANCED_STRING_TRIM_H_ diff --git a/services/vr/performanced/task.cpp b/services/vr/performanced/task.cpp index bda1682331..2fc96bf3f5 100644 --- a/services/vr/performanced/task.cpp +++ b/services/vr/performanced/task.cpp @@ -10,10 +10,10 @@ #include #include +#include #include #include "stdio_filebuf.h" -#include "string_trim.h" namespace { @@ -102,7 +102,7 @@ std::string Task::GetStatusField(const std::string& field) const { // The status file has lines with the format :. Extract the // value after the colon. - return Trim(line.substr(offset + field.size() + 1)); + return android::base::Trim(line.substr(offset + field.size() + 1)); } } @@ -123,7 +123,7 @@ void Task::ReadStatusFields() { } std::string key = line.substr(0, offset); - std::string value = Trim(line.substr(offset + 1)); + std::string value = android::base::Trim(line.substr(offset + 1)); ALOGD_IF(TRACE, "Task::ReadStatusFields: key=\"%s\" value=\"%s\"", key.c_str(), value.c_str()); @@ -156,7 +156,7 @@ std::string Task::GetCpuSetPath() const { std::string line = ""; std::getline(file_stream, line); - return Trim(line); + return android::base::Trim(line); } else { return ""; } -- cgit v1.2.3-59-g8ed1b