XJ music engine  1.9.6
In-game runtime engine for XJ music.
Static Public Member Functions | List of all members
XJ::StringUtils Class Reference

#include <StringUtils.h>

Static Public Member Functions

static std::vector< std::string > split (const std::string &input, const char delimiter)
 
static std::string join (const std::vector< std::string > &input, const std::string &delimiter)
 
static std::string trim (const std::string &str)
 
static std::string toMeme (const std::string &raw)
 
static std::string toMeme (const std::string *raw, const std::string &defaultValue)
 
static std::string toEvent (const std::string &raw)
 
static bool isNullOrEmpty (const std::string *raw)
 
static std::string toAlphabetical (const std::string &raw)
 
static std::string toAlphanumeric (const std::string &raw)
 
static std::string toUpperCase (const std::string &input)
 
static std::string toLowerCase (const std::string &input)
 
static std::string formatFloat (float value)
 
static std::string stripExtraSpaces (const std::string &value)
 
static std::optional< std::string > match (const std::regex &pattern, const std::string &text)
 
static int countMatches (const std::regex &regex, const std::string &basicString)
 
static int countMatches (const char regex, const std::string &basicString)
 
static std::string toShipKey (const std::string &name)
 
static std::string toLowerScored (const std::string &raw)
 
static std::string toUpperScored (const std::string &raw)
 
static std::string toScored (const std::string &raw)
 
static std::string toProper (std::string raw)
 
static std::string toProperSlug (const std::string &raw)
 
static std::string toSlug (std::string raw)
 
static std::string toLowerSlug (const std::string &raw)
 
static std::string toUpperSlug (const std::string &raw)
 
static std::vector< std::string > sort (const std::set< std::string > &items)
 
static std::string zeroPadded (unsigned long long value, int digits)
 

Member Function Documentation

◆ countMatches() [1/2]

int StringUtils::countMatches ( const char  regex,
const std::string &  basicString 
)
static

Count the matches of a character in a string

Parameters
regexto use
basicStringto search
Returns
number of matches

◆ countMatches() [2/2]

int StringUtils::countMatches ( const std::regex &  regex,
const std::string &  basicString 
)
static

Count the matches of a regex in a string

Parameters
regexto use
basicStringto search
Returns
number of matches

◆ formatFloat()

std::string StringUtils::formatFloat ( float  value)
static

Format a float as a string with the minimum required number of digits after the floating point (minimum of 1 digit)

Parameters
valueThe float to format
Returns
The formatted string

◆ isNullOrEmpty()

bool StringUtils::isNullOrEmpty ( const std::string *  raw)
static

Check if a string is null or empty

Parameters
rawThe string to check
Returns
True if the string is null or empty

◆ join()

std::string StringUtils::join ( const std::vector< std::string > &  input,
const std::string &  delimiter 
)
static

Join a vector of strings with a delimiter

Parameters
inputThe vector of strings
delimiterThe delimiter
Returns
The joined string

◆ match()

std::optional< std::string > StringUtils::match ( const std::regex &  pattern,
const std::string &  text 
)
static

First group matching pattern in text, else null

Parameters
patternto use
textto search
Returns
match if found

◆ sort()

std::vector< std::string > StringUtils::sort ( const std::set< std::string > &  items)
static

Sort a set of strings into an ordered vector

Parameters
itemsset of strings
Returns
vector of strings

◆ split()

std::vector< std::string > StringUtils::split ( const std::string &  input,
const char  delimiter 
)
static

Split a string by a delimiter

Parameters
inputThe string to split
delimiterThe delimiter
Returns
The split string

◆ stripExtraSpaces()

std::string StringUtils::stripExtraSpaces ( const std::string &  value)
static

Replace more than one space with one space, and strip leading and trailing spaces

Parameters
valueto strip
Returns
stripped value

◆ toAlphabetical()

std::string StringUtils::toAlphabetical ( const std::string &  raw)
static

Remove all non-alphabetical characters from a string

Parameters
rawThe string to clean
Returns
The cleaned string

◆ toAlphanumeric()

std::string StringUtils::toAlphanumeric ( const std::string &  raw)
static

Remove all non-alphanumeric characters from a string

Parameters
rawThe string to clean
Returns
The cleaned string

◆ toEvent()

std::string StringUtils::toEvent ( const std::string &  raw)
static

Conform to Upper-slug non-numeric and strip special characters, e.g. "BUN"

Parameters
rawinput
Returns
purified

◆ toLowerCase()

std::string StringUtils::toLowerCase ( const std::string &  input)
static

Convert a string to lowercase

Parameters
inputThe string to convert
Returns
The lowercase string

◆ toLowerScored()

std::string StringUtils::toLowerScored ( const std::string &  raw)
static

Conform to Lower-scored (e.g. "buns_and_jams")

Parameters
rawinput
Returns
purified

◆ toLowerSlug()

std::string StringUtils::toLowerSlug ( const std::string &  raw)
static

Conform to Lowercase slug (e.g. "mush")

Parameters
rawinput
Returns
purified

◆ toMeme() [1/2]

std::string StringUtils::toMeme ( const std::string &  raw)
static

Conform to Upper-slug including some special characters, e.g. "BUN!"

Parameters
rawinput
Returns
purified

◆ toMeme() [2/2]

std::string StringUtils::toMeme ( const std::string *  raw,
const std::string &  defaultValue 
)
static

Conform to Upper-slug (e.g. "BUN"), else default value

Parameters
rawinput
defaultValueif no input
Returns
purified

◆ toProper()

std::string StringUtils::toProper ( std::string  raw)
static

Conform to Proper (e.g. "Jam")

Parameters
rawinput
Returns
purified

◆ toProperSlug()

std::string StringUtils::toProperSlug ( const std::string &  raw)
static

Conform to Proper-slug (e.g. "Jam")

Parameters
rawinput
Returns
purified

◆ toScored()

std::string StringUtils::toScored ( const std::string &  raw)
static

Conform to toScored (e.g. "mush_bun")

Parameters
rawinput
Returns
purified

◆ toShipKey()

std::string StringUtils::toShipKey ( const std::string &  name)
static

Convert a string to a ship key

Parameters
nameThe name to convert
Returns
The ship key

◆ toSlug()

std::string StringUtils::toSlug ( std::string  raw)
static

Conform to Slug (e.g. "jim")

Parameters
rawinput
Returns
purified

◆ toUpperCase()

std::string StringUtils::toUpperCase ( const std::string &  input)
static

Convert a string to uppercase

Parameters
inputThe string to convert
Returns
The uppercase string

◆ toUpperScored()

std::string StringUtils::toUpperScored ( const std::string &  raw)
static

Conform to Upper-scored (e.g. "BUNS_AND_JAMS")

Parameters
rawinput
Returns
purified

◆ toUpperSlug()

std::string StringUtils::toUpperSlug ( const std::string &  raw)
static

Conform to Uppercase slug (e.g. "MUSH")

Parameters
rawinput
Returns
purified

◆ trim()

std::string StringUtils::trim ( const std::string &  str)
static

Function to trim whitespace from the start and end of a string

Parameters
strThe string to trim
Returns
The trimmed string

◆ zeroPadded()

static std::string XJ::StringUtils::zeroPadded ( unsigned long long  value,
int  digits 
)
inlinestatic

Pad the value with zeros to the given number of digits

Parameters
valueto pad
digitstotal after padding
Returns
padded value

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