libostd
Classes | Typedefs | Functions
string.hh File Reference

String slice implementation as well as other utilities. More...

Go to the source code of this file.

Classes

struct  ostd::basic_char_range< T >
 A string slice type. More...
 
struct  ostd::ranged_traits< std::basic_string< T, TR, A > >
 Mutable range integration for std::basic_string. More...
 
struct  ostd::ranged_traits< std::basic_string< T, TR, A > const >
 Immutable range integration for std::basic_string. More...
 
struct  ostd::utf::utf_error
 Thrown on UTF-8 decoding failure. More...
 
struct  std::hash< ostd::basic_char_range< T > >
 Standard std::hash integration for string slices. More...
 

Typedefs

using ostd::char_range = basic_char_range< char >
 A mutable slice over char.
 
using ostd::wchar_range = basic_char_range< wchar_t >
 A mutable slice over wchar_t.
 
using ostd::char16_range = basic_char_range< char16_t >
 A mutable slice over char16_t.
 
using ostd::char32_range = basic_char_range< char32_t >
 A mutable slice over char32_t.
 
using ostd::string_range = basic_char_range< char const >
 An immutable slice over char. More...
 
using ostd::wstring_range = basic_char_range< wchar_t const >
 An immutable slice over wchar_t. More...
 
using ostd::u16string_range = basic_char_range< char16_t const >
 An immutable slice over char16_t. More...
 
using ostd::u32string_range = basic_char_range< char32_t const >
 An immutable slice over char32_t. More...
 
using ostd::utf::wchar_fixed_t = std::conditional_t< sizeof(wchar_t)==sizeof(char32_t), char32_t, std::conditional_t< sizeof(wchar_t)==sizeof(char16_t), char16_t, char > >
 A Unicode type of the same size as wchar_t. More...
 
template<std::size_t N>
using ostd::utf::unicode_t = typename detail::unicode_t_base< N >::type
 The UTF unit type according to utf::unit_bits. More...
 
template<typename T >
using ostd::utf::unicode_base_t = unicode_t< unit_bits< T > >
 A normalized Unicode type for the given character type. More...
 

Functions

bool ostd::operator== (string_range lhs, string_range rhs) noexcept
 Like !lhs.compare(rhs).
 
bool ostd::operator!= (string_range lhs, string_range rhs) noexcept
 Like lhs.compare(rhs).
 
bool ostd::operator< (string_range lhs, string_range rhs) noexcept
 Like lhs.compare(rhs) < 0.
 
bool ostd::operator> (string_range lhs, string_range rhs) noexcept
 Like lhs.compare(rhs) > 0.
 
bool ostd::operator<= (string_range lhs, string_range rhs) noexcept
 Like lhs.compare(rhs) <= 0.
 
bool ostd::operator>= (string_range lhs, string_range rhs) noexcept
 Like lhs.compare(rhs) >= 0.
 
bool ostd::operator== (u16string_range lhs, u16string_range rhs) noexcept
 Like !lhs.compare(rhs).
 
bool ostd::operator!= (u16string_range lhs, u16string_range rhs) noexcept
 Like lhs.compare(rhs).
 
bool ostd::operator< (u16string_range lhs, u16string_range rhs) noexcept
 Like lhs.compare(rhs) < 0.
 
bool ostd::operator> (u16string_range lhs, u16string_range rhs) noexcept
 Like lhs.compare(rhs) > 0.
 
bool ostd::operator<= (u16string_range lhs, u16string_range rhs) noexcept
 Like lhs.compare(rhs) <= 0.
 
bool ostd::operator>= (u16string_range lhs, u16string_range rhs) noexcept
 Like lhs.compare(rhs) >= 0.
 
bool ostd::operator== (u32string_range lhs, u32string_range rhs) noexcept
 Like !lhs.compare(rhs).
 
bool ostd::operator!= (u32string_range lhs, u32string_range rhs) noexcept
 Like lhs.compare(rhs).
 
