37constexpr char hexdigit(
unsigned X,
bool LowerCase =
false) noexcept {
38 const char HexChar = LowerCase ?
'a' :
'A';
39 return X < 10 ?
'0' + X : HexChar + X - 10;
47 if (C >=
'0' && C <=
'9') {
50 if (C >=
'a' && C <=
'f') {
53 if (C >=
'A' && C <=
'F') {
61 return C >=
'0' && C <=
'9';
71 return (
'a' <= C && C <=
'z') || (
'A' <= C && C <=
'Z');
82 return static_cast<unsigned char>(C) <= 127;
90 unsigned char UC =
static_cast<unsigned char>(C);
91 return (0x20 <= UC) && (UC <= 0x7E);
96 if (x >=
'A' && x <=
'Z') {
104 if (x >=
'a' && x <=
'z') {
105 return x -
'a' +
'A';
111 bool lowerCase =
false) {
113 char* bufptr = std::end(buf);
120 unsigned char mod =
static_cast<unsigned char>(val) & 15;
125 return std::string(bufptr, std::end(buf));
133 auto length = lhs.size();
134 return length == rhs.size() && std::string_view::traits_type::compare(
135 lhs.data(), rhs.data(), length) == 0;
148 return lhs.size() == rhs.size() &&
compare_lower(lhs, rhs) == 0;
159 std::string_view::size_type
from = 0) noexcept;
191 std::string_view::size_type
from = std::string_view::npos)
noexcept;
209 const char* other)
noexcept {
226 std::string_view::size_type n = std::string_view::npos)
noexcept {
227 auto length = str.size();
229 return {str.data() + start, (
std::min)(n, length - start)};
237 return substr(str, 0, prefix.size()) == prefix;
244 return !str.empty() && std::string_view::traits_type::eq(str.front(), prefix);
270 const char* prefix)
noexcept {
279 return str.size() >= suffix.size() &&
280 str.compare(str.size() - suffix.size(), std::string_view::npos,
288 return !str.empty() && std::string_view::traits_type::eq(str.back(), suffix);
321 return str.find(other) != std::string_view::npos;
328 return str.find(ch) != std::string_view::npos;
335 return str.find(other) != std::string_view::npos;
343 return find_lower(str, other) != std::string_view::npos;
350 return find_lower(str, ch) != std::string_view::npos;
357 return find_lower(str, other) != std::string_view::npos;
366 str.remove_prefix(n);
375 str.remove_suffix(n);
386 auto length = str.size();
400 auto length = str.size();
421 std::string_view::size_type start,
422 std::string_view::size_type end)
noexcept {
423 auto length = str.size();
426 return {str.data() + start, end - start};
441constexpr std::pair<std::string_view, std::string_view>
split(
443 auto idx = str.find(separator);
444 if (idx == std::string_view::npos) {
447 return {
slice(str, 0, idx),
slice(str, idx + 1, std::string_view::npos)};
462constexpr std::pair<std::string_view, std::string_view>
split(
464 auto idx = str.find(separator);
465 if (idx == std::string_view::npos) {
468 return {
slice(str, 0, idx),
469 slice(str, idx + separator.size(), std::string_view::npos)};
484constexpr std::pair<std::string_view, std::string_view>
rsplit(
486 auto idx = str.rfind(separator);
487 if (idx == std::string_view::npos) {
490 return {
slice(str, 0, idx),
slice(str, idx + 1, std::string_view::npos)};
505constexpr std::pair<std::string_view, std::string_view>
rsplit(
507 auto idx = str.rfind(separator);
508 if (idx == std::string_view::npos) {
511 return {
slice(str, 0, idx),
512 slice(str, idx + separator.size(), std::string_view::npos)};
533 bool keepEmpty =
true) noexcept;
553 char separator,
int maxSplit = -1,
bool keepEmpty = true) noexcept;
578 str, str.size() - (
std::min)(str.size(), str.find_last_not_of(ch) + 1));
589 str.size() - (
std::min)(str.size(), str.find_last_not_of(chars) + 1));
612 unsigned long long& result)
noexcept;
614 long long& result)
noexcept;
618 unsigned long long& result)
noexcept;
620 long long& result)
noexcept;
635 unsigned radix)
noexcept {
638 static_cast<T
>(val) != val) {
647 unsigned radix)
noexcept {
648 using Int =
unsigned long long;
654 static_cast<Int
>(
static_cast<T
>(val)) != val) {
674 unsigned radix)
noexcept {
675 using Int =
long long;
678 static_cast<Int
>(
static_cast<T
>(val)) != val) {
687 unsigned radix)
noexcept {
688 using Int =
unsigned long long;
691 static_cast<Int
>(
static_cast<T
>(val)) != val) {
738template <
class OutputIt,
class... Args>
740 fmt::format_string<Args...> fmt, Args&&... args) {
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable from
Definition: ThirdPartyNotices.txt:128
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:579
basic_string_view< char > string_view
Definition: core.h:501
detail namespace with internal helper functions
Definition: xchar.h:20
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_opt >::value > is_signed
Definition: format.h:811
T mod(T x, int y)
Definition: chrono.h:1605
UnitTypeLhs() max(const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
Definition: base.h:3417
UnitTypeLhs() min(const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
Definition: base.h:3409
bool GetAsSignedInteger(std::string_view str, unsigned radix, long long &result) noexcept
bool ConsumeUnsignedInteger(std::string_view &str, unsigned radix, unsigned long long &result) noexcept
bool GetAsUnsignedInteger(std::string_view str, unsigned radix, unsigned long long &result) noexcept
bool ConsumeSignedInteger(std::string_view &str, unsigned radix, long long &result) noexcept
Definition: ntcore_cpp.h:26
constexpr char hexdigit(unsigned X, bool LowerCase=false) noexcept
hexdigit - Return the hexadecimal character for the given number X (which should be less than 16).
Definition: StringExtras.h:37
constexpr std::string_view slice(std::string_view str, std::string_view::size_type start, std::string_view::size_type end) noexcept
Returns a reference to the substring of str from [start, end).
Definition: StringExtras.h:420
constexpr std::pair< std::string_view, std::string_view > split(std::string_view str, char separator) noexcept
Splits str into two substrings around the first occurrence of a separator character.
Definition: StringExtras.h:441
int compare_lower(std::string_view lhs, std::string_view rhs) noexcept
compare_lower - Compare two strings, ignoring case.
constexpr std::string_view ltrim(std::string_view str, char ch) noexcept
Returns str with consecutive ch characters starting from the the left removed.
Definition: StringExtras.h:559
constexpr std::span< T > drop_back(std::span< T, N > in, typename std::span< T >::size_type n=1)
Drop the last N elements of the array.
Definition: SpanExtras.h:22
constexpr std::span< T > drop_front(std::span< T, N > in, typename std::span< T >::size_type n=1)
Drop the first N elements of the array.
Definition: SpanExtras.h:14
std::optional< double > parse_float< double >(std::string_view str) noexcept
constexpr bool isAlnum(char C) noexcept
Checks whether character C is either a decimal digit or an uppercase or lowercase letter as classifie...
Definition: StringExtras.h:76
std::optional< T > consume_integer(std::string_view *str, unsigned radix) noexcept
Parses the string str as an integer of the specified radix.
Definition: StringExtras.h:673
std::string_view::size_type find_lower(std::string_view str, char ch, std::string_view::size_type from=0) noexcept
Search for the first character ch in str, ignoring case.
constexpr bool isHexDigit(char C) noexcept
Checks if character C is a hexadecimal numeric character.
Definition: StringExtras.h:65
constexpr bool isDigit(char C) noexcept
Checks if character C is one of the 10 decimal digits.
Definition: StringExtras.h:60
std::optional< T > parse_integer(std::string_view str, unsigned radix) noexcept
Parses the string str as an integer of the specified radix.
Definition: StringExtras.h:634
constexpr unsigned hexDigitValue(char C) noexcept
Interpret the given character C as a hexadecimal digit and return its value.
Definition: StringExtras.h:46
constexpr char toLower(char x) noexcept
Returns the corresponding lowercase character if x is uppercase.
Definition: StringExtras.h:95
constexpr std::string_view trim(std::string_view str, char ch) noexcept
Returns str with consecutive ch characters starting from the left and right removed.
Definition: StringExtras.h:596
constexpr char toUpper(char x) noexcept
Returns the corresponding uppercase character if x is lowercase.
Definition: StringExtras.h:103
constexpr std::span< T > take_front(std::span< T, N > in, typename std::span< T >::size_type n=1)
Returns a span equal to in but with only the first n elements remaining.
Definition: SpanExtras.h:34
constexpr bool contains(std::string_view str, std::string_view other) noexcept
Checks if str contains the substring other.
Definition: StringExtras.h:320
bool ends_with_lower(std::string_view str, std::string_view suffix) noexcept
Checks if str ends with the given suffix, ignoring case.
std::string_view::size_type rfind_lower(std::string_view str, char ch, std::string_view::size_type from=std::string_view::npos) noexcept
Search for the last character ch in str, ignoring case.
bool starts_with_lower(std::string_view str, std::string_view prefix) noexcept
Checks if str starts with the given prefix, ignoring case.
constexpr bool equals_lower(std::string_view lhs, std::string_view rhs) noexcept
equals_lower - Check for string equality, ignoring case.
Definition: StringExtras.h:146
std::optional< long double > parse_float< long double >(std::string_view str) noexcept
constexpr std::pair< std::string_view, std::string_view > rsplit(std::string_view str, char separator) noexcept
Splits str into two substrings around the last occurrence of a separator character.
Definition: StringExtras.h:484
constexpr std::string_view substr(std::string_view str, std::string_view::size_type start, std::string_view::size_type n=std::string_view::npos) noexcept
Returns the substring of str from [start, start + n).
Definition: StringExtras.h:224
constexpr bool equals(std::string_view lhs, std::string_view rhs) noexcept
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
Definition: StringExtras.h:132
constexpr bool isPrint(char C) noexcept
Checks whether character C is printable.
Definition: StringExtras.h:89
constexpr std::span< T > take_back(std::span< T, N > in, typename std::span< T >::size_type n=1)
Returns a span equal to in but with only the last n elements remaining.
Definition: SpanExtras.h:49
std::pair< std::string_view, std::string_view > UnescapeCString(std::string_view str, SmallVectorImpl< char > &buf)
Unescapes a C-style string (reverse operation to raw_ostream::write_escaped).
void format_to_n_c_str(OutputIt out, std::iter_difference_t< OutputIt > n, fmt::format_string< Args... > fmt, Args &&... args)
Like std::format_to_n() in that it writes at most n bytes to the output buffer, but also includes a t...
Definition: StringExtras.h:739
constexpr bool isASCII(char C) noexcept
Checks whether character C is valid ASCII (high bit is zero).
Definition: StringExtras.h:81
constexpr bool isAlpha(char C) noexcept
Checks if character C is a valid letter as classified by "C" locale.
Definition: StringExtras.h:70
constexpr std::string_view rtrim(std::string_view str, char ch) noexcept
Returns str with consecutive Char characters starting from the right removed.
Definition: StringExtras.h:576
std::optional< T > parse_float(std::string_view str) noexcept
Parses the string str as a floating point value.
constexpr bool ends_with(std::string_view str, std::string_view suffix) noexcept
Checks if str ends with the given suffix.
Definition: StringExtras.h:277
std::string utohexstr(unsigned long long val, bool lowerCase=false)
Definition: StringExtras.h:110
std::optional< float > parse_float< float >(std::string_view str) noexcept
constexpr bool starts_with(std::string_view str, std::string_view prefix) noexcept
Checks if str starts with the given prefix.
Definition: StringExtras.h:235
bool contains_lower(std::string_view str, std::string_view other) noexcept
Checks if str contains the substring other, ignoring case.
Definition: StringExtras.h:341
auto format_to_n(OutputIt out, size_t n, const S &fmt, T &&... args) -> format_to_n_result< OutputIt >
Definition: xchar.h:204