/* * Copyright 2004 The WebRTC Project Authors. All rights reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// 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; booloperator()(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, absl::string_view source);
// TODO(jonasolsson): replace with absl::Hex when that becomes available.
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(constchar (&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 operatorconstchar*() { 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(constchar (&a)[N]) { return rtc_base_string_utils_internal::CompileTimeString<N>(a);
}
} // namespace rtc
#endif// RTC_BASE_STRING_UTILS_H_
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.