bool ostd::operator< (u32string_range lhs, u32string_range rhs) noexcept
 Like lhs.compare(rhs) < 0.
 
bool ostd::operator> (u32string_range lhs, u32string_range rhs) noexcept
 Like lhs.compare(rhs) > 0.
 
bool ostd::operator<= (u32string_range lhs, u32string_range rhs) noexcept
 Like lhs.compare(rhs) <= 0.
 
bool ostd::operator>= (u32string_range lhs, u32string_range rhs) noexcept
 Like lhs.compare(rhs) >= 0.
 
bool ostd::operator== (wstring_range lhs, wstring_range rhs) noexcept
 Like !lhs.compare(rhs).
 
bool ostd::operator!= (wstring_range lhs, wstring_range rhs) noexcept
 Like lhs.compare(rhs).
 
bool ostd::operator< (wstring_range lhs, wstring_range rhs) noexcept
 Like lhs.compare(rhs) < 0.
 
bool ostd::operator> (wstring_range lhs, wstring_range rhs) noexcept
 Like lhs.compare(rhs) > 0.
 
bool ostd::operator<= (wstring_range lhs, wstring_range rhs) noexcept
 Like lhs.compare(rhs) <= 0.
 
bool ostd::operator>= (wstring_range lhs, wstring_range rhs) noexcept
 Like lhs.compare(rhs) >= 0.
 
bool ostd::starts_with (string_range a, string_range b) noexcept
 Checks if a string slice starts with another slice.
 
bool ostd::starts_with (u16string_range a, u16string_range b) noexcept
 Checks if a string slice starts with another slice.
 
bool ostd::starts_with (u32string_range a, u32string_range b) noexcept
 Checks if a string slice starts with another slice.
 
bool ostd::starts_with (wstring_range a, wstring_range b) noexcept
 Checks if a string slice starts with another slice.
 
OSTD_EXPORT bool ostd::utf::decode (string_range &r, char32_t &ret) noexcept
 
OSTD_EXPORT bool ostd::utf::decode (u16string_range &r, char32_t &ret) noexcept
 
OSTD_EXPORT bool ostd::utf::decode (u32string_range &r, char32_t &ret) noexcept
 
OSTD_EXPORT bool ostd::utf::decode (wstring_range &r, char32_t &ret) noexcept
 
template<typename C , typename R >
std::size_t ostd::utf::encode (R &sink, char32_t ch)
 
template<typename C , typename OR , typename IR >
std::size_t ostd::utf::encode (OR &sink, IR &r)
 Encode a Unicode code point from a string in the given encoding. More...
 
template<typename C , typename R >
std::size_t ostd::utf::replace (R &sink)
 Write a Unicode replacement character into the sink. More...
 
OSTD_EXPORT std::size_t ostd::utf::length (string_range r, string_range &cont) noexcept
 Get the number of Unicode code points in a string. More...
 
OSTD_EXPORT std::size_t ostd::utf::length (u16string_range r, u16string_range &cont) noexcept
 Get the number of Unicode code points in a string. More...
 
OSTD_EXPORT std::size_t ostd::utf::length (u32string_range r, u32string_range &cont) noexcept
 Get the number of Unicode code points in a string. More...
 
OSTD_EXPORT std::size_t ostd::utf::length (wstring_range r, wstring_range &cont) noexcept
 Get the number of Unicode code points in a string. More...
 
OSTD_EXPORT std::size_t ostd::utf::length (string_range r) noexcept
 Get the number of Unicode code points in a UTF-8 string. More...
 
OSTD_EXPORT std::size_t ostd::utf::length (u16string_range r) noexcept
 Get the number of Unicode code points in a UTF-16 string. More...
 
OSTD_EXPORT std::size_t ostd::utf::length (u32string_range r) noexcept
 Get the number of Unicode code points in a UTF-32 string. More...
 
