0.4.1
Loading...
Searching...
No Matches
StringUtil.hpp File Reference

Utility functions for working with std::strings. More...

Go to the source code of this file.

Namespaces

namespace  NAV
 
namespace  NAV::str
 

Concepts

concept  NAV::str::StdString
 Concept limiting the type to std::string and std::wstring, but also allowing convertible types like const char*.
 

Enumerations

enum  NAV::str::CaseSensitivity : uint8_t {
  NAV::str::RespectCase ,
  NAV::str::IgnoreCase
}
 Enum for case sensitive tasks. More...
 

Functions

static void NAV::str::ltrim (std::string &s)
 Trim from start (in place)
 
static void NAV::str::ltrim (std::string_view &sv)
 Trim from start (in place)
 
static std::string NAV::str::ltrim_copy (std::string s)
 Trim from start (copying)
 
static std::string_view NAV::str::ltrim_copy (std::string_view sv)
 Trim from start (copying)
 
static bool NAV::str::replace (std::string &str, const std::string &from, const std::string &to, CaseSensitivity cs=RespectCase)
 Replaces the first occurrence of a search pattern with another sequence.
 
static void NAV::str::replaceAll (std::string &str, const std::string &from, const std::string &to)
 Replaces all occurrence of a search pattern with another sequence.
 
static void NAV::str::replaceAll (std::string &str, const std::string &from, const std::string &to, CaseSensitivity cs)
 Replaces all occurrence of a search pattern with another sequence.
 
static std::string NAV::str::replaceAll_copy (std::string str, const std::string &from, const std::string &to)
 Replaces all occurrence of a search pattern with another sequence.
 
static std::string NAV::str::replaceAll_copy (std::string str, const std::string &from, const std::string &to, CaseSensitivity cs)
 Replaces all occurrence of a search pattern with another sequence.
 
static void NAV::str::rtrim (std::string &s)
 Trim from end (in place)
 
static void NAV::str::rtrim (std::string_view &sv)
 Trim from end (in place)
 
static std::string NAV::str::rtrim_copy (std::string s)
 Trim from end (copying)
 
static std::string_view NAV::str::rtrim_copy (std::string_view sv)
 Trim from end (copying)
 
static std::vector< std::string > NAV::str::split (const std::string &str, char delimiter)
 Splits a string into parts at a delimiter.
 
static std::vector< std::string > NAV::str::split (const std::string &str, const std::string &delimiter)
 Splits a string into parts at a delimiter.
 
static std::vector< std::string > NAV::str::split_wo_empty (const std::string &str, char delimiter)
 Splits a string into parts at a delimiter and removes empty entries.
 
static std::vector< std::string > NAV::str::split_wo_empty (const std::string &str, const std::string &delimiter)
 Splits a string into parts at a delimiter and removes empty entries.
 
template<StdString String>
double NAV::str::stod (const String &str, double default_value, std::size_t *pos=nullptr) noexcept
 Interprets a value in the string str.
 
template<StdString String>
float NAV::str::stof (const String &str, float default_value, std::size_t *pos=nullptr) noexcept
 Interprets a value in the string str.
 
template<StdString String>
int NAV::str::stoi (const String &str, int default_value, std::size_t *pos=nullptr, int base=10) noexcept
 Interprets a value in the string str.
 
template<StdString String>
int64_t NAV::str::stol (const String &str, int64_t default_value, std::size_t *pos=nullptr, int base=10) noexcept
 Interprets a value in the string str.
 
template<StdString String>
long double NAV::str::stold (const String &str, long double default_value, std::size_t *pos=nullptr) noexcept
 Interprets a value in the string str.
 
template<StdString String>
int64_t NAV::str::stoll (const String &str, int64_t default_value, std::size_t *pos=nullptr, int base=10) noexcept
 Interprets a value in the string str.
 
template<StdString String>
uint64_t NAV::str::stoul (const String &str, uint64_t default_value, std::size_t *pos=nullptr, int base=10) noexcept
 Interprets a value in the string str.
 
static void NAV::str::trim (std::string &s)
 Trim from both ends (in place)
 
static void NAV::str::trim (std::string_view &sv)
 Trim from both ends (in place)
 
static std::string NAV::str::trim_copy (std::string s)
 Trim from both ends (copying)
 
static std::string_view NAV::str::trim_copy (std::string_view sv)
 Trim from both ends (copying)
 

Detailed Description

Utility functions for working with std::strings.

Author
T. Topp (topp@.nosp@m.ins..nosp@m.uni-s.nosp@m.tutt.nosp@m.gart..nosp@m.de)
Date
2020-09-16

Definition in file StringUtil.hpp.