SPH
Functions
StringUtils.cpp File Reference
#include "objects/utility/StringUtils.h"

Go to the source code of this file.

Functions

template<>
NAMESPACE_SPH_BEGIN Optional< std::string > fromString (const std::string &s)
 Converts a string to given type. More...
 
bool startsWith (const std::string &s, const std::string &start)
 Checks if the given string starts with given substring. More...
 
std::string trim (const std::string &s)
 Removes all leading and trailing spaces from a string. More...
 
std::string lowercase (const std::string &s)
 Converts all uppercase characters to their lowercase variants. Other characters are unchanged. More...
 
std::string replaceFirst (const std::string &source, const std::string &old, const std::string &s)
 Replaces first occurence of string with a new string. More...
 
std::string replaceAll (const std::string &source, const std::string &old, const std::string &s)
 Replaces all occurences of string with a new string. More...
 
std::string setLineBreak (const std::string &s, const Size lineWidth)
 Inserts
to string so that no line is longer than given limit. More...
 
Array< std::string > split (const std::string &s, const char delimiter)
 Splits a string into an array of string using given delimiter. More...
 
Pair< std::string > splitByFirst (const std::string &s, const char delimiter)
 Splits a string into two parts, using first occurence of given delimiter. More...
 
std::string capitalize (const std::string &input)
 Capitalizes first letters of all words in the string, except for words like 'and', 'or', etc. More...
 

Function Documentation

◆ capitalize()

std::string capitalize ( const std::string &  input)

Capitalizes first letters of all words in the string, except for words like 'and', 'or', etc.

Definition at line 231 of file StringUtils.cpp.

◆ fromString()

template<>
Optional< double > fromString ( const std::string &  s)

Converts a string to given type.

Definition at line 6 of file StringUtils.cpp.

◆ lowercase()

std::string lowercase ( const std::string &  s)

Converts all uppercase characters to their lowercase variants. Other characters are unchanged.

Definition at line 94 of file StringUtils.cpp.

◆ replaceAll()

std::string replaceAll ( const std::string &  source,
const std::string &  old,
const std::string &  s 
)

Replaces all occurences of string with a new string.

Definition at line 114 of file StringUtils.cpp.

◆ replaceFirst()

std::string replaceFirst ( const std::string &  source,
const std::string &  old,
const std::string &  s 
)

Replaces first occurence of string with a new string.

Definition at line 104 of file StringUtils.cpp.

◆ setLineBreak()

std::string setLineBreak ( const std::string &  s,
const Size  lineWidth 
)

Inserts
to string so that no line is longer than given limit.

Definition at line 127 of file StringUtils.cpp.

◆ split()

Array<std::string> split ( const std::string &  s,
const char  delimiter 
)

Splits a string into an array of string using given delimiter.

Definition at line 192 of file StringUtils.cpp.

◆ splitByFirst()

Pair<std::string> splitByFirst ( const std::string &  s,
const char  delimiter 
)

Splits a string into two parts, using first occurence of given delimiter.

Definition at line 205 of file StringUtils.cpp.

◆ startsWith()

bool startsWith ( const std::string &  s,
const std::string &  start 
)

Checks if the given string starts with given substring.

Definition at line 70 of file StringUtils.cpp.

◆ trim()

std::string trim ( const std::string &  s)

Removes all leading and trailing spaces from a string.

Definition at line 74 of file StringUtils.cpp.