String Trimming Utilities
Functions
- omni::extras::ltrim: Performs an in-place left-trim on a given string. 
- omni::extras::rtrim: Performs an in-place right-trim on a given string. 
- omni::extras::trim: Performs an in-place trim (from both sides) on a given string. 
- omni::extras::trimCopy: Performs a trim (from both sides) on a given string, returning a copy. 
Variables
- omni::extras::kTrimCharsDefault: Default whitespace characters for string trimming functions. 
Functions
- 
inline std::string &omni::extras::ltrim(std::string &s, const char *t = kTrimCharsDefault)
- Performs an in-place left-trim on a given string. - This will trim the characters in - tfrom the left side of- s. e.g. given- s=- " asdf "with the default- tvalue,- swould be modified to contain- "asdf ". This is effectively- s.erase(0, s.find_first_not_of(t)).- See also - Parameters
- s – The string to trim in-place 
- t – A string containing the list of characters to trim (such as kTrimCharsDefault) 
 
- Returns
- sfor convenience
 
- 
inline std::string &omni::extras::rtrim(std::string &s, const char *t = kTrimCharsDefault)
- Performs an in-place right-trim on a given string. - This will trim the characters in - tfrom the right side of- s. e.g. given- s=- " asdf "with the default- tvalue,- swould be modified to contain- " asdf". This is effectively- s.erase(s.find_last_not_of(t) + 1).- See also - Parameters
- s – The string to trim in-place 
- t – A string containing the list of characters to trim (such as kTrimCharsDefault) 
 
- Returns
- sfor convenience
 
- 
inline std::string &omni::extras::trim(std::string &s, const char *t = kTrimCharsDefault)
- Performs an in-place trim (from both sides) on a given string. - This will trim the characters in - tfrom both sides of- s. e.g. given- s=- " asdf "with the default- tvalue,- swould be modified to contain- "asdf". This is effectively- ltrim(rtrim(s, t), t).- See also - Parameters
- s – The string to trim in-place 
- t – A string containing the list of characters to trim (such as kTrimCharsDefault) 
 
- Returns
- sfor convenience
 
- 
inline std::string omni::extras::trimCopy(std::string s, const char *t = kTrimCharsDefault)
- Performs a trim (from both sides) on a given string, returning a copy. - This will trim the characters in - tfrom both sides of- s. e.g. given- s=- " asdf "with the default- tvalue,- "asdf"would be returned. This is effectively- std::string copy(s); return trim(copy);.- Parameters
- s – The string to trim 
- t – A string containing the list of characters to trim (such as kTrimCharsDefault) 
 
- Returns
- The trimmed string