stc
Loading...
Searching...
No Matches
Functions
stc::string Namespace Reference

Functions

std::vector< std::string > split (const std::string &input, const char delimiter, int64_t limit=-1)
 
std::vector< std::string > split (const std::string &input, const std::string &delimiter, int64_t limit=-1)
 
std::vector< int > byteArrayOf (const std::string &input)
 
std::string getByteString (const std::string &input)
 
void replaceAll (std::string &input, const std::string &find, const std::string &replaceWith, size_t limit=0)
 
void removeDuplicateWhitespace (const std::string &input, std::string &output)
 

Function Documentation

◆ byteArrayOf()

std::vector< int > stc::string::byteArrayOf ( const std::string &  input)
inline

◆ getByteString()

std::string stc::string::getByteString ( const std::string &  input)
inline

Turns a string into a string of bytes. Useful for debugging the internal representation of a string

◆ removeDuplicateWhitespace()

void stc::string::removeDuplicateWhitespace ( const std::string &  input,
std::string &  output 
)
inline

Strips sequential whitespace, but leaving one intact. This means at most one whitespace is preserved.

◆ replaceAll()

void stc::string::replaceAll ( std::string &  input,
const std::string &  find,
const std::string &  replaceWith,
size_t  limit = 0 
)
inline

◆ split() [1/2]

std::vector< std::string > stc::string::split ( const std::string &  input,
const char  delimiter,
int64_t  limit = -1 
)
inline

Splits a string by a character.

This is partly covered by C++20 ranges, but C++20 ranges does not offer limiting the number of splits, which is very useful in certain parsing tasks. If you have no need for the limit argument, you probably want ranges instead.

See also
https://en.cppreference.com/w/cpp/ranges/split_view.html

◆ split() [2/2]

std::vector< std::string > stc::string::split ( const std::string &  input,
const std::string &  delimiter,
int64_t  limit = -1 
)
inline

Splits a string by a substring. Calls the method splitting by character if delimiter.size() <= 1.

This is partly covered by C++20 ranges, but C++20 ranges does not offer limiting the number of splits, which is very useful in certain parsing tasks. If you have no need for the limit argument, you probably want ranges instead.

See also
https://en.cppreference.com/w/cpp/ranges/split_view.html