Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
DefaultValueHelper.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/UnrealString.h"
6#include "CoreTypes.h"
7#include "Math/MathFwd.h"
8#include "Misc/Timespan.h"
9
10struct FColor;
11struct FLinearColor;
12
13//
14// FDefaultValueHelper
15//
16
18{
19 /** Something like TEXT macro for chars is needed */
20 static TCHAR TS(const TCHAR* Sign);
21
22 static bool IsWhitespace(TCHAR Char);
23
24 /**
25 * advances Pos to first non-whitespace symbol
26 * returns if some non-Whitespace sign remains in string
27 */
28 static bool Trim(int32& Pos, const FString& Source);
29
30 /** returns address of the first char in the string */
31 static const TCHAR* StartOf(const FString& Source);
32
33 /** returns address of the last (empty) char in the string */
34 static const TCHAR* EndOf(const FString& Source);
35
36 /**
37 * advances Pos to first non-whitespace symbol
38 * returns if some non-Whitespace sign remains in string
39 */
40 static bool Trim(const TCHAR* & Start, const TCHAR* End );
41
42 /**
43 * @param Start - address of the first symbol of the checked string
44 * @param End - address of the first symbol after of the checked string (also address of the terminating empty symbol)
45 */
46 static bool IsStringValidFloat(const TCHAR* Start, const TCHAR* End);
47
48 /** return if the string can be parse to an int. OutBase is the base of the integer (8, 10, 16)*/
49 static bool IsStringValidInteger(const TCHAR* Start, const TCHAR* End, int32& OutBase);
50 static bool IsStringValidInteger(const TCHAR* Start, const TCHAR* End);
51
52public:
53
55
56 static bool HasWhitespaces(const FString& Source);
57
58 static FString RemoveWhitespaces(const FString& Source);
59
60 /** Shell parameters list: " TypeName ( A a, B b ) " -> "A a, B b" */
61 static bool GetParameters(const FString& Source, const FString& TypeName, FString& OutForm);
62
63 /** returns if given strings are equal, ignores initial and final white spaces in Source */
64 static bool Is(const FString& Source, const TCHAR* CompareStr);
65
66 /**
67 * source forms: TypeName( TEXT ("ABC") ), TEXT("ABC"), TypeName("ABC"), "ABC"
68 * output form: ABC
69 */
70 static bool StringFromCppString(const FString& Source, const FString& TypeName, FString& OutForm);
71
72 /*
73 * Following functions accept c++ style representations of numbers.
74 * e.g. 13.5e-2f for float or -0x123 for int
75 */
76 static bool IsStringValidInteger(const FString& Source);
77
78 static bool IsStringValidFloat(const FString& Source);
79
80 /** accepted form: " %f, %f, %f" */
81 static bool IsStringValidVector(const FString& Source);
82
83 /** accepted form: " %f, %f, %f" */
84 static bool IsStringValidRotator(const FString& Source);
85
86 /** accepted form: " %f, %f, %f " or " %f, %f, %f, %f " (alpha is optional) */
87 static bool IsStringValidLinearColor(const FString& Source);
88
89
90 /**
91 * Converts a string into a int32.
92 *
93 * @param Source the input string to try to convert
94 * @param OutVal the output integer
95 *
96 * @return true if the conversion happened, false otherwise
97 */
98 static bool ParseInt(const FString& Source, int32& OutVal);
99
100 /**
101 * Converts a string into a int64.
102 *
103 * @param Source the input string to try to convert
104 * @param OutVal the output integer
105 *
106 * @return true if the conversion happened, false otherwise
107 */
108 static bool ParseInt64(const FString& Source, int64& OutVal);
109
110 /**
111 * Converts a string into a float.
112 *
113 * @param Source the input string to try to convert
114 * @param OutVal the output float
115 *
116 * @return true if the conversion happened, false otherwise
117 */
118 static bool ParseFloat(const FString& Source, float& OutVal);
119
120 /**
121 * Converts a string into a double.
122 *
123 * @param Source the input string to try to convert
124 * @param OutVal the output double
125 *
126 * @return true if the conversion happened, false otherwise
127 */
128 static bool ParseDouble(const FString& Source, double& OutVal);
129
130 /**
131 * Converts a string into a FVector. Accepted form: " %f, %f, %f "
132 *
133 * @param Source the input string to try to convert
134 * @param OutVal the output vector
135 *
136 * @return true if the conversion happened, false otherwise
137 */
138 static bool ParseVector(const FString& Source, FVector3f& OutVal);
139 static bool ParseVector(const FString& Source, FVector3d& OutVal);
140
141 /**
142 * Converts a string into a FVector. Accepted form: " %f, %f "
143 *
144 * @param Source the input string to try to convert
145 * @param OutVal the output vector2D
146 *
147 * @return true if the conversion happened, false otherwise
148 */
149 static bool ParseVector2D(const FString& Source, FVector2f& OutVal);
150 static bool ParseVector2D(const FString& Source, FVector2d& OutVal);
151
152 /**
153 * Converts a string into a FVector4. Accepted form: " %f, %f, %f, %f "
154 *
155 * @param Source the input string to try to convert
156 * @param OutVal the output vector4
157 *
158 * @return true if the conversion happened, false otherwise
159 */
160 static bool ParseVector4(const FString& Source, FVector4f& OutVal);
161 static bool ParseVector4(const FString& Source, FVector4d& OutVal);
162
163 /**
164 * Converts a string into a FRotator. Accepted form: " %f, %f, %f "
165 *
166 * @param Source the input string to try to convert
167 * @param OutVal the output rotator
168 *
169 * @return true if the conversion happened, false otherwise
170 */
171 static bool ParseRotator(const FString& Source, FRotator3f& OutVal);
172 static bool ParseRotator(const FString& Source, FRotator3d& OutVal);
173
174 /**
175 * Converts a string into a FLinearColor.
176 * Accepted forms: " %f, %f, %f " or " %f, %f, %f, %f " (alpha is optional).
177 *
178 * @param Source the input string to try to convert
179 * @param OutVal the output color
180 *
181 * @return true if the conversion happened, false otherwise
182 */
183 static bool ParseLinearColor(const FString& Source, FLinearColor& OutVal);
184
185 /**
186 * Converts a string into a FLinearColor.
187 * Accepted forms: " %d, %d, %d " or " %d, %d, %d, %d " (alpha is optional).
188 *
189 * @param Source the input string to try to convert
190 * @param OutVal the output color
191 *
192 * @return true if the conversion happened, false otherwise
193 */
194 static bool ParseColor(const FString& Source, FColor& OutVal);
195};
static bool ParseRotator(const FString &Source, FRotator3d &OutVal)
static bool Trim(const TCHAR *&Start, const TCHAR *End)
static bool ParseVector(const FString &Source, FVector3d &OutVal)
static const TCHAR * StartOf(const FString &Source)
static bool ParseFloat(const FString &Source, float &OutVal)
static bool ParseLinearColor(const FString &Source, FLinearColor &OutVal)
static bool IsStringValidFloat(const TCHAR *Start, const TCHAR *End)
static bool ParseInt64(const FString &Source, int64 &OutVal)
static const TCHAR * EndOf(const FString &Source)
static FString GetUnqualifiedEnumValue(const FString &Source)
static bool ParseInt(const FString &Source, int32 &OutVal)
static bool HasWhitespaces(const FString &Source)
static FString RemoveWhitespaces(const FString &Source)
static bool IsStringValidInteger(const TCHAR *Start, const TCHAR *End, int32 &OutBase)
static bool IsWhitespace(TCHAR Char)
static bool ParseDouble(const FString &Source, double &OutVal)
static bool IsStringValidVector(const FString &Source)
static bool ParseVector2D(const FString &Source, FVector2f &OutVal)
static bool ParseVector4(const FString &Source, FVector4d &OutVal)
static bool ParseRotator(const FString &Source, FRotator3f &OutVal)
static bool ParseColor(const FString &Source, FColor &OutVal)
static bool IsStringValidFloat(const FString &Source)
static bool Is(const FString &Source, const TCHAR *CompareStr)
static bool Trim(int32 &Pos, const FString &Source)
static bool GetParameters(const FString &Source, const FString &TypeName, FString &OutForm)
static bool IsStringValidInteger(const TCHAR *Start, const TCHAR *End)
static TCHAR TS(const TCHAR *Sign)
static bool IsStringValidLinearColor(const FString &Source)
static bool StringFromCppString(const FString &Source, const FString &TypeName, FString &OutForm)
static bool ParseVector2D(const FString &Source, FVector2d &OutVal)
static bool ParseVector(const FString &Source, FVector3f &OutVal)
static bool IsStringValidInteger(const FString &Source)
static bool ParseVector4(const FString &Source, FVector4f &OutVal)
static bool IsStringValidRotator(const FString &Source)