Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
Lightweight UTF-8 string wrapper with safe conversions. More...
#include <src/utils/string.h>
Public Member Functions | |
constexpr | Utf8String (const char8_t *str) |
constexpr | Utf8String (std::u8string_view str) |
Utf8String (const Utf8String &)=default | |
Utf8String (Utf8String &&)=default | |
Utf8String & | operator= (const Utf8String &)=default |
Utf8String & | operator= (Utf8String &&)=default |
std::string_view | view () const noexcept |
const std::string & | str () const noexcept |
const char * | c_str () const noexcept |
auto | empty () const noexcept |
fs::path | to_path () const |
std::u8string | to_u8_string () const |
QString | to_qstring () const |
juce::String | to_juce_string () const |
juce::File | to_juce_file () const |
operator std::string_view () const noexcept | |
bool | operator== (std::string_view other) const noexcept |
Utf8String & | operator+= (const Utf8String &other) |
Utf8String | operator+ (const Utf8String &other) const |
operator fs::path () const | |
operator QString () const | |
Utf8String | escape_html () const |
bool | is_ascii () const |
bool | contains_substr (const Utf8String &substr) const |
bool | contains_substr_case_insensitive (const Utf8String &substr) const |
bool | is_equal_ignore_case (const Utf8String &other) const |
Utf8String | to_upper () const |
Utf8String | to_lower () const |
Utf8String | convert_to_filename () const |
Returns a filename-safe version of the given string. | |
Utf8String | get_substr_before_suffix (const Utf8String &suffix) const |
Removes the suffix starting from suffix from full_str and returns a newly allocated string. | |
Utf8String | remove_until_after_first_match (const Utf8String &match) const |
Removes everything up to and including the first match of match from the start of the string. | |
Utf8String | replace (const Utf8String &from, const Utf8String &to) const |
Utf8String | get_regex_group (const Utf8String ®ex, int group) const |
Gets the string in the given regex group. | |
int | get_regex_group_as_int (const Utf8String ®ex, int group, int def) const |
Gets the string in the given regex group as an integer. | |
std::pair< int, Utf8String > | get_int_after_last_space () const |
Returns the integer found at the end of a string like "My String 3" -> 3, or -1 if no number is found. | |
Utf8String | symbolify () const |
Returns a new string with only ASCII alphanumeric characters and replaces the rest with underscore. | |
Utf8String | expand_env_vars () const |
Expands environment variables enclosed in ${} in the given string. | |
Static Public Member Functions | |
static Utf8String | from_path (const fs::path &path) |
static Utf8String | from_qstring (const QString &str) |
static Utf8String | from_qurl (const QUrl &url) |
static Utf8String | from_juce_string (const juce::String &str) |
static constexpr Utf8String | from_utf8_encoded_string (std::string_view str) |
Construct from a std::string_view that we are 100% sure is UTF8-encoded. | |
static Utf8String | join (const RangeOf< Utf8String > auto &strings, const Utf8String &delimiter) |
Friends | |
void | to_json (nlohmann::json &j, const Utf8String &s) |
void | from_json (const nlohmann::json &j, Utf8String &s) |
std::ostream & | operator<< (std::ostream &os, const Utf8String &str) |
auto | operator<=> (const Utf8String &a, const Utf8String &b) noexcept |
bool | operator== (const Utf8String &a, const Utf8String &b) noexcept |
Lightweight UTF-8 string wrapper with safe conversions.
Guarantees valid UTF-8 storage and explicit encoding handling.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlinenoexcept |
Utf8String zrythm::utils::Utf8String::convert_to_filename | ( | ) | const |
Returns a filename-safe version of the given string.
Example: "MIDI Region #1" -> "MIDI_Region_1".
|
inlinenoexcept |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestaticconstexpr |
std::pair< int, Utf8String > zrythm::utils::Utf8String::get_int_after_last_space | ( | ) | const |
Returns the integer found at the end of a string like "My String 3" -> 3, or -1 if no number is found.
See https://www.debuggex.com/cheatsheet/regex/pcre for more info.
Utf8String zrythm::utils::Utf8String::get_regex_group | ( | const Utf8String & | regex, |
int | group ) const |
Gets the string in the given regex group.
int zrythm::utils::Utf8String::get_regex_group_as_int | ( | const Utf8String & | regex, |
int | group, | ||
int | def ) const |
Gets the string in the given regex group as an integer.
def | Default. |
|
inlinestatic |
|
inline |
|
inline |
|
inlineexplicitnoexcept |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inline |
|
inlinenoexcept |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |