SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
sourcepp::string Namespace Reference

Functions

bool contains (std::string_view s, char c)
bool matches (std::string_view in, std::string_view search)
 A very basic regex-like pattern checker for ASCII strings.
bool iequals (std::string_view s1, std::string_view s2)
void ltrim (std::string &s)
std::string_view ltrim (std::string_view s)
void rtrim (std::string &s)
std::string_view rtrim (std::string_view s)
void trim (std::string &s)
std::string_view trim (std::string_view s)
void trimInternal (std::string &s)
std::string trimInternal (std::string_view s)
void ltrim (std::string &s, std::string_view chars)
std::string_view ltrim (std::string_view s, std::string_view chars)
void rtrim (std::string &s, std::string_view chars)
std::string_view rtrim (std::string_view s, std::string_view chars)
void trim (std::string &s, std::string_view chars)
std::string_view trim (std::string_view s, std::string_view chars)
void trimInternal (std::string &s, std::string_view chars)
std::string trimInternal (std::string_view s, std::string_view chars)
std::vector< std::string > split (std::string_view s, char delim)
void toLower (std::string &input)
std::string toLower (std::string_view input)
void toUpper (std::string &input)
std::string toUpper (std::string_view input)
std::string createRandom (uint16_t length=32, std::string_view chars="0123456789_abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ")
std::string generateUUIDv4 ()
std::string padNumber (int64_t number, int width)
void normalizeSlashes (std::string &path, bool stripSlashPrefix=false, bool stripSlashSuffix=true)
void denormalizeSlashes (std::string &path, bool stripSlashPrefix=false, bool stripSlashSuffix=true)
std::from_chars_result toBool (std::string_view number, bool &out, int base=10)
std::from_chars_result toInt (std::string_view number, std::integral auto &out, int base=10)
std::from_chars_result toFloat (std::string_view number, std::floating_point auto &out)
std::vector< std::byte > decodeHex (std::string_view hex)
std::string encodeHex (std::span< const std::byte > hex)

Function Documentation

◆ contains()

bool sourcepp::string::contains ( std::string_view s,
char c )
nodiscard

Definition at line 22 of file String.cpp.

◆ createRandom()

std::string sourcepp::string::createRandom ( uint16_t length = 32,
std::string_view chars = "0123456789_abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ" )
nodiscard

Definition at line 187 of file String.cpp.

◆ decodeHex()

std::vector< std::byte > sourcepp::string::decodeHex ( std::string_view hex)
nodiscard

Definition at line 254 of file String.cpp.

◆ denormalizeSlashes()

void sourcepp::string::denormalizeSlashes ( std::string & path,
bool stripSlashPrefix = false,
bool stripSlashSuffix = true )

Definition at line 237 of file String.cpp.

◆ encodeHex()

std::string sourcepp::string::encodeHex ( std::span< const std::byte > hex)
nodiscard

Definition at line 281 of file String.cpp.

◆ generateUUIDv4()

std::string sourcepp::string::generateUUIDv4 ( )
nodiscard

Definition at line 199 of file String.cpp.

◆ iequals()

bool sourcepp::string::iequals ( std::string_view s1,
std::string_view s2 )
nodiscard

Definition at line 63 of file String.cpp.

◆ ltrim() [1/4]

void sourcepp::string::ltrim ( std::string & s)

Definition at line 69 of file String.cpp.

◆ ltrim() [2/4]

void sourcepp::string::ltrim ( std::string & s,
std::string_view chars )

Definition at line 110 of file String.cpp.

◆ ltrim() [3/4]

std::string_view sourcepp::string::ltrim ( std::string_view s)
nodiscard

Definition at line 73 of file String.cpp.

◆ ltrim() [4/4]

std::string_view sourcepp::string::ltrim ( std::string_view s,
std::string_view chars )
nodiscard

Definition at line 116 of file String.cpp.

◆ matches()

