MCRO
C++23 utilities for Unreal Engine.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
TupleAsString.h
Go to the documentation of this file.
1/** @noop License Comment
2 * @file
3 * @copyright
4 * This Source Code is subject to the terms of the Mozilla Public License, v2.0.
5 * If a copy of the MPL was not distributed with this file You can obtain one at
6 * https://mozilla.org/MPL/2.0/
7 *
8 * @author David Mórász
9 * @date 2025
10 */
11
12#pragma once
13#include "CoreMinimal.h"
14
15#include "Mcro/Text.h"
16#include "Mcro/Tuples.h"
17
18namespace Mcro::Text
19{
20 using namespace Mcro::Tuples;
21
22 /** @brief Convert Unreal/STL/Range-V3 tuples to string the following way: `(Item0, Item1, Item2, ...)`*/
23 template <CTuple Operand>
24 struct TAsFormatArgument<Operand>
25 {
26 template <typename Tuple, size_t... Indices>
27 static FString Render(Tuple const& tuple, std::index_sequence<Indices...>&&)
28 {
29 auto body = Join(TEXT_", ", AsString(GetItem<Indices>(tuple))...);
30 return TEXT_"(" + body + TEXT_")";
31 }
32
33 template <CConvertibleToDecayed<Operand> Arg>
34 FString operator () (Arg&& left) const
35 {
36 return Render(left, TIndexSequenceForTuple<Operand>());
37 }
38 };
39}
#define TEXT_
A convenience alternative to Unreal's own TEXT macro but this one doesn't require parenthesis around ...
Definition TextMacros.h:51
Mixed text utilities and type traits.
Definition Enums.h:51
FString Join(const TCHAR *separator, Args... args)
Join the given string arguments with a delimiter and skip empty entries.
Definition Text.h:263
FString AsString(T &&input)
Attempt to convert anything to string which can tell via some method how to do so.
Definition Text.h:388
Templating utilities for manipulating TTuples.
Definition Tuples.h:23
decltype(auto) GetItem(T &&tuple)
Definition Tuples.h:104
std::make_index_sequence< GetSize< T >()> TIndexSequenceForTuple
Definition Tuples.h:134
static FString Render(Tuple const &tuple, std::index_sequence< Indices... > &&)