Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
WildcardString.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 "Misc/CString.h"
8
9/**
10 * Implements a string with wild card pattern matching abilities.
11 *
12 * The FWildcardString is meant to hold the pattern you are matching against.
13 * For basic use, just call the static functions IsMatch() or IsMatchSubstring
14 * if you have FStringView
15 */
17 : public FString
18{
19public:
20
21 /** Default constructor. */
23 : FString()
24 { }
25
26 /**
27 * Creates and initializes a new instance with the specified pattern.
28 *
29 * @param Pattern The pattern string.
30 */
31 FWildcardString( const FString& Pattern )
32 : FString(Pattern)
33 { }
34
35 /**
36 * Creates and initializes a new instance with the specified pattern.
37 *
38 * @param Pattern The pattern string.
39 */
40 FWildcardString( const TCHAR* Pattern )
41 : FString(Pattern)
42 { }
43
44public:
45
46 /**
47 * Checks whether this string contains wild card characters.
48 *
49 * @return true if this string contains wild cards, false otherwise.
50 */
51 bool ContainsWildcards( ) const
52 {
53 return ContainsWildcards(**this);
54 }
55
56 /**
57 * Matches the given input string to this wild card pattern.
58 *
59 * @param Input The string to match.
60 * @return true if the input string matches this pattern, false otherwise.
61 */
62 bool IsMatch( const TCHAR* Input ) const
63 {
64 return IsMatch(**this, Input);
65 }
66
67 /**
68 * Matches the given input string to this wild card pattern.
69 *
70 * @param Input The string to match.
71 * @return true if the input string matches this pattern, false otherwise.
72 */
73 bool IsMatch( const FString& Input ) const
74 {
75 return IsMatch(**this, *Input);
76 }
77
78public:
79
80 /**
81 * Checks whether the specified pattern contains wild card characters.
82 *
83 * @param Pattern The string to check.
84 * @return true if the string contains wild cards, false otherwise.
85 */
86 static bool ContainsWildcards( const TCHAR* Pattern );
87
88 /**
89 * Non-recursive wild card string matching algorithm.
90 *
91 * @param Pattern The pattern to match.
92 * @param Input The input string to check.
93 */
94 static bool IsMatch( const TCHAR* Pattern, const TCHAR* Input );
95
96 /**
97 *
98 * As IsMatch, except can accept the end of the input string in order to facilitate
99 * FStringView usage.
100 *
101 * if ESearchCase::IgnoreCase is used, the pattern and input are ToLower()d before
102 * comparison (note - does not apply locale and just uses c runtime style tolower)
103 */
104 static bool IsMatchSubstring( const TCHAR* Pattern, const TCHAR* Input, const TCHAR* InputEnd, ESearchCase::Type SearchCase = ESearchCase::CaseSensitive);
105
106protected:
107
108 /** Holds the string terminator character. */
109 static const TCHAR EndOfString = TCHAR('\0');
110
111 /** Holds the wild card that matches exactly one character (default is '?'). */
112 static const TCHAR ExactWildcard = TCHAR('?');
113
114 /** Holds the wild card that matches a sequence of characters (default is '*'). */
115 static const TCHAR SequenceWildcard = TCHAR('*');
116};
FString()=default
FString(const FString &)=default
UE_NODISCARD FORCEINLINE const TCHAR * operator*() const UE_LIFETIMEBOUND
ARK_API FString(const WIDECHAR *Str)
Definition String.cpp:250
static bool IsMatchSubstring(const TCHAR *Pattern, const TCHAR *Input, const TCHAR *InputEnd, ESearchCase::Type SearchCase=ESearchCase::CaseSensitive)
static const TCHAR ExactWildcard
static bool ContainsWildcards(const TCHAR *Pattern)
bool IsMatch(const FString &Input) const
static const TCHAR EndOfString
FWildcardString(const FString &Pattern)
bool IsMatch(const TCHAR *Input) const
FWildcardString(const TCHAR *Pattern)
static const TCHAR SequenceWildcard
static bool IsMatch(const TCHAR *Pattern, const TCHAR *Input)
bool ContainsWildcards() const
@ CaseSensitive
Definition CString.h:25