bool sourcepp::string::matches ( std::string_view in,
std::string_view search )
nodiscard

A very basic regex-like pattern checker for ASCII strings.

Supports: %? - matches any character w - matches a whitespace character (defined by std::isspace) a - matches a letter (A-Z, a-z) u - matches an uppercase letter (A-Z) l - matches a lowercase letter (a-z) d - matches a single digit (0-9) %% - escaped percent character

Definition at line 26 of file String.cpp.

◆ normalizeSlashes()

void sourcepp::string::normalizeSlashes ( std::string & path,
bool stripSlashPrefix = false,
bool stripSlashSuffix = true )

Definition at line 227 of file String.cpp.

◆ padNumber()

std::string sourcepp::string::padNumber ( int64_t number,
int width )
nodiscard

Definition at line 223 of file String.cpp.

◆ rtrim() [1/4]

void sourcepp::string::rtrim ( std::string & s)

Definition at line 80 of file String.cpp.

◆ rtrim() [2/4]

void sourcepp::string::rtrim ( std::string & s,
std::string_view chars )

Definition at line 123 of file String.cpp.

◆ rtrim() [3/4]

std::string_view sourcepp::string::rtrim ( std::string_view s)
nodiscard

Definition at line 84 of file String.cpp.

◆ rtrim() [4/4]

std::string_view sourcepp::string::rtrim ( std::string_view s,
std::string_view chars )
nodiscard

Definition at line 129 of file String.cpp.

◆ split()

std::vector< std::string > sourcepp::string::split ( std::string_view s,
char delim )
nodiscard

Definition at line 157 of file String.cpp.

◆ toBool()

std::from_chars_result sourcepp::string::toBool ( std::string_view number,
bool & out,
int base = 10 )

Definition at line 247 of file String.cpp.

◆ toFloat()

std::from_chars_result sourcepp::string::toFloat ( std::string_view number,
std::floating_point auto & out )

Definition at line 87 of file String.h.

◆ toInt()

std::from_chars_result sourcepp::string::toInt ( std::string_view number,
std::integral auto & out,
int base = 10 )

Definition at line 83 of file String.h.

◆ toLower() [1/2]

void sourcepp::string::toLower ( std::string & input)

Definition at line 167 of file String.cpp.

◆ toLower() [2/2]

std::string sourcepp::string::toLower ( std::string_view input)
nodiscard

Definition at line 171 of file String.cpp.

◆ toUpper() [1/2]

void sourcepp::string::toUpper ( std::string & input)

Definition at line 177 of file String.cpp.

◆ toUpper() [2/2]

std::string sourcepp::string::toUpper ( std::string_view input)
nodiscard

Definition at line 181 of file String.cpp.

◆ trim() [1/4]

void sourcepp::string::trim ( std::string & s)

Definition at line 91 of file String.cpp.

◆ trim() [2/4]

void sourcepp::string::trim ( std::string & s,
std::string_view chars )

Definition at line 136 of file String.cpp.

◆ trim() [3/4]

std::string_view sourcepp::string::trim ( std::string_view s)
nodiscard

Definition at line 96 of file String.cpp.

◆ trim() [4/4]

std::string_view sourcepp::string::trim ( std::string_view s,
std::string_view chars )
nodiscard

Definition at line 141 of file String.cpp.

◆ trimInternal() [1/4]

void sourcepp::string::trimInternal ( std::string & s)

Definition at line 100 of file String.cpp.

◆ trimInternal() [2/4]

void sourcepp::string::trimInternal ( std::string & s,
std::string_view chars )

Definition at line 145 of file String.cpp.

◆ trimInternal() [3/4]

std::string sourcepp::string::trimInternal ( std::string_view s)
nodiscard

Definition at line 104 of file String.cpp.

◆ trimInternal() [4/4]

std::string sourcepp::string::trimInternal ( std::string_view s,
std::string_view chars )
nodiscard

Definition at line 149 of file String.cpp.