MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Mcro::Text Namespace Reference

Mixed text utilities and type traits. More...

Namespaces

namespace  Detail
 
namespace  Macros
 This namespace is used by MCRO text literal macros, don't use it directly!
 

Data Structures

struct  TAsFormatArgument
 
struct  TAsFormatArgument< FStdStringView >
 
struct  TAsFormatArgument< Operand >
 Convert Unreal/STL/Range-V3 tuples to string the following way: (Item0, Item1, Item2, ...) More...
 
struct  TAsFormatArgument< TStdString< CharType > >
 

Concepts

concept  CStringViewInvariant
 Concept constraining given type to a string view of any character type.
 
concept  CStringInvariant
 Concept constraining given type to a string of any character type.
 
concept  CStringOrView
 Concept constraining given type to a string or a a view of TCHAR.
 
concept  CStringOrViewInvariant
 Concept constraining given type to a string or a a view of any character type.
 
concept  CStringOrViewOrName
 Concept constraining given type to a string, a view or an FName of TCHAR.
 
concept  CStdStringOrView
 Concept constraining given type to a std::string or a view of TCHAR.
 
concept  CStdStringOrViewTyped
 Concept constraining given type to a std::string or a view of given character type.
 
concept  CStdStringInvariant
 Concept constraining given type to only a std::string of any character type.
 
concept  CStdStringViewInvariant
 Concept constraining given type to only a std::string_view of any character type.
 
concept  CStdStringOrViewInvariant
 Concept constraining given type to a std::string or a view of any character type.
 
concept  CDirectStringFormatArgument
 A type which is directly convertible to FStringFormatArg.
 
concept  CHasToString
 A type which which provides a ToString() member method.
 
concept  CHasPtrToString
 A type which which provides a ToString() member method.
 
concept  CHasStringFormatArgumentConversion
 A type which can be used with FStringFormatArg via a TAsFormatArgument specialization.
 
concept  CStringFormatArgument
 A type which can be converted to FStringFormatArg via any method.
 

Typedefs

template<class CharT , class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
using TStdString = std::basic_string<CharT, Traits, Allocator>
 Unreal style alias for STL strings.
 
template<class CharT , class Traits = std::char_traits<CharT>>
using TStdStringView = std::basic_string_view<CharT, Traits>
 Unreal style alias for STL string views.
 
using FUtf16StringView = TStringView<UTF16CHAR>
 
using FUtf32StringView = TStringView<UTF32CHAR>
 
using FStdString = TStdString<TCHAR>
 cross-TCHAR alias for std::[w]string
 
using FStdStringView = TStdStringView<TCHAR>
 cross-TCHAR alias for std::[w]string_view
 

Functions

template<typename CharType >
constexpr auto UnrealView (TStdStringView< CharType > const &stdStr)
 View an STL string object via an Unreal TStringView
 
template<CStringViewInvariant T>
constexpr auto StdView (T const &unrealStr)
 View an Unreal TStringView via an STL string view.
 
template<CConvertibleToDecayed< FString > T>
auto StdView (T const &unrealStr)
 View an Unreal string via an STL string view.
 
MCRO_API FString UnrealCopy (FStdStringView const &stdStr)
 Create a copy of an input STL string.
 
template<CStdStringOrViewInvariant T>
FString UnrealConvert (T const &stdStr)
 Create a copy and convert an input STL string to TCHAR.
 
MCRO_API FName UnrealNameCopy (FStdStringView const &stdStr)
 Create a copy of an input STL string as an FName.
 
template<CStdStringOrViewInvariant T>
FName UnrealNameConvert (T const &stdStr)
 Create a copy and convert an input STL string to TCHAR as an FName.
 
MCRO_API FStdString StdCopy (FStringView const &unrealStr)
 Create an Stl copy of an input Unreal string view.
 
MCRO_API FStdString StdCopy (FName const &unrealStr)
 Create an Stl copy of an input Unreal string.
 
