Pyrogenesis  trunk
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
fmt::BasicWriter< Char > Class Template Reference

This template provides operations for formatting and writing data into a character stream. More...

#include <format.h>

Collaboration diagram for fmt::BasicWriter< Char >:
Collaboration graph
[legend]

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...
 
BasicWriteroperator<< (int value)
 
BasicWriteroperator<< (unsigned value)
 
BasicWriteroperator<< (long value)
 
BasicWriteroperator<< (unsigned long value)
 
BasicWriteroperator<< (LongLong value)
 
BasicWriteroperator<< (ULongLong value)
 Formats value and writes it to the stream. More...
 
BasicWriteroperator<< (double value)
 
BasicWriteroperator<< (long double value)
 Formats value using the general format for floating-point numbers ('g') and writes it to the stream. More...
 
BasicWriteroperator<< (char value)
 Writes a character to the stream. More...
 
BasicWriteroperator<< (wchar_t value)
 
BasicWriteroperator<< (fmt::BasicStringRef< Char > value)
 Writes value to the stream. More...
 
template<typename T , typename Spec , typename FillChar >
BasicWriteroperator<< (const IntFormatSpec< T, Spec, FillChar > &spec)
 
template<typename StrChar >
BasicWriteroperator<< (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_SIZEbuffer_
 

Friends

class internal::ArgFormatter< Char >
 
class internal::PrintfFormatter< Char >
 

Detailed Description

template<typename Char>
class fmt::BasicWriter< 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().

Member Typedef Documentation

template<typename Char>
typedef internal::CharTraits<Char>::CharPtr fmt::BasicWriter< Char >::CharPtr
private

Constructor & Destructor Documentation

template<typename Char>
fmt::BasicWriter< Char >::BasicWriter ( )
inline

Constructs a BasicWriter object.

Member Function Documentation

template<typename Char>
const Char* fmt::BasicWriter< Char >::c_str ( ) const
inline

Returns a pointer to the output buffer content with terminating null character appended.

template<typename Char>
void fmt::BasicWriter< Char >::clear ( )
inline
template<typename Char>
const Char* fmt::BasicWriter< Char >::data ( ) const
inline

Returns a pointer to the output buffer content.

No terminating null character is appended.

template<typename Char >
template fmt::BasicWriter< wchar_t >::CharPtr fmt::BasicWriter< Char >::fill_padding ( CharPtr  buffer,
unsigned  total_size,
std::size_t  content_size,
wchar_t  fill 
)
staticprivate
template<typename Char>
static Char* fmt::BasicWriter< Char >::get ( Char *  p)
inlinestaticprivate
template<typename Char>
CharPtr fmt::BasicWriter< Char >::grow_buffer ( std::size_t  n)
inlineprivate
template<typename Char>
void fmt::BasicWriter< Char >::operator<< ( typename internal::CharTraits< Char >::UnsupportedStrType  )
private
template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( int  value)
inline
template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( unsigned  value)
inline
template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( long  value)
inline
template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( unsigned long  value)
inline
template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( LongLong  value)
inline
template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( ULongLong  value)
inline

Formats value and writes it to the stream.

template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( double  value)
inline
template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( long double  value)
inline

Formats value using the general format for floating-point numbers ('g') and writes it to the stream.

template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( char  value)
inline

Writes a character to the stream.

template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( wchar_t  value)
inline
template<typename Char>
BasicWriter& fmt::BasicWriter< Char >::operator<< ( fmt::BasicStringRef< Char >  value)
inline

Writes value to the stream.

template<typename Char>
template<typename T , typename Spec , typename FillChar >
BasicWriter& fmt::BasicWriter< Char >::operator<< ( const IntFormatSpec< T, Spec, FillChar > &  spec)
inline
template<typename Char>
template<typename StrChar >
BasicWriter& fmt::BasicWriter< Char >::operator<< ( const StrFormatSpec< StrChar > &  spec)
inline
template<typename Char>
CharPtr fmt::BasicWriter< Char >::prepare_int_buffer ( unsigned  num_digits,
const EmptySpec ,
const char *  prefix,
unsigned  prefix_size 
)
inlineprivate
template<typename Char>
template<typename Spec >
CharPtr fmt::BasicWriter< Char >::prepare_int_buffer ( unsigned  num_digits,
const Spec &  spec,
const char *  prefix,
unsigned  prefix_size 
)
private
template<typename Char>
template<typename Spec >
fmt::BasicWriter<Char>::CharPtr fmt::BasicWriter< Char >::prepare_int_buffer ( unsigned  num_digits,
const Spec &  spec,
const char *  prefix,
unsigned  prefix_size 
)
template<typename Char>
std::size_t fmt::BasicWriter< Char >::size ( ) const
inline

Returns the total number of characters written.

template<typename Char>
std::basic_string<Char> fmt::BasicWriter< Char >::str ( ) const
inline

Returns the content of the output buffer as an std::string.

template<typename Char>
void fmt::BasicWriter< Char >::write ( BasicStringRef< Char >  format,
const ArgList args 
)
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_.

template<typename Char >
template<typename T >
void fmt::BasicWriter< Char >::write_double ( T  value,
const FormatSpec spec 
)
private
template<typename Char >
template<typename T , typename Spec >
void fmt::BasicWriter< Char >::write_int ( T  value,
const Spec &  spec 
)
private
template<typename Char>
template<typename StrChar >
void fmt::BasicWriter< Char >::write_str ( const Arg::StringValue< StrChar > &  str,
const FormatSpec spec 
)
template<typename Char >
template<typename StrChar >
BasicWriter< Char >::CharPtr fmt::BasicWriter< Char >::write_str ( const StrChar *  s,
std::size_t  size,
const AlignSpec spec 
)
private
template<typename Char>
template<typename StrChar >
void fmt::BasicWriter< Char >::write_str ( const internal::Arg::StringValue< StrChar > &  str,
const FormatSpec spec 
)
private

Friends And Related Function Documentation

template<typename Char>
friend class internal::ArgFormatter< Char >
friend
template<typename Char>
friend class internal::PrintfFormatter< Char >
friend

Member Data Documentation

template<typename Char>
internal::Array<Char, internal::INLINE_BUFFER_SIZE> fmt::BasicWriter< Char >::buffer_
mutableprivate

The documentation for this class was generated from the following files: