// Copyright (c) 2012-2023 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::format_arg_store as{ args... }; fmt::internal::vformat_to(buffer, fmt::to_string_view(format), fmt::basic_format_args(as)); } } #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 format_to(ctx.out(), TEXT(formatText), ##__VA_ARGS__); \ } \ }; \ } #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::internal::copy(str.Get(), str.Get() + str.Length(), ctx.out()); \ } \ }; \ }