template<typename ConvertTo >
auto StdConvert (FStringView const &unrealStr) -> TStdString< ConvertTo >
 Create a copy and convert an input Unreal string to the given character type.
 
template<typename ConvertTo >
auto StdConvert (FStdStringView const &stdStr) -> TStdString< ConvertTo >
 Create a copy and convert an input STL string of TCHAR to the given character type.
 
template<typename ConvertTo >
auto StdConvert (FName const &name) -> TStdString< ConvertTo >
 Create a copy and convert an input FName to the given character type.
 
template<CStringOrView... Args>
FString Join (const TCHAR *separator, Args... args)
 Join the given string arguments with a delimiter and skip empty entries.
 
template<CStringFormatArgument T>
auto AsFormatArgument (T &&input)
 
template<CStringFormatArgument T>
requires (!CSameAsDecayed<T, FString>)
FString AsString (T &&input)
 Attempt to convert anything to string which can tell via some method how to do so.
 
template<CSameAsDecayed< FString > T>
decltype(auto) AsString (T &&input)
 
template<CStringFormatArgument T>
requires (!CSameAsDecayed<T, FText>)
FText AsText (T &&input)
 Convert anything which is compatible with AsString to FText.
 
template<CSameAsDecayed< FText > T>
decltype(auto) AsText (T &&input)
 
template<CStringFormatArgument... Args>
FStringFormatOrderedArguments OrderedArguments (Args &&... args)
 Create an ordered argument list for a string format from input arguments.
 
template<CStringFormatArgument... Args>
FStringFormatNamedArguments NamedArguments (TTuple< FString, Args >... args)
 Create a named argument list for a string format from input argument tuples.
 

Detailed Description

Mixed text utilities and type traits.

Typedef Documentation

◆ FStdString

cross-TCHAR alias for std::[w]string

Definition at line 57 of file Text.h.

◆ FStdStringView

cross-TCHAR alias for std::[w]string_view

Definition at line 60 of file Text.h.

◆ FUtf16StringView

using Mcro::Text::FUtf16StringView = TStringView<UTF16CHAR>

Definition at line 53 of file Text.h.

◆ FUtf32StringView

using Mcro::Text::FUtf32StringView = TStringView<UTF32CHAR>

Definition at line 54 of file Text.h.

◆ TStdString

template<class CharT , class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>>
using Mcro::Text::TStdString = std::basic_string<CharT, Traits, Allocator>

Unreal style alias for STL strings.

Definition at line 44 of file Text.h.

◆ TStdStringView

template<class CharT , class Traits = std::char_traits<CharT>>
using Mcro::Text::TStdStringView = std::basic_string_view<CharT, Traits>

Unreal style alias for STL string views.

Definition at line 51 of file Text.h.

Function Documentation

◆ AsFormatArgument()

template<CStringFormatArgument T>
auto Mcro::Text::AsFormatArgument ( T && input)

Definition at line 381 of file Text.h.

◆ AsString() [1/2]

template<CStringFormatArgument T>
requires (!CSameAsDecayed<T, FString>)
FString Mcro::Text::AsString ( T && input)

Attempt to convert anything to string which can tell via some method how to do so.

This may be more expensive than directly using an already existing designated string conversion for a given type, because it uses FStringFormatArg and a TAsFormatArgument as intermediate steps. However, this can be still useful for types where such conversion doesn't already exist or when using this in a template.

It's still much faster than using FMT_(myVar) "{0}"

Definition at line 397 of file Text.h.

◆ AsString() [2/2]

template<CSameAsDecayed< FString > T>
decltype(auto) Mcro::Text::AsString ( T && input)

Definition at line 404 of file Text.h.

◆ AsText() [1/2]

template<CStringFormatArgument T>
requires (!CSameAsDecayed<T, FText>)
FText Mcro::Text::AsText ( T && input)

Convert anything which is compatible with AsString to FText.

Definition at line 414 of file Text.h.

