XDGKit v0.1.0-1
XDG Utilities for C++
Loading...
Searching...
No Matches
Functions
XDG::XDGUtils Namespace Reference

Utilities for data structures. More...

Functions

std::string trimString (const std::string &str) noexcept
 Removes leading and trailing whitespace from a string.
 
std::vector< std::string > splitString (const std::string &input, char delimiter, bool trim=true) noexcept
 Splits a string into a vector of substrings based on a delimiter.
 
template<class T >
void removeDuplicates (std::vector< T > &vec) noexcept
 Removes duplicate elements from a vector in place.
 

Detailed Description

Utilities for data structures.

Function Documentation

◆ trimString()

std::string trimString ( const std::string &  str)
inlinenoexcept

Removes leading and trailing whitespace from a string.

Parameters
strThe input string to be trimmed.
Returns
A new string with leading and trailing spaces removed.

◆ splitString()

std::vector< std::string > splitString ( const std::string &  input,
char  delimiter,
bool  trim = true 
)
noexcept

Splits a string into a vector of substrings based on a delimiter.

Parameters
inputThe string to split.
delimiterThe character used to split the string.
trimIf true, removes leading and trailing spaces from each substring.
Returns
A vector of strings resulting from the split operation.

◆ removeDuplicates()

template<class T >
void removeDuplicates ( std::vector< T > &  vec)
inlinenoexcept

Removes duplicate elements from a vector in place.

Template Parameters
TThe type of elements in the vector.
Parameters
vecThe vector from which duplicates will be removed.