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::strutils Namespace Reference

Functions

std::vector< std::string > split (std::string_view input, std::string_view delim) noexcept
 Split a string based on a delimiter.
 
void replace_first (std::string &input, std::string_view to_replace, std::string_view replace_with) noexcept
 Replace first occurrence of a string.
 
void 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.
 
void ltrim (std::string &input) noexcept
 Trim string from end.
 
void rtrim (std::string &input) noexcept
 Trim string from start.
 
void trim (std::string &input) noexcept
 Trim both ends of string.
 
void make_single_spaced (std::string &input) noexcept
 Make a string single spaced.
 

Function Documentation

◆ split()

std::vector< std::string > galaxy::strutils::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()

void galaxy::strutils::replace_first ( std::string & input,
std::string_view to_replace,
std::string_view replace_with )
noexcept

Replace first occurrence of a string.

Returns input string if to_replace not found.

Parameters
inputString to modify.
to_replaceSubstring to be replaced.
replace_withString to be inserted.

Definition at line 37 of file StringUtils.cpp.

◆ replace_all()

void galaxy::strutils::replace_all ( std::string & input,
std::string_view to_replace,
std::string_view replace_with )
noexcept

Replaces all occurrences of a string.

Returns input string if to_replace not found.

Parameters
inputString to modify.
to_replaceSubstring to be replaced.
replace_withString to be inserted.

Definition at line 47 of file StringUtils.cpp.

+ Here is the caller graph for this function:

◆ begins_with()

bool galaxy::strutils::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 62 of file StringUtils.cpp.

+ Here is the caller graph for this function:

◆ ltrim()

void galaxy::strutils::ltrim ( std::string & input)
noexcept

Trim string from end.

Parameters
inputString to trim.

Definition at line 67 of file StringUtils.cpp.

+ Here is the caller graph for this function:

◆ rtrim()

void galaxy::strutils::rtrim ( std::string & input)
noexcept

Trim string from start.

Parameters
inputString to trim.

Definition at line 75 of file StringUtils.cpp.

+ Here is the caller graph for this function:

◆ trim()

void galaxy::strutils::trim ( std::string & input)
noexcept

Trim both ends of string.

Parameters
inputString to trim.

Definition at line 83 of file StringUtils.cpp.

+ Here is the call graph for this function:

◆ make_single_spaced()

void galaxy::strutils::make_single_spaced ( std::string & input)
noexcept

Make a string single spaced.

Parameters
inputString to reduce spacing from.

Definition at line 89 of file StringUtils.cpp.