adopt absl::string_view in rtc_base/third_party/
Bug: webrtc:13579 Change-Id: Ic0c4843f09f168b158f41df79b211ac9f7f1c3cd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/259301 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Ali Tofigh <alito@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36591}
This commit is contained in:
parent
098c4ea2ca
commit
22d094d4c9
1
rtc_base/third_party/base64/BUILD.gn
vendored
1
rtc_base/third_party/base64/BUILD.gn
vendored
@ -18,4 +18,5 @@ rtc_library("base64") {
|
||||
"../..:checks",
|
||||
"../../system:rtc_export",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
|
||||
}
|
||||
|
||||
3
rtc_base/third_party/base64/base64.cc
vendored
3
rtc_base/third_party/base64/base64.cc
vendored
@ -18,6 +18,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "rtc_base/checks.h"
|
||||
|
||||
using std::vector;
|
||||
@ -85,7 +86,7 @@ bool Base64::GetNextBase64Char(char ch, char* next_ch) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Base64::IsBase64Encoded(const std::string& str) {
|
||||
bool Base64::IsBase64Encoded(absl::string_view str) {
|
||||
for (size_t i = 0; i < str.size(); ++i) {
|
||||
if (!IsBase64Char(str.at(i)))
|
||||
return false;
|
||||
|
||||
11
rtc_base/third_party/base64/base64.h
vendored
11
rtc_base/third_party/base64/base64.h
vendored
@ -15,6 +15,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "rtc_base/system/rtc_export.h"
|
||||
|
||||
namespace rtc {
|
||||
@ -56,7 +57,7 @@ class Base64 {
|
||||
|
||||
// Determines whether the given string consists entirely of valid base64
|
||||
// encoded characters.
|
||||
static bool IsBase64Encoded(const std::string& str);
|
||||
static bool IsBase64Encoded(absl::string_view str);
|
||||
|
||||
RTC_EXPORT static void EncodeFromArray(const void* data,
|
||||
size_t len,
|
||||
@ -78,23 +79,23 @@ class Base64 {
|
||||
size_t* data_used);
|
||||
|
||||
// Convenience Methods
|
||||
static inline std::string Encode(const std::string& data) {
|
||||
static inline std::string Encode(absl::string_view data) {
|
||||
std::string result;
|
||||
EncodeFromArray(data.data(), data.size(), &result);
|
||||
return result;
|
||||
}
|
||||
static inline std::string Decode(const std::string& data, DecodeFlags flags) {
|
||||
static inline std::string Decode(absl::string_view data, DecodeFlags flags) {
|
||||
std::string result;
|
||||
DecodeFromArray(data.data(), data.size(), flags, &result, nullptr);
|
||||
return result;
|
||||
}
|
||||
static inline bool Decode(const std::string& data,
|
||||
static inline bool Decode(absl::string_view data,
|
||||
DecodeFlags flags,
|
||||
std::string* result,
|
||||
size_t* data_used) {
|
||||
return DecodeFromArray(data.data(), data.size(), flags, result, data_used);
|
||||
}
|
||||
static inline bool Decode(const std::string& data,
|
||||
static inline bool Decode(absl::string_view data,
|
||||
DecodeFlags flags,
|
||||
std::vector<char>* result,
|
||||
size_t* data_used) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user