![]() |
MCRO
C++23 utilities for Unreal Engine.
|
Use leading FMT_
or trailing _FMT
fake text literals to create modern formatted strings with a better API.
More...
#include <string>
#include "CoreMinimal.h"
#include "Mcro/Text.h"
#include "Mcro/TextMacros.h"
#include "Mcro/Enums.h"
#include "Mcro/Macros.h"
Go to the source code of this file.
Macros | |
#define | MCRO_FMT_NAMED_ARG_TRANSFORM(s, data, elem) |
#define | MCRO_FMT_NAMED_ARG(key, value) |
#define | MCRO_FMT_NAMED(seq) |
#define | MCRO_FMT_NAMED_0(seq) |
#define | MCRO_FMT_ORDERED(...) |
#define | MCRO_FMT_ARGS(...) |
#define | FMT_(...) |
Leading fake text literal which makes using FString::Format(...); much more comfortable. | |
#define | _FMT(...) |
Trailing fake text literal which makes using FString::Format(...); much more comfortable. | |
Functions | |
template<size_t N> | |
FString | operator% (FStringFormatOrderedArguments &&args, const TCHAR(&format)[N]) |
template<size_t N> | |
FString | operator% (const TCHAR(&format)[N], FStringFormatOrderedArguments &&args) |
template<size_t N> | |
FString | operator% (FStringFormatNamedArguments &&args, const TCHAR(&format)[N]) |
template<size_t N> | |
FString | operator% (const TCHAR(&format)[N], FStringFormatNamedArguments &&args) |
Use leading FMT_
or trailing _FMT
fake text literals to create modern formatted strings with a better API.
The major difference from PRINTF_
or FString::Printf(...)
is that FMT
macros can take user defined string conversions into account, so more types can be used directly as arguments.
Definition in file FmtMacros.h.
#define _FMT | ( | ... | ) |
Trailing fake text literal which makes using FString::Format(...);
much more comfortable.
FMT
macros allow more types to be used directly in the format arguments expression because Mcro::Text
has a couple of conversion utilities. If the first argument of _FMT
is a sequence of ("key", value)
pairs enclosed in parentheses, then named format arguments are assumed. Ordered format arguments are assumed otherwise. The two modes cannot be mixed.
Usage:
The following argument types are supported out-of-box:
FStringFormatArg
and what's implicitly convertable toFString, FStringView, int32, uint32, int64, uint64, float, double
ANSICHAR, WIDECHAR, UCS2CHAR, UTF8CHAR
pointer stringsToString()
member method which produces one of the above typeFText
and FName
for exampleTAsFormatArgument
template functor for your preferred type and return a value which is implicitly convertible to FStringFormatArg
in the Mcro::Text
namespace. For example check Enums.h
to see how that's done with enums. For your own types you can also implement a ToString()
member method to get automatic support._FMT((A, a) (B, b) (C, c))
) must not have comma ,
between the individual pairs. This is because named argument pairs are passed into this macro as a "sequence" instead of variadic arguments. Ordered format arguments however should be passed in as regular variadic arguments separated by comma ,
as nature intended.FMT
macros are the only things in MCRO where excessive preprocessing is used Definition at line 186 of file FmtMacros.h.
#define FMT_ | ( | ... | ) |
Leading fake text literal which makes using FString::Format(...);
much more comfortable.
FMT
macros allow more types to be used directly in the format arguments expression because Mcro::Text
has a couple of conversion utilities. If the first argument of FMT_
is a sequence of ("key", value)
pairs enclosed in parentheses, then named format arguments are assumed. Ordered format arguments are assumed otherwise. The two modes cannot be mixed.
Usage:
The following argument types are supported out-of-box:
FStringFormatArg
and what's implicitly convertable toFString, FStringView, int32, uint32, int64, uint64, float, double
ANSICHAR, WIDECHAR, UCS2CHAR, UTF8CHAR
pointer stringsToString()
member method which produces one of the above typeFText
and FName
for exampleTAsFormatArgument
template functor for your preferred type and return a value which is implicitly convertible to FStringFormatArg
in the Mcro::Text
namespace. For example check Enums.h
to see how that's done with enums. For your own types you can also implement a ToString()
member method to get automatic support.FMT_((A, a) (B, b) (C, c))
) must not have comma ,
between the individual pairs. This is because named argument pairs are passed into this macro as a "sequence" instead of variadic arguments. Ordered format arguments however should be passed in as regular variadic arguments separated by comma ,
as nature intended.FMT
macros are the only things in MCRO where excessive preprocessing is used Definition at line 136 of file FmtMacros.h.
#define MCRO_FMT_ARGS | ( | ... | ) |
Definition at line 84 of file FmtMacros.h.
#define MCRO_FMT_NAMED | ( | seq | ) |
Definition at line 66 of file FmtMacros.h.
#define MCRO_FMT_NAMED_0 | ( | seq | ) |
Definition at line 72 of file FmtMacros.h.
#define MCRO_FMT_NAMED_ARG | ( | key, | |
value ) |
Definition at line 64 of file FmtMacros.h.
#define MCRO_FMT_NAMED_ARG_TRANSFORM | ( | s, | |
data, | |||
elem ) |
Definition at line 63 of file FmtMacros.h.
#define MCRO_FMT_ORDERED | ( | ... | ) |
Definition at line 82 of file FmtMacros.h.
FString operator% | ( | const TCHAR(&) | format[N], |
FStringFormatNamedArguments && | args ) |
Definition at line 56 of file FmtMacros.h.
FString operator% | ( | const TCHAR(&) | format[N], |
FStringFormatOrderedArguments && | args ) |
Definition at line 40 of file FmtMacros.h.
FString operator% | ( | FStringFormatNamedArguments && | args, |
const TCHAR(&) | format[N] ) |
Definition at line 48 of file FmtMacros.h.
FString operator% | ( | FStringFormatOrderedArguments && | args, |
const TCHAR(&) | format[N] ) |
Definition at line 32 of file FmtMacros.h.