nlib
StringView free function list

Functions

bool nn::nlib::StartsWith (const StringView &str, const StringView &prefix) noexcept
 Returns true if prefix is the prefix of str.
 
bool nn::nlib::StartsWith (const StringView &str, const char *prefix) noexcept
 Returns true if prefix is the prefix of str.
 
bool nn::nlib::StartsWith (const StringView &str, char c) noexcept
 Returns true if c is the prefix of str.
 
bool nn::nlib::EndsWith (const StringView &str, const StringView &suffix) noexcept
 Returns true if suffix is the suffix of str.
 
bool nn::nlib::EndsWith (const StringView &str, const char *suffix) noexcept
 Returns true if suffix is the suffix of str.
 
bool nn::nlib::EndsWith (const StringView &str, char c) noexcept
 Returns true if c is the suffix of str.
 
bool nn::nlib::ToCstring (char *buf, size_t buf_size, const StringView &str) noexcept
 Copies a string as a null terminated string. Returns true if the string was successfully copied.
 
template<size_t N>
bool nn::nlib::ToCstring (char(&buf)[N], const StringView &str) noexcept
 Copies a string as a null terminated string. Returns true if the string was successfully copied.
 
UniquePtr< char[]> nn::nlib::ToCstring (const StringView &str) noexcept
 Allocates memory and copies a string as a null terminated string. Returns true if the string was successfully copied.
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (int8_t *v, const StringView &str, int base) noexcept
 Internally calls nlib_int8_from_chars() to convert a string to a numerical value. The returned value is a pair of the error value and the number of read characters.
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (int16_t *v, const StringView &str, int base) noexcept
 Internally calls nlib_int16_from_chars() to convert a string to a numerical value. The returned value is a pair of the error value and the number of read characters.
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (int32_t *v, const StringView &str, int base) noexcept
 Internally calls nlib_int32_from_chars() to convert a string to a numerical value. The returned value is a pair of the error value and the number of read characters.
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (int64_t *v, const StringView &str, int base) noexcept
 Internally calls nlib_int64_from_chars() to convert a string to a numerical value. The returned value is a pair of the error value and the number of read characters.
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (uint8_t *v, const StringView &str, int base) noexcept
 Internally calls nlib_uint8_from_chars() to convert a string to a numerical value. The returned value is a pair of the error value and the number of read characters.
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (uint16_t *v, const StringView &str, int base) noexcept
 Internally calls nlib_uint16_from_chars() to convert a string to a numerical value. The returned value is a pair of the error value and the number of read characters.
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (uint32_t *v, const StringView &str, int base) noexcept
 Internally calls nlib_uint32_from_chars() to convert a string to a numerical value. The returned value is a pair of the error value and the number of read characters.
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (uint64_t *v, const StringView &str, int base) noexcept
 Internally calls nlib_uint64_from_chars() to convert a string to a numerical value. The returned value is a pair of the error value and the number of read characters.
 
std::pair< errno_t, size_t > nn::nlib::ToFloat (float *v, const StringView &str) noexcept
 Internally calls nlib_float_from_chars() to convert a string to a numerical value. The returned value is a pair of the error value and the number of read characters.
 
std::pair< errno_t, size_t > nn::nlib::ToDouble (double *v, const StringView &str) noexcept
 Internally calls nlib_double_from_chars() to convert a string to a numerical value. The returned value is a pair of the error value and the number of read characters.
 
template<class T >
std::pair< errno_t, size_t > nn::nlib::ToInteger (T *v, const StringView &str) noexcept
 Returns ToInteger(v, str, 10). This means that a character is converted to a decimal numerical value.
 
bool nn::nlib::TrimLeft (StringView &str) noexcept
 Removes any white spaces from the beginning of the string. More...
 
bool nn::nlib::TrimRight (StringView &str) noexcept
 Removes any white spaces from the end of the string. More...
 
void nn::nlib::Trim (StringView &str) noexcept
 Removes any white spaces from the beginning and end of the string.
 
StringView nn::nlib::GetLine (StringView &str) noexcept
 Obtains the strings from the start to the end of the line. Its own object ( str) moves to the beginning of the next line. More...
 
StringView nn::nlib::GetName (StringView &str) noexcept
 Obtains a string that is generally handled as a variable name. Its own object ( str) moves to the position immediately after the obtained string. More...
 
bool nn::nlib::Proceed (StringView &str, const StringView &prefix) noexcept
 If str starts with prefix, it is allowed to go forward by the length of that string. More...
 
bool nn::nlib::Proceed (StringView &str, const char *prefix) noexcept
 If str starts with prefix, it is allowed to go forward by the length of that string. More...
 
bool nn::nlib::Proceed (StringView &str, char c) noexcept
 If str starts with c, it is allowed to go forward by the length of that string. More...
 

Detailed Description

Function Documentation

◆ GetLine()

nn::nlib::GetLine ( StringView str)
inlinenoexcept

Obtains the strings from the start to the end of the line. Its own object ( str) moves to the beginning of the next line.

Parameters
[in,out]strThe StringView object to be processed.
Returns
A substring corresponding to one line (not including the newline character).

Definition at line 456 of file StringView.h.

◆ GetName()

nn::nlib::GetName ( StringView str)
inlinenoexcept

Obtains a string that is generally handled as a variable name. Its own object ( str) moves to the position immediately after the obtained string.

Parameters
[in,out]strThe StringView object to be processed.
Returns
The matching string.
Description
Returns the leading substring that matches the regular expression [a-zA-Z_][a-zA-Z0-9_]*.

Definition at line 483 of file StringView.h.

◆ Proceed() [1/3]

nn::nlib::Proceed ( StringView str,
const StringView prefix 
)
inlinenoexcept

If str starts with prefix, it is allowed to go forward by the length of that string.

Parameters
[in,out]strThe StringView object to be processed.
[in]prefixThe string to be checked.
Returns
Returns true if str starts with prefix.
Examples:
misc/stringutils/stringutils.cpp.

Definition at line 470 of file StringView.h.

◆ Proceed() [2/3]

nn::nlib::Proceed ( StringView str,
const char *  prefix 
)
inlinenoexcept

If str starts with prefix, it is allowed to go forward by the length of that string.

Parameters
[in,out]strThe StringView object to be processed.
[in]prefixThe string to be checked.
Returns
Returns true if str starts with prefix.

Definition at line 475 of file StringView.h.

◆ Proceed() [3/3]

nn::nlib::Proceed ( StringView str,
char  c 
)
inlinenoexcept

If str starts with c, it is allowed to go forward by the length of that string.

Parameters
[in,out]strThe StringView object to be processed.
[in]cThe string to be checked.
Returns
Returns true if str starts with c.

Definition at line 478 of file StringView.h.

◆ TrimLeft()

nn::nlib::TrimLeft ( StringView str)
inlinenoexcept

Removes any white spaces from the beginning of the string.

Parameters
[in,out]strThe StringView object to be processed.
Returns
Returns true if white spaces were removed.
Examples:
misc/stringutils/stringutils.cpp.

Definition at line 430 of file StringView.h.

◆ TrimRight()

nn::nlib::TrimRight ( StringView str)
inlinenoexcept

Removes any white spaces from the end of the string.

Parameters
[in,out]strThe StringView object to be processed.
Returns
Returns true if white spaces were removed.

Definition at line 441 of file StringView.h.