MCRO
C++23 utilities for Unreal Engine.
Loading...
Searching...
No Matches
Yaml.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
14
#include "CoreMinimal.h"
15
#include "
Mcro/Text.h
"
16
17
#include "
Mcro/LibraryIncludes/Start.h
"
18
#include "PreMagicEnum.h"
19
#include "magic_enum.hpp"
20
#include "yaml-cpp/yaml.h"
21
#include "
Mcro/LibraryIncludes/End.h
"
22
23
namespace
Mcro::Yaml
24
{
25
using namespace
Mcro::Text
;
26
27
/**
28
* RAII friendly region annotation for YAML::Emitter streams
29
* @tparam Begin The YAML region begin tag
30
* @tparam End The YAML region end tag
31
*/
32
template
<YAML::EMITTER_MANIP Begin, YAML::EMITTER_MANIP End>
33
class
TScopedRegion
34
{
35
YAML::Emitter& Out;
36
37
public
:
38
TScopedRegion
(YAML::Emitter& out) : Out(out) { Out << Begin; }
39
~TScopedRegion
() { Out << End; }
40
41
template
<
typename
T>
42
TScopedRegion
&
operator <<
(T&& rhs)
43
{
44
Out << Forward<T>(rhs);
45
return
*
this
;
46
}
47
};
48
49
/** Annotate a mapping region in a YAML::Emitter stream, which ends when this object goes out of scope */
50
using
FMap
=
TScopedRegion<YAML::BeginMap, YAML::EndMap>
;
51
52
/** Annotate a sequence region in a YAML::Emitter stream, which ends when this object goes out of scope */
53
using
FSeq
=
TScopedRegion<YAML::BeginSeq, YAML::EndSeq>
;
54
55
/** Convenience operator to append Unreal or potentially wide strings to YAML::Emitter streams */
56
template
<
typename
String>
57
requires
(CStringOrViewOrName<String> || CStdStringOrView<String>)
58
YAML::Emitter&
operator
<< (YAML::Emitter& out, String&& v)
59
{
60
out << StdConvertUtf8(Forward<String>(v));
61
return
out;
62
}
63
64
/** Convenience operator to append enums as strings to a YAML::Emitter streams */
65
template
<CEnum Enum>
66
YAML::Emitter&
operator <<
(YAML::Emitter& out, Enum v)
67
{
68
out <<
StdConvertUtf8
(magic_enum::enum_name(v));
69
return
out;
70
}
71
}
End.h
Start.h
Text.h
Mcro::Yaml::TScopedRegion
Definition
Yaml.h:34
Mcro::Yaml::TScopedRegion::operator<<
TScopedRegion & operator<<(T &&rhs)
Definition
Yaml.h:42
Mcro::Yaml::TScopedRegion::~TScopedRegion
~TScopedRegion()
Definition
Yaml.h:39
Mcro::Yaml::TScopedRegion::TScopedRegion
TScopedRegion(YAML::Emitter &out)
Definition
Yaml.h:38
Mcro::Text
Definition
Text.h:20
Mcro::Text::StdConvertUtf8
MCRO_API std::string StdConvertUtf8(FStringView const &unrealStr)
Mcro::Yaml
Definition
Yaml.h:24
Mcro::Yaml::operator<<
YAML::Emitter & operator<<(YAML::Emitter &out, String &&v)
Definition
Yaml.h:58
Mcro_Origin
Public
Mcro
Yaml.h
Generated by
1.12.0