18#ifndef TRINITYCORE_STRING_FORMAT_H
19#define TRINITYCORE_STRING_FORMAT_H
26 template<
typename... Args>
33 template<
typename... Args>
34 constexpr auto MakeFormatArgs(Args&&... args) {
return fmt::make_format_args(args...); }
37 template<
typename... Args>
42 return fmt::format(
fmt, std::forward<Args>(args)...);
44 catch (std::exception
const& formatError)
46 return fmt::format(
"An error occurred formatting string \"{}\" : {}",
FormatStringView(
fmt), formatError.what());
50 template<
typename OutputIt,
typename... Args>
55 return fmt::format_to(out,
fmt, std::forward<Args>(args)...);
57 catch (std::exception
const& formatError)
59 return fmt::format_to(out,
"An error occurred formatting string \"{}\" : {}",
FormatStringView(
fmt), formatError.what());
67 return fmt::vformat(
fmt, args);
69 catch (std::exception
const& formatError)
71 return fmt::format(
"An error occurred formatting string \"{}\" : {}",
fmt, formatError.what());
75 template<
typename OutputIt>
80 return fmt::vformat_to(out,
fmt, args);
82 catch (std::exception
const& formatError)
84 return fmt::format_to(out,
"An error occurred formatting string \"{}\" : {}",
fmt, formatError.what());
91 return fmt ==
nullptr;
108 return fmt.size() == 0;
112template<
typename T,
typename Char>
115 template<
typename FormatContext>
118 if (value.has_value())
126template <
typename E, std::enable_if_t<std::is_enum_v<E>, std::
nullptr_t> =
nullptr>
127auto format_as(E e) {
return std::underlying_type_t<E>(e); }
std::optional< T > Optional
Optional helper class to wrap optional values within.
fmt::format_args FormatArgs
OutputIt StringFormatTo(OutputIt out, FormatString< Args... > fmt, Args &&... args)
std::string StringVFormat(FormatStringView fmt, FormatArgs args)
std::string StringFormat(FormatString< Args... > fmt, Args &&... args)
Default TC string format function.
bool IsFormatEmptyOrNull(char const *fmt)
Returns true if the given char pointer is null.
fmt::format_string< Args... > FormatString
constexpr auto MakeFormatArgs(Args &&... args)
OutputIt StringVFormatTo(OutputIt out, FormatStringView fmt, FormatArgs args)
fmt::string_view FormatStringView