Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FAsciiSet Class Reference

#include <AsciiSet.h>

Classes

struct  InitData
 

Public Member Functions

template<typename CharType , int N>
constexpr FAsciiSet (const CharType(&Chars)[N])
 
template<typename CharType >
constexpr FORCEINLINE bool Contains (CharType Char) const
 
template<typename CharType >
constexpr FORCEINLINE uint64 Test (CharType Char) const
 
constexpr FORCEINLINE FAsciiSet operator+ (char Char) const
 
constexpr FORCEINLINE FAsciiSet operator~ () const
 

Static Public Member Functions

template<class CharType >
static constexpr const CharType * FindFirstOrEnd (const CharType *Str, FAsciiSet Set)
 
template<class CharType >
static constexpr const CharType * FindLastOrEnd (const CharType *Str, FAsciiSet Set)
 
template<typename CharType >
static constexpr const CharType * Skip (const CharType *Str, FAsciiSet Set)
 
template<typename CharType >
static constexpr bool HasAny (const CharType *Str, FAsciiSet Set)
 
template<typename CharType >
static constexpr bool HasNone (const CharType *Str, FAsciiSet Set)
 
template<typename CharType >
static constexpr bool HasOnly (const CharType *Str, FAsciiSet Set)
 
template<class StringType >
static constexpr StringType FindPrefixWith (const StringType &Str, FAsciiSet Set)
 
template<class StringType >
static constexpr StringType FindPrefixWithout (const StringType &Str, FAsciiSet Set)
 
template<class StringType >
static constexpr StringType TrimPrefixWith (const StringType &Str, FAsciiSet Set)
 
template<class StringType >
static constexpr StringType TrimPrefixWithout (const StringType &Str, FAsciiSet Set)
 
template<class StringType >
static constexpr StringType FindSuffixWith (const StringType &Str, FAsciiSet Set)
 
template<class StringType >
static constexpr StringType FindSuffixWithout (const StringType &Str, FAsciiSet Set)
 
template<class StringType >
static constexpr StringType TrimSuffixWith (const StringType &Str, FAsciiSet Set)
 
template<class StringType >
static constexpr StringType TrimSuffixWithout (const StringType &Str, FAsciiSet Set)
 
template<class StringType >
static constexpr bool HasAny (const StringType &Str, FAsciiSet Set)
 
template<class StringType >
static constexpr bool HasNone (const StringType &Str, FAsciiSet Set)
 
template<class StringType >
static constexpr bool HasOnly (const StringType &Str, FAsciiSet Set)
 

Private Types

enum class  EDir { Forward , Reverse }
 
enum class  EInclude { Members , NonMembers }
 
enum class  EKeep { Head , Tail }
 

Private Member Functions

constexpr FORCEINLINE uint64 TestImpl (uint32 Char) const
 
constexpr FAsciiSet (InitData Bitset)
 
constexpr FAsciiSet (uint64 Lo, uint64 Hi)
 

Static Private Member Functions

template<EInclude Include, typename CharType >
static constexpr const CharType * FindFirst (FAsciiSet Set, const CharType *It, const CharType *End)
 
template<EInclude Include, typename CharType >
static constexpr const CharType * FindLast (FAsciiSet Set, const CharType *It, const CharType *End)
 
template<EDir Dir, EInclude Include, EKeep Keep, class StringType >
static constexpr StringType Scan (const StringType &Str, FAsciiSet Set)
 
static constexpr FORCEINLINE void SetImpl (InitData &Bitset, uint32 Char)
 
template<typename CharType , int N>
static constexpr InitData StringToBitset (const CharType(&Chars)[N])
 

Private Attributes

uint64 LoMask
 
uint64 HiMask
 

Static Private Attributes

static constexpr uint64 NilMask = uint64(1) << '\0'
 

Detailed Description

ASCII character bitset useful for fast and readable parsing

Entirely constexpr. Works with both wide and narrow strings.

Example use cases:

constexpr FAsciiSet WhitespaceCharacters(" \v\f\t\r\n"); bool bIsWhitespace = WhitespaceCharacters.Test(MyChar); const char* HelloWorld = FAsciiSet::Skip(" \t\tHello world!", WhitespaceCharacters);

constexpr FAsciiSet XmlEscapeChars("&<>\"'"); check(FAsciiSet::HasNone(EscapedXmlString, XmlEscapeChars));

