Delete rtc::string_trim. Replaced with absl::StripAsciiWhitespace.
Bug: webrtc:6424, webrtc:13579 Change-Id: I222e1bfb62d5f1f1a2c74e5fce1038e04e7bebfb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/255824 Reviewed-by: Ali Tofigh <alito@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36234}
This commit is contained in:
parent
c367346a75
commit
658b88a48e
@ -9,11 +9,14 @@
|
||||
*/
|
||||
|
||||
#include "modules/desktop_capture/win/full_screen_win_application_handler.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cwctype>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/ascii.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "modules/desktop_capture/win/screen_capture_utils.h"
|
||||
#include "modules/desktop_capture/win/window_capture_utils.h"
|
||||
@ -145,7 +148,8 @@ class FullScreenPowerPointHandler : public FullScreenApplicationHandler {
|
||||
std::string GetDocumentFromEditorTitle(HWND window) const {
|
||||
std::string title = WindowText(window);
|
||||
auto position = title.find(kDocumentTitleSeparator);
|
||||
return rtc::string_trim(title.substr(0, position));
|
||||
return std::string(absl::StripAsciiWhitespace(
|
||||
absl::string_view(title).substr(0, position)));
|
||||
}
|
||||
|
||||
std::string GetDocumentFromSlideShowTitle(HWND window) const {
|
||||
@ -158,12 +162,13 @@ class FullScreenPowerPointHandler : public FullScreenApplicationHandler {
|
||||
|
||||
if (right_pos > left_pos + kSeparatorLength) {
|
||||
auto result_len = right_pos - left_pos - kSeparatorLength;
|
||||
auto document = title.substr(left_pos + kSeparatorLength, result_len);
|
||||
return rtc::string_trim(document);
|
||||
auto document = absl::string_view(title).substr(
|
||||
left_pos + kSeparatorLength, result_len);
|
||||
return std::string(absl::StripAsciiWhitespace(document));
|
||||
} else {
|
||||
auto document =
|
||||
title.substr(left_pos + kSeparatorLength, std::wstring::npos);
|
||||
return rtc::string_trim(document);
|
||||
auto document = absl::string_view(title).substr(
|
||||
left_pos + kSeparatorLength, std::wstring::npos);
|
||||
return std::string(absl::StripAsciiWhitespace(document));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/strings/ascii.h"
|
||||
#include "api/candidate.h"
|
||||
#include "api/crypto_params.h"
|
||||
#include "api/jsep_ice_candidate.h"
|
||||
@ -349,7 +350,7 @@ static bool ParseFmtpAttributes(const std::string& line,
|
||||
const cricket::MediaType media_type,
|
||||
MediaContentDescription* media_desc,
|
||||
SdpParseError* error);
|
||||
static bool ParseFmtpParam(const std::string& line,
|
||||
static bool ParseFmtpParam(absl::string_view line,
|
||||
std::string* parameter,
|
||||
std::string* value,
|
||||
SdpParseError* error);
|
||||
@ -3643,14 +3644,14 @@ bool ParseRtpmapAttribute(const std::string& line,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParseFmtpParam(const std::string& line,
|
||||
bool ParseFmtpParam(absl::string_view line,
|
||||
std::string* parameter,
|
||||
std::string* value,
|
||||
SdpParseError* error) {
|
||||
if (!rtc::tokenize_first(line, kSdpDelimiterEqualChar, parameter, value)) {
|
||||
// Support for non-key-value lines like RFC 2198 or RFC 4733.
|
||||
*parameter = "";
|
||||
*value = line;
|
||||
*value = std::string(line);
|
||||
return true;
|
||||
}
|
||||
// a=fmtp:<payload_type> <param1>=<value1>; <param2>=<value2>; ...
|
||||
@ -3693,14 +3694,13 @@ bool ParseFmtpAttributes(const std::string& line,
|
||||
}
|
||||
|
||||
// Parse out format specific parameters.
|
||||
std::vector<std::string> fields;
|
||||
rtc::split(line_params, kSdpDelimiterSemicolonChar, &fields);
|
||||
|
||||
cricket::CodecParameterMap codec_params;
|
||||
for (auto& iter : fields) {
|
||||
for (absl::string_view param :
|
||||
rtc::split(line_params, kSdpDelimiterSemicolonChar)) {
|
||||
std::string name;
|
||||
std::string value;
|
||||
if (!ParseFmtpParam(rtc::string_trim(iter), &name, &value, error)) {
|
||||
if (!ParseFmtpParam(absl::StripAsciiWhitespace(param), &name, &value,
|
||||
error)) {
|
||||
return false;
|
||||
}
|
||||
if (codec_params.find(name) != codec_params.end()) {
|
||||
|
||||
@ -30,19 +30,6 @@ size_t strcpyn(char* buffer,
|
||||
return srclen;
|
||||
}
|
||||
|
||||
static const char kWhitespace[] = " \n\r\t";
|
||||
|
||||
std::string string_trim(const std::string& s) {
|
||||
std::string::size_type first = s.find_first_not_of(kWhitespace);
|
||||
std::string::size_type last = s.find_last_not_of(kWhitespace);
|
||||
|
||||
if (first == std::string::npos || last == std::string::npos) {
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
return s.substr(first, last - first + 1);
|
||||
}
|
||||
|
||||
std::string ToHex(const int i) {
|
||||
char buffer[50];
|
||||
snprintf(buffer, sizeof(buffer), "%x", i);
|
||||
|
||||
@ -82,9 +82,6 @@ inline std::string ToUtf8(const std::wstring& wstr) {
|
||||
|
||||
#endif // WEBRTC_WIN
|
||||
|
||||
// Remove leading and trailing whitespaces.
|
||||
std::string string_trim(const std::string& s);
|
||||
|
||||
// TODO(jonasolsson): replace with absl::Hex when that becomes available.
|
||||
std::string ToHex(int i);
|
||||
|
||||
|
||||
@ -14,14 +14,6 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
TEST(string_trim_Test, Trimming) {
|
||||
EXPECT_EQ("temp", string_trim("\n\r\t temp \n\r\t"));
|
||||
EXPECT_EQ("temp\n\r\t temp", string_trim(" temp\n\r\t temp "));
|
||||
EXPECT_EQ("temp temp", string_trim("temp temp"));
|
||||
EXPECT_EQ("", string_trim(" \r\n\t"));
|
||||
EXPECT_EQ("", string_trim(""));
|
||||
}
|
||||
|
||||
TEST(string_toHexTest, ToHex) {
|
||||
EXPECT_EQ(ToHex(0), "0");
|
||||
EXPECT_EQ(ToHex(0X1243E), "1243e");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user