Chris@16: /* Chris@101: * Copyright Andrey Semashev 2007 - 2015. Chris@16: * Distributed under the Boost Software License, Version 1.0. Chris@16: * (See accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: */ Chris@16: /*! Chris@16: * \file to_log.hpp Chris@16: * \author Andrey Semashev Chris@16: * \date 06.11.2012 Chris@16: * Chris@16: * This header contains the \c to_log output manipulator. Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_LOG_UTILITY_MANIPULATORS_TO_LOG_HPP_INCLUDED_ Chris@16: #define BOOST_LOG_UTILITY_MANIPULATORS_TO_LOG_HPP_INCLUDED_ Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #ifdef BOOST_HAS_PRAGMA_ONCE Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: BOOST_LOG_OPEN_NAMESPACE Chris@16: Chris@16: /*! Chris@16: * \brief Generic manipulator for customizing output to log Chris@16: */ Chris@16: template< typename T, typename TagT = void > Chris@16: class to_log_manip Chris@16: { Chris@16: public: Chris@16: //! Output value type Chris@16: typedef T value_type; Chris@16: //! Value tag type Chris@16: typedef TagT tag_type; Chris@16: Chris@16: private: Chris@16: //! Reference to the value Chris@16: value_type const& m_value; Chris@16: Chris@16: public: Chris@16: explicit to_log_manip(value_type const& value) : m_value(value) {} Chris@16: to_log_manip(to_log_manip const& that) : m_value(that.m_value) {} Chris@16: Chris@16: value_type const& get() const { return m_value; } Chris@16: }; Chris@16: Chris@16: template< typename CharT, typename TraitsT, typename T, typename TagT > Chris@16: inline std::basic_ostream< CharT, TraitsT >& operator<< (std::basic_ostream< CharT, TraitsT >& strm, to_log_manip< T, TagT > manip) Chris@16: { Chris@16: strm << manip.get(); Chris@16: return strm; Chris@16: } Chris@16: Chris@16: template< typename CharT, typename TraitsT, typename AllocatorT, typename T, typename TagT > Chris@16: inline basic_formatting_ostream< CharT, TraitsT, AllocatorT >& operator<< (basic_formatting_ostream< CharT, TraitsT, AllocatorT >& strm, to_log_manip< T, TagT > manip) Chris@16: { Chris@16: strm << manip.get(); Chris@16: return strm; Chris@16: } Chris@16: Chris@16: template< typename T > Chris@16: inline to_log_manip< T > to_log(T const& value) Chris@16: { Chris@16: return to_log_manip< T >(value); Chris@16: } Chris@16: Chris@16: template< typename TagT, typename T > Chris@16: inline to_log_manip< T, TagT > to_log(T const& value) Chris@16: { Chris@16: return to_log_manip< T, TagT >(value); Chris@16: } Chris@16: Chris@16: BOOST_LOG_CLOSE_NAMESPACE // namespace log Chris@16: Chris@16: } // namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif // BOOST_LOG_UTILITY_MANIPULATORS_TO_LOG_HPP_INCLUDED_