![]() |
Lumiera 0.pre.04
»edit your freedom«
|
#include "lib/format-string.hpp"
A front-end for using printf-style formatting.
Values to be formatted can be supplied through the operator%. Custom defined string conversions on objects will be used, any errors while invoking the format operation will be suppressed. The implementation is based on boost::format, but kept opaque to keep code size and compilation times down.
Definition at line 148 of file format-string.hpp.
Classes | |
| struct | Converter |
| helper to prepare parameters for inclusion More... | |
| struct | Converter< bool > |
| struct | Converter< CStr > |
| struct | Converter< lib::Literal > |
| struct | Converter< lib::Symbol > |
| struct | Converter< SP, lib::meta::enable_if< _shall_show_smartWrapper< SP > > > |
| struct | Converter< VAL * > |
| struct | Converter< VAL, lib::meta::enable_if< _shall_convert_toString< VAL > > > |
| some custom types explicitly provide a string representation More... | |
| struct | Converter< VAL, lib::meta::enable_if< _shall_format_directly< VAL > > > |
| some basic types are directly forwarded down to the implementation; More... | |
| struct | Converter< void * > |
Public Member Functions | |
| ~_Fmt () | |
| _Fmt (string formatString) | |
| Build a formatter object based on the given format string. | |
| operator string () const | |
| get the formatted result | |
| template<typename VAL > | |
| _Fmt & | operator% (VAL const &) |
The percent operator ('' ) is used do feed parameter values to be included into the formatted result, at the positions marked by printf-style placeholders within the format string. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, _Fmt const &) |
| send the formatted buffer directly to the output stream. | |
| bool | operator== (_Fmt const &, _Fmt const &) |
| bool | operator== (_Fmt const &, string const &) |
| bool | operator== (_Fmt const &, CStr const) |
| bool | operator== (string const &, _Fmt const &) |
| bool | operator== (CStr const, _Fmt const &) |
| template<typename X > | |
| bool | operator!= (_Fmt const &fmt, X const &x) |
| template<typename X > | |
| bool | operator!= (X const &x, _Fmt const &fmt) |
Private Types | |
| enum | { FORMATTER_SIZE = lib::meta::SizeTrait::BOOST_FORMAT } |
| size of an opaque implementation Buffer More... | |
| typedef std::byte | Implementation[FORMATTER_SIZE] |
Static Private Member Functions | |
| template<typename VAL > | |
| static void | format (const VAL, Implementation &) |
| call into the opaque implementation | |
Private Attributes | |
| Implementation | formatter_ |
Additional Inherited Members | |
Private Member Functions inherited from NonCopyable | |
| ~NonCopyable ()=default | |
| NonCopyable ()=default | |
| NonCopyable (NonCopyable const &)=delete | |
| NonCopyable & | operator= (NonCopyable const &)=delete |
| ~_Fmt | ( | ) |
Definition at line 133 of file format-string.cpp.
References _Fmt::formatter_.
| _Fmt | ( | string | formatString | ) |
Build a formatter object based on the given format string.
The actual implementation is delegated to an boost::format object, which is placement-constructed into an opaque buffer embedded into this object. Defining the necessary size for this buffer relies on implementation details of boost::format (and might break)
Definition at line 114 of file format-string.cpp.
References _Fmt::formatter_, and _Fmt::FORMATTER_SIZE.
|
private |
Definition at line 154 of file format-string.hpp.
|
private |
size of an opaque implementation Buffer
| Enumerator | |
|---|---|
| FORMATTER_SIZE | |
Definition at line 152 of file format-string.hpp.
|
staticprivate |
call into the opaque implementation
access point for the frontend, allowing to push a single parameter value down into the implementation for the actual formatting. Only selected primitive types are handled directly this way, while all custom conversions, the handling of pointers and the fallback (showing a type string) is done in the frontend.
Definition at line 154 of file format-string.cpp.
| operator string | ( | ) | const |
get the formatted result
Definition at line 213 of file format-string.cpp.
|
inline |
The percent operator ('' ) is used do feed parameter values to be included into the formatted result, at the positions marked by printf-style placeholders within the format string.
void*. Any other type gets just translated into a type-ID (using the mangled RTTI info). In case of errors during the conversion, a string representation of the error is returned | val | arbitrary value or pointer to be included into the result |
Definition at line 221 of file format-string.hpp.
References _Fmt::Converter< VAL, SEL >::dump(), and _Fmt::formatter_.
Here is the call graph for this function:
|
mutableprivate |
buffer to hold a boost::format
Definition at line 158 of file format-string.hpp.
Referenced by _Fmt::_Fmt(), _Fmt::~_Fmt(), and _Fmt::operator%().
|
friend |
send the formatted buffer directly to the output stream.
Definition at line 238 of file format-string.cpp.
Definition at line 464 of file format-string.hpp.
|
friend |
Definition at line 470 of file format-string.hpp.
Definition at line 476 of file format-string.hpp.
|
friend |
Definition at line 482 of file format-string.hpp.
Definition at line 488 of file format-string.hpp.
Definition at line 192 of file format-string.hpp.
Definition at line 194 of file format-string.hpp.
Inheritance diagram for _Fmt:
Collaboration diagram for _Fmt: