// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Types/BaseTypes.h" #include "Engine/Core/Memory/StlWrapper.h" #include namespace fmt_flax { typedef std_flax::allocator allocator; typedef std_flax::allocator allocator_ansi; typedef fmt::basic_memory_buffer memory_buffer; typedef fmt::basic_memory_buffer memory_buffer_ansi; template FORCE_INLINE static void format(fmt::basic_memory_buffer>& buffer, const T* format, const Args& ... args) { typedef fmt::buffer_context context; fmt::detail::vformat_to(buffer, fmt::basic_string_view(format), fmt::make_format_args(args...), {}); } } #define DEFINE_DEFAULT_FORMATTING(type, formatText, ...) \ namespace fmt \ { \ template<> \ struct formatter \ { \ template \ auto parse(ParseContext& ctx) \ { \ return ctx.begin(); \ } \ template \ auto format(const type& v, FormatContext& ctx) -> decltype(ctx.out()) \ { \ return fmt::format_to(ctx.out(), basic_string_view(TEXT(formatText)), ##__VA_ARGS__); \ } \ }; \ } static_assert(true, "") #define DEFINE_DEFAULT_FORMATTING_VIA_TO_STRING(type) \ namespace fmt \ { \ template<> \ struct formatter \ { \ template \ auto parse(ParseContext& ctx) \ { \ return ctx.begin(); \ } \ template \ auto format(const type& v, FormatContext& ctx) -> decltype(ctx.out()) \ { \ const String str = v.ToString(); \ return fmt::detail::copy_str(str.Get(), str.Get() + str.Length(), ctx.out()); \ } \ }; \ } static_assert(true, "")