Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:27

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   to_log.hpp
0009  * \author Andrey Semashev
0010  * \date   06.11.2012
0011  *
0012  * This header contains the \c to_log output manipulator.
0013  */
0014 
0015 #ifndef BOOST_LOG_UTILITY_MANIPULATORS_TO_LOG_HPP_INCLUDED_
0016 #define BOOST_LOG_UTILITY_MANIPULATORS_TO_LOG_HPP_INCLUDED_
0017 
0018 #include <iosfwd>
0019 #include <boost/core/enable_if.hpp>
0020 #include <boost/log/detail/config.hpp>
0021 #include <boost/log/detail/is_ostream.hpp>
0022 #include <boost/log/utility/formatting_ostream_fwd.hpp>
0023 #include <boost/log/detail/header.hpp>
0024 
0025 #ifdef BOOST_HAS_PRAGMA_ONCE
0026 #pragma once
0027 #endif
0028 
0029 namespace boost {
0030 
0031 BOOST_LOG_OPEN_NAMESPACE
0032 
0033 /*!
0034  * \brief Generic manipulator for customizing output to log
0035  */
0036 template< typename T, typename TagT = void >
0037 class to_log_manip
0038 {
0039 public:
0040     //! Output value type
0041     typedef T value_type;
0042     //! Value tag type
0043     typedef TagT tag_type;
0044 
0045 private:
0046     //! Reference to the value
0047     value_type const& m_value;
0048 
0049 public:
0050     explicit to_log_manip(value_type const& value) BOOST_NOEXCEPT : m_value(value) {}
0051     to_log_manip(to_log_manip const& that) BOOST_NOEXCEPT : m_value(that.m_value) {}
0052 
0053     value_type const& get() const BOOST_NOEXCEPT { return m_value; }
0054 };
0055 
0056 template< typename StreamT, typename T, typename TagT >
0057 inline typename enable_if_c< log::aux::is_ostream< StreamT >::value, StreamT& >::type operator<< (StreamT& strm, to_log_manip< T, TagT > manip)
0058 {
0059     strm << manip.get();
0060     return strm;
0061 }
0062 
0063 template< typename T >
0064 inline to_log_manip< T > to_log(T const& value) BOOST_NOEXCEPT
0065 {
0066     return to_log_manip< T >(value);
0067 }
0068 
0069 template< typename TagT, typename T >
0070 inline to_log_manip< T, TagT > to_log(T const& value) BOOST_NOEXCEPT
0071 {
0072     return to_log_manip< T, TagT >(value);
0073 }
0074 
0075 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0076 
0077 } // namespace boost
0078 
0079 #include <boost/log/detail/footer.hpp>
0080 
0081 #endif // BOOST_LOG_UTILITY_MANIPULATORS_TO_LOG_HPP_INCLUDED_