0.4.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
NAV::str Namespace Reference

Concepts

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

Enumerations

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

Functions

static void ltrim (std::string &s)
 Trim from start (in place)
 
static void ltrim (std::string_view &sv)
 Trim from start (in place)
 
static std::string ltrim_copy (std::string s)
 Trim from start (copying)
 
static std::string_view ltrim_copy (std::string_view sv)
 Trim from start (copying)
 
static bool 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 replaceAll (std::string &str, const std::string &from, const std::string &to)
 Replaces all occurrence of a search pattern with another sequence.
 
static void 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 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 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 rtrim (std::string &s)
 Trim from end (in place)
 
static void rtrim (std::string_view &sv)
 Trim from end (in place)
 
static std::string rtrim_copy (std::string s)
 Trim from end (copying)
 
static std::string_view rtrim_copy (std::string_view sv)
 Trim from end (copying)
 
static std::vector< std::string > split (const std::string &str, char delimiter)
 Splits a string into parts at a delimiter.
 
static std::vector< std::string > split (const std::string &str, const std::string &delimiter)
 Splits a string into parts at a delimiter.
 
static std::vector< std::string > 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 > 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 stod (const String &str, double default_value, std::size_t *pos=nullptr) noexcept
 Interprets a value in the string str.
 
template<StdString String>
float stof (const String &str, float default_value, std::size_t *pos=nullptr) noexcept
 Interprets a value in the string str.
 
template<StdString String>
int 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 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 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 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 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 trim (std::string &s)
 Trim from both ends (in place)
 
static void trim (std::string_view &sv)
 Trim from both ends (in place)
 
static std::string trim_copy (std::string s)
 Trim from both ends (copying)
 
static std::string_view trim_copy (std::string_view sv)
 Trim from both ends (copying)
 

Enumeration Type Documentation

◆ CaseSensitivity

enum NAV::str::CaseSensitivity : uint8_t

Enum for case sensitive tasks.

Enumerator
RespectCase 

Respect the case.

IgnoreCase 

Ignore case.

Definition at line 137 of file StringUtil.hpp.

Function Documentation

◆ ltrim() [1/2]

static void NAV::str::ltrim ( std::string & s)
inlinestatic

Trim from start (in place)

Parameters
[in,out]sThe string to trim

Definition at line 28 of file StringUtil.hpp.

◆ ltrim() [2/2]

static void NAV::str::ltrim ( std::string_view & sv)
inlinestatic

Trim from start (in place)

Parameters
[in,out]svThe string view to trim

Definition at line 62 of file StringUtil.hpp.

◆ ltrim_copy() [1/2]

static std::string NAV::str::ltrim_copy ( std::string s)
inlinestatic

Trim from start (copying)

Parameters
[in]sThe string to trim
Returns
The trimmed string

Definition at line 85 of file StringUtil.hpp.

◆ ltrim_copy() [2/2]

static std::string_view NAV::str::ltrim_copy ( std::string_view sv)
inlinestatic

Trim from start (copying)

Parameters
[in]svThe string view to trim
Returns
The trimmed string

Definition at line 112 of file StringUtil.hpp.

◆ replace()

static bool NAV::str::replace ( std::string & str,
const std::string & from,
const std::string & to,
CaseSensitivity cs = RespectCase )
inlinestatic

Replaces the first occurrence of a search pattern with another sequence.

Parameters
[in,out]strString to search in and return value
[in]fromString pattern to search for
[in]toReplacement string
[in]csCase sensitivity
Returns
True if something was replaced

Definition at line 149 of file StringUtil.hpp.

◆ replaceAll() [1/2]

static void NAV::str::replaceAll ( std::string & str,
const std::string & from,
const std::string & to )
inlinestatic

Replaces all occurrence of a search pattern with another sequence.

Parameters
[in,out]strString to search in and return value
[in]fromString pattern to search for
[in]toReplacement string

Definition at line 184 of file StringUtil.hpp.

◆ replaceAll() [2/2]

static void NAV::str::replaceAll ( std::string & str,
const std::string & from,
const std::string & to,
CaseSensitivity cs )
inlinestatic

Replaces all occurrence of a search pattern with another sequence.

Parameters
[in,out]strString to search in and return value
[in]fromString pattern to search for
[in]toReplacement string
[in]csCase sensitivity

Definition at line 175 of file StringUtil.hpp.

◆ replaceAll_copy() [1/2]

static std::string NAV::str::replaceAll_copy ( std::string str,
const std::string & from,
const std::string & to )
inlinestatic

Replaces all occurrence of a search pattern with another sequence.

Parameters
[in,out]strString to search in and return value
[in]fromString pattern to search for
[in]toReplacement string
Returns
The string with the replacements

Definition at line 211 of file StringUtil.hpp.

◆ replaceAll_copy() [2/2]

static std::string NAV::str::replaceAll_copy ( std::string str,
const std::string & from,
const std::string & to,
CaseSensitivity cs )
inlinestatic

Replaces all occurrence of a search pattern with another sequence.

Parameters
[in,out]strString to search in and return value
[in]fromString pattern to search for
[in]toReplacement string
[in]csCase sensitivity
Returns
The string with the replacements

Definition at line 200 of file StringUtil.hpp.

◆ rtrim() [1/2]

static void NAV::str::rtrim ( std::string & s)
inlinestatic

Trim from end (in place)

Parameters
[in,out]sThe string to trim

Definition at line 39 of file StringUtil.hpp.

◆ rtrim() [2/2]