constexpr FAsciiSet Delimiters(".:;"); const TCHAR* DelimiterOrEnd = FAsciiSet::FindFirstOrEnd(PrefixedName, Delimiters); FString Prefix(PrefixedName, DelimiterOrEnd - PrefixedName);

constexpr FAsciiSet Slashes("/\\"); const TCHAR* SlashOrEnd = FAsciiSet::FindLastOrEnd(PathName, Slashes); const TCHAR* FileName = *SlashOrEnd ? SlashOrEnd + 1 : PathName;

Definition at line 29 of file AsciiSet.h.

Member Enumeration Documentation

◆ EDir

enum class FAsciiSet::EDir
strongprivate
Enumerator
Forward 
Reverse 

Definition at line 209 of file AsciiSet.h.

◆ EInclude

Enumerator
Members 
NonMembers 

Definition at line 210 of file AsciiSet.h.

◆ EKeep

enum class FAsciiSet::EKeep
strongprivate
Enumerator
Head 
Tail 

Definition at line 211 of file AsciiSet.h.

Constructor & Destructor Documentation

◆ FAsciiSet() [1/3]

template<typename CharType , int N>
constexpr FAsciiSet::FAsciiSet ( const CharType(&) Chars[N])
inlineconstexpr

Definition at line 33 of file AsciiSet.h.

◆ FAsciiSet() [2/3]

constexpr FAsciiSet::FAsciiSet ( InitData Bitset)
inlineconstexprprivate

Definition at line 274 of file AsciiSet.h.

◆ FAsciiSet() [3/3]

constexpr FAsciiSet::FAsciiSet ( uint64 Lo,
uint64 Hi )
inlineconstexprprivate

Definition at line 278 of file AsciiSet.h.

Member Function Documentation

◆ Contains()

template<typename CharType >
constexpr FORCEINLINE bool FAsciiSet::Contains ( CharType Char) const
inlineconstexpr

Returns true if a character is part of the set

Definition at line 39 of file AsciiSet.h.

◆ FindFirst()

template<EInclude Include, typename CharType >
static constexpr const CharType * FAsciiSet::FindFirst ( FAsciiSet Set,
const CharType * It,
const CharType * End )
inlinestaticconstexprprivate

Definition at line 214 of file AsciiSet.h.

◆ FindFirstOrEnd()

template<class CharType >
static constexpr const CharType * FAsciiSet::FindFirstOrEnd ( const CharType * Str,
FAsciiSet Set )
inlinestaticconstexpr

Find first character of string inside set or end pointer. Never returns null.

Definition at line 69 of file AsciiSet.h.

◆ FindLast()

template<EInclude Include, typename CharType >
static constexpr const CharType * FAsciiSet::FindLast ( FAsciiSet Set,
const CharType * It,
const CharType * End )
inlinestaticconstexprprivate

Definition at line 221 of file AsciiSet.h.

◆ FindLastOrEnd()

template<class CharType >
static constexpr const CharType * FAsciiSet::FindLastOrEnd ( const CharType * Str,
FAsciiSet Set )
inlinestaticconstexpr

Find last character of string inside set or end pointer. Never returns null.

Definition at line 78 of file AsciiSet.h.

◆ FindPrefixWith()

template<class StringType >
static constexpr StringType FAsciiSet::FindPrefixWith ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Get initial substring with all characters in set

Definition at line 127 of file AsciiSet.h.

◆ FindPrefixWithout()

template<class StringType >
static constexpr StringType FAsciiSet::FindPrefixWithout ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Get initial substring with no characters in set

Definition at line 134 of file AsciiSet.h.

◆ FindSuffixWith()

template<class StringType >
static constexpr StringType FAsciiSet::FindSuffixWith ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Get trailing substring with all characters in set

Definition at line 155 of file AsciiSet.h.

◆ FindSuffixWithout()

template<class StringType >
static constexpr StringType FAsciiSet::FindSuffixWithout ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Get trailing substring with no characters in set

Definition at line 162 of file AsciiSet.h.

◆ HasAny() [1/2]

template<typename CharType >
static constexpr bool FAsciiSet::HasAny ( const CharType * Str,
FAsciiSet Set )
inlinestaticconstexpr

Test if string contains any character in set

Definition at line 104 of file AsciiSet.h.

◆ HasAny() [2/2]

