diff options
author | Dominick Allen <djallen@librehumanitas.org> | 2024-11-03 13:04:00 -0600 |
---|---|---|
committer | Dominick Allen <djallen@librehumanitas.org> | 2024-11-03 13:04:00 -0600 |
commit | 1e89700693e92bb9c78ace739c71431b74d91e22 (patch) | |
tree | 08d40bf1c650987fac55805ce4b930a19c065fec /include | |
parent | 9b4b87765d48d2d6aed6ac1f40c4aa2684fad766 (diff) |
Rename FudUtf8 to Utf8.
Diffstat (limited to 'include')
-rw-r--r-- | include/fud_string.hpp | 11 | ||||
-rw-r--r-- | include/fud_utf8.hpp | 64 | ||||
-rw-r--r-- | include/fud_utf8_iterator.hpp | 4 |
3 files changed, 44 insertions, 35 deletions
diff --git a/include/fud_string.hpp b/include/fud_string.hpp index 86261c4..935e1c1 100644 --- a/include/fud_string.hpp +++ b/include/fud_string.hpp @@ -286,16 +286,25 @@ class String { /** \brief Attempts to reserve newCapacity bytes of storage. */ FudStatus reserve(size_t newCapacity); + /** \brief Returns the first character in the sequence if the length is + * greater than zero. */ + [[nodiscard]] Option<utf8> front(); + /** \brief Returns the last character in the sequence if the length is * greater than zero. */ [[nodiscard]] Option<utf8> back(); + /** \brief Append a character to the back of the string, growing it if necessary. */ FudStatus pushBack(char letter); + /** @copydoc String::pushBack(char letter) */ FudStatus pushBack(utf8 letter); - FudStatus pushBack(const FudUtf8& letter); + /** @copydoc String::pushBack(char letter) */ + FudStatus pushBack(const Utf8& letter); + /** \brief Pop and return a character from the back of the string if its + * length is greater than zero. */ Option<utf8> pop(); FudStatus append(const char* source); diff --git a/include/fud_utf8.hpp b/include/fud_utf8.hpp index 414352f..119640c 100644 --- a/include/fud_utf8.hpp +++ b/include/fud_utf8.hpp @@ -281,18 +281,18 @@ static_assert(Utf8TypeSet.m_values[1] == static_cast<uint8_t>(Utf8Type::Utf82Byt static_assert(Utf8TypeSet.m_values[2] == static_cast<uint8_t>(Utf8Type::Utf83Byte)); static_assert(Utf8TypeSet.m_values[3] == static_cast<uint8_t>(Utf8Type::Utf84Byte)); -struct FudUtf8 { +struct Utf8 { Utf8Variant m_variant{Utf8Variant{Ascii{}}}; static constexpr Ascii invalidAsciiCode{Ascii{0xFF}}; - static FudUtf8 from(const String& fudString, size_t index) noexcept; + static Utf8 from(const String& fudString, size_t index) noexcept; - static FudUtf8 from(StringView view, size_t index) noexcept; + static Utf8 from(StringView view, size_t index) noexcept; - static constexpr FudUtf8 make(const Array<utf8, 4>& data) + static constexpr Utf8 make(const Array<utf8, 4>& data) { - FudUtf8 unicode{}; + Utf8 unicode{}; if (Ascii::valid(data[0])) { unicode.m_variant = Ascii{data[0]}; } else if (Utf82Byte::valid(data[0], data[1])) { @@ -307,14 +307,14 @@ struct FudUtf8 { return unicode; } - static constexpr FudUtf8 make(utf8 utf8Char) + static constexpr Utf8 make(utf8 utf8Char) { return make(Ascii{utf8Char}); } - static constexpr FudUtf8 make(Ascii utf8Char) + static constexpr Utf8 make(Ascii utf8Char) { - FudUtf8 unicode{{Utf8Variant{Ascii{}}}}; + Utf8 unicode{{Utf8Variant{Ascii{}}}}; if (utf8Char.valid()) { unicode.m_variant = utf8Char; } else { @@ -323,9 +323,9 @@ struct FudUtf8 { return unicode; } - static constexpr FudUtf8 make(Utf8Variant utf8Variant) + static constexpr Utf8 make(Utf8Variant utf8Variant) { - FudUtf8 unicode{}; + Utf8 unicode{}; unicode.m_variant = utf8Variant; if (!std::visit([](auto arg) { return arg.valid(); }, utf8Variant)) { unicode.m_variant = invalidAsciiCode; @@ -333,9 +333,9 @@ struct FudUtf8 { return unicode; } - static constexpr FudUtf8 invalidAscii() + static constexpr Utf8 invalidAscii() { - FudUtf8 character{}; + Utf8 character{}; character.m_variant = Ascii{invalidAsciiCode}; return character; } @@ -450,15 +450,15 @@ struct FudUtf8 { } } - constexpr bool operator==(const FudUtf8& other) const noexcept = default; + constexpr bool operator==(const Utf8& other) const noexcept = default; - constexpr auto operator<=>(const FudUtf8& other) const noexcept + constexpr auto operator<=>(const Utf8& other) const noexcept { - auto hasSameAlternative = []<typename T>(const FudUtf8& lhs, const FudUtf8& rhs) noexcept { + auto hasSameAlternative = []<typename T>(const Utf8& lhs, const Utf8& rhs) noexcept { return std::holds_alternative<T>(lhs.m_variant) && std::holds_alternative<T>(rhs.m_variant); }; - auto getSameAlternative = []<typename T>(const FudUtf8& lhs, const FudUtf8& rhs) noexcept { + auto getSameAlternative = []<typename T>(const Utf8& lhs, const Utf8& rhs) noexcept { return std::get<T>(lhs.m_variant).operator<=>(std::get<T>(rhs.m_variant)); }; @@ -514,14 +514,14 @@ namespace classify { using CharPredicate = bool (*)(char); using Utf8Predicate = bool (*)(utf8); -using FudUtf8Predicate = bool (*)(FudUtf8); +using FudUtf8Predicate = bool (*)(Utf8); /** \brief Checks if a character is ascii. */ [[nodiscard]] bool isAscii(char character); [[nodiscard]] bool isAscii(utf8 character); -[[nodiscard]] bool isAscii(FudUtf8 character); +[[nodiscard]] bool isAscii(Utf8 character); /** \brief Checks if a character is alphanumeric. */ [[nodiscard]] bool isAlphanumeric(char character); @@ -530,7 +530,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isAlphanumeric(utf8 character); /** \brief Checks if a character is alphanumeric. */ -[[nodiscard]] bool isAlphanumeric(FudUtf8 character); +[[nodiscard]] bool isAlphanumeric(Utf8 character); /** \brief Checks if a character is alphabetic. */ [[nodiscard]] bool isAlpha(char character); @@ -539,7 +539,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isAlpha(utf8 character); /** \brief Checks if a character is alphabetic. */ -[[nodiscard]] bool isAlpha(FudUtf8 character); +[[nodiscard]] bool isAlpha(Utf8 character); /** \brief Checks if a character is lowercase. */ [[nodiscard]] bool isLowercase(char character); @@ -548,7 +548,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isLowercase(utf8 character); /** \brief Checks if a character is lowercase. */ -[[nodiscard]] bool isLowercase(FudUtf8 character); +[[nodiscard]] bool isLowercase(Utf8 character); /** \brief Checks if a character is uppercase. */ [[nodiscard]] bool isUppercase(char character); @@ -557,7 +557,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isUppercase(utf8 character); /** \brief Checks if a character is uppercase. */ -[[nodiscard]] bool isUppercase(FudUtf8 character); +[[nodiscard]] bool isUppercase(Utf8 character); /** \brief Checks if a character is a digit. */ [[nodiscard]] bool isDigit(char character); @@ -566,7 +566,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isDigit(utf8 character); /** \brief Checks if a character is a digit. */ -[[nodiscard]] bool isDigit(FudUtf8 character); +[[nodiscard]] bool isDigit(Utf8 character); /** \brief Checks if a character is a hexadecimal character. */ [[nodiscard]] bool isHexDigit(char character); @@ -575,7 +575,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isHexDigit(utf8 character); /** \brief Checks if a character is a hexadecimal digit. */ -[[nodiscard]] bool isHexDigit(FudUtf8 character); +[[nodiscard]] bool isHexDigit(Utf8 character); /** \brief Checks if a character is a control character. */ [[nodiscard]] bool isControl(char character); @@ -584,7 +584,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isControl(utf8 character); /** \brief Checks if a character is a control character. */ -[[nodiscard]] bool isControl(FudUtf8 character); +[[nodiscard]] bool isControl(Utf8 character); /** \brief Checks if a character is a graphical character. */ [[nodiscard]] bool isGraphical(char character); @@ -593,7 +593,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isGraphical(utf8 character); /** \brief Checks if a character is a graphical character. */ -[[nodiscard]] bool isGraphical(FudUtf8 character); +[[nodiscard]] bool isGraphical(Utf8 character); /** \brief Checks if a character is a space character. */ [[nodiscard]] bool isSpace(char character); @@ -602,7 +602,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isSpace(utf8 character); /** \brief Checks if a character is a space character. */ -[[nodiscard]] bool isSpace(FudUtf8 character); +[[nodiscard]] bool isSpace(Utf8 character); /** \brief Checks if a character is a blank character. */ [[nodiscard]] bool isBlank(char character); @@ -611,7 +611,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isBlank(utf8 character); /** \brief Checks if a character is a blank character. */ -[[nodiscard]] bool isBlank(FudUtf8 character); +[[nodiscard]] bool isBlank(Utf8 character); /** \brief Checks if a character is a printable character. */ [[nodiscard]] bool isPrintable(char character); @@ -620,7 +620,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isPrintable(utf8 character); /** \brief Checks if a character is a printable character. */ -[[nodiscard]] bool isPrintable(FudUtf8 character); +[[nodiscard]] bool isPrintable(Utf8 character); /** \brief Checks if a character is a punctuation character. */ [[nodiscard]] bool isPunctuation(char character); @@ -629,7 +629,7 @@ using FudUtf8Predicate = bool (*)(FudUtf8); [[nodiscard]] bool isPunctuation(utf8 character); /** \brief Checks if a character is a punctuation character. */ -[[nodiscard]] bool isPunctuation(FudUtf8 character); +[[nodiscard]] bool isPunctuation(Utf8 character); } // namespace classify @@ -637,13 +637,13 @@ using FudUtf8Predicate = bool (*)(FudUtf8); uint8_t charToLower(uint8_t character); /** \brief Converts character to lowercase if valid. */ -FudUtf8 utf8ToLower(FudUtf8 character); +Utf8 utf8ToLower(Utf8 character); /** \brief Converts character to uppercase if valid. */ uint8_t charToUpper(uint8_t character); /** \brief Converts character to uppercase if valid. */ -FudUtf8 utf8ToUpper(FudUtf8 character); +Utf8 utf8ToUpper(Utf8 character); } // namespace fud diff --git a/include/fud_utf8_iterator.hpp b/include/fud_utf8_iterator.hpp index 25aaae6..4f036a4 100644 --- a/include/fud_utf8_iterator.hpp +++ b/include/fud_utf8_iterator.hpp @@ -47,8 +47,8 @@ class Utf8Iterator { m_index = 0; } - [[nodiscard]] Option<FudUtf8> peek() const; - Option<FudUtf8> next(); + [[nodiscard]] Option<Utf8> peek() const; + Option<Utf8> next(); }; } // namespace fud |