summaryrefslogtreecommitdiff
path: root/core/src/Utils/String.hpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2021-03-31 20:19:18 -0700
committerrtk0c <[email protected]>2021-03-31 20:19:18 -0700
commit44f5fa5c8f258e8fc1f7d7e2e45e0485bd6cc490 (patch)
tree3f09a1cce46d38f5a8c6266150e67af3802d4b95 /core/src/Utils/String.hpp
parent31950890c939862f79c817053c106bf711c63a64 (diff)
Complete items tab (UI and serialization)
Diffstat (limited to 'core/src/Utils/String.hpp')
-rw-r--r--core/src/Utils/String.hpp84
1 files changed, 0 insertions, 84 deletions
diff --git a/core/src/Utils/String.hpp b/core/src/Utils/String.hpp
deleted file mode 100644
index f2829d7..0000000
--- a/core/src/Utils/String.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-#pragma once
-
-#include <cstddef>
-#include <string>
-#include <string_view>
-
-class Utf8Iterator {
-public:
- using iterator_category = std::bidirectional_iterator_tag;
- using value_type = char32_t;
- using difference_type = std::string_view::difference_type;
- using pointer = const char32_t*;
- using reference = const char32_t&;
-
-private:
- std::string_view::iterator mIter;
- mutable char32_t mCurrentCodePoint = 0;
- mutable bool mDirty = true;
-
-public:
- Utf8Iterator(std::string_view::iterator it);
- ~Utf8Iterator() = default;
-
- Utf8Iterator(const Utf8Iterator& that) = default;
- Utf8Iterator& operator=(const Utf8Iterator& that) = default;
- Utf8Iterator(Utf8Iterator&& that) = default;
- Utf8Iterator& operator=(Utf8Iterator&& that) = default;
-
- Utf8Iterator& operator++();
- Utf8Iterator operator++(int);
- Utf8Iterator& operator--();
- Utf8Iterator operator--(int);
-
- char32_t operator*() const;
- std::string_view::iterator AsInternal() const;
-
- friend bool operator==(const Utf8Iterator& lhs, const Utf8Iterator& rhs);
- friend bool operator!=(const Utf8Iterator& lhs, const Utf8Iterator& rhs);
- friend bool operator==(const Utf8Iterator& lhs, std::string_view::iterator rhs);
- friend bool operator!=(const Utf8Iterator& lhs, std::string_view::iterator rhs);
-
-private:
- void UpdateCurrentValue() const;
-};
-
-class Utf8IterableString {
-private:
- std::string_view mStr;
-
-public:
- Utf8IterableString(std::string_view str);
- Utf8Iterator begin() const;
- Utf8Iterator end() const;
-};
-
-struct StringEqual {
- using is_transparent = std::true_type;
- bool operator()(std::string_view l, std::string_view r) const noexcept { return l == r; }
-};
-struct StringHash {
- using is_transparent = std::true_type;
- auto operator()(std::string_view str) const noexcept { return std::hash<std::string_view>{}(str); }
-};
-
-std::u32string ConvertUtf8To32(std::string_view str);
-std::string ConvertUtf32To8(std::u32string_view str);
-
-/// Slice the given UTF-8 string into the given range, in codepoints.
-std::string_view StringRange(std::string_view str, size_t begin, size_t end);
-
-/// Calculate the given UTF-8 string's number of codepoints.
-size_t StringLength(std::string_view str);
-
-struct CodepointInfo {
- size_t index;
- size_t byteOffset;
-};
-
-/// Find info about the last codepoint in the given UTF-8 string.
-/// \param str A non-empty UTF-8 encoded string.
-CodepointInfo StringLastCodepoint(std::string_view str);
-/// Find info about the nth codepoint in the given UTF-8 string. If codepointIdx is larger than the length, info for the last codepoint will be returned.
-/// \param str A non-empty UTF-8 encoded string.
-CodepointInfo StringCodepoint(std::string_view str, size_t codepointIdx);