Boost C++ Libraries

PrevUpHomeNext

Class template fmt_char_decorator

boost::log::formatters::fmt_char_decorator

Synopsis

// In header: <boost/log/formatters/char_decorator.hpp>

template<typename FormatterT> 
class fmt_char_decorator : public basic_formatter< FormatterT::char_type, fmt_char_decorator< FormatterT > >
{
public:
  // types
  typedef base_type::char_type    char_type;       // Character type. 
  typedef FormatterT              formatter_type;  // Decorated formatter type. 
  typedef base_type::string_type  string_type;     // String type. 
  typedef base_type::ostream_type ostream_type;    // Stream type. 
  typedef base_type::record_type  record_type;     // Log record type. 

  // construct/copy/destruct
  template<typename RangeT> 
    fmt_char_decorator(formatter_type const &, RangeT const &);
  template<typename RangeT1, typename RangeT2> 
    fmt_char_decorator(formatter_type const &, RangeT1 const &, 
                       RangeT2 const &);
  fmt_char_decorator(fmt_char_decorator const &);
  fmt_char_decorator& operator=(fmt_char_decorator const &);

  // public member functions
  void operator()(ostream_type &, record_type const &) const;
};

Description

Character decorator class. This formatter allows to modify strings generated by other formatters on character level. The most obvious application of decorators is replacing a certain set of characters with decorated equivalents to satisfy requirements of text-based sinks.

The fmt_char_decorator class aggregates the formatter being decorated, and a set of string pairs that are used as decorations. All decorations are applied sequentially. The fmt_char_decorator class is a formatter itself, so it can be used to construct more complex formatters, including nesting decorators.

fmt_char_decorator public construct/copy/destruct

  1. template<typename RangeT> 
      fmt_char_decorator(formatter_type const & fmt, RangeT const & decorations);

    Initializing constructor. Creates decorator of the fmt formatter with the specified decorations.

  2. template<typename RangeT1, typename RangeT2> 
      fmt_char_decorator(formatter_type const & fmt, RangeT1 const & from, 
                         RangeT2 const & to);

    Initializing constructor. Creates decorator of the fmt formatter with decorations specified in form of two same-sized string sequences. Each i'th decoration will be from[i] -> to[i].

  3. fmt_char_decorator(fmt_char_decorator const & that);

    Copy constructor

  4. fmt_char_decorator& operator=(fmt_char_decorator const & that);
    Assignment prohibited.

fmt_char_decorator public member functions

  1. void operator()(ostream_type & strm, record_type const & record) const;

    Formatting operator. Invokes the decorated formatter, then sequentially applies all decorations to the output. The resulting string is the output of the decorator.

    Parameters:
    record

    A logging record

    strm

    A reference to the stream, where the final text of the logging record is composed


PrevUpHomeNext