galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::str Namespace Reference

Functions

std::vector< std::string > split (std::string_view input, std::string_view delim) noexcept
 Split a string based on a delimiter.
 
std::string replace_first (std::string input, std::string_view to_replace, std::string_view replace_with) noexcept
 Replace first occurrence of a string.
 
std::string replace_all (std::string input, std::string_view to_replace, std::string_view replace_with) noexcept
 Replaces all occurrences of a string.
 
bool begins_with (const std::string &input, const std::string &find) noexcept
 Check if string begins with another string.
 
std::string ltrim (std::string input) noexcept
 Trim string from end.
 
std::string rtrim (std::string input) noexcept
 Trim string from start.
 
std::string trim (std::string input) noexcept
 Trim both ends of string.
 
std::string make_single_spaced (std::string input) noexcept
 Make a string single spaced.
 

Function Documentation

◆ split()

std::vector< std::string > galaxy::str::split ( std::string_view input,
std::string_view delim )
nodiscardnoexcept

Split a string based on a delimiter.

Parameters
inputInput string to process.
delimDelimiter to split string on.
Returns
Array of strings split. Does not return empty entries or delimiter.

Definition at line 17 of file StringUtils.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replace_first()

std::string galaxy::str::replace_first ( std::string input,
std::string_view to_replace,
std::string_view replace_with )
nodiscardnoexcept

Replace first occurrence of a string.

Parameters
inputString to modify. This is a copy.
to_replaceSubstring to be replaced.
replace_withString to be inserted.
Returns
String with replacement, or input string if to_replace not found.

Definition at line 37 of file StringUtils.cpp.

+ Here is the caller graph for this function:

◆ replace_all()

std::string galaxy::str::replace_all ( std::string input,
std::string_view to_replace,
std::string_view replace_with )
nodiscardnoexcept

Replaces all occurrences of a string.

Returns input string if to_replace not found.

Parameters
inputString to modify. This is a copy.
to_replaceSubstring to be replaced.
replace_withString to be inserted.
Returns
String with replacement, or input string if to_replace not found.

Definition at line 49 of file StringUtils.cpp.

+ Here is the caller graph for this function:

◆ begins_with()

bool galaxy::str::begins_with ( const std::string & input,
const std::string & find )
nodiscardnoexcept

Check if string begins with another string.

Parameters
inputInput string to check.
findString to check for at beginning of input string.
Returns
True if input string begins with find string.

Definition at line 66 of file StringUtils.cpp.

+ Here is the caller graph for this function:

◆ ltrim()

std::string galaxy::str::ltrim ( std::string input)
nodiscardnoexcept

Trim string from end.

Parameters
inputString to trim. This is a copy.
Returns
Trimmed string.

Definition at line 71 of file StringUtils.cpp.

+ Here is the caller graph for this function:

◆ rtrim()

std::string galaxy::str::rtrim ( std::string input)
nodiscardnoexcept

Trim string from start.

Parameters
inputString to trim. This is a copy.
Returns
Trimmed string.

Definition at line 81 of file StringUtils.cpp.

+ Here is the caller graph for this function:

◆ trim()

std::string galaxy::str::trim ( std::string input)
nodiscardnoexcept

Trim both ends of string.

Parameters
inputString to trim. This is a copy.
Returns
Trimmed string.

Definition at line 91 of file StringUtils.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_single_spaced()

std::string galaxy::str::make_single_spaced ( std::string input)
nodiscardnoexcept

Make a string single spaced.

Parameters
inputString to reduce spacing from. This is a copy.
Returns
Single spaced string.

Definition at line 99 of file StringUtils.cpp.

+ Here is the caller graph for this function: