aboutsummaryrefslogtreecommitdiff
path: root/include/cru/platform
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/platform')
-rw-r--r--include/cru/platform/Check.hpp15
-rw-r--r--include/cru/platform/GraphBase.hpp11
-rw-r--r--include/cru/platform/gui/InputMethod.hpp51
3 files changed, 37 insertions, 40 deletions
diff --git a/include/cru/platform/Check.hpp b/include/cru/platform/Check.hpp
index 9ecd2d1d..5d99aa9c 100644
--- a/include/cru/platform/Check.hpp
+++ b/include/cru/platform/Check.hpp
@@ -2,9 +2,8 @@
#include "Exception.hpp"
#include "Resource.hpp"
-#include "cru/common/StringUtil.hpp"
+#include "cru/common/String.hpp"
-#include <fmt/format.h>
#include <memory>
#include <type_traits>
@@ -15,10 +14,10 @@ TTarget* CheckPlatform(IPlatformResource* resource,
Expects(resource);
const auto result = dynamic_cast<TTarget*>(resource);
if (result == nullptr) {
- throw UnsupportPlatformException(String::FromUtf8(fmt::format(
- "Try to convert resource to target platform failed. Platform id of "
+ throw UnsupportPlatformException(Format(
+ u"Try to convert resource to target platform failed. Platform id of "
"resource to convert: {} . Target platform id: {} .",
- resource->GetPlatformId().ToUtf8(), target_platform.ToUtf8())));
+ resource->GetPlatformId(), target_platform));
}
return result;
}
@@ -31,10 +30,10 @@ std::shared_ptr<TTarget> CheckPlatform(const std::shared_ptr<TSource>& resource,
Expects(resource);
const auto result = std::dynamic_pointer_cast<TTarget>(resource);
if (result == nullptr) {
- throw UnsupportPlatformException(String::FromUtf8(fmt::format(
- "Try to convert resource to target platform failed. Platform id of "
+ throw UnsupportPlatformException(Format(
+ u"Try to convert resource to target platform failed. Platform id of "
"resource to convert: {} . Target platform id: {} .",
- resource->GetPlatformId().ToUtf8(), target_platform.ToUtf8())));
+ resource->GetPlatformId(), target_platform));
}
return result;
}
diff --git a/include/cru/platform/GraphBase.hpp b/include/cru/platform/GraphBase.hpp
index cc0ffcc7..2cfc9cc4 100644
--- a/include/cru/platform/GraphBase.hpp
+++ b/include/cru/platform/GraphBase.hpp
@@ -4,8 +4,8 @@
#include "Color.hpp"
#include "cru/common/Format.hpp"
#include "cru/common/Range.hpp"
+#include "cru/common/String.hpp"
-#include <fmt/core.h>
#include <cstdint>
#include <limits>
#include <optional>
@@ -20,8 +20,8 @@ struct Point final {
constexpr Point(const float x, const float y) : x(x), y(y) {}
explicit constexpr Point(const Size& size);
- std::u16string ToDebugString() const {
- return fmt::format(u"({}, {})", ToUtf16String(x), ToUtf16String(y));
+ String ToDebugString() const {
+ return Format(u"({}, {})", ToUtf16String(x), ToUtf16String(y));
}
constexpr Point& operator+=(const Point& other) {
@@ -62,9 +62,8 @@ struct Size final {
std::numeric_limits<float>::max()};
}
- std::u16string ToDebugString() const {
- return fmt::format(u"({}, {})", ToUtf16String(width),
- ToUtf16String(height));
+ String ToDebugString() const {
+ return Format(u"({}, {})", ToUtf16String(width), ToUtf16String(height));
}
float width = 0;
diff --git a/include/cru/platform/gui/InputMethod.hpp b/include/cru/platform/gui/InputMethod.hpp
index 9b07959c..c259e63c 100644
--- a/include/cru/platform/gui/InputMethod.hpp
+++ b/include/cru/platform/gui/InputMethod.hpp
@@ -3,7 +3,6 @@
#include "cru/common/Event.hpp"
-#include <fmt/format.h>
#include <memory>
#include <vector>
@@ -54,28 +53,28 @@ struct IInputMethodContext : virtual IPlatformResource {
};
} // namespace cru::platform::gui
-template <>
-struct fmt::formatter<cru::platform::gui::CompositionText, char16_t>
- : fmt::formatter<std::u16string_view, char16_t> {
- auto parse(fmt::basic_format_parse_context<char16_t>& ctx) {
- return fmt::formatter<std::u16string_view, char16_t>::parse(ctx);
- }
-
- template <typename FormatContext>
- auto format(const cru::platform::gui::CompositionText& ct,
- FormatContext& ctx) {
- auto output = ctx.out();
- output = format_to(output, u"text: {}\n", ct.text);
- output = format_to(output, u"clauses:\n");
- for (gsl::index i = 0; i < static_cast<gsl::index>(ct.clauses.size());
- i++) {
- const auto& clause = ct.clauses[i];
- output =
- format_to(output, u"\t{}. start: {} end: {}{}\n", i, clause.start,
- clause.end, clause.target ? u" target" : u"");
- }
- output = format_to(output, u"selection: position: {} count: {}",
- ct.selection.position, ct.selection.count);
- return output;
- }
-};
+// template <>
+// struct fmt::formatter<cru::platform::gui::CompositionText, char16_t>
+// : fmt::formatter<std::u16string_view, char16_t> {
+// auto parse(fmt::basic_format_parse_context<char16_t>& ctx) {
+// return fmt::formatter<std::u16string_view, char16_t>::parse(ctx);
+// }
+
+// template <typename FormatContext>
+// auto format(const cru::platform::gui::CompositionText& ct,
+// FormatContext& ctx) {
+// auto output = ctx.out();
+// output = format_to(output, u"text: {}\n", ct.text);
+// output = format_to(output, u"clauses:\n");
+// for (gsl::index i = 0; i < static_cast<gsl::index>(ct.clauses.size());
+// i++) {
+// const auto& clause = ct.clauses[i];
+// output =
+// format_to(output, u"\t{}. start: {} end: {}{}\n", i, clause.start,
+// clause.end, clause.target ? u" target" : u"");
+// }
+// output = format_to(output, u"selection: position: {} count: {}",
+// ct.selection.position, ct.selection.count);
+// return output;
+// }
+// };