diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/String.cpp | 9 | ||||
-rw-r--r-- | src/platform/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/platform/Color.cpp | 4 | ||||
-rw-r--r-- | src/platform/gui/Keyboard.cpp | 7 | ||||
-rw-r--r-- | src/ui/UiManager.cpp | 1 |
5 files changed, 12 insertions, 11 deletions
diff --git a/src/common/String.cpp b/src/common/String.cpp index 602bcc51..3d3e4a3c 100644 --- a/src/common/String.cpp +++ b/src/common/String.cpp @@ -222,6 +222,11 @@ Range String::RangeFromCodePointToCodeUnit(Range code_point_range) const { IndexFromCodePointToCodeUnit(code_point_range.GetEnd())); } +String& String::operator+=(const String& other) { + append(other); + return *this; +} + namespace { inline int Compare(std::uint16_t left, std::uint16_t right) { if (left < right) return -1; @@ -305,9 +310,6 @@ void FormatAppendFromFormatTokenList( } } // namespace details -StringView::StringView(const std::uint16_t* ptr) - : ptr_(ptr), size_(GetStrSize(ptr)) {} - int StringView::Compare(const StringView& other) const { const_iterator i1 = cbegin(); const_iterator i2 = other.cbegin(); @@ -340,6 +342,7 @@ StringView StringView::substr(Index pos) { StringView StringView::substr(Index pos, Index size) { Expects(pos >= 0 && pos < size_); + return StringView(ptr_ + pos, std::min(size, size_ - pos)); } diff --git a/src/platform/CMakeLists.txt b/src/platform/CMakeLists.txt index e831c544..0288bed0 100644 --- a/src/platform/CMakeLists.txt +++ b/src/platform/CMakeLists.txt @@ -8,7 +8,7 @@ target_sources(cru_platform_base PUBLIC ${CRU_PLATFORM_BASE_INCLUDE_DIR}/Check.hpp ${CRU_PLATFORM_BASE_INCLUDE_DIR}/Color.hpp ${CRU_PLATFORM_BASE_INCLUDE_DIR}/Exception.hpp - ${CRU_PLATFORM_BASE_INCLUDE_DIR}/GraphBase.hpp + ${CRU_PLATFORM_BASE_INCLUDE_DIR}/GraphicsBase.hpp ${CRU_PLATFORM_BASE_INCLUDE_DIR}/HeapDebug.hpp ${CRU_PLATFORM_BASE_INCLUDE_DIR}/Matrix.hpp ${CRU_PLATFORM_BASE_INCLUDE_DIR}/Resource.hpp diff --git a/src/platform/Color.cpp b/src/platform/Color.cpp index 52534048..cced498c 100644 --- a/src/platform/Color.cpp +++ b/src/platform/Color.cpp @@ -13,11 +13,11 @@ String Color::ToString() const { return v >= 10 ? v - 10 + u'a' : v + u'0'; }; - auto to_two_hex_digit = [to_hex](std::uint8_t v) -> std::u16string { + auto to_two_hex_digit = [to_hex](std::uint8_t v) -> String { return {to_hex(v /= 16), to_hex(v %= 16)}; }; - std::u16string result = u"#"; + String result = u"#"; result.append(to_two_hex_digit(red)); result.append(to_two_hex_digit(green)); result.append(to_two_hex_digit(blue)); diff --git a/src/platform/gui/Keyboard.cpp b/src/platform/gui/Keyboard.cpp index 24880e00..7d4903e5 100644 --- a/src/platform/gui/Keyboard.cpp +++ b/src/platform/gui/Keyboard.cpp @@ -5,8 +5,7 @@ #include <string_view> namespace cru::platform::gui { -constexpr std::array<std::u16string_view, - static_cast<int>(KeyCode::NumPad9) + 1> +const std::array<StringView, static_cast<int>(KeyCode::NumPad9) + 1> key_code_string_list{u"Unknown", u"LeftButton", u"MiddleButton", @@ -106,13 +105,13 @@ constexpr std::array<std::u16string_view, u"NumPad8", u"NumPad9"}; -std::u16string_view ToString(KeyCode key_code) { +String ToString(KeyCode key_code) { if (static_cast<int>(key_code) < 0 || static_cast<int>(key_code) >= static_cast<int>(key_code_string_list.size())) return u"UNKNOWN_KEYCODENAME"; - return key_code_string_list[static_cast<int>(key_code)]; + return key_code_string_list[static_cast<int>(key_code)].ToString(); } std::u16string ToString(KeyModifier key_modifier, diff --git a/src/ui/UiManager.cpp b/src/ui/UiManager.cpp index 45dd1775..b0cc769a 100644 --- a/src/ui/UiManager.cpp +++ b/src/ui/UiManager.cpp @@ -2,7 +2,6 @@ #include <optional> #include "Helper.hpp" -#include "cru/platform/GraphBase.hpp" #include "cru/platform/graphics/Brush.hpp" #include "cru/platform/graphics/Factory.hpp" #include "cru/platform/graphics/Font.hpp" |