Bump to WebRTC M120 release
Some API deprecation -- ExperimentalAgc and ExperimentalNs are gone. We're continuing to carry iSAC even though it's gone upstream, but maybe we'll want to drop that soon.
This commit is contained in:
@ -11,11 +11,11 @@
|
||||
#ifndef RTC_BASE_STRING_UTILS_H_
|
||||
#define RTC_BASE_STRING_UTILS_H_
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
#include <malloc.h>
|
||||
#include <wchar.h>
|
||||
@ -30,15 +30,26 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
namespace rtc {
|
||||
|
||||
const size_t SIZE_UNKNOWN = static_cast<size_t>(-1);
|
||||
|
||||
// An absl::string_view comparator functor for use with container types such as
|
||||
// std::map that support heterogenous lookup.
|
||||
//
|
||||
// Example usage:
|
||||
// std::map<std::string, int, rtc::AbslStringViewCmp> my_map;
|
||||
struct AbslStringViewCmp {
|
||||
using is_transparent = void;
|
||||
bool operator()(absl::string_view a, absl::string_view b) const {
|
||||
return a < b;
|
||||
}
|
||||
};
|
||||
|
||||
// Safe version of strncpy that always nul-terminate.
|
||||
size_t strcpyn(char* buffer,
|
||||
size_t buflen,
|
||||
const char* source,
|
||||
size_t srclen = SIZE_UNKNOWN);
|
||||
size_t strcpyn(char* buffer, size_t buflen, absl::string_view source);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// UTF helpers (Windows only)
|
||||
@ -57,7 +68,7 @@ inline std::wstring ToUtf16(const char* utf8, size_t len) {
|
||||
return ws;
|
||||
}
|
||||
|
||||
inline std::wstring ToUtf16(const std::string& str) {
|
||||
inline std::wstring ToUtf16(absl::string_view str) {
|
||||
return ToUtf16(str.data(), str.length());
|
||||
}
|
||||
|
||||
@ -82,11 +93,45 @@ 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(const int i);
|
||||
std::string ToHex(int i);
|
||||
|
||||
// CompileTimeString comprises of a string-like object which can be used as a
|
||||
// regular const char* in compile time and supports concatenation. Useful for
|
||||
// concatenating constexpr strings in for example macro declarations.
|
||||
namespace rtc_base_string_utils_internal {
|
||||
template <int NPlus1>
|
||||
struct CompileTimeString {
|
||||
char string[NPlus1] = {0};
|
||||
constexpr CompileTimeString() = default;
|
||||
template <int MPlus1>
|
||||
explicit constexpr CompileTimeString(const char (&chars)[MPlus1]) {
|
||||
char* chars_pointer = string;
|
||||
for (auto c : chars)
|
||||
*chars_pointer++ = c;
|
||||
}
|
||||
template <int MPlus1>
|
||||
constexpr auto Concat(CompileTimeString<MPlus1> b) {
|
||||
CompileTimeString<NPlus1 + MPlus1 - 1> result;
|
||||
char* chars_pointer = result.string;
|
||||
for (auto c : string)
|
||||
*chars_pointer++ = c;
|
||||
chars_pointer = result.string + NPlus1 - 1;
|
||||
for (auto c : b.string)
|
||||
*chars_pointer++ = c;
|
||||
result.string[NPlus1 + MPlus1 - 2] = 0;
|
||||
return result;
|
||||
}
|
||||
constexpr operator const char*() { return string; }
|
||||
};
|
||||
} // namespace rtc_base_string_utils_internal
|
||||
|
||||
// Makes a constexpr CompileTimeString<X> without having to specify X
|
||||
// explicitly.
|
||||
template <int N>
|
||||
constexpr auto MakeCompileTimeString(const char (&a)[N]) {
|
||||
return rtc_base_string_utils_internal::CompileTimeString<N>(a);
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
|
Reference in New Issue
Block a user