|
jaulib v1.4.1-17-gd77ace3-dirty
Jau Support Library (C++, Java, ..)
|
Author: Sven Gothel sgoth.nosp@m.el@j.nosp@m.ausof.nosp@m.t.co.nosp@m.m Copyright (c) 2021-2026 Gothel Software e.K. More...
Namespaces | |
| namespace | impl |
Classes | |
| struct | FormatOpts |
| class | Result |
Enumerations | |
| enum class | cspec_t : uint16_t { cspec_t::none , cspec_t::character , cspec_t::string , cspec_t::pointer , cspec_t::signed_int , cspec_t::unsigned_int , cspec_t::floating_point , cspec_t::exp_float , cspec_t::alt_float , cspec_t::hex_float } |
| Format conversion specifier (fully defined w/ radix) More... | |
| enum class | flags_t : uint16_t { flags_t::none = 0 , flags_t::hash = (uint16_t)1 << 1 , flags_t::zeropad = (uint16_t)1 << 2 , flags_t::left = (uint16_t)1 << 3 , flags_t::space = (uint16_t)1 << 4 , flags_t::plus = (uint16_t)1 << 5 , flags_t::thousands = (uint16_t)1 << 6 , flags_t::uppercase = (uint16_t)1 << 8 } |
| Format flags. More... | |
| enum class | plength_t : uint16_t { plength_t::none , plength_t::hh , plength_t::h , plength_t::l , plength_t::ll , plength_t::L , plength_t::j , plength_t::z , plength_t::t } |
| Format length modifiers. More... | |
| enum class | pstate_t : uint16_t { pstate_t::error , pstate_t::outside , pstate_t::start , pstate_t::field_width , pstate_t::precision } |
Functions | |
| template<typename... Targs> | |
| consteval_cxx20 ssize_t | 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 | 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 | 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 | 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 | 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 | checkR2 (std::string_view format) noexcept |
| Strict compile-time type validation of explicit argument-types against the format string. | |
| template<typename... Targs> | |
| std::string | 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 | format (std::string_view fmt, const Targs &...args) noexcept |
| Strict format with type validation of arguments against the format string. | |
| template<typename... Targs> | |
| Result | 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 | 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 | 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 | 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. | |
| JAU_MAKE_BITFIELD_ENUM_STRING (flags_t, hash, zeropad, left, space, plus, thousands, uppercase) | |
| JAU_MAKE_ENUM_STRING (cspec_t, character, string, pointer, signed_int, unsigned_int, floating_point, exp_float, alt_float, hex_float) | |
| JAU_MAKE_ENUM_STRING (plength_t, hh, h, l, ll, L, j, z, t) | |
| std::ostream & | operator<< (std::ostream &out, const FormatOpts &o) |
| std::ostream & | operator<< (std::ostream &out, const Result &pc) |
| static constexpr const char * | to_string (pstate_t s) noexcept |
Variables | |
| constexpr const size_t | default_string_capacity = 511 |
| Default string reserved capacity w/o EOS (511) | |
| constexpr const size_t | num_max_slen = 31 |
| Maximum net number string len w/o EOS, up to uint64_t. | |
Author: Sven Gothel sgoth.nosp@m.el@j.nosp@m.ausof.nosp@m.t.co.nosp@m.m Copyright (c) 2021-2026 Gothel Software e.K.
SPDX-License-Identifier: MIT
This Source Code Form is subject to the terms of the MIT License If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/license/mit/.
consteval capable constexpr implementationstatic_assert expressions within your IDEjau_string_check(fmt, ...) macro utilizing jau::cfmt::check2 The macro resolves the passed arguments types via decltype to be utilized for jau::cfmt::check2 jau::format_string jau_format_string macro (the actual goal) Implementation follows type conversion rules as described in Variadic Default Conversion
uint64, const char* const, std::string_view, reducing code footprintnullptr conversion value similar to glibc(null)(nil)enum types for integer conversion.unsigned, it can't be used for signed integer conversion (see above)s string arguments<E#1@1234:Cnv> where the 1st argument caused a conversion error (Cnv) as detected in string_cfmt.hpp like 1234.Len tags a length modifier errorCnv tags a conversion error%[flags][width][.precision][length modifier]conversion
The following flags are supported
#: hash, C99. Adds leading prefix for radix != 10.0: zeropad, C99-: left, C99 : space, C99+: plus, C99': thousands, POSIX,: thousands, OpenJDK (alias for Java users)Width and precision also supports * to use the next argument for its value.
However, *m$ (decimal integer m) for the m-th argument is not yet supported.
The following length modifiers are supported
hh [unsigned] char, ignored for floating pointh [unsigned] short, ignored for floating pointl [unsigned] long, ignored for floating pointll [unsigned] long longq deprecated synonym for llL long doublej uintmax_t or intmax_tz size_t or ssize_tZ deprecated synonym for zt ptrdiff_tThe following standard conversion specifiers are supported:
c characters stringp pointerd signed integral or io octal unsignedx X hexadecimal unsigned low and capital charsb binary unsigned presentation (extension)u decimal unsignedf or F double floating pointe, E exponential low- and capital Eg, G alternate exponential low- and capital Ea, A hexadecimal low- and capital charsi -> dF -> fb bitpattern of unsigned integral w/ prefix 0b (if # flag is added)To the project A printf / sprintf Implementation for Embedded Systems worked on by Marco Paland and many others. I have used their test_suite.cpp code within our unit test test_stringfmt_format.cpp and also utilized their floating point parsing within append_float and append_efloat.