MySQL 9.3.0
Source Code Documentation
utils_string.h File Reference
#include <wctype.h>
#include <algorithm>
#include <cctype>
#include <cstdint>
#include <cstring>
#include <cwchar>
#include <string>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include "mysqlrouter/jit_executor_plugin_export.h"

Go to the source code of this file.

Classes

struct  shcore::Case_sensitive_comparator
 
struct  shcore::Case_insensitive_comparator
 
struct  shcore::Case_comparator
 
struct  shcore::Lexicographical_comparator
 
struct  shcore::string_hash
 Transparent hashing function, enables heterogeneous lookup in unordered containers. More...
 

Namespaces

namespace  shcore
 
namespace  shcore::internal
 Checks whether a string has another as a prefix.
 

Macros

#define STRINGIFY(s)   STRINGIFY_(s)
 
#define STRINGIFY_(s)   #s
 

Typedefs

template<typename Key , typename T >
using shcore::heterogeneous_map = std::unordered_map< Key, T, string_hash, std::equal_to<> >
 
template<typename Key >
using shcore::heterogeneous_set = std::unordered_set< Key, string_hash, std::equal_to<> >
 

Functions

void shcore::clear_buffer (char *buffer, size_t size)
 
void shcore::clear_buffer (std::string &buffer)
 
template<typename Char , typename F >
std::basic_string< Char > shcore::internal::transform (std::basic_string_view< Char > s, F fun)
 
std::string shcore::str_upper (std::string_view s)
 Convert a copy of an ASCII string to uppercase and return. More...
 
std::wstring shcore::str_upper (std::wstring_view s)
 
std::string shcore::str_lower (std::string_view s)
 Convert a copy of an ASCII string to lowercase and return. More...
 
std::wstring shcore::str_lower (std::wstring_view s)
 
int shcore::str_casecmp (const char *a, const char *b)
 Compares 2 strings case insensitive (for ascii) More...
 
int shcore::str_casecmp (const wchar_t *a, const wchar_t *b)
 
int shcore::str_casecmp (const char *a, const char *b, size_t n)
 
int shcore::str_casecmp (const wchar_t *a, const wchar_t *b, size_t n)
 
template<typename Char >
bool shcore::internal::str_caseeq_pair (std::basic_string_view< Char > a, std::basic_string_view< Char > b)
 
template<typename Char , typename... T>
bool shcore::internal::str_caseeq (std::basic_string_view< Char > a, T &&...tokens)
 
template<typename... T>
bool shcore::str_caseeq (std::string_view a, std::string_view token, T &&...tokens)
 
template<typename... T>
bool shcore::str_caseeq (std::wstring_view a, std::wstring_view token, T &&...tokens)
 
template<typename Char >
bool shcore::internal::str_beginswith_pair (std::basic_string_view< Char > s, std::basic_string_view< Char > prefix)
 
template<typename Char , typename... T>
bool shcore::internal::str_beginswith (std::basic_string_view< Char > s, T &&...prefixes)
 
template<typename... T>
bool shcore::str_beginswith (std::string_view s, std::string_view prefix, T &&...prefixes)
 
template<typename... T>
bool shcore::str_beginswith (std::wstring_view s, std::wstring_view prefix, T &&...prefixes)
 
template<typename Char >
bool shcore::internal::str_ibeginswith_pair (std::basic_string_view< Char > s, std::basic_string_view< Char > prefix)
 
template<typename Char , typename... T>
bool shcore::internal::str_ibeginswith (std::basic_string_view< Char > s, T &&...prefixes)
 
template<typename... T>
bool shcore::str_ibeginswith (std::string_view s, std::string_view prefix, T &&...prefixes)
 
template<typename... T>
bool shcore::str_ibeginswith (std::wstring_view s, std::wstring_view prefix, T &&...prefixes)
 
template<typename Char >
bool shcore::internal::str_endswith_pair (std::basic_string_view< Char > s, std::basic_string_view< Char > suffix)
 
template<typename Char , typename... T>
bool shcore::internal::str_endswith (std::basic_string_view< Char > s, T &&...suffixes)
 
template<typename... T>
bool shcore::str_endswith (std::string_view s, std::string_view suffix, T &&...suffixes)
 
template<typename... T>
bool shcore::str_endswith (std::wstring_view s, std::wstring_view suffix, T &&...suffixes)
 
template<typename Char >
bool shcore::internal::str_iendswith_pair (std::basic_string_view< Char > s, std::basic_string_view< Char > suffix)
 
template<typename Char , typename... T>
bool shcore::internal::str_iendswith (std::basic_string_view< Char > s, T &&...suffixes)
 
template<typename... T>
bool shcore::str_iendswith (std::string_view s, std::string_view suffix, T &&...suffixes)
 
template<typename... T>
bool shcore::str_iendswith (std::wstring_view s, std::wstring_view suffix, T &&...suffixes)
 
const char * shcore::str_casestr (const char *haystack, const char *needle)
 
size_t shcore::str_span (const std::string &s1, const std::string &s2)
 Return position of the first difference in the strings or npos if they're the same. More...
 
template<class TOutput = std::string>
std::pair< TOutput, TOutput > shcore::str_partition (std::string_view s, std::string_view sep, bool *found_sep=nullptr)
 Partition a string in 2 at a separator, if present. More...
 
template<class TOutput = std::string>
std::pair< TOutput, TOutput > shcore::str_partition_after (std::string_view s, std::string_view sep)
 Partition a string in 2 after separator, in place, if present. More...
 