static void NAV::str::rtrim ( std::string_view & sv)
inlinestatic

Trim from end (in place)

Parameters
[in,out]svThe string view to trim

Definition at line 69 of file StringUtil.hpp.

◆ rtrim_copy() [1/2]

static std::string NAV::str::rtrim_copy ( std::string s)
inlinestatic

Trim from end (copying)

Parameters
[in]sThe string to trim
Returns
The trimmed string

Definition at line 94 of file StringUtil.hpp.

◆ rtrim_copy() [2/2]

static std::string_view NAV::str::rtrim_copy ( std::string_view sv)
inlinestatic

Trim from end (copying)

Parameters
[in]svThe string view to trim
Returns
The trimmed string

Definition at line 121 of file StringUtil.hpp.

◆ split() [1/2]

static std::vector< std::string > NAV::str::split ( const std::string & str,
char delimiter )
inlinestatic

Splits a string into parts at a delimiter.

Parameters
[in]strString to split
[in]delimiterCharacter to split at
Returns
List with splitted parts

Definition at line 241 of file StringUtil.hpp.

◆ split() [2/2]

static std::vector< std::string > NAV::str::split ( const std::string & str,
const std::string & delimiter )
inlinestatic

Splits a string into parts at a delimiter.

Parameters
[in]strString to split
[in]delimiterSequence of characters to split at
Returns
List with splitted parts

Definition at line 221 of file StringUtil.hpp.

◆ split_wo_empty() [1/2]

static std::vector< std::string > NAV::str::split_wo_empty ( const std::string & str,
char delimiter )
inlinestatic

Splits a string into parts at a delimiter and removes empty entries.

Parameters
[in]strString to split
[in]delimiterCharacter to split at
Returns
List with splitted parts

Definition at line 280 of file StringUtil.hpp.

◆ split_wo_empty() [2/2]

static std::vector< std::string > NAV::str::split_wo_empty ( const std::string & str,
const std::string & delimiter )
inlinestatic

Splits a string into parts at a delimiter and removes empty entries.

Parameters
[in]strString to split
[in]delimiterSequence of characters to split at
Returns
List with splitted parts

Definition at line 250 of file StringUtil.hpp.

◆ stod()

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 Parameters
Stringstd::string or std::wstring and also allowing convertible types like const char*
Parameters
strthe string to convert
default_valuedefault value to take if an invalid argument is given
posaddress of an integer to store the number of characters processed
Returns
Value corresponding to the content of str

Definition at line 395 of file StringUtil.hpp.

◆ stof()

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 Parameters
Stringstd::string or std::wstring and also allowing convertible types like const char*
Parameters
strthe string to convert
default_valuedefault value to take if an invalid argument is given
posaddress of an integer to store the number of characters processed
Returns
Value corresponding to the content of str

Definition at line 376 of file StringUtil.hpp.

◆ stoi()

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 Parameters
Stringstd::string or std::wstring and also allowing convertible types like const char*
Parameters
strthe string to convert
default_valuedefault value to take if an invalid argument is given
posaddress of an integer to store the number of characters processed
basethe number base
Returns
Value corresponding to the content of str

Definition at line 297 of file StringUtil.hpp.

◆ stol()

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 Parameters
Stringstd::string or std::wstring and also allowing convertible types like const char*
Parameters
strthe string to convert
default_valuedefault value to take if an invalid argument is given
posaddress of an integer to store the number of characters processed
basethe number base
Returns
Value corresponding to the content of str

Definition at line 317 of file StringUtil.hpp.

◆ stold()

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 Parameters
Stringstd::string or std::wstring and also allowing convertible types like const char*
Parameters
strthe string to convert
default_valuedefault value to take if an invalid argument is given
posaddress of an integer to store the number of characters processed
Returns
Value corresponding to the content of str

Definition at line 414 of file StringUtil.hpp.

◆ stoll()

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 Parameters
Stringstd::string or std::wstring and also allowing convertible types like const char*
Parameters
strthe string to convert
default_valuedefault value to take if an invalid argument is given
posaddress of an integer to store the number of characters processed
basethe number base
Returns
Value corresponding to the content of str

Definition at line 357 of file StringUtil.hpp.

◆ stoul()

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.

Template Parameters
Stringstd::string or std::wstring and also allowing convertible types like const char*
Parameters
strthe string to convert
default_valuedefault value to take if an invalid argument is given
posaddress of an integer to store the number of characters processed
basethe number base
Returns
Value corresponding to the content of str

Definition at line 337 of file StringUtil.hpp.

◆ trim() [1/2]

static void NAV::str::trim ( std::string & s)
inlinestatic

Trim from both ends (in place)

Parameters
[in,out]sThe string to trim

Definition at line 54 of file StringUtil.hpp.

◆ trim() [2/2]

static void NAV::str::trim ( std::string_view & sv)
inlinestatic

Trim from both ends (in place)

Parameters
[in,out]svThe string view to trim

Definition at line 76 of file StringUtil.hpp.

◆ trim_copy() [1/2]

static std::string NAV::str::trim_copy ( std::string s)
inlinestatic

Trim from both ends (copying)

Parameters
[in]sThe string to trim
Returns
The trimmed string

Definition at line 103 of file StringUtil.hpp.

◆ trim_copy() [2/2]

static std::string_view NAV::str::trim_copy ( std::string_view sv)
inlinestatic

Trim from both ends (copying)

Parameters
[in]svThe string view to trim
Returns
The trimmed string

Definition at line 130 of file StringUtil.hpp.