Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ParseTokens.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/ArrayView.h"
6#include "Containers/ContainersFwd.h"
7#include "Containers/StringFwd.h"
8#include "Containers/StringView.h"
9#include "CoreTypes.h"
10#include "Misc/EnumClassFlags.h"
11#include "Templates/Function.h"
12
13template <typename FuncType> class TFunctionRef;
14
15namespace UE::String
16{
17
19{
20 /** Use the default options when parsing tokens. */
21 None = 0,
22 /** Ignore case when comparing delimiters against the string. */
23 IgnoreCase = 1 << 0,
24 /** Skip tokens that are empty or, if trimming, only whitespace. */
25 SkipEmpty = 1 << 1,
26 /** Trim whitespace from each parsed token. */
27 Trim = 1 << 2,
28};
29
31
32/**
33 * Visit every token in the input string, as separated by the delimiter.
34 *
35 * By default, comparisons with the delimiter are case-sensitive and empty tokens are visited.
36 *
37 * @param View A view of the string to split into tokens.
38 * @param Delimiter A delimiter character to split on.
39 * @param Visitor A function that is called for each token.
40 * @param Options Flags to modify the default behavior.
41 */
43 FAnsiStringView View,
44 ANSICHAR Delimiter,
45 TFunctionRef<void (FAnsiStringView)> Visitor,
48 FWideStringView View,
49 WIDECHAR Delimiter,
50 TFunctionRef<void (FWideStringView)> Visitor,
53 FUtf8StringView View,
54 UTF8CHAR Delimiter,
55 TFunctionRef<void (FUtf8StringView)> Visitor,
57
58/**
59 * Parses every token in the input string, as separated by the delimiter.
60 *
61 * Output strings are sub-views of the input view and have the same lifetime as the input view.
62 * By default, comparisons with the delimiter are case-sensitive and empty tokens are visited.
63 *
64 * @param View A view of the string to split into tokens.
65 * @param Delimiter A delimiter character to split on.
66 * @param Output The output to add parsed tokens to by calling Output.Add(FStringView).
67 * @param Options Flags to modify the default behavior.
68 */
69template <typename OutputType>
70inline void ParseTokens(
71 const FAnsiStringView View,
72 const ANSICHAR Delimiter,
73 OutputType& Output,
75{
77}
78template <typename OutputType>
79inline void ParseTokens(
80 const FWideStringView View,
81 const WIDECHAR Delimiter,
82 OutputType& Output,
84{
86}
87template <typename OutputType>
88inline void ParseTokens(
89 const FUtf8StringView View,
90 const UTF8CHAR Delimiter,
91 OutputType& Output,
93{
95}
96
97/**
98 * Visit every token in the input string, as separated by the delimiter.
99 *
100 * By default, comparisons with the delimiter are case-sensitive and empty tokens are visited.
101 *
102 * @param View A view of the string to split into tokens.
103 * @param Delimiter A non-empty delimiter to split on.
104 * @param Visitor A function that is called for each token.
105 * @param Options Flags to modify the default behavior.
106 */
108 FAnsiStringView View,
109 FAnsiStringView Delimiter,
110 TFunctionRef<void (FAnsiStringView)> Visitor,
113 FWideStringView View,
114 FWideStringView Delimiter,
115 TFunctionRef<void (FWideStringView)> Visitor,
118 FUtf8StringView View,
119 FUtf8StringView Delimiter,
120 TFunctionRef<void (FUtf8StringView)> Visitor,
122
123/**
124 * Parses every token in the input string, as separated by the delimiter.
125 *
126 * Output strings are sub-views of the input view and have the same lifetime as the input view.
127 * By default, comparisons with the delimiter are case-sensitive and empty tokens are visited.
128 *
129 * @param View A view of the string to split into tokens.
130 * @param Delimiter A non-empty delimiter to split on.
131 * @param Output The output to add parsed tokens to by calling Output.Add(FStringView).
132 * @param Options Flags to modify the default behavior.
133 */
134template <typename OutputType>
135inline void ParseTokens(
136 const FAnsiStringView View,
137 const FAnsiStringView Delimiter,
138 OutputType& Output,
140{
142}
143template <typename OutputType>
144inline void ParseTokens(
145 const FWideStringView View,
146 const FWideStringView Delimiter,
147 OutputType& Output,
149{
151}
152template <typename OutputType>
153inline void ParseTokens(
154 const FUtf8StringView View,
155 const FUtf8StringView Delimiter,
156 OutputType& Output,
158{
160}
161
162/**
163 * Visit every token in the input string, as separated by any of the delimiters.
164 *
165 * By default, comparisons with delimiters are case-sensitive and empty tokens are visited.
166 *
167 * @param View A view of the string to split into tokens.
168 * @param Delimiters An array of delimiter characters to split on.
169 * @param Visitor A function that is called for each token.
170 * @param Options Flags to modify the default behavior.
171 */
173 FAnsiStringView View,
174 TConstArrayView<ANSICHAR> Delimiters,
175 TFunctionRef<void (FAnsiStringView)> Visitor,
178 FWideStringView View,
179 TConstArrayView<WIDECHAR> Delimiters,
180 TFunctionRef<void (FWideStringView)> Visitor,
183 FUtf8StringView View,
184 TConstArrayView<UTF8CHAR> Delimiters,
185 TFunctionRef<void (FUtf8StringView)> Visitor,
187
188/**
189 * Parses every token in the input string, as separated by any of the delimiters.
190 *
191 * Output strings are sub-views of the input view and have the same lifetime as the input view.
192 * By default, comparisons with delimiters are case-sensitive and empty tokens are visited.
193 *
194 * @param View A view of the string to split into tokens.
195 * @param Delimiters An array of delimiter characters to split on.
196 * @param Output The output to add parsed tokens to by calling Output.Add(FStringView).
197 * @param Options Flags to modify the default behavior.
198 */
199template <typename OutputType>
201 const FAnsiStringView View,
202 const TConstArrayView<ANSICHAR> Delimiters,
203 OutputType& Output,
205{
207}
208template <typename OutputType>
210 const FWideStringView View,
211 const TConstArrayView<WIDECHAR> Delimiters,
212 OutputType& Output,
214{
216}
217template <typename OutputType>
219 const FUtf8StringView View,
220 const TConstArrayView<UTF8CHAR> Delimiters,
221 OutputType& Output,
223{
225}
226
227/**
228 * Visit every token in the input string, as separated by any of the delimiters.
229 *
230 * By default, comparisons with delimiters are case-sensitive and empty tokens are visited.
231 * Behavior is undefined when delimiters overlap each other, such as the delimiters
232 * ("AB, "BC") and the input string "1ABC2".
233 *
234 * @param View A view of the string to split into tokens.
235 * @param Delimiters An array of non-overlapping non-empty delimiters to split on.
236 * @param Visitor A function that is called for each token.
237 * @param Options Flags to modify the default behavior.
238 */
240 FAnsiStringView View,
241 TConstArrayView<FAnsiStringView> Delimiters,
242 TFunctionRef<void (FAnsiStringView)> Visitor,
245 FWideStringView View,
246 TConstArrayView<FWideStringView> Delimiters,
247 TFunctionRef<void (FWideStringView)> Visitor,
250 FUtf8StringView View,
251 TConstArrayView<FUtf8StringView> Delimiters,
252 TFunctionRef<void (FUtf8StringView)> Visitor,
254
255/**
256 * Parses every token in the input string, as separated by any of the delimiters.
257 *
258 * Output strings are sub-views of the input view and have the same lifetime as the input view.
259 * By default, comparisons with delimiters are case-sensitive and empty tokens are visited.
260 * Behavior is undefined when delimiters overlap each other, such as the delimiters
261 * ("AB, "BC") and the input string "1ABC2".
262 *
263 * @param View A view of the string to split into tokens.
264 * @param Delimiters An array of non-overlapping non-empty delimiters to split on.
265 * @param Output The output to add parsed tokens to by calling Output.Add(FStringView).
266 * @param Options Flags to modify the default behavior.
267 */
268template <typename OutputType>
270 const FAnsiStringView View,
271 const TConstArrayView<FAnsiStringView> Delimiters,
272 OutputType& Output,
274{
276}
277template <typename OutputType>
279 const FWideStringView View,
280 const TConstArrayView<FWideStringView> Delimiters,
281 OutputType& Output,
283{
285}
286template <typename OutputType>
288 const FUtf8StringView View,
289 const TConstArrayView<FUtf8StringView> Delimiters,
290 OutputType& Output,
292{
294}
295
296} // UE::String
#define ENUM_CLASS_FLAGS(Enum)
void ParseTokensMultiple(const FWideStringView View, const TConstArrayView< WIDECHAR > Delimiters, OutputType &Output, const EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokens(FAnsiStringView View, ANSICHAR Delimiter, TFunctionRef< void(FAnsiStringView)> Visitor, EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokens(FUtf8StringView View, FUtf8StringView Delimiter, TFunctionRef< void(FUtf8StringView)> Visitor, EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokens(FUtf8StringView View, UTF8CHAR Delimiter, TFunctionRef< void(FUtf8StringView)> Visitor, EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokens(FWideStringView View, FWideStringView Delimiter, TFunctionRef< void(FWideStringView)> Visitor, EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokens(const FUtf8StringView View, const FUtf8StringView Delimiter, OutputType &Output, const EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokensMultiple(const FUtf8StringView View, const TConstArrayView< UTF8CHAR > Delimiters, OutputType &Output, const EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokens(const FWideStringView View, const WIDECHAR Delimiter, OutputType &Output, const EParseTokensOptions Options=EParseTokensOptions::None)
Definition ParseTokens.h:79
void ParseTokens(const FAnsiStringView View, const ANSICHAR Delimiter, OutputType &Output, const EParseTokensOptions Options=EParseTokensOptions::None)
Definition ParseTokens.h:70
void ParseTokens(FWideStringView View, WIDECHAR Delimiter, TFunctionRef< void(FWideStringView)> Visitor, EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokensMultiple(FWideStringView View, TConstArrayView< WIDECHAR > Delimiters, TFunctionRef< void(FWideStringView)> Visitor, EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokens(const FAnsiStringView View, const FAnsiStringView Delimiter, OutputType &Output, const EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokens(const FUtf8StringView View, const UTF8CHAR Delimiter, OutputType &Output, const EParseTokensOptions Options=EParseTokensOptions::None)
Definition ParseTokens.h:88
void ParseTokens(const FWideStringView View, const FWideStringView Delimiter, OutputType &Output, const EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokensMultiple(FAnsiStringView View, TConstArrayView< ANSICHAR > Delimiters, TFunctionRef< void(FAnsiStringView)> Visitor, EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokensMultiple(FUtf8StringView View, TConstArrayView< UTF8CHAR > Delimiters, TFunctionRef< void(FUtf8StringView)> Visitor, EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokens(FAnsiStringView View, FAnsiStringView Delimiter, TFunctionRef< void(FAnsiStringView)> Visitor, EParseTokensOptions Options=EParseTokensOptions::None)
void ParseTokensMultiple(const FAnsiStringView View, const TConstArrayView< ANSICHAR > Delimiters, OutputType &Output, const EParseTokensOptions Options=EParseTokensOptions::None)
Definition Vector.h:40