jaulib v1.3.6
Jau Support Library (C++, Java, ..)
|
String utilities for type conversion and manipulation. More...
Namespaces | |
namespace | jau::cfmt2::impl |
namespace | jau::cfmt::impl |
Classes | |
struct | jau::cfmt::PResult |
struct | jau::cfmt2::PResult |
struct | jau::string_hash |
C++20: Heterogeneous Lookup in (Un)ordered Containers. More... | |
Typedefs | |
template<typename T> | |
using | jau::StringHashMap = std::unordered_map<std::string, T, string_hash, std::equal_to<>> |
using | jau::StringHashSet = std::unordered_set<std::string, string_hash, std::equal_to<>> |
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. | |
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, const bool skipLeading0x=false) noexcept |
std::string | jau::bytesHexString (const void *data, const nsize_t length, const bool lsbFirst, const bool lowerCase=true, const bool skipLeading0x=false) noexcept |
Produce a hexadecimal string representation of the given byte values. | |
template<typename... Targs> | |
constexpr bool | jau::cfmt2::check (const std::string_view fmt, const Targs &...) noexcept |
Strict type validation of arguments against the format string. | |
template<typename... Targs> | |
constexpr bool | jau::cfmt::check (const std::string_view fmt, const Targs &...) noexcept |
Strict type validation of arguments against the format string. | |
template<typename... Targs> | |
constexpr bool | jau::cfmt2::check2 (const std::string_view fmt) noexcept |
Strict type validation of arguments against the format string. | |
template<typename... Targs> | |
constexpr bool | jau::cfmt::check2 (const std::string_view fmt) noexcept |
Strict type validation of arguments against the format string. | |
template<typename StrView, typename... Targs> | |
constexpr bool | jau::cfmt::check3 (StrView fmt) noexcept |
template<typename... Targs> | |
constexpr const PResult | jau::cfmt2::checkR (const std::string_view fmt, const Targs &...) noexcept |
Strict type validation of arguments against the format string. | |
template<typename... Targs> | |
constexpr PResult | jau::cfmt::checkR (const std::string_view fmt, const Targs &...) noexcept |
Strict type validation of arguments against the format string. | |
template<typename... Targs> | |
constexpr const PResult | jau::cfmt2::checkR2 (const std::string_view fmt) noexcept |
Strict type validation of arguments against the format string. | |
template<typename... Targs> | |
constexpr PResult | jau::cfmt::checkR2 (const std::string_view fmt) noexcept |
Strict type validation of arguments against the format string. | |
std::string | jau::format_string (const char *format,...) |
Returns a string according to printf() formatting rules and variable number of arguments following the format argument. | |
template<typename... Args> | |
constexpr std::string | jau::format_string_v (const std::size_t maxStrLen, const std::string_view format, const Args &...args) |
Safely returns a string according to printf() formatting rules and variable number of arguments following the format argument. | |
uint64_t | jau::from_hexstring (std::string const &s, const bool lsbFirst=!jau::is_little_endian(), const bool checkLeading0x=true) noexcept |
Converts a given hexadecimal string representation into a uint64_t value according to hexStringBytes(). | |
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). | |
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. | |
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() | |
bool | jau::is_ascii_code (int c) noexcept |
static constexpr bool | jau::cfmt2::isDigit (const char c) noexcept |
static constexpr bool | jau::cfmt::isDigit (const char c) noexcept |
std::ostream & | jau::cfmt2::operator<< (std::ostream &out, const PResult &pc) |
std::ostream & | jau::cfmt::operator<< (std::ostream &out, const PResult &pc) |
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 . | |
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. | |
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, const bool skipLeading0x=false) noexcept |
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given pointer. | |
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) |
static constexpr const char * | jau::cfmt2::to_string (plength_t s) noexcept |
static constexpr const char * | jau::cfmt2::to_string (pstate_t s) noexcept |
static constexpr const char * | jau::cfmt::to_string (plength_t s) noexcept |
static constexpr const char * | jau::cfmt::to_string (pstate_t s) noexcept |
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 | |
void | jau::trimInPlace (std::string &s) noexcept |
trim in place | |
std::string | jau::vformat_string (const char *format, va_list ap) |
Returns a string according to vprintf() formatting rules using va_list instead of a variable number of arguments. | |
String utilities for type conversion and manipulation.
using jau::StringHashMap = std::unordered_map<std::string, T, string_hash, std::equal_to<>> |
Definition at line 458 of file string_util.hpp.
using jau::StringHashSet = std::unordered_set<std::string, string_hash, std::equal_to<>> |
Definition at line 460 of file string_util.hpp.
|
strong |
Enumerator | |
---|---|
error | |
outside | |
start | |
field_width | |
precision |
Definition at line 98 of file string_cfmt.hpp.
|
strong |
Enumerator | |
---|---|
hh | |
h | |
none | |
l | |
ll | |
j | |
z | |
t | |
L |
Definition at line 114 of file string_cfmt.hpp.
|
strong |
Enumerator | |
---|---|
error | |
outside | |
start | |
field_width | |
precision |
Definition at line 97 of file string_cfmt2.hpp.
|
strong |
Enumerator | |
---|---|
hh | |
h | |
none | |
l | |
ll | |
j | |
z | |
t | |
L |
Definition at line 113 of file string_cfmt2.hpp.
|
staticconstexprnoexcept |
|
staticconstexprnoexcept |
Definition at line 125 of file string_cfmt.hpp.
|
staticconstexprnoexcept |
Definition at line 140 of file string_cfmt.hpp.
|
inline |
Definition at line 242 of file string_cfmt.hpp.
|
constexprnoexcept |
Strict type validation of arguments against the format string.
See jau_cfmt_header for details
Targs | the argument template type pack to be validated against the format string |
fmt | the snprintf format string |
args | passed arguments, used for template type deduction only |
Definition at line 734 of file string_cfmt.hpp.
|
constexprnoexcept |
Strict type validation of arguments against the format string.
See jau_cfmt_header for details
Targs | the argument template type pack to be validated against the format string |
fmt | the snprintf format string |
Definition at line 754 of file string_cfmt.hpp.
|
constexprnoexcept |
|
constexprnoexcept |
Strict type validation of arguments against the format string.
See jau_cfmt_header for details
Targs | the argument template type pack to be validated against the format string |
fmt | the snprintf format string |
args | passed arguments, used for template type deduction only |
Definition at line 787 of file string_cfmt.hpp.
|
constexprnoexcept |
Strict type validation of arguments against the format string.
See jau_cfmt_header for details
Targs | the argument template type pack to be validated against the format string |
fmt | the snprintf format string |
Definition at line 808 of file string_cfmt.hpp.
|
inlinenoexcept |
Definition at line 55 of file string_util.hpp.
|
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 480 of file basic_types.cpp.
|
noexcept |
trim in place
Definition at line 486 of file basic_types.cpp.
|
noexcept |
trim copy
Definition at line 495 of file basic_types.cpp.
|
noexcept |
Split given string str
at separator
into the resulting std::vector excluding the separator sequence .
Definition at line 501 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.
If string is in MSB first (default w/ leading 0x) and platform jau::is_little_endian(), lsbFirst = false shall be passed.
In case hexstr contains an odd number of hex-nibbles, it will be interpreted as follows
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 645 of file basic_types.cpp.
|
noexcept |
See hexStringBytes()
Definition at line 649 of file basic_types.cpp.
|
noexcept |
Converts a given hexadecimal string representation into a uint64_t value according to hexStringBytes().
If string is in MSB first (default w/ leading 0x) and platform jau::is_little_endian(), lsbFirst = false shall be passed (default).
s | 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 717 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
if !skipLeading0x (default).
data | 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 (default), otherwise capital letters are being used. |
skipLeading0x | false to add leading 0x if !lsbFirst (default), true to not add (skip).. |
Definition at line 736 of file basic_types.cpp.
|
noexcept |
Definition at line 151 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 782 of file basic_types.cpp.
|
inlinenoexcept |
Produce a lower-case hexadecimal string representation with leading 0x
in MSB of the given pointer.
Produce a lower-case hexadecimal string representation with leading 0x
in MSB of the given value with standard layout.
value_type | a pointer type |
v | the pointer of given pointer type |
skipLeading0x | false to add leading 0x (default), true to not add (skip).. |
value_type | a standard layout value type |
v | the value of given standard layout type |
skipLeading0x | false to add leading 0x (default), true to not add (skip).. |
Definition at line 177 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 233 of file string_util.hpp.
std::string jau::vformat_string | ( | const char * | format, |
va_list | ap ) |
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 598 of file basic_types.cpp.
std::string jau::format_string | ( | const char * | format, |
... ) |
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 623 of file basic_types.cpp.
|
constexpr |
Safely returns a string according to printf()
formatting rules and variable number of arguments following the format
argument.
jau::cfmt2::check() is utilize to pre-validate the given arguments against the format string. If invalid, method returns an empty string. Otherwise std::snprintf() is being utilized.
maxStrLen | maximum resulting string length |
format | printf() compliant format string |
args | optional arguments matching the format string |
Definition at line 294 of file string_util.hpp.
|
inline |
Definition at line 326 of file string_util.hpp.
std::string jau::to_string | ( | std::vector< T > const & | list, |
const std::string & | delim ) |
Definition at line 417 of file string_util.hpp.
std::string jau::to_string | ( | std::vector< T > const & | list | ) |
Definition at line 434 of file string_util.hpp.
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 828 of file basic_types.cpp.
|
staticconstexprnoexcept |
|
staticconstexprnoexcept |
Definition at line 124 of file string_cfmt2.hpp.
|
staticconstexprnoexcept |
Definition at line 139 of file string_cfmt2.hpp.
|
inline |
Definition at line 256 of file string_cfmt2.hpp.
|
constexprnoexcept |
Strict type validation of arguments against the format string.
See jau_cfmt_header for details
Targs | the argument template type pack to be validated against the format string |
fmt | the snprintf format string |
args | passed arguments, used for template type deduction only |
Definition at line 740 of file string_cfmt2.hpp.
|
constexprnoexcept |
Strict type validation of arguments against the format string.
See jau_cfmt_header for details
Targs | the argument template type pack to be validated against the format string |
fmt | the snprintf format string |
Definition at line 755 of file string_cfmt2.hpp.
|
constexprnoexcept |
Strict type validation of arguments against the format string.
See jau_cfmt_header for details
Targs | the argument template type pack to be validated against the format string |
fmt | the snprintf format string |
args | passed arguments, used for template type deduction only |
Definition at line 771 of file string_cfmt2.hpp.
|
constexprnoexcept |
Strict type validation of arguments against the format string.
See jau_cfmt_header for details
Targs | the argument template type pack to be validated against the format string |
fmt | the snprintf format string |
Definition at line 786 of file string_cfmt2.hpp.