std::string shcore::str_partition_after_inpl (std::string *s, const std::string &sep)
 Partition a string in 2 after separator, in place, if present. More...
 
std::vector< std::string > shcore::str_split (std::string_view input, std::string_view separator_chars=" \r\n\t", int maxsplit=-1, bool compress=false)
 Splits string based on each of the individual characters of the separator string. More...
 
template<class TCallback >
bool shcore::str_itersplit (std::string_view input, TCallback &&f, std::string_view separator_chars=" \r\n\t", int maxsplit=-1, bool compress=false)
 Split the given input string and call the functor for each token. More...
 
std::string_view shcore::str_strip_view (std::string_view s, std::string_view chars=" \r\n\t")
 Strip a string out of blank chars. More...
 
std::string_view shcore::str_lstrip_view (std::string_view s, std::string_view chars)
 
std::string_view shcore::str_rstrip_view (std::string_view s, std::string_view chars)
 
std::string shcore::str_strip (std::string_view s, std::string_view chars)
 
std::string shcore::str_lstrip (std::string_view s, std::string_view chars)
 
std::string shcore::str_rstrip (std::string_view s, std::string_view chars)
 
std::string shcore::str_ljust (const std::string &s, size_t width, char pad=' ')
 
std::string shcore::str_rjust (const std::string &s, size_t width, char pad=' ')
 
std::string shcore::str_format (const char *formats,...)
 Return a formatted a string. More...
 
template<typename Iter >
std::string shcore::str_join (Iter begin, Iter end, std::string_view sep)
 
template<typename Iter , typename CTransform >
std::string shcore::str_join (Iter begin, Iter end, std::string_view sep, CTransform &&f)
 
template<typename C >
std::string shcore::str_join (const C &container, std::string_view sep)
 
template<typename C , typename CTransform >
std::string shcore::str_join (const C &container, std::string_view sep, CTransform &&f)
 
std::string shcore::str_replace (std::string_view s, std::string_view from, std::string_view to)
 
template<typename... Args>
std::string JIT_EXECUTOR_PLUGIN_EXPORT shcore::str_replace (std::string_view s, std::string_view from, std::string_view to, const Args &...rest)
 
std::string shcore::bits_to_string (uint64_t bits, int nbits)
 
std::pair< uint64_t, int > shcore::string_to_bits (std::string_view s)
 
std::string shcore::bits_to_string_hex (uint64_t bits, int nbits)
 
size_t shcore::bits_to_string_hex_size (int nbits)
 
std::string shcore::string_to_hex (std::string_view s, bool prefix)
 
std::string shcore::quote_string (const std::string &s, char quote)
 Escape quote and \ chars. More...
 
std::string shcore::unquote_string (std::string_view s, char quote)
 Inverse of quote_string(). More...
 
std::vector< std::string > shcore::str_break_into_lines (const std::string &line, std::size_t line_width)
 Breaks string into lines of specified width without breaking words. More...
 
std::pair< std::string::size_type, std::string::size_type > shcore::get_quote_span (const char quote_char, const std::string &str)
 Auxiliary function to get the quotes span (i.e., start and end positions) for the given string. More...
 
std::wstring shcore::utf8_to_wide (const std::string &utf8)
 Convert UTF-8 string to UTF-16/UTF-32 (platform dependent) string. More...
 
std::wstring shcore::utf8_to_wide (const char *utf8, const size_t utf8_length)
 Convert UTF-8 string to UTF-16/UTF-32 (platform dependent) string. More...
 
std::wstring shcore::utf8_to_wide (const char *utf8)
 Convert UTF-8 string to UTF-16/UTF-32 (platform dependent) string. More...
 
std::string shcore::wide_to_utf8 (const std::wstring &wide)
 Convert UTF-16/UTF-32 (platform dependent) string to UTF-8 string. More...
 
std::string shcore::wide_to_utf8 (const wchar_t *wide, const size_t wide_length)
 Convert UTF-16/UTF-32 (platform dependent) string to UTF-8 string. More...
 
std::string shcore::wide_to_utf8 (const wchar_t *wide)
 Convert UTF-16/UTF-32 (platform dependent) string to UTF-8 string. More...
 
std::string shcore::truncate (const std::string &str, const size_t max_length)
 Truncates the given string to max_length code points. More...
 
std::string shcore::truncate (const char *str, const size_t length, const size_t max_length)
 Truncates the given string to max_length code points. More...
 
std::wstring shcore::truncate (const std::wstring &str, const size_t max_length)
 Truncates the given string to max_length code points. More...
 
std::wstring shcore::truncate (const wchar_t *str, const size_t length, const size_t max_length)
 Truncates the given string to max_length code points. More...
 
bool shcore::is_valid_utf8 (std::string_view s)
 Checks if the given string contains only valid UTF-8 code points. More...
 
std::string shcore::pctencode (std::string_view s)
 Generates a percent encoded string based on RFC-3986, only unreserved characters are not encoded. More...
 
std::string shcore::pctdecode (std::string_view s)
 Decodes a string that is percent encoded based on RFC-3986. More...
 
std::string shcore::get_random_string (size_t size, const char *source)
 Returns a string of the given size created with random characters from the provided source. More...
 
std::string shcore::utf8_upper (std::string_view s)
 
std::string shcore::utf8_lower (std::string_view s)
 

Macro Definition Documentation

◆ STRINGIFY

#define STRINGIFY (   s)    STRINGIFY_(s)

◆ STRINGIFY_

#define STRINGIFY_ (   s)    #s