OSTD_EXPORT std::size_t ostd::utf::length (wstring_range r) noexcept
 Get the number of Unicode code points in a wide string. More...
 
template<typename C , typename R >
auto ostd::utf::iter_u (R &&str)
 Iterate a Unicode string as a different encoding. More...
 
OSTD_EXPORT bool ostd::utf::isalnum (char32_t c) noexcept
 Check whether a code point is alphanumeric. More...
 
OSTD_EXPORT bool ostd::utf::isalpha (char32_t c) noexcept
 Check whether a code point is alphabetic. More...
 
OSTD_EXPORT bool ostd::utf::isblank (char32_t c) noexcept
 Check whether a code point is a blank. More...
 
OSTD_EXPORT bool ostd::utf::iscntrl (char32_t c) noexcept
 Check whether a code point is a control character. More...
 
OSTD_EXPORT bool ostd::utf::isdigit (char32_t c) noexcept
 Check whether a code point is a digit. More...
 
OSTD_EXPORT bool ostd::utf::isgraph (char32_t c) noexcept
 Check whether a code point is graphic. More...
 
OSTD_EXPORT bool ostd::utf::islower (char32_t c) noexcept
 Check whether a code point is lowercase. More...
 
OSTD_EXPORT bool ostd::utf::isprint (char32_t c) noexcept
 Check whether a code point is printable. More...
 
OSTD_EXPORT bool ostd::utf::ispunct (char32_t c) noexcept
 Check whether a code point is punctuation. More...
 
OSTD_EXPORT bool ostd::utf::isspace (char32_t c) noexcept
 Check whether a code point is a whitespace. More...
 
OSTD_EXPORT bool ostd::utf::istitle (char32_t c) noexcept
 Check whether a code point is titlecase. More...
 
OSTD_EXPORT bool ostd::utf::isupper (char32_t c) noexcept
 Check whether a code point is uppercase. More...
 
OSTD_EXPORT bool ostd::utf::isvalid (char32_t c) noexcept
 Check whether a code point is a valid character. More...
 
OSTD_EXPORT bool ostd::utf::isxdigit (char32_t c) noexcept
 Check whether a code point is a hexadecimal digit. More...
 
OSTD_EXPORT char32_t ostd::utf::tolower (char32_t c) noexcept
 Convert a Unicode code point to lowercase. More...
 
OSTD_EXPORT char32_t ostd::utf::toupper (char32_t c) noexcept
 Convert a Unicode code point to uppercase. More...
 
int ostd::utf::compare (string_range s1, string_range s2) noexcept
 Compare two UTF-8 strings. More...
 
int ostd::utf::compare (u16string_range s1, u16string_range s2) noexcept
 Compare two UTF-16 strings. More...
 
int ostd::utf::compare (u32string_range s1, u32string_range s2) noexcept
 Compare two UTF-32 strings. More...
 
int ostd::utf::compare (wstring_range s1, wstring_range s2) noexcept
 Compare two wide strings. More...
 
OSTD_EXPORT int ostd::utf::case_compare (string_range s1, string_range s2) noexcept
 Compare two UTF-8 strings as case insensitive. More...
 
OSTD_EXPORT int ostd::utf::case_compare (u16string_range s1, u16string_range s2) noexcept
 Compare two UTF-16 strings as case insensitive. More...
 
OSTD_EXPORT int ostd::utf::case_compare (u32string_range s1, u32string_range s2) noexcept
 Compare two UTF-32 strings as case insensitive. More...
 
OSTD_EXPORT int ostd::utf::case_compare (wstring_range s1, wstring_range s2) noexcept
 Compare two wide strings as case insensitive. More...
 
string_range ostd::literals::string_literals::operator"" _sr (char const *str, std::size_t len) noexcept
 A custom literal for string ranges. More...
 

Detailed Description

String slice implementation as well as other utilities.

This file implements string slices, their comparisons, utilities, standard C++ string range integration, range literals, std::hash support for string slices and others.