98#ifndef UTIL_FORMAT_STRING_H
99#define UTIL_FORMAT_STRING_H
116 template<
typename C,
class _TRAITS>
119 using ostream = basic_ostream<char, char_traits<char>>;
162 template<
typename VAL>
166 template<
typename VAL,
class SEL =
void>
173 _Fmt (
string formatString);
175 operator string()
const;
177 template<
typename VAL>
219 template<
typename VAL>
267 : __and_<__not_<_shall_format_directly<X>>
268 , std::bool_constant<lib::meta::can_convertToString<X>::value>
273 template<
typename SP>
281 template <
typename T,
typename D>
288 template<
typename SP>
290 : __and_<__not_<_shall_convert_toString<SP>>
291 ,_is_smart_wrapper<std::remove_reference_t<std::remove_cv_t<SP>>>
303 TRACE_IF (errID, progress,
"Lumiera errorstate '%s' cleared.", errID);
310 WARN (progress,
"Error while invoking custom string conversion: %s", ex.what());
312 return string(
"<string conversion failed: ")+ex.what()+
">";
315 return "(formatting failure)";
323 ERROR (progress,
"Unknown error while invoking custom string conversion. Lumiera error flag = %s", errID);
325 ERROR (progress,
"Unknown error while invoking custom string conversion. No Lumiera error flag set.");
326 return "<Unknown error in string conversion>";
337 template<
typename VAL,
class SEL>
343 format (
"«"+typeStr<VAL>()+
"»", impl);
347 template<
typename VAL>
351 dump (
const VAL *pVal, Implementation& impl)
356 format (BOTTOM_INDICATOR, impl);
364 dump (
const void* address, Implementation& impl)
366 format (address, impl);
376 format (cString? cString : BOTTOM_INDICATOR, impl);
386 format (yes?
"true":
"false", impl);
396 format (literal.
empty()?
"" : literal.
c(), impl);
406 format (symbol.
c(), impl);
411 template<
typename VAL>
417 format (
string(val), impl);
419 catch(std::exception
const& ex)
421 format (_log_and_stringify(ex), impl);
425 format (_log_unknown_exception(), impl);
429 template<
typename SP>
437 catch(std::exception
const& ex)
439 format (_log_and_stringify(ex), impl);
443 format (_log_unknown_exception(), impl);
449 template<
typename VAL>
466 return string(left) == string(right);
472 return string(fmt) == str;
478 return string(fmt) == string(cString);
490 return fmt == cString;
constexpr const char * c() const
constexpr bool empty() const
Token or Atom with distinct identity.
Any copy and copy construction prohibited.
A front-end for using printf-style formatting.
std::byte Implementation[FORMATTER_SIZE]
friend bool operator!=(_Fmt const &fmt, X const &x)
friend std::ostream & operator<<(std::ostream &os, _Fmt const &)
send the formatted buffer directly to the output stream.
Implementation formatter_
static void format(const VAL, Implementation &)
call into the opaque implementation
friend bool operator==(_Fmt const &, _Fmt const &)
_Fmt & operator%(VAL const &)
The percent operator ('' ) is used do feed parameter values to be included into the formatted result,...
lumiera_err lumiera_error(void)
Get and clear current error state.
#define LUMIERA_ERROR_DECLARE(err)
Forward declare an error constant.
Lumiera error handling (C++ interface).
Implementation namespace for support and library code.
basic_ostream< char, char_traits< char > > ostream
std::string showSmartPtr(SP const &smPtr, std::string label="smP")
bool operator==(_Fmt const &left, _Fmt const &right)
Mix-Ins to allow or prohibit various degrees of copying and cloning.
Metaprogramming definitions to deal with dependency on implementation size and layout.
static void dump(CStr cString, Implementation &impl)
static void dump(const VAL *pVal, Implementation &impl)
static void dump(bool yes, Implementation &impl)
static void dump(lib::Literal const &literal, Implementation &impl)
static void dump(lib::Symbol const &symbol, Implementation &impl)
static void dump(const void *address, Implementation &impl)
helper to prepare parameters for inclusion
static void dump(VAL const &, Implementation &impl)
Marker types to indicate a literal string and a Symbol.