◆ AsText() [2/2]

template<CSameAsDecayed< FText > T>
decltype(auto) Mcro::Text::AsText ( T && input)

Definition at line 420 of file Text.h.

◆ Join()

template<CStringOrView... Args>
FString Mcro::Text::Join ( const TCHAR * separator,
Args... args )

Join the given string arguments with a delimiter and skip empty entries.

Definition at line 274 of file Text.h.

◆ NamedArguments()

template<CStringFormatArgument... Args>
FStringFormatNamedArguments Mcro::Text::NamedArguments ( TTuple< FString, Args >... args)

Create a named argument list for a string format from input argument tuples.

While you can it is not recommended to be used directly because the boilerplate it still needs is very verbose. Check _FMT or FMT_ macros for a comfortable string format syntax.

Definition at line 444 of file Text.h.

◆ OrderedArguments()

template<CStringFormatArgument... Args>
FStringFormatOrderedArguments Mcro::Text::OrderedArguments ( Args &&... args)

Create an ordered argument list for a string format from input arguments.

While you can it is not recommended to be used directly because the boilerplate it still needs is very verbose. Check _FMT or FMT_ macros for a comfortable string format syntax.

Definition at line 432 of file Text.h.

◆ StdConvert() [1/3]

template<typename ConvertTo >
auto Mcro::Text::StdConvert ( FName const & name) -> TStdString<ConvertTo>

Create a copy and convert an input FName to the given character type.

Definition at line 267 of file Text.h.

◆ StdConvert() [2/3]

template<typename ConvertTo >
auto Mcro::Text::StdConvert ( FStdStringView const & stdStr) -> TStdString<ConvertTo>

Create a copy and convert an input STL string of TCHAR to the given character type.

Definition at line 250 of file Text.h.

◆ StdConvert() [3/3]

template<typename ConvertTo >
auto Mcro::Text::StdConvert ( FStringView const & unrealStr) -> TStdString<ConvertTo>

Create a copy and convert an input Unreal string to the given character type.

Definition at line 233 of file Text.h.

◆ StdCopy() [1/2]

MCRO_API FStdString Mcro::Text::StdCopy ( FName const & unrealStr)

Create an Stl copy of an input Unreal string.

◆ StdCopy() [2/2]

MCRO_API FStdString Mcro::Text::StdCopy ( FStringView const & unrealStr)

Create an Stl copy of an input Unreal string view.

◆ StdView() [1/2]

template<CStringViewInvariant T>
auto Mcro::Text::StdView ( T const & unrealStr)
constexpr

View an Unreal TStringView via an STL string view.

Definition at line 182 of file Text.h.

◆ StdView() [2/2]

template<CConvertibleToDecayed< FString > T>
auto Mcro::Text::StdView ( T const & unrealStr)

View an Unreal string via an STL string view.

Definition at line 189 of file Text.h.

◆ UnrealConvert()

template<CStdStringOrViewInvariant T>
FString Mcro::Text::UnrealConvert ( T const & stdStr)

Create a copy and convert an input STL string to TCHAR.

Definition at line 199 of file Text.h.

◆ UnrealCopy()

MCRO_API FString Mcro::Text::UnrealCopy ( FStdStringView const & stdStr)

Create a copy of an input STL string.

◆ UnrealNameConvert()

template<CStdStringOrViewInvariant T>
FName Mcro::Text::UnrealNameConvert ( T const & stdStr)

Create a copy and convert an input STL string to TCHAR as an FName.

Definition at line 215 of file Text.h.

◆ UnrealNameCopy()

MCRO_API FName Mcro::Text::UnrealNameCopy ( FStdStringView const & stdStr)

Create a copy of an input STL string as an FName.

◆ UnrealView()

template<typename CharType >
auto Mcro::Text::UnrealView ( TStdStringView< CharType > const & stdStr)
constexpr

View an STL string object via an Unreal TStringView

Definition at line 175 of file Text.h.