template<class StringType >
static constexpr bool FAsciiSet::HasAny ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Test if string contains any character in set

Definition at line 183 of file AsciiSet.h.

◆ HasNone() [1/2]

template<typename CharType >
static constexpr bool FAsciiSet::HasNone ( const CharType * Str,
FAsciiSet Set )
inlinestaticconstexpr

Test if string contains no character in set

Definition at line 111 of file AsciiSet.h.

◆ HasNone() [2/2]

template<class StringType >
static constexpr bool FAsciiSet::HasNone ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Test if string contains no character in set

Definition at line 190 of file AsciiSet.h.

◆ HasOnly() [1/2]

template<typename CharType >
static constexpr bool FAsciiSet::HasOnly ( const CharType * Str,
FAsciiSet Set )
inlinestaticconstexpr

Test if string contains any character outside of set

Definition at line 118 of file AsciiSet.h.

◆ HasOnly() [2/2]

template<class StringType >
static constexpr bool FAsciiSet::HasOnly ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Test if string contains any character outside of set

Definition at line 202 of file AsciiSet.h.

◆ operator+()

constexpr FORCEINLINE FAsciiSet FAsciiSet::operator+ ( char Char) const
inlineconstexpr

Create new set with specified character in it

Definition at line 52 of file AsciiSet.h.

◆ operator~()

constexpr FORCEINLINE FAsciiSet FAsciiSet::operator~ ( ) const
inlineconstexpr

Create new set containing inverse set of characters - likely including null-terminator

Definition at line 60 of file AsciiSet.h.

◆ Scan()

template<EDir Dir, EInclude Include, EKeep Keep, class StringType >
static constexpr StringType FAsciiSet::Scan ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexprprivate

Definition at line 228 of file AsciiSet.h.

◆ SetImpl()

static constexpr FORCEINLINE void FAsciiSet::SetImpl ( InitData & Bitset,
uint32 Char )
inlinestaticconstexprprivate

Definition at line 243 of file AsciiSet.h.

◆ Skip()

template<typename CharType >
static constexpr const CharType * FAsciiSet::Skip ( const CharType * Str,
FAsciiSet Set )
inlinestaticconstexpr

Find first character of string outside of set. Never returns null.

Definition at line 92 of file AsciiSet.h.

◆ StringToBitset()

template<typename CharType , int N>
static constexpr InitData FAsciiSet::StringToBitset ( const CharType(&) Chars[N])
inlinestaticconstexprprivate

Definition at line 263 of file AsciiSet.h.

◆ Test()

template<typename CharType >
constexpr FORCEINLINE uint64 FAsciiSet::Test ( CharType Char) const
inlineconstexpr

Returns non-zero if a character is part of the set. Prefer Contains() to avoid VS2019 conversion warnings.

Definition at line 46 of file AsciiSet.h.

◆ TestImpl()

constexpr FORCEINLINE uint64 FAsciiSet::TestImpl ( uint32 Char) const
inlineconstexprprivate

Definition at line 253 of file AsciiSet.h.

◆ TrimPrefixWith()

template<class StringType >
static constexpr StringType FAsciiSet::TrimPrefixWith ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Trim initial characters in set

Definition at line 141 of file AsciiSet.h.

◆ TrimPrefixWithout()

template<class StringType >
static constexpr StringType FAsciiSet::TrimPrefixWithout ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Trim initial characters not in set

Definition at line 148 of file AsciiSet.h.

◆ TrimSuffixWith()

template<class StringType >
static constexpr StringType FAsciiSet::TrimSuffixWith ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Trim trailing characters in set

Definition at line 169 of file AsciiSet.h.

◆ TrimSuffixWithout()

template<class StringType >
static constexpr StringType FAsciiSet::TrimSuffixWithout ( const StringType & Str,
FAsciiSet Set )
inlinestaticconstexpr

Trim trailing characters not in set

Definition at line 176 of file AsciiSet.h.

Member Data Documentation

◆ HiMask

uint64 FAsciiSet::HiMask
private

Definition at line 282 of file AsciiSet.h.

◆ LoMask

uint64 FAsciiSet::LoMask
private

Definition at line 282 of file AsciiSet.h.

◆ NilMask

constexpr uint64 FAsciiSet::NilMask = uint64(1) << '\0'
staticconstexprprivate

Definition at line 241 of file AsciiSet.h.


The documentation for this class was generated from the following file: