MCRO
C++23 utilities for Unreal Engine.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
TextMacros.h File Reference

Use leading TEXT_ without parenthesis for Unreal compatible text literals. More...

#include <string>
#include "CoreMinimal.h"
#include "Mcro/FunctionTraits.h"

Go to the source code of this file.

Data Structures

struct  Mcro::Text::Macros::FDefer_AsLocalizable_Advanced
 
struct  Mcro::Text::Macros::FInvTextFakeLiteralTag
 
struct  Mcro::Text::Macros::FStringViewFakeLiteralTag
 
struct  Mcro::Text::Macros::FStringFakeLiteralTag
 
struct  Mcro::Text::Macros::FNameFakeLiteralTag
 
struct  Mcro::Text::Macros::FStdStringLiteralTag
 
struct  Mcro::Text::Macros::TStringPrintfLiteral< Args >
 

Namespaces

namespace  Mcro
 
namespace  Mcro::Text
 Mixed text utilities and type traits.
 
namespace  Mcro::Text::Macros
 This namespace is used by MCRO text literal macros, don't use it directly!
 

Macros

#define UTF8TEXT_PASTE_   u8""
 
#define UTF16TEXT_PASTE_   u""
 
#define WIDETEXT_PASTE_   L""
 
#define UTF8TEXT_   UTF8TEXT_PASTE_
 
#define UTF16TEXT_   UTF16TEXT_PASTE_
 
#define WIDETEXT_   WIDETEXT_PASTE_
 
#define TEXT_PASTE_   WIDETEXT_
 
#define TEXT_   TEXT_PASTE_
 A convenience alternative to Unreal's own TEXT macro but this one doesn't require parenthesis around the text literal, relying on string literal concatenation rules of C++.
 
#define LOCTEXT_(key)
 A convenience alternative to Unreal's own LOCTEXT macro but this one doesn't require parenthesis around the text literal.
 
#define NSLOCTEXT_(ns, key)
 A convenience alternative to Unreal's own NSLOCTEXT macro but this one doesn't require parenthesis around the text literal.
 
#define INVTEXT_    Mcro::Text::Macros::FInvTextFakeLiteralTag() % TEXT_
 A convenience alternative to Unreal's own INVTEXT macro but this one doesn't require parenthesis around the text literal.
 
#define TEXTVIEW_   Mcro::Text::Macros::FStringViewFakeLiteralTag() % TEXT_
 A convenience alternative to Unreal's own TEXTVIEW macro but this one doesn't require parenthesis around the text literal.
 
#define STDVIEW_   Mcro::Text::Macros::FStdStringLiteralTag() % TEXT_
 A convenience alternative to Unreal's own TEXTVIEW macro but this one doesn't require parenthesis around the text literal and it returns an STL string view.
 
#define STRING_   Mcro::Text::Macros::FStringFakeLiteralTag() % TEXT_
 A convenience macro to allocate an FString directly.
 
#define NAME_   Mcro::Text::Macros::FNameFakeLiteralTag() % TEXT_
 A convenience macro to allocate an FName directly.
 
#define _PRINTF(...)
 Trailing fake text literal which shortens down the FString::Printf(TEXT("..."), ...); expression.
 
#define PRINTF_(...)
 Leading fake text literal which shortens down the FString::Printf(TEXT("..."), ...); expression.
 

Functions

FORCEINLINE FText Mcro::Text::Macros::AsLocalizable_Advanced (const FTextKey &Namespace, const FTextKey &Key, const TCHAR *String)
 
template<typename... Args>
TStringPrintfLiteral< Args... > Mcro::Text::Macros::MakePrintfLiteral (Args &&... args)
 

Detailed Description

Use leading TEXT_ without parenthesis for Unreal compatible text literals.

Author
David Mórász
Date
2025

Definition in file TextMacros.h.

Macro Definition Documentation

◆ _PRINTF

#define _PRINTF ( ...)
Value:
TStringPrintfLiteral< Args... > MakePrintfLiteral(Args &&... args)
Definition TextMacros.h:157

Trailing fake text literal which shortens down the FString::Printf(TEXT("..."), ...); expression.

Usage:

