Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class template basic_record_ostream

boost::log::basic_record_ostream — Logging record adapter with a streaming capability.

Synopsis

// In header: <boost/log/sources/record_ostream.hpp>

template<typename CharT> 
class basic_record_ostream : public basic_formatting_ostream< CharT > {
public:
  // types
  typedef CharT                           char_type;    // Character type. 
  typedef std::basic_string< char_type >  string_type;  // String type to be used as a message text holder. 
  typedef std::basic_ostream< char_type > stream_type;  // Stream type. 

  // construct/copy/destruct
  basic_record_ostream();
  explicit basic_record_ostream(record &);
  basic_record_ostream(basic_record_ostream const &) = delete;
  basic_record_ostream& operator=(basic_record_ostream const &) = delete;
  ~basic_record_ostream();

  // public member functions
  bool operator!() const;
  record & get_record();
  record const & get_record() const;
  void attach_record(record &);
  void detach_from_record();

  // private member functions
  void init_stream();
};

Description

This class allows to compose the logging record message by streaming operations. It aggregates the log record and provides the standard output stream interface.

basic_record_ostream public construct/copy/destruct

  1. basic_record_ostream();

    Default constructor. Creates an empty record that is equivalent to the invalid record handle. The stream capability is not available after construction.

    Postconditions:

    !*this == true

  2. explicit basic_record_ostream(record & rec);

    Constructor from a record object. Attaches to the provided record.

    Parameters:

    rec

    The record handle being attached to

    Requires:

    !!rec == true

    Postconditions:

    &this->get_record() == &rec

  3. basic_record_ostream(basic_record_ostream const &) = delete;
  4. basic_record_ostream& operator=(basic_record_ostream const &) = delete;
  5. ~basic_record_ostream();

    Destructor. Destroys the record, releases any sinks and attribute values that were involved in processing this record.

basic_record_ostream public member functions

  1. bool operator!() const;

    Conversion to an unspecified boolean type

    Inverted conversion to an unspecified boolean type

    Returns:

    true, if stream is valid and ready for formatting, false, if the stream is not valid. The latter also applies to the case when the stream is not attached to a log record.

    Returns:

    false, if stream is valid and ready for formatting, true, if the stream is not valid. The latter also applies to the case when the stream is not attached to a log record.

  2. record & get_record();

    Flushes internal buffers to complete all pending formatting operations and returns the aggregated log record

    Returns:

    The aggregated record object

  3. record const & get_record() const;

    Flushes internal buffers to complete all pending formatting operations and returns the aggregated log record

    Returns:

    The aggregated record object

  4. void attach_record(record & rec);

    If the stream is attached to a log record, flushes internal buffers to complete all pending formatting operations. Then reattaches the stream to another log record.

    Parameters:

    rec

    New log record to attach to

  5. void detach_from_record();
    The function resets the stream into a detached (default initialized) state.

basic_record_ostream private member functions

  1. void init_stream();
    The function initializes the stream and the stream buffer.

PrevUpHomeNext