Pyrogenesis
trunk
|
This template provides operations for formatting and writing data into a character stream. More...
#include <format.h>
Public Member Functions | |
BasicWriter () | |
Constructs a BasicWriter object. More... | |
std::size_t | size () const |
Returns the total number of characters written. More... | |
const Char * | data () const |
Returns a pointer to the output buffer content. More... | |
const Char * | c_str () const |
Returns a pointer to the output buffer content with terminating null character appended. More... | |
std::basic_string< Char > | str () const |
Returns the content of the output buffer as an std::string . More... | |
void | write (BasicStringRef< Char > format, const ArgList &args) |
Writes formatted data. More... | |
BasicWriter & | operator<< (int value) |
BasicWriter & | operator<< (unsigned value) |
BasicWriter & | operator<< (long value) |
BasicWriter & | operator<< (unsigned long value) |
BasicWriter & | operator<< (LongLong value) |
BasicWriter & | operator<< (ULongLong value) |
Formats value and writes it to the stream. More... | |
BasicWriter & | operator<< (double value) |
BasicWriter & | operator<< (long double value) |
Formats value using the general format for floating-point numbers ('g' ) and writes it to the stream. More... | |
BasicWriter & | operator<< (char value) |
Writes a character to the stream. More... | |
BasicWriter & | operator<< (wchar_t value) |
BasicWriter & | operator<< (fmt::BasicStringRef< Char > value) |
Writes value to the stream. More... | |
template<typename T , typename Spec , typename FillChar > | |
BasicWriter & | operator<< (const IntFormatSpec< T, Spec, FillChar > &spec) |
template<typename StrChar > | |
BasicWriter & | operator<< (const StrFormatSpec< StrChar > &spec) |
void | clear () |
template<typename StrChar > | |
void | write_str (const Arg::StringValue< StrChar > &str, const FormatSpec &spec) |
template<typename Spec > | |
fmt::BasicWriter< Char >::CharPtr | prepare_int_buffer (unsigned num_digits, const Spec &spec, const char *prefix, unsigned prefix_size) |
Private Types | |
typedef internal::CharTraits< Char >::CharPtr | CharPtr |
Private Member Functions | |
CharPtr | grow_buffer (std::size_t n) |
CharPtr | prepare_int_buffer (unsigned num_digits, const EmptySpec &, const char *prefix, unsigned prefix_size) |
template<typename Spec > | |
CharPtr | prepare_int_buffer (unsigned num_digits, const Spec &spec, const char *prefix, unsigned prefix_size) |
template<typename T , typename Spec > | |
void | write_int (T value, const Spec &spec) |
template<typename T > | |
void | write_double (T value, const FormatSpec &spec) |
template<typename StrChar > | |
CharPtr | write_str (const StrChar *s, std::size_t size, const AlignSpec &spec) |
template<typename StrChar > | |
void | write_str (const internal::Arg::StringValue< StrChar > &str, const FormatSpec &spec) |
void | operator<< (typename internal::CharTraits< Char >::UnsupportedStrType) |
Static Private Member Functions | |
static Char * | get (Char *p) |
static CharPtr | fill_padding (CharPtr buffer, unsigned total_size, std::size_t content_size, wchar_t fill) |
Private Attributes | |
internal::Array< Char, internal::INLINE_BUFFER_SIZE > | buffer_ |
Friends | |
class | internal::ArgFormatter< Char > |
class | internal::PrintfFormatter< Char > |
This template provides operations for formatting and writing data into a character stream.
The output is stored in a memory buffer that grows dynamically.
You can use one of the following typedefs for common character types:
+------—+-------------------—+ | Type | Definition | +=========+======================+ | Writer | BasicWriter<char> | +------—+-------------------—+ | WWriter | BasicWriter<wchar_t> | +------—+-------------------—+
Example**::
Writer out; out << "The answer is " << 42 << "\n"; out.write("({:+f}, {:+f})", -3.14, 3.14);
This will write the following output to the out
object:
.. code-block:: none
The answer is 42 (-3.140000, +3.140000)
The output can be converted to an std::string
with out.str()
or accessed as a C string with out.c_str()
.
|
private |
|
inline |
Constructs a BasicWriter
object.
|
inline |
Returns a pointer to the output buffer content with terminating null character appended.
|
inline |
|
inline |
Returns a pointer to the output buffer content.
No terminating null character is appended.
|
staticprivate |
|
inlinestaticprivate |
|
inlineprivate |
|
private |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Formats value and writes it to the stream.
|
inline |
|
inline |
Formats value using the general format for floating-point numbers ('g'
) and writes it to the stream.
|
inline |
Writes a character to the stream.
|
inline |
|
inline |
Writes value to the stream.
|
inline |
|
inline |
|
inlineprivate |
|
private |
fmt::BasicWriter<Char>::CharPtr fmt::BasicWriter< Char >::prepare_int_buffer | ( | unsigned | num_digits, |
const Spec & | spec, | ||
const char * | prefix, | ||
unsigned | prefix_size | ||
) |
|
inline |
Returns the total number of characters written.
|
inline |
Returns the content of the output buffer as an std::string
.
|
inline |
Writes formatted data.
args* is an argument list representing arbitrary arguments.
Example**::
Writer out; out.write("Current point:\n"); out.write("({:+f}, {:+f})", -3.14, 3.14);
This will write the following output to the out
object:
.. code-block:: none
Current point: (-3.140000, +3.140000)
The output can be accessed using :meth:data
, :meth:c_str
or :meth:str
methods.
See also Format String Syntax
_.
|
private |
|
private |
void fmt::BasicWriter< Char >::write_str | ( | const Arg::StringValue< StrChar > & | str, |
const FormatSpec & | spec | ||
) |
|
private |
|
private |
|
friend |
|
friend |
|
mutableprivate |