Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
Escape.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/StringFwd.h"
6#include "Containers/StringView.h"
7#include "CoreTypes.h"
8
9namespace UE::String::Private
10{
11
12struct FEscape { FStringView Input; };
13struct FQuoteEscape { FStringView Input; };
14
15} // UE::String::Private
16
17namespace UE::String
18{
19
20/**
21 * Escape the string into the string builder.
22 *
23 * Example: Escape("Tab is \t and \" is a quote.", Output) -> "Tab is \\t and \\\" is a quote."
24 */
25void EscapeTo(FStringView Input, FStringBuilderBase& Output);
26
27/**
28 * Escape the string when appended to a string builder.
29 *
30 * Example: Builder << String::Escape(Value);
31 */
32inline Private::FEscape Escape(FStringView Input) { return {Input}; }
33
34/**
35 * Quote and escape the string into the string builder.
36 *
37 * Example: QuoteEscape("Tab is \t and \" is a quote.", Output) -> "\"Tab is \\t and \\\" is a quote.\""
38 */
39void QuoteEscapeTo(FStringView Input, FStringBuilderBase& Output);
40
41/**
42 * Quote and escape the string when appended to a string builder.
43 *
44 * Example: Builder << String::QuoteEscape(Value);
45 */
46inline Private::FQuoteEscape QuoteEscape(FStringView Input) { return {Input}; }
47
48} // UE::String
49
50namespace UE::String::Private
51{
52
53inline FStringBuilderBase& operator<<(FStringBuilderBase& Builder, const FEscape& Adapter)
54{
55 EscapeTo(Adapter.Input, Builder);
56 return Builder;
57}
58
59inline FStringBuilderBase& operator<<(FStringBuilderBase& Builder, const FQuoteEscape& Adapter)
60{
61 QuoteEscapeTo(Adapter.Input, Builder);
62 return Builder;
63}
64
65} // UE::String::Private
Private::FQuoteEscape QuoteEscape(FStringView Input)
Definition Escape.h:46
void QuoteEscapeTo(FStringView Input, FStringBuilderBase &Output)
Private::FEscape Escape(FStringView Input)
Definition Escape.h:32
void EscapeTo(FStringView Input, FStringBuilderBase &Output)
Definition Vector.h:40