Gamp v0.0.7-67-g7798ac4
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
string_cfmt.hpp File Reference
#include <sys/types.h>
#include <cassert>
#include <cerrno>
#include <concepts>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <limits>
#include <ostream>
#include <string>
#include <string_view>
#include <type_traits>
#include <iostream>
#include <jau/base_math.hpp>
#include <jau/byte_util.hpp>
#include <jau/cpp_lang_util.hpp>
#include <jau/int_math.hpp>
#include <jau/int_types.hpp>
#include <jau/exceptions.hpp>
#include <jau/float_types.hpp>
#include <jau/packed_attribute.hpp>
#include <jau/type_traits_queries.hpp>
#include <jau/type_concepts.hpp>
#include <jau/string_util.hpp>
#include <jau/cpp_pragma.hpp>
#include <jau/enum_util.hpp>
Include dependency graph for string_cfmt.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  jau::cfmt::Config
 Global jau::cfmt configuration. More...
 
struct  jau::cfmt::FormatOpts
 
class  jau::cfmt::Result
 

Namespaces

namespace  jau
 __pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
 
namespace  jau::cfmt
 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.
 

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.
 

Enumerations

enum class  jau::cfmt::cspec_t : uint16_t {
  jau::cfmt::cspec_t::none , jau::cfmt::cspec_t::character , jau::cfmt::cspec_t::string , jau::cfmt::cspec_t::pointer ,
  jau::cfmt::cspec_t::signed_int , jau::cfmt::cspec_t::unsigned_int , jau::cfmt::cspec_t::floating_point , jau::cfmt::cspec_t::exp_float ,
  jau::cfmt::cspec_t::alt_float , jau::cfmt::cspec_t::hex_float
}
 Format conversion specifier (fully defined w/ radix) More...
 
enum class  jau::cfmt::flags_t : uint16_t {
  jau::cfmt::flags_t::none = 0 , jau::cfmt::flags_t::hash = (uint16_t)1 << 1 , jau::cfmt::flags_t::zeropad = (uint16_t)1 << 2 , jau::cfmt::flags_t::left = (uint16_t)1 << 3 ,
  jau::cfmt::flags_t::space = (uint16_t)1 << 4 , jau::cfmt::flags_t::plus = (uint16_t)1 << 5 , jau::cfmt::flags_t::thousands = (uint16_t)1 << 6 , jau::cfmt::flags_t::uppercase = (uint16_t)1 << 8
}
 Format flags. More...
 
enum class  jau::cfmt::plength_t : uint16_t {
  jau::cfmt::plength_t::none , jau::cfmt::plength_t::hh , jau::cfmt::plength_t::h , jau::cfmt::plength_t::l ,
  jau::cfmt::plength_t::ll , jau::cfmt::plength_t::L , jau::cfmt::plength_t::j , jau::cfmt::plength_t::z ,
  jau::cfmt::plength_t::t
}
 Format length modifiers. More...
 
enum class  jau::cfmt::pstate_t : uint16_t {
  jau::cfmt::pstate_t::error , jau::cfmt::pstate_t::outside , jau::cfmt::pstate_t::start , jau::cfmt::pstate_t::field_width ,
  jau::cfmt::pstate_t::precision
}
 

Functions

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.
 
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.
 
template<typename... Args>
std::string jau::format_string (std::string_view fmt, const Args &...args) noexcept
 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.
 
template<typename... Args>
std::string jau::format_string_h (const std::size_t strLenHint, std::string_view fmt, const Args &...args) noexcept
 Safely returns a (non-truncated) string according to snprintf() formatting rules and variable number of arguments following the fmt argument.
 
template<typename... Args>
std::string jau::format_string_hn (const std::size_t strLenHint, const std::size_t maxLen, std::string_view fmt, const Args &...args) noexcept
 Safely returns a (potentially truncated) string according to snprintf() formatting rules and variable number of arguments following the fmt argument.
 
template<typename... Args>
std::string jau::format_string_n (const std::size_t maxLen, std::string_view fmt, const Args &...args) noexcept
 Safely returns a (potentially truncated) string according to snprintf() formatting rules and variable number of arguments following the fmt argument.
 
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.
 
 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)
 
std::ostream & jau::cfmt::operator<< (std::ostream &out, const FormatOpts &o)
 
std::ostream & jau::cfmt::operator<< (std::ostream &out, const Result &pc)
 
static constexpr const char * jau::cfmt::to_string (pstate_t s) noexcept
 

Variables

constexpr const size_t jau::cfmt::default_string_capacity = 511
 Default string reserved capacity w/o EOS (511)
 
constexpr const size_t jau::cfmt::num_max_slen = 31
 Maximum net number string len w/o EOS, up to uint64_t.