cpp-toolbox  0.0.1
A toolbox library for C++
Loading...
Searching...
No Matches
string.hpp File Reference
#include <limits>
#include <string>
#include <string_view>
#include <vector>
#include <cpp-toolbox/cpp-toolbox_export.hpp>
Include dependency graph for string.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  toolbox
 
namespace  toolbox::container
 
namespace  toolbox::container::string
 

Macros

#define CPP_TOOLBOX_CONTAINER_STRING_HPP
 

Functions

CPP_TOOLBOX_EXPORT auto toolbox::container::string::split (std::string_view str, std::string_view delimiter) -> std::vector< std::string >
 使用字符串分隔符将字符串视图分割成字符串向量 / Splits a string view into a vector of strings based on a string delimiter.
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::split (std::string_view str, char delimiter) -> std::vector< std::string >
 使用字符分隔符将字符串视图分割成字符串向量 / Splits a string view into a vector of strings based on a character delimiter
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::join (const std::vector< std::string > &parts, std::string_view glue) -> std::string
 使用连接字符串将字符串向量连接成单个字符串 / Joins a vector of strings into a single string, separated by a glue string
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::join (const std::vector< std::string_view > &parts, std::string_view glue) -> std::string
 使用连接字符串将字符串视图向量连接成单个字符串 / Joins a vector of string views into a single string, separated by a glue string
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::trim_left (std::string_view str) -> std::string
 删除字符串视图开头的空白字符 / Removes leading whitespace characters from a string view
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::trim_right (std::string_view str) -> std::string
 删除字符串视图末尾的空白字符 / Removes trailing whitespace characters from a string view
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::trim (std::string_view str) -> std::string
 删除字符串视图两端的空白字符 / Removes both leading and trailing whitespace characters from a string view
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::starts_with (std::string_view s, std::string_view prefix) -> bool
 检查字符串视图是否以指定前缀开头 / Checks if a string view starts with a specified prefix
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::ends_with (std::string_view s, std::string_view suffix) -> bool
 检查字符串视图是否以指定后缀结尾 / Checks if a string view ends with a specified suffix
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::contains (std::string_view s, std::string_view substring) -> bool
 检查字符串视图是否包含指定子字符串 / Checks if a string view contains a specified substring
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::is_empty_or_whitespace (std::string_view s) -> bool
 检查字符串视图是否为空或仅包含空白字符 / Checks if a string view is empty or consists only of whitespace characters
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::is_numeric (std::string_view s) -> bool
 检查字符串视图是否表示数值(整数或浮点数)/ Checks if a string view represents a numeric value (integer or floating-point)
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::is_integer (std::string_view s) -> bool
 检查字符串视图是否表示有效的整数值 / Checks if a string view represents a valid integer value
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::is_float (std::string_view s) -> bool
 检查字符串视图是否表示有效的浮点数值 / Checks if a string view represents a valid floating-point value
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::replace (std::string_view s, std::string_view old_value, std::string_view new_value, std::size_t count=std::numeric_limits< std::size_t >::max()) -> std::string
 在字符串视图中将一个子字符串替换为另一个子字符串,最多替换指定次数 / Replaces occurrences of a substring within a string view with another substring, up to a specified count
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::replace_all (std::string_view s, std::string_view old_value, std::string_view new_value) -> std::string
 替换字符串视图中所有出现的子字符串 / Replaces all occurrences of a substring within a string view
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::replace_by_nth (std::string_view s, std::string_view old_value, std::string_view new_value, std::size_t n) -> std::string
 替换字符串中第N次出现的子字符串 / Replaces the Nth occurrence of a substring within a string
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::remove_nth (std::string_view s, std::string_view from, std::size_t n) -> std::string
 删除字符串中第N次出现的子字符串 / Removes the Nth occurrence of a substring within a string
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::remove (std::string_view s, std::string_view value, std::size_t count=std::numeric_limits< std::size_t >::max()) -> std::string
 从字符串视图中删除子字符串的出现,最多删除指定次数 / Removes occurrences of a substring from a string view, up to a specified count
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::remove_all (std::string_view s, std::string_view value) -> std::string
 从字符串视图中删除所有出现的子字符串 / Removes all occurrences of a substring from a string view
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::remove_all (std::string_view s, char value) -> std::string
 从字符串视图中删除所有出现的特定字符 / Removes all occurrences of a specific character from a string view
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::to_lower (std::string_view s) -> std::string
 将字符串视图中的所有字符转换为小写 / Converts all characters in a string view to lowercase
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::to_upper (std::string_view s) -> std::string
 将字符串视图中的所有字符转换为大写 / Converts all characters in a string view to uppercase
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::to_string (std::string_view s) -> std::string
 将字符串视图转换为标准字符串 / Converts a string view to a standard string
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::left_pad (std::string_view s, std::size_t width, char pad_char=' ') -> std::string
 在字符串左侧填充指定字符以达到最小宽度 / Pads a string on the left with a specified character to reach a minimum width
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::right_pad (std::string_view s, std::size_t width, char pad_char=' ') -> std::string
 在字符串右侧填充指定字符以达到最小宽度 / Pads a string on the right with a specified character to reach a minimum width
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::pad (std::string_view s, std::size_t width, char pad_char=' ', std::size_t position=0) -> std::string
 使用指定字符填充字符串以达到最小宽度,可控制填充位置 / Pads a string with a specified character to reach a minimum width, controlling padding position
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::reverse (std::string_view s) -> std::string
 反转字符串视图中字符的顺序 / Reverses the order of characters in a string view
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::try_parse_int (std::string_view s, int &out) -> bool
 尝试从字符串视图解析整数 / Attempts to parse an integer from a string view
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::try_parse_double (std::string_view s, double &out) -> bool
 尝试从字符串视图解析双精度浮点数 / Attempts to parse a double-precision floating-point number from a string view
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::try_parse_float (std::string_view s, float &out) -> bool
 尝试从字符串视图解析单精度浮点数 / Attempts to parse a single-precision floating-point number from a string view
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::levenshtein_distance (std::string_view s1, std::string_view s2) -> std::size_t
 计算两个字符串之间的Levenshtein距离 / Calculates the Levenshtein distance between two strings
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::longest_common_subsequence_length (std::string_view s1, std::string_view s2) -> std::size_t
 计算两个字符串的最长公共子序列(LCS)长度 / Calculates the length of the Longest Common Subsequence (LCS) of two strings
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::longest_common_substring_length (std::string_view s1, std::string_view s2) -> std::size_t
 计算两个字符串的最长公共子串长度 / Calculates the length of the Longest Common Substring of two strings
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::url_encode (std::string_view s) -> std::string
 对字符串进行百分比编码以安全地包含在URL中 / Percent-encodes a string for safe inclusion in a URL
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::url_decode (std::string_view s) -> std::string
 解码百分比编码的字符串(URL解码) / Decodes a percent-encoded string (URL decoding)
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::base64_encode (std::string_view data) -> std::string
 将二进制数据(以字符串视图表示)编码为Base64格式 / Encodes binary data (represented as a string_view) into Base64 format
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::base64_decode (std::string_view encoded_data) -> std::string
 将Base64编码的字符串解码回原始数据 / Decodes a Base64 encoded string back into its original data
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::slugify (std::string_view s) -> std::string
 将字符串转换为URL友好的"slug" / Converts a string into a URL-friendly "slug"
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::hexview (const char *data, std::size_t size, bool with_prefix=true) -> std::string
 将二进制数据转换为十六进制字符串表示/Convert binary data to hexadecimal string representation
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::hexview (const std::string &data, bool with_prefix=true) -> std::string
 将字符串转换为十六进制表示/Convert string to hexadecimal representation
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::hexview (const std::vector< char > &data, bool with_prefix=true) -> std::string
 将字符向量转换为十六进制表示/Convert vector of chars to hexadecimal representation
 
CPP_TOOLBOX_EXPORT auto toolbox::container::string::hexview (const std::vector< std::byte > &data, bool with_prefix=true) -> std::string
 将字节向量转换为十六进制表示/Convert vector of bytes to hexadecimal representation
 
template<typename T >
auto toolbox::container::string::hex_to_integral (const std::string &hex_str, bool with_prefix=true) -> T
 将十六进制字符串转换为整数类型/Convert hexadecimal string to integral type
 
template<typename Container >
auto toolbox::container::string::hex_to_bytes (const std::string &hex_str, bool with_prefix=true) -> Container
 将十六进制字符串转换为字节容器/Convert hexadecimal string to byte container
 

Macro Definition Documentation

◆ CPP_TOOLBOX_CONTAINER_STRING_HPP

#define CPP_TOOLBOX_CONTAINER_STRING_HPP