MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
utils_string.cc File Reference
#include "utils/utils_string.h"
#include <array>
#include <bitset>
#include <cassert>
#include <cstdarg>
#include <functional>
#include <random>
#include <stdexcept>
#include <cwchar>

Namespaces

namespace  shcore
 
namespace  shcore::anonymous_namespace{utils_string.cc}
 

Functions

void shcore::clear_buffer (char *buffer, size_t size)
 
void shcore::clear_buffer (std::string &buffer)
 
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_format (const char *formats,...)
 Return a formatted a string. More...
 
std::string shcore::str_replace (std::string_view s, std::string_view from, std::string_view to)
 
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::string shcore::str_subvars (std::string_view s, const std::function< std::string(std::string_view)> &subvar, std::string_view var_begin, std::string_view var_end)
 
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)
 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)
 Convert UTF-16/UTF-32 (platform dependent) string to UTF-8 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::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::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...
 
const char * shcore::str_casestr (const char *haystack, const char *needle)
 

Variables

const int shcore::anonymous_namespace{utils_string.cc}::k_reserved_chars []
 
const int shcore::anonymous_namespace{utils_string.cc}::k_hex_values []