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') {
56 return (std::numeric_limits<unsigned>::max)();
61 return C >=
'0' && C <=
'9';
66 return hexDigitValue(C) != (std::numeric_limits<unsigned>::max)();
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));
132constexpr bool equals(std::string_view lhs, std::string_view rhs)
noexcept {
133 auto length = lhs.size();
135 lhs.data(), rhs.data(), length) == 0;
147 std::string_view rhs)
noexcept {
148 return lhs.size() == rhs.size() &&
compare_lower(lhs, rhs) == 0;
158 std::string_view str,
char ch,
159 std::string_view::size_type
from = 0) noexcept;
190 std::string_view str,
char ch,
191 std::string_view::size_type
from = std::string_view::npos)
noexcept;
200 std::string_view other)
noexcept;
208inline std::string_view::size_type
rfind_lower(std::string_view str,
209 const char* other)
noexcept {
225 std::string_view str, std::string_view::size_type start,
226 std::string_view::size_type n = std::string_view::npos)
noexcept {
227 auto length = str.size();
228 start = (std::min)(start, length);
229 return {str.data() + start, (std::min)(n, length - start)};
236 std::string_view prefix)
noexcept {
237 return substr(str, 0, prefix.size()) == prefix;
243constexpr bool starts_with(std::string_view str,
char prefix)
noexcept {
244 return !str.empty() && std::string_view::traits_type::eq(str.front(), prefix);
250constexpr bool starts_with(std::string_view str,
const char* prefix)
noexcept {
270 const char* prefix)
noexcept {
278 std::string_view suffix)
noexcept {
279 return str.size() >= suffix.size() &&
280 str.compare(str.size() - suffix.size(), std::string_view::npos,
287constexpr bool ends_with(std::string_view str,
char suffix)
noexcept {
288 return !str.empty() && std::string_view::traits_type::eq(str.back(), suffix);
294constexpr bool ends_with(std::string_view str,
const char* suffix)
noexcept {
295 return ends_with(str, std::string_view(suffix));
320constexpr bool contains(std::string_view str, std::string_view other)
noexcept {
321 return str.find(other) != std::string_view::npos;
327constexpr bool contains(std::string_view str,
char ch)
noexcept {
328 return str.find(ch) != std::string_view::npos;
334constexpr bool contains(std::string_view str,
const char* other)
noexcept {
335 return str.find(other) != std::string_view::npos;
342 std::string_view other)
noexcept {
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;
365constexpr std::optional<std::string_view>
remove_prefix(std::string_view str, std::string_view prefix)
noexcept {
366 if (str.starts_with(prefix)) {
367 str.remove_prefix(prefix.size());
378constexpr std::optional<std::string_view>
remove_suffix(std::string_view str, std::string_view suffix)
noexcept {
379 if (str.ends_with(suffix)) {
380 str.remove_suffix(suffix.size());
391 std::string_view str, std::string_view::size_type n = 1) noexcept {
400 std::string_view str, std::string_view::size_type n = 1) noexcept {
401 str.remove_suffix(n);
411 std::string_view str, std::string_view::size_type n = 1) noexcept {
412 auto length = str.size();
425 std::string_view str, std::string_view::size_type n = 1) noexcept {
426 auto length = str.size();
446constexpr std::string_view
slice(std::string_view str,
447 std::string_view::size_type start,
448 std::string_view::size_type end)
noexcept {
449 auto length = str.size();
450 start = (std::min)(start, length);
451 end = (std::min)((std::max)(start, end), length);
452 return {str.data() + start, end - start};
467constexpr std::pair<std::string_view, std::string_view>
split(
468 std::string_view str,
char separator)
noexcept {
469 auto idx = str.find(separator);
470 if (idx == std::string_view::npos) {
473 return {
slice(str, 0, idx),
slice(str, idx + 1, std::string_view::npos)};
488constexpr std::pair<std::string_view, std::string_view>
split(
489 std::string_view str, std::string_view separator)
noexcept {
490 auto idx = str.find(separator);
491 if (idx == std::string_view::npos) {
494 return {
slice(str, 0, idx),
495 slice(str, idx + separator.size(), std::string_view::npos)};
510constexpr std::pair<std::string_view, std::string_view>
rsplit(
511 std::string_view str,
char separator)
noexcept {
512 auto idx = str.rfind(separator);
513 if (idx == std::string_view::npos) {
516 return {
slice(str, 0, idx),
slice(str, idx + 1, std::string_view::npos)};
531constexpr std::pair<std::string_view, std::string_view>
rsplit(
532 std::string_view str, std::string_view separator)
noexcept {
533 auto idx = str.rfind(separator);
534 if (idx == std::string_view::npos) {
537 return {
slice(str, 0, idx),
538 slice(str, idx + separator.size(), std::string_view::npos)};
558 std::string_view separator,
int maxSplit = -1,
559 bool keepEmpty =
true) noexcept;
579 char separator,
int maxSplit = -1,
bool keepEmpty = true) noexcept;
586 return drop_front(str, (std::min)(str.size(), str.find_first_not_of(ch)));
594 std::string_view str, std::string_view chars =
" \t\n\v\f\r") noexcept {
595 return drop_front(str, (std::min)(str.size(), str.find_first_not_of(chars)));
602constexpr std::string_view
rtrim(std::string_view str,
char ch)
noexcept {
604 str, str.size() - (std::min)(str.size(), str.find_last_not_of(ch) + 1));
612 std::string_view str, std::string_view chars =
" \t\n\v\f\r") noexcept {
615 str.size() - (std::min)(str.size(), str.find_last_not_of(chars) + 1));
622constexpr std::string_view
trim(std::string_view str,
char ch)
noexcept {
630constexpr std::string_view
trim(
631 std::string_view str, std::string_view chars =
" \t\n\v\f\r") noexcept {
637 std::string_view str,
unsigned radix,
638 unsigned long long& result)
noexcept;
640 long long& result)
noexcept;
643 std::string_view& str,
unsigned radix,
644 unsigned long long& result)
noexcept;
646 long long& result)
noexcept;
659 std::enable_if_t<std::numeric_limits<T>::is_signed,
bool> =
true>
661 unsigned radix)
noexcept {
664 static_cast<T
>(val) != val) {
671 std::enable_if_t<!std::numeric_limits<T>::is_signed,
bool> =
true>
673 unsigned radix)
noexcept {
674 using Int =
unsigned long long;
680 static_cast<Int
>(
static_cast<T
>(val)) != val) {
683 return static_cast<T
>(val);
698 std::enable_if_t<std::numeric_limits<T>::is_signed,
bool> =
true>
700 unsigned radix)
noexcept {
701 using Int =
long long;
704 static_cast<Int
>(
static_cast<T
>(val)) != val) {
711 std::enable_if_t<!std::numeric_limits<T>::is_signed,
bool> =
true>
713 unsigned radix)
noexcept {
714 using Int =
unsigned long long;
717 static_cast<Int
>(
static_cast<T
>(val)) != val) {
739 std::string_view str)
noexcept;
764template <
class OutputIt,
class... Args>
766 fmt::format_string<Args...> fmt, Args&&... args) {
768 fmt::format_to_n(out, n - 1, fmt, std::forward<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 and nanopb were all modified for use in 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:141
FMT_CONSTEXPR void remove_prefix(size_t n) noexcept
Definition base.h:558
FMT_CONSTEXPR auto compare(basic_string_view other) const -> int
Definition base.h:575
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition sha1.h:30
detail namespace with internal helper functions
Definition input_adapters.h:32
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280
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
Foonathan namespace.
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:446
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:467
int compare_lower(std::string_view lhs, std::string_view rhs) noexcept
compare_lower - Compare two strings, ignoring case.
constexpr std::optional< std::string_view > remove_prefix(std::string_view str, std::string_view prefix) noexcept
Return an optional containing str but with prefix removed if the string starts with the prefix.
Definition StringExtras.h:365
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:585
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:699
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:660
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::optional< std::string_view > remove_suffix(std::string_view str, std::string_view suffix) noexcept
Return an optional containing str but with suffix removed if the string ends with the suffix.
Definition StringExtras.h:378
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:622
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:510
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 T mod(U Numerator, V Denominator)
Returns the remainder of the Euclidean division of LHS by RHS.
Definition MathExtras.h:432
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:765
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:602
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