|
ReXGlue SDK
|
ASCII and UTF-8 text operations, the string builder and the string keys. More...
#include <algorithm>#include <cstdarg>#include <cstddef>#include <cstring>#include <filesystem>#include <format>#include <string>#include <string.h>#include <string_view>#include <utility>#include <variant>#include <vector>#include <rex/memory/endian.h>#include <rex/platform.h>#include <rex/types.h>#include <strings.h>Go to the source code of this file.
Classes | |
| class | rex::string::StringBuffer |
| struct | rex::string::StringKey |
| struct | rex::string::StringKey::Hash |
| struct | rex::string::StringKeyIgnoreCase |
| struct | rex::string::StringKeyIgnoreCase::Hash |
| struct | std::hash< rex::string::StringKey > |
| struct | std::hash< rex::string::StringKeyIgnoreCase > |
Namespaces | |
| namespace | rex |
Functions | |
| i32 | rex::string::CompareIgnoreCase (const char *string1, const char *string2) |
| i32 | rex::string::CompareIgnoreCaseN (const char *string1, const char *string2, size_t count) |
| template<typename CharT> | |
| std::basic_string_view< CharT > | rex::string::TrimLeft (std::basic_string_view< CharT > sv, std::basic_string_view< CharT > chars=kWhitespaceOf< CharT >) |
| template<typename CharT> | |
| std::basic_string_view< CharT > | rex::string::TrimRight (std::basic_string_view< CharT > sv, std::basic_string_view< CharT > chars=kWhitespaceOf< CharT >) |
| template<typename CharT> | |
| std::basic_string_view< CharT > | rex::string::Trim (std::basic_string_view< CharT > sv, std::basic_string_view< CharT > chars=kWhitespaceOf< CharT >) |
| std::string_view | rex::string::TrimLeft (std::string_view sv, std::string_view chars=kWhitespace) |
| std::string_view | rex::string::TrimRight (std::string_view sv, std::string_view chars=kWhitespace) |
| std::string_view | rex::string::Trim (std::string_view sv, std::string_view chars=kWhitespace) |
| std::string | rex::string::TrimString (std::string_view sv, std::string_view chars=kWhitespace) |
| char * | rex::string::Duplicate (const char *source) |
| size_t | rex::string::CopyTruncating (char *dest, const std::string_view source, size_t dest_buffer_count) |
| size_t | rex::string::CopyTruncating (char16_t *dest, const std::u16string_view source, size_t dest_buffer_count) |
| size_t | rex::string::CopyAndSwapTruncating (char16_t *dest, const std::u16string_view source, size_t dest_buffer_count) |
| size_t | rex::string::CopyUnterminated (char *dest, const std::string_view source, size_t dest_buffer_count) |
| std::string | rex::string::utf8_lower_ascii (const std::string_view view) |
| std::string | rex::string::utf8_upper_ascii (const std::string_view view) |
| size_t | rex::string::utf8_hash_fnv1a (const std::string_view view) |
| size_t | rex::string::utf8_hash_fnv1a_case (const std::string_view view) |
| std::vector< std::string_view > | rex::string::utf8_split (const std::string_view haystack, const std::string_view needles, bool remove_empty=false) |
| bool | rex::string::utf8_equal_z (const std::string_view left, const std::string_view right) |
| bool | rex::string::utf8_equal_case (const std::string_view left, const std::string_view right) |
| bool | rex::string::utf8_equal_case_z (const std::string_view left, const std::string_view right) |
| std::string_view::size_type | rex::string::utf8_find_any_of (const std::string_view haystack, const std::string_view needles) |
| std::string_view::size_type | rex::string::utf8_find_any_of_case (const std::string_view haystack, const std::string_view needles) |
| std::string_view::size_type | rex::string::utf8_find_first_of (const std::string_view haystack, const std::string_view needle) |
| std::string_view::size_type | rex::string::utf8_find_first_of_case (const std::string_view haystack, const std::string_view needle) |
| bool | rex::string::utf8_starts_with (const std::string_view haystack, const std::string_view needle) |
| bool | rex::string::utf8_starts_with_case (const std::string_view haystack, const std::string_view needle) |
| bool | rex::string::utf8_ends_with (const std::string_view haystack, const std::string_view needle) |
| bool | rex::string::utf8_ends_with_case (const std::string_view haystack, const std::string_view needle) |
| std::string | rex::string::ToUTF8 (const std::u16string_view source) |
| std::u16string | rex::string::ToUTF16 (const std::string_view source) |
| std::wstring | rex::string::ToWideString (const std::string_view source) |
| std::string | rex::string::ToUTF8 (const std::wstring_view source) |
| std::string | rex::string::ShiftJISToUTF8 (const std::string_view source) |
| std::string | rex::string::UTF8ToShiftJIS (const std::string_view source) |
| std::string | rex::string::PathToUTF8 (const std::filesystem::path &path) |
| std::u16string | rex::string::PathToUTF16 (const std::filesystem::path &path) |
| std::filesystem::path | rex::string::to_path (const std::string_view source) |
| std::filesystem::path | rex::string::to_path (const std::u16string_view source) |
| size_t | rex::string::utf8_count (const std::string_view view) |
Variables | |
| template<typename CharT> | |
| constexpr std::basic_string_view< CharT > | rex::string::kWhitespaceOf {detail::kWhitespaceChars<CharT>, 4} |
| constexpr std::string_view | rex::string::kWhitespace = kWhitespaceOf<char> |
ASCII and UTF-8 text operations, the string builder and the string keys.
|
inline |
Compares two NUL terminated strings, ignoring ASCII case.
|
inline |
Compares up to count characters of two strings, ignoring ASCII case.
| count | Maximum number of characters to compare. |
|
inline |
Copies a UTF-16 string into a fixed buffer, byte swapping each code unit.
| dest_buffer_count | Size of dest in code units, including the terminator. |
|
inline |
Copies a string into a fixed buffer, truncating to fit, and NUL terminates it.
| dest_buffer_count | Size of dest in characters, including the terminator. |
|
inline |
Copies a UTF-16 string into a fixed buffer, truncating to fit, and NUL terminates it.
| dest_buffer_count | Size of dest in code units, including the terminator. |
|
inline |
Copies a string into a fixed buffer, truncating to fit, without a terminator.
| dest_buffer_count | Size of dest in characters. |
|
inline |
Copies a NUL terminated string to the heap.
| std::u16string rex::string::PathToUTF16 | ( | const std::filesystem::path & | path | ) |
Converts a host path to UTF-16.
| std::string rex::string::PathToUTF8 | ( | const std::filesystem::path & | path | ) |
Converts a host path to UTF-8.
| std::string rex::string::ShiftJISToUTF8 | ( | const std::string_view | source | ) |
Converts Shift-JIS (code page 932) to UTF-8. Returns the input unchanged without the platform converter.
| source | Shift-JIS text. |
| std::filesystem::path rex::string::to_path | ( | const std::string_view | source | ) |
Builds a host path from UTF-8 text.
| source | UTF-8 path text. |
| std::filesystem::path rex::string::to_path | ( | const std::u16string_view | source | ) |
Builds a host path from UTF-16 text.
| source | UTF-16 path text. |
| std::u16string rex::string::ToUTF16 | ( | const std::string_view | source | ) |
Converts UTF-8 to UTF-16.
| source | UTF-8 text. |
| std::string rex::string::ToUTF8 | ( | const std::u16string_view | source | ) |
Converts UTF-16 to UTF-8.
| source | UTF-16 text. |
| std::string rex::string::ToUTF8 | ( | const std::wstring_view | source | ) |
Converts the host wide string, UTF-16 or UTF-32 by wchar_t size, to UTF-8. Invalid code units become U+FFFD.
| std::wstring rex::string::ToWideString | ( | const std::string_view | source | ) |
Converts UTF-8 to the host wide string, UTF-16 or UTF-32 by wchar_t size. Invalid UTF-8 becomes U+FFFD.
| source | UTF-8 text. |
|
inline |
Removes leading and trailing characters.
|
inline |
Removes leading and trailing characters.
|
inline |
Removes leading characters.
|
inline |
Removes leading characters.
|
inline |
Removes trailing characters.
|
inline |
Removes trailing characters.
|
inline |
Removes leading and trailing characters into a new string.
| size_t rex::string::utf8_count | ( | const std::string_view | view | ) |
Counts code points.
| view | UTF-8 text. |
| bool rex::string::utf8_ends_with | ( | const std::string_view | haystack, |
| const std::string_view | needle ) |
Reports whether a string ends with a suffix.
| bool rex::string::utf8_ends_with_case | ( | const std::string_view | haystack, |
| const std::string_view | needle ) |
Reports whether a string ends with a suffix, ignoring ASCII case.
| bool rex::string::utf8_equal_case_z | ( | const std::string_view | left, |
| const std::string_view | right ) |
Reports whether two strings match up to the first NUL in each, ignoring ASCII case.
| bool rex::string::utf8_equal_z | ( | const std::string_view | left, |
| const std::string_view | right ) |
Reports whether two strings match up to the first NUL in each.
| std::string_view::size_type rex::string::utf8_find_any_of | ( | const std::string_view | haystack, |
| const std::string_view | needles ) |
Finds the first code point that matches any of a set.
| std::string_view::size_type rex::string::utf8_find_any_of_case | ( | const std::string_view | haystack, |
| const std::string_view | needles ) |
Finds the first code point that matches any of a set, ignoring ASCII case.
| std::string_view::size_type rex::string::utf8_find_first_of | ( | const std::string_view | haystack, |
| const std::string_view | needle ) |
Finds the first occurrence of a substring.
| std::string_view::size_type rex::string::utf8_find_first_of_case | ( | const std::string_view | haystack, |
| const std::string_view | needle ) |
Finds the first occurrence of a substring, ignoring ASCII case.
| size_t rex::string::utf8_hash_fnv1a | ( | const std::string_view | view | ) |
Hashes the code points of a string with FNV-1a.
| view | UTF-8 text. |
| size_t rex::string::utf8_hash_fnv1a_case | ( | const std::string_view | view | ) |
Hashes the code points of a string with FNV-1a, with ASCII letters lowercased first.
| view | UTF-8 text. |
| std::string rex::string::utf8_lower_ascii | ( | const std::string_view | view | ) |
Lowercases the ASCII letters of a string. Other code points pass through.
| view | UTF-8 text. |
| std::vector< std::string_view > rex::string::utf8_split | ( | const std::string_view | haystack, |
| const std::string_view | needles, | ||
| bool | remove_empty = false ) |
Splits a string on any of a set of delimiter code points.
| needles | Delimiter code points. |
| remove_empty | True to omit empty parts between adjacent delimiters. |
| bool rex::string::utf8_starts_with | ( | const std::string_view | haystack, |
| const std::string_view | needle ) |
Reports whether a string starts with a prefix.
| bool rex::string::utf8_starts_with_case | ( | const std::string_view | haystack, |
| const std::string_view | needle ) |
Reports whether a string starts with a prefix, ignoring ASCII case.
| std::string rex::string::utf8_upper_ascii | ( | const std::string_view | view | ) |
Uppercases the ASCII letters of a string.
| view | UTF-8 text. |
| std::string rex::string::UTF8ToShiftJIS | ( | const std::string_view | source | ) |
Converts UTF-8 to Shift-JIS (code page 932). Unrepresentable characters become '?'. Returns the input unchanged without the platform converter.
| source | UTF-8 text. |
|
inlineconstexpr |
Characters the trim functions remove by default.
|
inlineconstexpr |
The characters the trim functions remove by default, as a view of the character type.