|
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/utf8_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.
Definition at line 37 of file utf8_string.h.
|
inlineconstexpr |
Definition at line 41 of file utf8_string.h.
|
inlineconstexpr |
Definition at line 45 of file utf8_string.h.
|
inlinenoexcept |
Definition at line 91 of file utf8_string.h.
| 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 |
Definition at line 92 of file utf8_string.h.
|
inlinestatic |
Definition at line 59 of file utf8_string.h.
|
inlinestatic |
Definition at line 63 of file utf8_string.h.
|
inlinestatic |
Definition at line 69 of file utf8_string.h.
|
inlinestaticconstexpr |
Construct from a std::string_view that we are 100% sure is UTF8-encoded.
Definition at line 81 of file utf8_string.h.
| 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 |
Definition at line 195 of file utf8_string.h.
|
inline |
Definition at line 117 of file utf8_string.h.
|
inline |
Definition at line 118 of file utf8_string.h.
|
inlineexplicitnoexcept |
Definition at line 102 of file utf8_string.h.
|
inline |
Definition at line 112 of file utf8_string.h.
|
inline |
Definition at line 107 of file utf8_string.h.
|
inlinenoexcept |
Definition at line 103 of file utf8_string.h.
|
inlinenoexcept |
Definition at line 90 of file utf8_string.h.
|
inline |
Definition at line 95 of file utf8_string.h.
|
inline |
Definition at line 97 of file utf8_string.h.
|
inline |
Definition at line 96 of file utf8_string.h.
|
inlinenoexcept |
Definition at line 89 of file utf8_string.h.
|
friend |
Definition at line 119 of file utf8_string.h.
|
friend |
Definition at line 206 of file utf8_string.h.
|
friend |
Definition at line 210 of file utf8_string.h.