Photon Common Library 2.0.0-beta
A physically based renderer.
|
Contains various string manipulation helpers. More...
Namespaces | |
namespace | detail_from_to_char |
namespace | table |
Concepts | |
concept | CHasToString |
Enumerations | |
enum class | EWhitespace { Common , Standard } |
Functions | |
template<EWhitespace TYPE = EWhitespace::Common> | |
std::string_view | get_whitespaces () |
template<EWhitespace TYPE = EWhitespace::Common> | |
constexpr bool | is_whitespace (const char ch) |
bool | has_any_of (const std::string_view srcStr, const std::string_view candidates) |
bool | has_none_of (const std::string_view srcStr, const std::string_view candidates) |
std::string_view | cut_head (const std::string_view srcStr, const std::string_view candidates) |
Remove characters from the beginning. | |
std::string_view | cut_tail (const std::string_view srcStr, const std::string_view candidates) |
Remove characters from the end. | |
std::string_view | cut_ends (const std::string_view srcStr, const std::string_view candidates) |
Remove characters from both ends. | |
template<EWhitespace TYPE = EWhitespace::Common> | |
std::string_view | trim_head (const std::string_view srcStr) |
Remove white spaces from the beginning. | |
template<EWhitespace TYPE = EWhitespace::Common> | |
std::string_view | trim_tail (const std::string_view srcStr) |
Remove white spaces from the end. | |
template<EWhitespace TYPE = EWhitespace::Common> | |
std::string_view | trim (const std::string_view srcStr) |
Remove white spaces from both ends. | |
std::string_view | next_token (std::string_view srcStr, std::string_view *const out_remainingStr=nullptr, const std::string_view tokenSeparators=get_whitespaces<>()) |
Retrieve a token from a string. | |
char | az_to_AZ (const char ch) |
Convert lower-case characters to upper-case. | |
char | AZ_to_az (const char ch) |
Convert upper-case characters to lower-case. | |
void | az_to_AZ (std::string &str) |
Convert lower-case characters to upper-case. | |
void | AZ_to_az (std::string &str) |
Convert upper-case characters to lower-case. | |
std::string | repeat (const std::string_view str, const std::size_t n) |
Repeat the input string for N times. | |
void | erase_all (std::string &str, const char ch) |
Remove all occurrence of a character in the string. | |
template<typename T > | |
T | parse_float (const std::string_view floatStr) |
Returns a float by processing its string representation. Supports float, double, and long double. | |
template<typename T > | |
T | parse_int (std::string_view intStr) |
Returns an integer by processing its string representation. Supports the following: | |
template<typename NumberType > | |
NumberType | parse_number (const std::string_view numberStr) |
Returns a number by processing its string representation. Accepts all types supported by parse_float(std::string_view) and parse_int(std::string_view). | |
template<typename T > | |
std::size_t | stringify_float (const T value, char *const out_buffer, const std::size_t bufferSize) |
Converts a float to string. | |
template<std::integral T> | |
std::size_t | stringify_int_alphabetic (const T value, char *const out_buffer, const std::size_t bufferSize, const int base) |
Converts an integer to base [2, 62] string. | |
template<std::integral T> | |
std::size_t | stringify_int (const T value, char *const out_buffer, const std::size_t bufferSize, const int base=10) |
Converts an integer to string. | |
template<typename NumberType > | |
std::size_t | stringify_number (const NumberType value, char *const out_buffer, const std::size_t bufferSize) |
Converts a number to string. Accepts all types supported by stringify_float(T, char*, std::size_t) and stringify_int(T, char*, std::size_t). The written string is not null terminated. | |
template<typename NumberType > | |
std::string & | stringify_number (const NumberType value, std::string &out_str, const std::size_t maxChars=64) |
Converts a number to string. Similar to stringify_number(NumberType, char*, std::size_t) , except that this variant writes to std::string and the resulting string is guaranteed to be null terminated (by calling std::string::c_str() ). | |
template<typename NumberType > | |
std::string | stringify_number (const NumberType value, const std::size_t maxChars=64) |
Converts a number to string. Similar to stringify_number(NumberType, std::string&, std::size_t) , except that this variant creates a new string. | |
Contains various string manipulation helpers.
|
strong |
Enumerator | |
---|---|
Common | Smaller set of whitespace characters that are often seen (see |
Standard | Complete set of whitespace characters (see |
|
inline |
Convert upper-case characters to lower-case.
Characters that are not English alphabets, or being lower-case already, will be preserved.
|
inline |
Convert upper-case characters to lower-case.
Characters that are not English alphabets, or being lower-case already, will be preserved.
[in,out] | str | String that is going to be converted in-place. |
|
inline |
Convert lower-case characters to upper-case.
Characters that are not English alphabets, or being upper-case already, will be preserved.
|
inline |
Convert lower-case characters to upper-case.
Characters that are not English alphabets, or being upper-case already, will be preserved.
[in,out] | str | String that is going to be converted in-place. |
|
inline |
Remove characters from both ends.
Characters in srcStr
will be removed from both ends if they match any of the character in candidates
. The process stops once a mismatch is encountered.
srcStr | String that is going to be cut. |
candidates | The character set used to remove characters from srcStr . |
|
inline |
Remove characters from the beginning.
Characters in srcStr
will be removed from the beginning if they match any of the character in candidates
. The process stops once a mismatch is encountered.
srcStr | String that is going to be cut. |
candidates | The character set used to remove characters from srcStr . |
|
inline |
Remove characters from the end.
Characters in srcStr
will be removed from the end if they match any of the character in candidates
. The process stops once a mismatch is encountered.
srcStr | String that is going to be cut. |
candidates | The character set used to remove characters from srcStr . |
|
inline |
Remove all occurrence of a character in the string.
|
inline |
|
inline |
|
inline |
|
inlineconstexpr |
|
inline |
Retrieve a token from a string.
srcStr | The string that token is going to be retrieved from. | |
[out] | out_remainingStr | If not null, stores the string with the retrieved token and its separator removed. Pointing to srcStr is valid, e.g., next_token(str, &str) . |
tokenSeparators | Charactors that separate the tokens. Defaults to whitespace characters. |
|
inline |
Returns a float by processing its string representation. Supports float, double, and long double.
|
inline |
Returns an integer by processing its string representation. Supports the following:
bool
).
|
inline |
Returns a number by processing its string representation. Accepts all types supported by parse_float(std::string_view) and parse_int(std::string_view).
|
inline |
Repeat the input string for N times.
|
inline |
Converts a float to string.
Supports all built-in floating point types (e.g., float, double, and long double). The function expects a large enough bufferSize
determined by the caller. The written string is not null terminated. By default, the stringified float guarantees round-trip conversion–feeding the converted string s
from value
to parse_float()
will result in the same value.
out_buffer | The buffer for storing the string. |
bufferSize | Size of out_buffer . |
out_buffer
.
|
inline |
Converts an integer to string.
Supports all signed and unsigned standard integer types (including bool
). The function expects a large enough bufferSize
determined by the caller. The written string is not null terminated.
out_buffer | The buffer for storing the string. |
bufferSize | Size of out_buffer . |
out_buffer
.
|
inline |
Converts an integer to base [2, 62] string.
Supports all signed and unsigned standard integer types (including bool
). The function expects a large enough bufferSize
determined by the caller. The written string is not null terminated.
out_buffer | The buffer for storing the string. |
bufferSize | Size of out_buffer . |
out_buffer
.
|
inline |
Converts a number to string. Accepts all types supported by stringify_float(T, char*, std::size_t) and stringify_int(T, char*, std::size_t). The written string is not null terminated.
out_buffer
.
|
inline |
Converts a number to string. Similar to stringify_number(NumberType, std::string&, std::size_t)
, except that this variant creates a new string.
out_str | The string to append the result to. |
|
inline |
Converts a number to string. Similar to stringify_number(NumberType, char*, std::size_t)
, except that this variant writes to std::string
and the resulting string is guaranteed to be null terminated (by calling std::string::c_str()
).
out_str | The string to append the result to. |
out_str
for convenience.
|
inline |
Remove white spaces from both ends.
srcStr | String that is going to be trimmed. |
|
inline |
Remove white spaces from the beginning.
srcStr | String that is going to be trimmed. |
|
inline |
Remove white spaces from the end.
srcStr | String that is going to be trimmed. |