|
jaulib v1.4.1-42-g12a2879
Jau Support Library (C++, Java, ..)
|
String utilities for type conversion and manipulation. More...
Namespaces | |
| namespace | jau::cfmt::impl |
Classes | |
| class | jau::BasicStringLiteral< CharT, N > |
| Static compile-time string literal storage. More... | |
| struct | jau::cfmt::FormatOpts |
| class | jau::cfmt::Result |
Macros | |
| #define | jau_format_check(fmt, ...) |
Macro produces compile time validation using a static_assert against jau::cfmt::check2. | |
| #define | jau_format_checkLine(fmt, ...) |
Macro produces compile time validation using a static_assert against jau::cfmt::check2Line. | |
| #define | jau_format_string(fmt, ...) |
Macro, safely returns a (non-truncated) string according to snprintf() formatting rules using a reserved string length of jau::cfmt::default_string_capacity and variable number of arguments following the fmt argument. | |
| #define | jau_format_string2(fmt, ...) |
Macro, safely returns a (non-truncated) string according to snprintf() formatting rules using a reserved string length of jau::cfmt::default_string_capacity and variable number of arguments following the fmt argument. | |
| #define | jau_format_string_h(strLenHint, fmt, ...) |
Macro, safely returns a (non-truncated) string according to snprintf() formatting rules and variable number of arguments following the fmt argument. | |
Typedefs | |
| template<size_t N> | |
| using | jau::StringLiteral = BasicStringLiteral<char, N> |
| template<size_t N> | |
| using | jau::WStringLiteral = BasicStringLiteral<wchar_t, N> |
Functions | |
| std::string & | jau::appendBitString (std::string &dest, const void *data, const nsize_t length, const bit_order_t bitOrder=bit_order_t::msb, const PrefixOpt prefix=PrefixOpt::prefix, size_t bit_len=0) noexcept |
| Appends a binary string representation of the given lsb-first byte values. | |
| std::string & | jau::appendHexString (std::string &dest, const uint8_t value, const LoUpCase capitalization=LoUpCase::lower) noexcept |
| Produce a hexadecimal string representation of the given byte value and appends it to the given string. | |
| std::string & | jau::appendHexString (std::string &dest, const void *data, const nsize_t length, const lb_endian_t byteOrder=lb_endian_t::big, const LoUpCase capitalization=LoUpCase::lower, const PrefixOpt prefix=PrefixOpt::prefix) noexcept |
| Appends a hexadecimal string representation of the given lsb-first byte values. | |
| template<std::integral value_type> | |
| std::string & | jau::appendIntString (std::string &dest, value_type val, const uint32_t radix, const LoUpCase capitalization=LoUpCase::lower, const PrefixOpt prefix=PrefixOpt::prefix, const uint32_t min_width=0, const char separator=0, const char padding='0') noexcept |
| Appends an integer string representation of an integral integer value with given radix. | |
| template<typename CharT, std::convertible_to< CharT >... Rest> | |
| jau::BasicStringLiteral (CharT, Rest...) -> BasicStringLiteral< CharT, 1+sizeof...(Rest)> | |
| template<typename CharT, size_t O> | |
| jau::BasicStringLiteral (const CharT(&str)[O]) -> BasicStringLiteral< CharT, O - 1 > | |
| template<typename... Targs> | |
| consteval_cxx20 ssize_t | jau::cfmt::check (std::string_view fmt, const Targs &...) noexcept |
| Strict compile-time type validation of deduced argument-types against the format string. | |
| template<typename... Targs> | |
| consteval_cxx20 ssize_t | jau::cfmt::check2 (std::string_view fmt) noexcept |
| Strict compile-time type validation of explicit argument-types against the format string. | |
| template<typename... Targs> | |
| consteval_cxx20 int | jau::cfmt::check2Line (std::string_view fmt) noexcept |
| Strict compile-time type validation of explicit argument-types against the format string. | |
| template<typename... Targs> | |
| consteval_cxx20 int | jau::cfmt::checkLine (std::string_view fmt, const Targs &...) noexcept |
| Strict compile-time type validation of deduced argument-types against the format string. | |
| template<typename... Targs> | |
| consteval_cxx20 Result | jau::cfmt::checkR (std::string_view fmt, const Targs &...) noexcept |
| Strict compile-time type validation of deduced argument-types against the format string. | |
| template<typename... Targs> | |
| consteval_cxx20 Result | jau::cfmt::checkR2 (std::string_view format) noexcept |
| Strict compile-time type validation of explicit argument-types against the format string. | |
| constexpr int32_t | jau::digit (const uint8_t c, const uint32_t radix=10) noexcept |
Returns digit value of given char c matching the radix 16, 10, 8 or 2, -1 on no match. | |
| template<class UnaryPredicate> | |
| void | jau::do_noexcept (UnaryPredicate p) noexcept |
No throw wrap for given unary predicate producing a std::string. | |
| void | jau::unsafe::errPrint (FILE *out, const char *msg, bool addErrno, bool addBacktrace, const char *func, const char *file, const int line, const char *format,...) noexcept |
| template<typename... Targs> | |
| std::string | jau::cfmt::format (size_t maxLen, std::string_view fmt, const Targs &...args) noexcept |
| Strict format with type validation of arguments against the format string. | |
| template<typename... Targs> | |
| std::string | jau::cfmt::format (std::string_view fmt, const Targs &...args) noexcept |
| Strict format with type validation of arguments against the format string. | |
| std::string | jau::unsafe::format_string (const char *format,...) noexcept |
Returns a (non-truncated) string according to snprintf() formatting rules and variable number of arguments following the format argument while utilizing the unsafe vsnprintf. | |
| std::string | jau::unsafe::format_string_h (const std::size_t strLenHint, const char *format,...) noexcept |
Returns a (non-truncated) string according to snprintf() formatting rules and variable number of arguments following the format argument while utilizing the unsafe vsnprintf. | |
| std::string | jau::unsafe::format_string_n (const std::size_t maxStrLen, const char *format,...) noexcept |
Returns a (potentially truncated) string according to snprintf() formatting rules and variable number of arguments following the format argument while utilizing the unsafe vsnprintf. | |
| template<typename... Targs> | |
| Result | jau::cfmt::formatR (const std::size_t strLenHint, std::string &s, size_t maxLen, std::string_view fmt, const Targs &...args) noexcept |
| Strict format with type validation of arguments against the format string, appending to the given destination. | |
| template<typename... Targs> | |
| Result | jau::cfmt::formatR (const std::size_t strLenHint, std::string &s, std::string_view fmt, const Targs &...args) noexcept |
| Strict format with type validation of arguments against the format string, appending to the given destination. | |
| template<typename... Targs> | |
| Result | jau::cfmt::formatR (std::string &s, size_t maxLen, std::string_view fmt, const Targs &...args) noexcept |
| Strict format with type validation of arguments against the format string, appending to the given destination. | |
| template<typename... Targs> | |
| Result | jau::cfmt::formatR (std::string &s, std::string_view fmt, const Targs &...args) noexcept |
| Strict format with type validation of arguments against the format string, appending to the given destination. | |
| UInt64SizeBoolTuple | jau::fromBitString (std::string_view const bitstr, const bit_order_t bitOrder=bit_order_t::msb, const Bool checkPrefix=Bool::True) noexcept |
| Converts a given binary string representation into a uint64_t value according to bitStringBytes(). | |
| SizeBoolPair | jau::fromBitString (std::vector< uint8_t > &out, const std::string_view bitstr, const bit_order_t bitOrder=bit_order_t::msb, const Bool checkPrefix=Bool::True) |
| See fromBitString() | |
| SizeBoolPair | jau::fromBitString (std::vector< uint8_t > &out, const uint8_t bitstr[], const size_t bitstr_len, const bit_order_t bitOrder=bit_order_t::msb, const Bool checkPrefix=Bool::True) |
| Converts a given binary string representation, appending to a byte vector (lsb-first). | |
| UInt8PtrSizeBoolPair | jau::fromBitString (uint8_t *out, size_t out_len, const std::string_view bitstr, const bit_order_t bitOrder=bit_order_t::msb, const Bool checkPrefix=Bool::True) noexcept |
| See fromBitString() | |
| UInt8PtrSizeBoolPair | jau::fromBitString (uint8_t *out, size_t out_len, const uint8_t bitstr[], const size_t bitstr_len, const bit_order_t bitOrder=bit_order_t::msb, const Bool checkPrefix=Bool::True) noexcept |
| Converts a given binary string representation, storing into a byte array(lsb-first). | |
| UInt64SizeBoolTuple | jau::fromHexString (std::string_view const hexstr, const lb_endian_t byteOrder=lb_endian_t::big, const Bool checkPrefix=Bool::True) noexcept |
| Converts a given hexadecimal string representation appending to a uint64_t value according to hexStringBytes(). | |
| SizeBoolPair | jau::fromHexString (std::vector< uint8_t > &out, const std::string_view hexstr, const lb_endian_t byteOrder=lb_endian_t::big, const Bool checkPrefix=Bool::True) |
| See hexStringBytes() | |
| SizeBoolPair | jau::fromHexString (std::vector< uint8_t > &out, const uint8_t hexstr[], const size_t hexstr_len, const lb_endian_t byteOrder=lb_endian_t::big, const Bool checkPrefix=Bool::True) |
| Converts a given hexadecimal string representation, appending to a byte vector (lsb-first). | |
| UInt8PtrSizeBoolPair | jau::fromHexString (uint8_t *out, size_t out_len, const std::string_view hexstr, const lb_endian_t byteOrder=lb_endian_t::big, const Bool checkPrefix=Bool::True) noexcept |
| See hexStringBytes() | |
| UInt8PtrSizeBoolPair | jau::fromHexString (uint8_t *out, size_t out_len, const uint8_t hexstr[], const size_t hexstr_len, const lb_endian_t byteOrder=lb_endian_t::big, const Bool checkPrefix=Bool::True) noexcept |
| Converts a given hexadecimal string representation, storing into a byte array(lsb-first). | |
| template<std::integral value_type> | |
| constexpr SizeBoolPair | jau::fromIntString (value_type &result, const char *str, size_t str_len, uint32_t radix=10, const char separator=0) noexcept |
| See fromIntString. | |
| template<std::integral value_type> | |
| constexpr SizeBoolPair | jau::fromIntString (value_type &result, std::string_view str, uint32_t radix=10, const char separator=0) noexcept |
Converts a given integer string representation to the given result reference, compatible with ::strtoll() | |
| std::string | jau::get_string (const uint8_t *buffer, nsize_t const buffer_len, nsize_t const max_len) |
| Returns a C++ String taken from buffer with maximum length of min(max_len, max_len). | |
| constexpr int32_t | jau::hexDigit (const uint8_t c) noexcept |
| bool | jau::is_ascii_code (int c) noexcept |
| constexpr bool | jau::is_digit (const char c, const uint32_t radix=10, const char separator=0) noexcept |
Returns true if given char c matches the char symbol range with the radix 16, 10 (default), 8 or 2. | |
| constexpr bool | jau::is_space (const char c) noexcept |
Returns true if given char c is one of the following whitespace character: | |
| jau::cfmt::JAU_MAKE_BITFIELD_ENUM_STRING (flags_t, hash, zeropad, left, space, plus, thousands, uppercase) | |
| jau::cfmt::JAU_MAKE_ENUM_STRING (cspec_t, character, string, pointer, signed_int, unsigned_int, floating_point, exp_float, alt_float, hex_float) | |
| jau::cfmt::JAU_MAKE_ENUM_STRING (plength_t, hh, h, l, ll, L, j, z, t) | |
| template<typename CharT, std::size_t N, std::size_t O> | |
| constexpr BasicStringLiteral< CharT, N+O-1 > | jau::operator+ (const BasicStringLiteral< CharT, N > &lhs, const char(&rhs)[O]) |
| template<typename CharT, size_t O, std::size_t N> | |
| constexpr BasicStringLiteral< CharT, N+O-1 > | jau::operator+ (const char(&lhs)[O], const BasicStringLiteral< CharT, N > rhs) |
| std::ostream & | jau::cfmt::operator<< (std::ostream &out, const FormatOpts &o) |
| std::ostream & | jau::cfmt::operator<< (std::ostream &out, const Result &pc) |
| std::vector< std::string > | jau::split_string (const std::string &str, const std::string &separator) |
Split given string str at separator into the resulting std::vector excluding the separator sequence . | |
| std::string | jau::string_noexcept (std::string_view v) noexcept |
No throw std::string(std::string_view) instantiation. | |
| template<class UnaryPredicate> | |
| std::string | jau::string_noexcept (UnaryPredicate p) noexcept |
No throw wrap for given unary predicate producing a std::string. | |
| 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. | |
| static constexpr const char * | jau::cfmt::to_string (pstate_t s) noexcept |
| template<typename CharT, std::size_t N> | |
| constexpr std::string | jau::to_string (const CharT(&ref)[N]) |
| template<class value_type> requires std::is_same_v<jau::StringLiteral<value_type::size>, value_type> | |
| constexpr std::string | jau::to_string (const value_type &ref) |
| template<class value_type, std::enable_if_t<(std::is_integral_v< value_type > &&!std::is_same_v< bool, std::remove_cv_t< 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 nsize_t radix) |
| template<typename T> | |
| std::string | jau::to_string (std::vector< T > const &list, const std::string &delim) |
| template<typename T> | |
| std::string | jau::to_string (std::vector< T > const &list, const std::string &delim, const nsize_t radix) |
| template<std::integral value_type> | |
| std::string | jau::to_string (value_type v, const nsize_t radix, const LoUpCase capitalization=LoUpCase::lower, const PrefixOpt prefix=PrefixOpt::prefix, const nsize_t min_width=0, const char separator=0, const char padding='0') noexcept |
| Produces an integer string representation of an integral integer value with given radix. | |
| template<class uint8_container_type> requires jau::req::contiguous_container<uint8_container_type> && std::convertible_to<typename uint8_container_type::value_type, uint8_t> | |
| std::string | jau::toBitString (const uint8_container_type &bytes, const bit_order_t bitOrder=bit_order_t::msb, const PrefixOpt prefix=PrefixOpt::prefix, size_t bit_len=0) noexcept |
Produce a binary string representation with leading 0b in MSB of the given uint8_t continuous container values. | |
| std::string | jau::toBitString (const void *data, const nsize_t length, const bit_order_t bitOrder=bit_order_t::msb, const PrefixOpt prefix=PrefixOpt::prefix, size_t bit_len=0) noexcept |
| Produce a binary string representation of the given lsb-first byte values. | |
| template<class value_type> requires jau::req::standard_layout<value_type> && jau::req::trivially_copyable<value_type> && (!jau::req::container<value_type>) && (!jau::req::pointer<value_type>) | |
| std::string | jau::toBitString (value_type const &v, const bit_order_t bitOrder=bit_order_t::msb, const PrefixOpt prefix=PrefixOpt::prefix, size_t bit_len=0) noexcept |
Produce a binary string representation with leading 0b in MSB of the given value with standard layout. | |
| template<class uint8_container_type> requires jau::req::contiguous_container<uint8_container_type> && std::convertible_to<typename uint8_container_type::value_type, uint8_t> | |
| std::string | jau::toHexString (const uint8_container_type &bytes, const lb_endian_t byteOrder=lb_endian_t::big, const LoUpCase capitalization=LoUpCase::lower, const PrefixOpt skipPrefix=PrefixOpt::prefix) noexcept |
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given uint8_t continuous container values. | |
| std::string | jau::toHexString (const void *data, const nsize_t length, const lb_endian_t byteOrder=lb_endian_t::big, const LoUpCase capitalization=LoUpCase::lower, const PrefixOpt prefix=PrefixOpt::prefix) noexcept |
| Produce a hexadecimal string representation of the given lsb-first byte values. | |
| template<class value_type> requires jau::req::pointer<value_type> && (!jau::req::container<value_type>) | |
| std::string | jau::toHexString (value_type const &v, const lb_endian_t byteOrder=lb_endian_t::big, const LoUpCase capitalization=LoUpCase::lower, const PrefixOpt prefix=PrefixOpt::prefix) noexcept |
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given pointer. | |
| std::string | jau::toLower (const std::string &s) |
| std::string & | jau::toLowerInPlace (std::string &s) noexcept |
| std::string | jau::trim (const std::string &s) |
| trim copy | |
| void | jau::trimInPlace (std::string &s) noexcept |
| trim in place | |
| std::string | jau::unsafe::vformat_string_h (const std::size_t strLenHint, const char *format, va_list args) noexcept |
| std::string | jau::unsafe::vformat_string_n (const std::size_t maxStrLen, const char *format, va_list args) noexcept |
Variables | |
| constexpr const size_t | jau::cfmt::default_string_capacity = 511 |
| Default string reserved capacity w/o EOS (511) | |
| constexpr const char * | jau::HexadecimalArrayBig = "0123456789ABCDEF" |
| constexpr const char * | jau::HexadecimalArrayLow = "0123456789abcdef" |
| constexpr const size_t | jau::cfmt::num_max_slen = 31 |
| Maximum net number string len w/o EOS, up to uint64_t. | |
String utilities for type conversion and manipulation.
| #define jau_format_string | ( | fmt, | |
| ... ) |
Macro, safely returns a (non-truncated) string according to snprintf() formatting rules using a reserved string length of jau::cfmt::default_string_capacity and variable number of arguments following the fmt argument.
This macro also produces compile time validation using a static_assert against jau::cfmt::check2.
jau::cfmt::formatR() is utilize to validate format against given arguments at runtime.
Resulting string size matches formated output w/o limitation and its capacity is left unchanged.
Use std::string::shrink_to_fit() on the returned string, if you desire efficiency for longer lifecycles.
See jau_cfmt_header for details
| format | printf() compliant format string |
| args | arguments matching the format string |
Definition at line 1978 of file string_cfmt.hpp.
| #define jau_format_string_h | ( | strLenHint, | |
| fmt, | |||
| ... ) |
Macro, safely returns a (non-truncated) string according to snprintf() formatting rules and variable number of arguments following the fmt argument.
This macro also produces compile time validation using a static_assert against jau::cfmt::check2.
jau::cfmt::formatR() is utilize to validate format against given arguments at runtime.
Resulting string size matches formated output w/o limitation and its capacity is left unchanged.
Use std::string::shrink_to_fit() on the returned string, if you desire efficiency for longer lifecycles.
See jau_cfmt_header for details
| strLenHint | initially used string length w/o EOS |
| format | printf() compliant format string |
| args | arguments matching the format string |
Definition at line 2003 of file string_cfmt.hpp.
| #define jau_format_string2 | ( | fmt, | |
| ... ) |
Macro, safely returns a (non-truncated) string according to snprintf() formatting rules using a reserved string length of jau::cfmt::default_string_capacity and variable number of arguments following the fmt argument.
This macro also produces compile time validation using a static_assert against jau::cfmt::check2Line.
jau::cfmt::formatR() is utilize to validate format against given arguments at runtime.
Resulting string size matches formated output w/o limitation and its capacity is left unchanged.
Use std::string::shrink_to_fit() on the returned string, if you desire efficiency for longer lifecycles.
See jau_cfmt_header for details
| format | printf() compliant format string |
| args | arguments matching the format string |
Definition at line 2028 of file string_cfmt.hpp.
| #define jau_format_check | ( | fmt, | |
| ... ) |
Macro produces compile time validation using a static_assert against jau::cfmt::check2.
See jau_cfmt_header for details
| format | printf() compliant format string |
| args | arguments matching the format string |
Definition at line 2041 of file string_cfmt.hpp.
| #define jau_format_checkLine | ( | fmt, | |
| ... ) |
Macro produces compile time validation using a static_assert against jau::cfmt::check2Line.
See jau_cfmt_header for details
| format | printf() compliant format string |
| args | arguments matching the format string |
Definition at line 2053 of file string_cfmt.hpp.
| using jau::StringLiteral = BasicStringLiteral<char, N> |
Definition at line 168 of file string_literal.hpp.
| using jau::WStringLiteral = BasicStringLiteral<wchar_t, N> |
Definition at line 171 of file string_literal.hpp.
|
strong |
| Enumerator | |
|---|---|
| error | |
| outside | |
| start | |
| field_width | |
| precision | |
Definition at line 211 of file string_cfmt.hpp.
|
strong |
Format flags.
Definition at line 229 of file string_cfmt.hpp.
|
strong |
Format length modifiers.
| Enumerator | |
|---|---|
| none | |
| hh | char integer |
| h | short integer |
| l | long integer |
| ll | long long integer |
| L | long double float |
| j | intmax_t or uintmax_t integer |
| z | size_t or ssize_t integer |
| t | ptrdiff_t |
Definition at line 244 of file string_cfmt.hpp.
|
strong |
Format conversion specifier (fully defined w/ radix)
| Enumerator | |
|---|---|
| none | none |
| character |
|
| string |
|
| pointer |
|
| signed_int |
|
| unsigned_int |
|
| floating_point |
|
| exp_float |
|
| alt_float |
|
| hex_float |
|
Definition at line 258 of file string_cfmt.hpp.
|
strong |
| Enumerator | |
|---|---|
| lower | |
| upper | |
Definition at line 178 of file string_util.hpp.
|
strong |
| Enumerator | |
|---|---|
| none | |
| prefix | |
Definition at line 183 of file string_util.hpp.
|
inlinenoexcept |
No throw wrap for given unary predicate producing a std::string.
Definition at line 496 of file cpp_lang_util.hpp.
|
inlinenoexcept |
No throw wrap for given unary predicate producing a std::string.
Definition at line 509 of file cpp_lang_util.hpp.
|
inlinenoexcept |
No throw std::string(std::string_view) instantiation.
Definition at line 521 of file cpp_lang_util.hpp.
|
staticconstexprnoexcept |
| jau::cfmt::JAU_MAKE_BITFIELD_ENUM_STRING | ( | flags_t | , |
| hash | , | ||
| zeropad | , | ||
| left | , | ||
| space | , | ||
| plus | , | ||
| thousands | , | ||
| uppercase | ) |
| jau::cfmt::JAU_MAKE_ENUM_STRING | ( | cspec_t | , |
| character | , | ||
| string | , | ||
| pointer | , | ||
| signed_int | , | ||
| unsigned_int | , | ||
| floating_point | , | ||
| exp_float | , | ||
| alt_float | , | ||
| hex_float | ) |
|
inline |
Definition at line 426 of file string_cfmt.hpp.
|
inline |
Definition at line 463 of file string_cfmt.hpp.
|
inlinenoexcept |
Strict format with type validation of arguments against the format string.
See jau_cfmt_header for details
| Targs | the argument template type pack for the given arguments args |
| fmt | the snprintf compliant format string |
| args | passed arguments, used for template type deduction only |
Definition at line 1540 of file string_cfmt.hpp.
|
inlinenoexcept |
Strict format with type validation of arguments against the format string.
See jau_cfmt_header for details
| Targs | the argument template type pack for the given arguments args |
| maxLen | maximum string length |
| fmt | the snprintf compliant format string |
| args | passed arguments, used for template type deduction only |
Definition at line 1571 of file string_cfmt.hpp.
|
inlinenoexcept |
Strict format with type validation of arguments against the format string, appending to the given destination.
See jau_cfmt_header for details
| Targs | the argument template type pack for the given arguments args |
| s | destination string to append the formatted string |
| maxLen | maximum string length |
| fmt | the snprintf compliant format string |
| args | passed arguments, used for template type deduction only |
Definition at line 1604 of file string_cfmt.hpp.
|
inlinenoexcept |
Strict format with type validation of arguments against the format string, appending to the given destination.
See jau_cfmt_header for details
| Targs | the argument template type pack for the given arguments args |
| s | destination string to append the formatted string |
| fmt | the snprintf compliant format string |
| args | passed arguments, used for template type deduction only |
Definition at line 1634 of file string_cfmt.hpp.
|
inlinenoexcept |
Strict format with type validation of arguments against the format string, appending to the given destination.
Resulting string is truncated to min(maxLen, formatLen), with formatLen being the given formatted string length of output w/o limitation and its capacity is left unchanged.
Use std::string::shrink_to_fit() on the returned string, if you desire efficiency for longer lifecycles (assuming maxLen hasn't been reached).
See jau_cfmt_header for details
| Targs | the argument template type pack for the given arguments args |
| strLenHint | initially used string length w/o EOS |
| s | destination string to append the formatted string |
| maxLen | maximum resulting string length including EOS |
| fmt | the snprintf compliant format string |
| args | arguments matching the format string |
Definition at line 1660 of file string_cfmt.hpp.
|
inlinenoexcept |
Strict format with type validation of arguments against the format string, appending to the given destination.
Resulting string size matches formated output w/o limitation and its capacity is left unchanged.
Use std::string::shrink_to_fit() on the returned string, if you desire efficiency for longer lifecycles.
See jau_cfmt_header for details
| Targs | the argument template type pack for the given arguments args |
| strLenHint | initially used string length w/o EOS |
| fmt | the snprintf compliant format string |
| args | arguments matching the format string |
Definition at line 1696 of file string_cfmt.hpp.
|
noexcept |
Strict compile-time type validation of deduced argument-types against the format string.
In case your can't provide constexpr arguments, use check2(). Types can always be produced, see macro jau_string_checkLine().
See jau_cfmt_header for details
| Targs | the argument template type pack to be validated against the format string |
| fmt | the snprintf compliant format string |
| args | passed arguments, used for template type deduction only |
Definition at line 1720 of file string_cfmt.hpp.
|
noexcept |
Strict compile-time type validation of deduced argument-types against the format string.
In case your can't provide constexpr arguments, use check2Line(). Types can always be produced, see macro jau_string_checkLine().
See jau_cfmt_header for details
| Targs | the argument template type pack to be validated against the format string |
| fmt | the snprintf compliant format string |
| args | passed arguments, used for template type deduction only |
Definition at line 1743 of file string_cfmt.hpp.
|
noexcept |
Strict compile-time type validation of explicit argument-types 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 compliant format string |
Definition at line 1764 of file string_cfmt.hpp.
|
noexcept |
Strict compile-time type validation of explicit argument-types 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 compliant format string |
Definition at line 1784 of file string_cfmt.hpp.
|
noexcept |
Strict compile-time type validation of deduced argument-types 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 compliant format string |
| args | passed arguments, used for template type deduction only |
Definition at line 1805 of file string_cfmt.hpp.
|
noexcept |
Strict compile-time type validation of explicit argument-types 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 compliant format string |
Definition at line 1825 of file string_cfmt.hpp.
| jau::BasicStringLiteral | ( | CharT | , |
| Rest... | ) -> BasicStringLiteral< CharT, 1+sizeof...(Rest)> |
| jau::BasicStringLiteral | ( | const CharT(&) | str[O] | ) | -> BasicStringLiteral< CharT, O - 1 > |
|
constexpr |
Definition at line 158 of file string_literal.hpp.
|
constexpr |
Definition at line 163 of file string_literal.hpp.
|
inlinenoexcept |
Definition at line 63 of file string_util.hpp.
|
constexprnoexcept |
Returns true if given char c is one of the following whitespace character:
Definition at line 76 of file string_util.hpp.
|
constexprnoexcept |
Returns true if given char c matches the char symbol range with the radix 16, 10 (default), 8 or 2.
Definition at line 89 of file string_util.hpp.
|
constexprnoexcept |
Returns digit value of given char c matching the radix 16, 10, 8 or 2, -1 on no match.
Definition at line 110 of file string_util.hpp.
|
constexprnoexcept |
| std::string jau::get_string | ( | const uint8_t * | buffer, |
| nsize_t const | buffer_len, | ||
| nsize_t const | max_len ) |
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 444 of file basic_types.cpp.
|
noexcept |
trim in place
Definition at line 450 of file basic_types.cpp.
| std::string jau::trim | ( | const std::string & | s | ) |
trim copy
Definition at line 459 of file basic_types.cpp.
| std::vector< std::string > jau::split_string | ( | const std::string & | str, |
| const std::string & | separator ) |
Split given string str at separator into the resulting std::vector excluding the separator sequence .
Definition at line 465 of file basic_types.cpp.
|
noexcept |
| std::string jau::toLower | ( | const std::string & | s | ) |
| SizeBoolPair jau::fromHexString | ( | std::vector< uint8_t > & | out, |
| const uint8_t | hexstr[], | ||
| const size_t | hexstr_len, | ||
| const lb_endian_t | byteOrder = lb_endian_t::big, | ||
| const Bool | checkPrefix = Bool::True ) |
Converts a given hexadecimal string representation, appending to a byte vector (lsb-first).
In case a non valid hexadecimal digit appears in the given string, conversion ends and fills the byte vector up until the violation.
In case hexstr contains an odd number of hex-nibbles, it will be interpreted as follows
Even if complete==false, result holds the partial value if consumed_chars>0.
You may use C++17 structured bindings to handle the pair.
| out | the byte vector sink to append, lsb-first |
| hexstr | the hexadecimal string representation |
| hexstr_len | length of hextstr |
| byteOrder | lb_endian_t::big for big-endian bytes in hexstr (default) |
| checkPrefix | if True, checks for a leading 0x and removes it, otherwise not. |
Definition at line 682 of file basic_types.cpp.
|
inline |
See hexStringBytes()
Definition at line 213 of file string_util.hpp.
|
noexcept |
Converts a given hexadecimal string representation, storing into a byte array(lsb-first).
In case a non valid hexadecimal digit appears in the given string, conversion ends and fills the byte vector up until the violation.
In case hexstr contains an odd number of hex-nibbles, it will be interpreted as follows
Even if complete==false, result holds the partial value if consumed_chars>0.
You may use C++17 structured bindings to handle the triple.
| out | byte array pointer to store result, lsb-first |
| out_len | size of byte array |
| hexstr | the hexadecimal string representation |
| hexstr_len | length of hextstr |
| byteOrder | lb_endian_t::big for big-endian bytes in hexstr (default) |
| checkPrefix | if True, checks for a leading 0x and removes it, otherwise not. |
Definition at line 759 of file basic_types.cpp.
|
inlinenoexcept |
See hexStringBytes()
Definition at line 245 of file string_util.hpp.
|
noexcept |
Converts a given hexadecimal string representation appending to a uint64_t value according to hexStringBytes().
Even if complete==false, result holds the partial value if consumed_chars>0.
You may use C++17 structured bindings to handle the tuple.
| hexstr | the hexadecimal string representation |
| byteOrder | lb_endian_t::big for big-endian bytes in hexstr (default) |
| checkPrefix | if True, checks for a leading 0x and removes it, otherwise not. |
Definition at line 841 of file basic_types.cpp.
|
noexcept |
Appends a hexadecimal string representation of the given lsb-first byte values.
If byteOrder is lb_endian_t::little, orders lsb-byte left, usual for byte streams. Result will not have a leading 0x. Otherwise, lb_endian_t::big (default), orders msb-byte left for integer values. Result will have a leading 0x if !skipPrefix.
| dest | the std::string to append to |
| data | pointer to the first byte to print, lsb-first |
| length | number of bytes to print |
| byteOrder | lb_endian_t::big for big-endian bytes in resulting hex-string (default). A leading 0x will be prepended if byteOrder == lb_endian_t::big and PrefixOpt::prefix given. |
| capitalization | LoUpCase capitalization, default is LoUpCase::lower |
| prefix | pass PrefixOpt::prefix (default) to add leading 0x if byteOrder == lb_endian_t::big (default) |
Definition at line 1046 of file basic_types.cpp.
|
inlinenoexcept |
Produce a hexadecimal string representation of the given lsb-first byte values.
If byteOrder is lb_endian_t::little, orders lsb-byte left, usual for byte streams. Result will not have a leading 0x. Otherwise, lb_endian_t::big (default), orders msb-byte left for integer values. Result will have a leading 0x if !skipPrefix.
| data | pointer to the first byte to print, lsb-first |
| length | number of bytes to print |
| byteOrder | lb_endian_t::big for big-endian bytes in resulting hex-string (default). A leading 0x will be prepended if byteOrder == lb_endian_t::big and PrefixOpt::prefix given. |
| capitalization | LoUpCase capitalization, default is LoUpCase::lower |
| prefix | pass PrefixOpt::prefix (default) to add leading 0x if byteOrder == lb_endian_t::big (default) |
Definition at line 303 of file string_util.hpp.
|
noexcept |
Produce a hexadecimal string representation of the given byte value and appends it to the given string.
| dest | the std::string reference destination to append |
| value | the byte value to represent |
| capitalization | LoUpCase capitalization, default is LoUpCase::lower |
Definition at line 1097 of file basic_types.cpp.
|
inlinenoexcept |
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given pointer.
| value_type | a pointer type |
| v | the pointer of given pointer type |
| byteOrder | lb_endian_t::big for big-endian bytes in resulting hex-string (default). A leading 0x will be prepended if byteOrder == lb_endian_t::big and PrefixOpt::prefix given. |
| capitalization | LoUpCase capitalization, default is LoUpCase::lower |
| prefix | pass PrefixOpt::prefix (default) to add leading 0x if byteOrder == lb_endian_t::big (default) |
Definition at line 335 of file string_util.hpp.
|
inlinenoexcept |
Produce a lower-case hexadecimal string representation with leading 0x in MSB of the given uint8_t continuous container values.
| uint8_container_type | a uint8_t continuous container type |
| bytes | the value of given uint8_t continuous container type |
| byteOrder | lb_endian_t::big for big-endian bytes in resulting hex-string (default). A leading 0x will be prepended if byteOrder == lb_endian_t::big and PrefixOpt::prefix given. |
| capitalization | LoUpCase capitalization, default is LoUpCase::lower |
| prefix | pass PrefixOpt::prefix (default) to add leading 0x if byteOrder == lb_endian_t::big (default) |
Definition at line 366 of file string_util.hpp.
| SizeBoolPair jau::fromBitString | ( | std::vector< uint8_t > & | out, |
| const uint8_t | bitstr[], | ||
| const size_t | bitstr_len, | ||
| const bit_order_t | bitOrder = bit_order_t::msb, | ||
| const Bool | checkPrefix = Bool::True ) |
Converts a given binary string representation, appending to a byte vector (lsb-first).
In case a non valid binary digit appears in the given string, conversion ends and fills the byte vector up until the violation.
In case bitstr contains an incomplete number of bit-nibbles, it will be interpreted as follows
Even if complete==false, result holds the partial value if consumed_chars>0.
You may use C++17 structured bindings to handle the pair.
| out | the byte vector sink to append, lsb-first |
| bitstr | the binary string representation |
| bitstr_len | length of bitstr |
| bitOrder | bit_order_t::msb for most significant bits in bitstr first (default) |
| checkPrefix | if True, checks for a leading 0b and removes it, otherwise not. |
Definition at line 866 of file basic_types.cpp.
|
inline |
See fromBitString()
Definition at line 435 of file string_util.hpp.
|
noexcept |
Converts a given binary string representation, storing into a byte array(lsb-first).
In case a non valid binary digit appears in the given string, conversion ends and fills the byte vector up until the violation.
In case bitstr contains an incomplete number of bit-nibbles, it will be interpreted as follows
Even if complete==false, result holds the partial value if consumed_chars>0.
You may use C++17 structured bindings to handle the triple.
| out | byte array pointer to store result, lsb-first |
| out_len | size of byte array |
| bitstr | the binary string representation |
| bitstr_len | length of bitstr |
| bitOrder | bit_order_t::msb for most significant bits in bitstr first (default) |
| checkPrefix | if True, checks for a leading 0b and removes it, otherwise not. |
Definition at line 945 of file basic_types.cpp.
|
inlinenoexcept |
See fromBitString()
Definition at line 468 of file string_util.hpp.
|
noexcept |
Converts a given binary string representation into a uint64_t value according to bitStringBytes().
Even if complete==false, result holds the partial value if consumed_chars>0.
You may use C++17 structured bindings to handle the tuple.
| bitstr | the binary string representation |
| checkPrefix | if true, checks for a leading 0b and removes it, otherwise not. |
| bitOrder | bit_order_t::msb for most significant bits in bitstr first (default) |
Definition at line 1028 of file basic_types.cpp.
|
noexcept |
Appends a binary string representation of the given lsb-first byte values.
If byteOrder is lb_endian_t::little, orders lsb-byte left, usual for byte streams. Result will not have a leading 0b. Otherwise, lb_endian_t::big (default), orders msb-byte left for integer values. Result will have a leading 0b if !skipPrefix.
| dest | the std::string to append to |
| data | pointer to the first byte to print, lsb-first |
| length | number of bytes to print |
| bitOrder | bit_order_t::msb for most-significant-bit first in resulting bit-string, bit_order_t::msb is default A leading 0b will be prepended if bitOrder == bit_order_t::msb and PrefixOpt::prefix given. |
| prefix | pass PrefixOpt::prefix (default) to add leading 0b if bitOrder == bit_order_t::msb (default) |
| bit_len | optional fixed number of bits to be printed counting from lsb excluding prefix. Pass zero for dropping zero leading bytes (default). |
Definition at line 1107 of file basic_types.cpp.
|
inlinenoexcept |
Produce a binary string representation of the given lsb-first byte values.
If byteOrder is lb_endian_t::little, orders lsb-byte left, usual for byte streams. Result will not have a leading 0b. Otherwise, lb_endian_t::big (default), orders msb-byte left for integer values. Result will have a leading 0b if !skipPrefix.
| data | pointer to the first byte to print, lsb-first |
| length | number of bytes to print |
| bitOrder | bit_order_t::msb for most-significant-bit first in resulting bit-string, bit_order_t::msb is default A leading 0b will be prepended if bitOrder == bit_order_t::msb and PrefixOpt::prefix given. |
| prefix | pass PrefixOpt::prefix (default) to add leading 0b if bitOrder == bit_order_t::msb (default) |
| bit_len | optional fixed number of bits to be printed counting from lsb excluding prefix. Pass zero for dropping zero leading bytes (default). |
Definition at line 522 of file string_util.hpp.
|
inlinenoexcept |
Produce a binary string representation with leading 0b in MSB of the given uint8_t continuous container values.
| uint8_container_type | a uint8_t continuous container type |
| bytes | the value of given uint8_t continuous container type |
| bitOrder | bit_order_t::msb for most-significant-bit first in resulting bit-string, bit_order_t::msb is default A leading 0b will be prepended if bitOrder == bit_order_t::msb and PrefixOpt::prefix given. |
| prefix | pass PrefixOpt::prefix (default) to add leading 0b if bitOrder == bit_order_t::msb (default) |
| bit_len | optional fixed number of bits to be printed counting from lsb excluding prefix. Pass zero for dropping zero leading bytes (default). |
Definition at line 545 of file string_util.hpp.
|
inlinenoexcept |
Produce a binary string representation with leading 0b in MSB of the given value with standard layout.
| value_type | a standard layout value type |
| v | the value of given standard layout type |
| bitOrder | bit_order_t::msb for most-significant-bit first in resulting bit-string, bit_order_t::msb is default A leading 0b will be prepended if bitOrder == bit_order_t::msb and PrefixOpt::prefix given. |
| prefix | pass PrefixOpt::prefix (default) to add leading 0b if bitOrder == bit_order_t::msb (default) |
| bit_len | optional fixed number of bits to be printed counting from lsb excluding prefix. Pass zero for dropping zero leading bytes (default). |
Definition at line 567 of file string_util.hpp.
|
noexcept |
Produce a decimal string representation of an integral integer value.
| value_type | 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 597 of file string_util.hpp.
|
constexprnoexcept |
Converts a given integer string representation to the given result reference, compatible with ::strtoll()
[space][+-][prefix][digits+sep][space][+][prefix][digits+sep]Even if complete==false due to empty string, under- or overflow, the result holds the partial value if consumed_chars>0.
Whitespace and non-matching chars
You may use C++17 structured bindings to handle the pair.
[size_t consumed_chars, bool complete]| result | the integral reference for the result |
| str | the decimal string representation |
| radix | base of the number system, supported: 2 binary, 8 octal, 10 decimal, 16 hexadecimal |
| separator | separator character (default 0, none), allowing to ignore like thousand separator characters |
Definition at line 661 of file string_util.hpp.
|
constexprnoexcept |
See fromIntString.
Definition at line 733 of file string_util.hpp.
|
noexcept |
Appends an integer string representation of an integral integer value with given radix.
[space][-][prefix][zeros_padding+sep][digits+sep]
| value_type | an integral integer type |
| dest | the std::string to append to |
| val | the unsigned integral integer value |
| radix | base of the number system, supported: 2 binary, 8 octal, 10 decimal, 16 hexadecimal |
| capitalization | LoUpCase capitalization, default is LoUpCase::lower |
| prefix | pass PrefixOpt::prefix (default) to add leading prefix for radix. Prefixes: 0x hex, 0 octal and 0b binary. |
| min_width | the minimum number of characters to be printed including sign and prefix. Add padding if sign+prefix+val-digits are shorter. |
| separator | separator character for each decimal 3 or other radix 4. Defaults to 0 for no separator. |
| padding | padding character, defaults to '0'. See 'min_width' above. |
Definition at line 754 of file string_util.hpp.
|
noexcept |
Produces an integer string representation of an integral integer value with given radix.
[space][-][prefix][zeros_padding+sep][digits+sep]
| value_type | an unsigned integral integer type |
| v | the integral integer value |
| radix | base of the number system, supported: 2 binary, 8 octal, 10 decimal, 16 hexadecimal |
| capitalization | LoUpCase capitalization, default is LoUpCase::lower |
| prefix | pass PrefixOpt::prefix (default) to add leading prefix for radix. Prefixes: 0x hex, 0 octal and 0b binary. |
| min_width | the minimum number of characters to be printed including prefix. Add padding with padding if result is shorter. |
| separator | separator character for each decimal 3 or other radix 4. Defaults to 0 for no separator. |
| padding | padding character, defaults to '0'. See 'min_width' above. |
Definition at line 863 of file string_util.hpp.
|
constexpr |
Definition at line 880 of file string_util.hpp.
|
constexpr |
Definition at line 886 of file string_util.hpp.
|
inline |
Definition at line 894 of file string_util.hpp.
| std::string jau::to_string | ( | std::vector< T > const & | list, |
| const std::string & | delim ) |
Definition at line 1002 of file string_util.hpp.
| std::string jau::to_string | ( | std::vector< T > const & | list | ) |
Definition at line 1018 of file string_util.hpp.
| std::string jau::to_string | ( | std::vector< T > const & | list, |
| const std::string & | delim, | ||
| const nsize_t | radix ) |
Definition at line 1021 of file string_util.hpp.
| std::string jau::to_string | ( | std::vector< T > const & | list, |
| const nsize_t | radix ) |
Definition at line 1037 of file string_util.hpp.
|
noexcept |
Returns a (potentially truncated) string according to snprintf() formatting rules and variable number of arguments following the format argument while utilizing the unsafe vsnprintf.
This variant doesn't validate format against given arguments, see jau::format_string_n.
Resulting string is truncated to min(maxStrLen, formatLen), with formatLen being the given formatted string length of output w/o limitation.
| maxStrLen | maximum resulting string length |
| format | printf() compliant format string |
| args | optional arguments matching the format string |
Definition at line 590 of file basic_types.cpp.
|
noexcept |
|
noexcept |
Returns a (non-truncated) string according to snprintf() formatting rules and variable number of arguments following the format argument while utilizing the unsafe vsnprintf.
This variant doesn't validate format against given arguments, see jau::format_string_h.
Resulting string size matches formated output w/o limitation.
| strLenHint | initially used string length w/o EOS |
| format | printf() compliant format string |
| args | optional arguments matching the format string |
Definition at line 636 of file basic_types.cpp.
|
noexcept |
|
noexcept |
Returns a (non-truncated) string according to snprintf() formatting rules and variable number of arguments following the format argument while utilizing the unsafe vsnprintf.
This variant doesn't validate format against given arguments, see jau::format_string.
Resulting string size matches formated output w/o limitation.
| format | printf() compliant format string |
| args | optional arguments matching the format string |
Definition at line 644 of file basic_types.cpp.
|
noexcept |
|
inlineconstexpr |
Maximum net number string len w/o EOS, up to uint64_t.
Definition at line 206 of file string_cfmt.hpp.
|
inlineconstexpr |
Default string reserved capacity w/o EOS (511)
Definition at line 209 of file string_cfmt.hpp.
|
inlineconstexpr |
Definition at line 267 of file string_util.hpp.
|
inlineconstexpr |
Definition at line 268 of file string_util.hpp.