int count, FString type;
TEXT_"My format literal with %d and %s" _PRINTF(count, type);
// ^ this space is important
#define TEXT_
A convenience alternative to Unreal's own TEXT macro but this one doesn't require parenthesis around ...
Definition TextMacros.h:51
#define _PRINTF(...)
Trailing fake text literal which shortens down the FString::Printf(TEXT("..."), .....
Definition TextMacros.h:245

This operation runs FString::Printf in runtime and allocates a struct which stores the format arguments (preserving CV-ref qualifiers).

Definition at line 245 of file TextMacros.h.

◆ INVTEXT_

A convenience alternative to Unreal's own INVTEXT macro but this one doesn't require parenthesis around the text literal.

This operation allocates FText in runtime and an empty tag struct

Definition at line 190 of file TextMacros.h.

◆ LOCTEXT_

#define LOCTEXT_ ( key)
Value:

A convenience alternative to Unreal's own LOCTEXT macro but this one doesn't require parenthesis around the text literal.

This operation allocates an argument deferring struct and FText in runtime

Definition at line 170 of file TextMacros.h.

◆ NAME_

A convenience macro to allocate an FName directly.

This operation allocates FName in runtime and an empty tag struct. This is not a custom string literal because they're not available for concatenated groups of string literals of mixed encodings.

Definition at line 229 of file TextMacros.h.

◆ NSLOCTEXT_

#define NSLOCTEXT_ ( ns,
key )
Value:

A convenience alternative to Unreal's own NSLOCTEXT macro but this one doesn't require parenthesis around the text literal.

This operation allocates an argument deferring struct and FText in runtime

Definition at line 180 of file TextMacros.h.

◆ PRINTF_

#define PRINTF_ ( ...)
Value:

Leading fake text literal which shortens down the FString::Printf(TEXT("..."), ...); expression.

Usage:

int count, FString type;
PRINTF_(count, type) "My format literal with %d and %s";
// ^ this space is optional
#define PRINTF_(...)
Leading fake text literal which shortens down the FString::Printf(TEXT("..."), ......
Definition TextMacros.h:261

This operation runs FString::Printf in runtime and allocates a struct which stores the format arguments (preserving CV-ref qualifiers).

Definition at line 261 of file TextMacros.h.

◆ STDVIEW_

A convenience alternative to Unreal's own TEXTVIEW macro but this one doesn't require parenthesis around the text literal and it returns an STL string view.

This operation creates a std::[w]string_view in consteval time. This is not a custom string literal because they're not available for concatenated groups of string literals of mixed encodings.

Definition at line 211 of file TextMacros.h.

◆ STRING_

A convenience macro to allocate an FString directly.

This operation allocates FString in runtime and an empty tag struct. This is not a custom string literal because they're not available for concatenated groups of string literals of mixed encodings.

Definition at line 220 of file TextMacros.h.

◆ TEXT_

#define TEXT_   TEXT_PASTE_

A convenience alternative to Unreal's own TEXT macro but this one doesn't require parenthesis around the text literal, relying on string literal concatenation rules of C++.

This operation is resolved entirely in compile time

Definition at line 51 of file TextMacros.h.

◆ TEXT_PASTE_

#define TEXT_PASTE_   WIDETEXT_

Definition at line 41 of file TextMacros.h.

◆ TEXTVIEW_

A convenience alternative to Unreal's own TEXTVIEW macro but this one doesn't require parenthesis around the text literal.

This operation creates an FStringView in consteval time. This is not a custom string literal because they're not available for concatenated groups of string literals of mixed encodings.

Definition at line 201 of file TextMacros.h.

◆ UTF16TEXT_

#define UTF16TEXT_   UTF16TEXT_PASTE_

Definition at line 35 of file TextMacros.h.

◆ UTF16TEXT_PASTE_

#define UTF16TEXT_PASTE_   u""

Definition at line 26 of file TextMacros.h.

◆ UTF8TEXT_

#define UTF8TEXT_   UTF8TEXT_PASTE_

Definition at line 34 of file TextMacros.h.

◆ UTF8TEXT_PASTE_

#define UTF8TEXT_PASTE_   u8""

Definition at line 25 of file TextMacros.h.

◆ WIDETEXT_

#define WIDETEXT_   WIDETEXT_PASTE_

Definition at line 36 of file TextMacros.h.

◆ WIDETEXT_PASTE_

#define WIDETEXT_PASTE_   L""

Definition at line 31 of file TextMacros.h.