jaulib v1.3.0
Jau Support Library (C++, Java, ..)
|
String utilities for type conversion and manipulation. More...
Functions | |
std::string & | jau::byteHexString (std::string &dest, const uint8_t value, const bool lowerCase) noexcept |
Produce a hexadecimal string representation of the given byte value. More... | |
template<class uint8_container_type , std::enable_if_t< std::is_integral_v< typename uint8_container_type::value_type > &&std::is_convertible_v< typename uint8_container_type::value_type, uint8_t >, bool > = true> | |
std::string | jau::bytesHexString (const uint8_container_type &bytes, const bool lsbFirst, const bool lowerCase=true) noexcept |
std::string | jau::bytesHexString (const void *data, const nsize_t offset, const nsize_t length, const bool lsbFirst, const bool lowerCase=true) noexcept |
Produce a hexadecimal string representation of the given byte values. More... | |
std::string | jau::format_string (const char *format,...) noexcept |
Returns a string according to printf() formatting rules and variable number of arguments following the format argument. More... | |
std::string | jau::get_string (const uint8_t *buffer, nsize_t const buffer_len, nsize_t const max_len) noexcept |
Returns a C++ String taken from buffer with maximum length of min(max_len, max_len). More... | |
size_t | jau::hexStringBytes (std::vector< uint8_t > &out, const std::string &hexstr, const bool lsbFirst, const bool checkLeading0x) noexcept |
Converts a given hexadecimal string representation into a byte vector. More... | |
size_t | jau::hexStringBytes (std::vector< uint8_t > &out, const uint8_t hexstr[], const size_t hexstr_len, const bool lsbFirst, const bool checkLeading0x) noexcept |
See hexStringBytes() More... | |
std::vector< std::string > | jau::split_string (const std::string &str, const std::string &separator) noexcept |
Split given string str at separator into the resulting std::vector excluding the separator sequence . More... | |
template<class value_type , std::enable_if_t< std::is_integral_v< value_type >, bool > = true> | |
std::string | jau::to_decstring (const value_type &v, const char separator=',', const nsize_t width=0) noexcept |
Produce a decimal string representation of an integral integer value. More... | |
template<class value_type , std::enable_if_t< std::is_pointer_v< value_type >, bool > = true> | |
std::string | jau::to_hexstring (value_type const &v) noexcept |
Produce a lower-case hexadecimal string representation of the given pointer. More... | |
bool | jau::to_integer (long long &result, const char *str, size_t str_len, const char limiter='\0', const char *limiter_pos=nullptr) |
bool | jau::to_integer (long long &result, const std::string &str, const char limiter='\0', const char *limiter_pos=nullptr) |
template<class value_type , std::enable_if_t< std::is_integral_v< value_type >||std::is_floating_point_v< value_type >, bool > = true> | |
std::string | jau::to_string (const value_type &ref) |
template<typename T > | |
std::string | jau::to_string (std::vector< T > const &list) |
template<typename T > | |
std::string | jau::to_string (std::vector< T > const &list, const std::string &delim) |
std::string | jau::toLower (const std::string &s) noexcept |
std::string & | jau::toLowerInPlace (std::string &s) noexcept |
std::string | jau::trim (const std::string &s) noexcept |
trim copy More... | |
void | jau::trimInPlace (std::string &s) noexcept |
trim in place More... | |
std::string | jau::vformat_string (const char *format, va_list ap) noexcept |
Returns a string according to vprintf() formatting rules using va_list instead of a variable number of arguments. More... | |
String utilities for type conversion and manipulation.
|
noexcept |
Returns a C++ String taken from buffer with maximum length of min(max_len, max_len).
The maximum length only delimits the string length and does not contain the EOS null byte. An EOS null byte will will be added.
The source string within buffer is not required to contain an EOS null byte;
Definition at line 249 of file basic_types.cpp.
|
noexcept |
trim in place
Definition at line 255 of file basic_types.cpp.
|
noexcept |
trim copy
Definition at line 264 of file basic_types.cpp.
|
noexcept |
Split given string str
at separator
into the resulting std::vector excluding the separator sequence .
Definition at line 270 of file basic_types.cpp.
|
noexcept |
|
noexcept |
|
noexcept |
Converts a given hexadecimal string representation into a byte vector.
In case a non valid hexadecimal digit appears in the given string, conversion ends and fills the byte vector up until the violation.
out | the byte vector sink |
hexstr | the hexadecimal string representation |
lsbFirst | low significant byte first |
checkLeading0x | if true, checks for a leading 0x and removes it, otherwise not. |
Definition at line 414 of file basic_types.cpp.
|
noexcept |
See hexStringBytes()
Definition at line 417 of file basic_types.cpp.
|
noexcept |
Produce a hexadecimal string representation of the given byte values.
If lsbFirst is true, orders LSB left -> MSB right, usual for byte streams. Result will not have a leading 0x
.
Otherwise orders MSB left -> LSB right, usual for readable integer values. Result will have a leading 0x
.
data | pointer to the first byte to print, less offset |
offset | offset to bytes pointer to the first byte to print |
length | number of bytes to print |
lsbFirst | true having the least significant byte printed first (lowest addressed byte to highest), otherwise have the most significant byte printed first (highest addressed byte to lowest). A leading 0x will be prepended if lsbFirst == false . |
lowerCase | true to use lower case hex-chars, otherwise capital letters are being used. |
Definition at line 466 of file basic_types.cpp.
|
noexcept |
Definition at line 121 of file string_util.hpp.
|
noexcept |
Produce a hexadecimal string representation of the given byte value.
dest | the std::string reference destination to append |
value | the byte value to represent |
lowerCase | true to use lower case hex-chars, otherwise capital letters are being used. |
Definition at line 503 of file basic_types.cpp.
|
inlinenoexcept |
Produce a lower-case hexadecimal string representation of the given pointer.
Produce a lower-case hexadecimal string representation of the given value with standard layout.
value_type | a pointer type |
v | the pointer of given pointer type |
value_type | a standard layout value type |
v | the value of given standard layout type |
Definition at line 145 of file string_util.hpp.
|
noexcept |
Produce a decimal string representation of an integral integer value.
T | an integral integer type |
v | the integral integer value |
separator | if not 0, use as separation character, otherwise no separation characters are being used |
width | the minimum number of characters to be printed. Add padding with blank space if result is shorter. |
Definition at line 184 of file string_util.hpp.
|
noexcept |
Returns a string according to vprintf()
formatting rules using va_list
instead of a variable number of arguments.
format | printf() compliant format string |
ap | va_list arguments |
Definition at line 367 of file basic_types.cpp.
|
noexcept |
Returns a string according to printf()
formatting rules and variable number of arguments following the format
argument.
format | printf() compliant format string |
Definition at line 392 of file basic_types.cpp.
|
inline |
Definition at line 242 of file string_util.hpp.
std::string jau::to_string | ( | std::vector< T > const & | list, |
const std::string & | delim | ||
) |
Definition at line 333 of file string_util.hpp.
std::string jau::to_string | ( | std::vector< T > const & | list | ) |
bool jau::to_integer | ( | long long & | result, |
const std::string & | str, | ||
const char | limiter = '\0' , |
||
const char * | limiter_pos = nullptr |
||
) |
bool jau::to_integer | ( | long long & | result, |
const char * | str, | ||
size_t | str_len, | ||
const char | limiter = '\0' , |
||
const char * | limiter_pos = nullptr |
||
) |
Definition at line 549 of file basic_types.cpp.