annotate DEPENDENCIES/generic/include/boost/log/expressions/formatters/format.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@101 2 * Copyright Andrey Semashev 2007 - 2015.
Chris@16 3 * Distributed under the Boost Software License, Version 1.0.
Chris@16 4 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7 /*!
Chris@16 8 * \file formatters/format.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 15.11.2012
Chris@16 11 *
Chris@16 12 * The header contains a generic log record formatter function.
Chris@16 13 */
Chris@16 14
Chris@16 15 #ifndef BOOST_LOG_EXPRESSIONS_FORMATTERS_FORMAT_HPP_INCLUDED_
Chris@16 16 #define BOOST_LOG_EXPRESSIONS_FORMATTERS_FORMAT_HPP_INCLUDED_
Chris@16 17
Chris@16 18 #include <string>
Chris@16 19 #include <boost/mpl/bool.hpp>
Chris@16 20 #include <boost/phoenix/core/actor.hpp>
Chris@16 21 #include <boost/phoenix/core/terminal_fwd.hpp>
Chris@16 22 #include <boost/phoenix/core/is_nullary.hpp>
Chris@16 23 #include <boost/phoenix/core/environment.hpp>
Chris@16 24 #include <boost/fusion/sequence/intrinsic/at_c.hpp>
Chris@16 25 #include <boost/log/detail/config.hpp>
Chris@16 26 #include <boost/log/detail/format.hpp>
Chris@16 27 #include <boost/log/detail/custom_terminal_spec.hpp>
Chris@16 28 #include <boost/log/detail/header.hpp>
Chris@16 29
Chris@16 30 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 31 #pragma once
Chris@16 32 #endif
Chris@16 33
Chris@16 34 namespace boost {
Chris@16 35
Chris@16 36 BOOST_LOG_OPEN_NAMESPACE
Chris@16 37
Chris@16 38 namespace expressions {
Chris@16 39
Chris@16 40 /*!
Chris@16 41 * \brief Template expressions terminal node with Boost.Format-like formatter
Chris@16 42 */
Chris@16 43 template< typename CharT >
Chris@16 44 class format_terminal
Chris@16 45 {
Chris@16 46 public:
Chris@16 47 //! Internal typedef for type categorization
Chris@16 48 typedef void _is_boost_log_terminal;
Chris@16 49
Chris@16 50 //! Character type
Chris@16 51 typedef CharT char_type;
Chris@16 52 //! Boost.Format formatter type
Chris@16 53 typedef boost::log::aux::basic_format< char_type > format_type;
Chris@16 54 //! String type
Chris@16 55 typedef std::basic_string< char_type > string_type;
Chris@16 56
Chris@16 57 //! Terminal result type
Chris@16 58 typedef typename format_type::pump result_type;
Chris@16 59
Chris@16 60 private:
Chris@16 61 //! Formatter object
Chris@16 62 mutable format_type m_format;
Chris@16 63
Chris@16 64 public:
Chris@16 65 //! Initializing constructor
Chris@16 66 explicit format_terminal(const char_type* format) : m_format(format) {}
Chris@16 67
Chris@16 68 //! Invokation operator
Chris@16 69 template< typename ContextT >
Chris@16 70 result_type operator() (ContextT const& ctx) const
Chris@16 71 {
Chris@16 72 return m_format.make_pump(fusion::at_c< 1 >(phoenix::env(ctx).args()));
Chris@16 73 }
Chris@16 74
Chris@16 75 BOOST_DELETED_FUNCTION(format_terminal())
Chris@16 76 };
Chris@16 77
Chris@16 78 /*!
Chris@16 79 * The function generates a terminal node in a template expression. The node will perform log record formatting
Chris@16 80 * according to the provided format string.
Chris@16 81 */
Chris@16 82 template< typename CharT >
Chris@16 83 BOOST_FORCEINLINE phoenix::actor< format_terminal< CharT > > format(const CharT* fmt)
Chris@16 84 {
Chris@16 85 typedef format_terminal< CharT > terminal_type;
Chris@16 86 phoenix::actor< terminal_type > act = {{ terminal_type(fmt) }};
Chris@16 87 return act;
Chris@16 88 }
Chris@16 89
Chris@16 90 /*!
Chris@16 91 * The function generates a terminal node in a template expression. The node will perform log record formatting
Chris@16 92 * according to the provided format string.
Chris@16 93 */
Chris@16 94 template< typename CharT, typename TraitsT, typename AllocatorT >
Chris@16 95 BOOST_FORCEINLINE phoenix::actor< format_terminal< CharT > > format(std::basic_string< CharT, TraitsT, AllocatorT > const& fmt)
Chris@16 96 {
Chris@16 97 typedef format_terminal< CharT > terminal_type;
Chris@16 98 phoenix::actor< terminal_type > act = {{ terminal_type(fmt.c_str()) }};
Chris@16 99 return act;
Chris@16 100 }
Chris@16 101
Chris@16 102 } // namespace expressions
Chris@16 103
Chris@16 104 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 105
Chris@16 106 #ifndef BOOST_LOG_DOXYGEN_PASS
Chris@16 107
Chris@16 108 namespace phoenix {
Chris@16 109
Chris@16 110 namespace result_of {
Chris@16 111
Chris@16 112 template< typename CharT >
Chris@16 113 struct is_nullary< custom_terminal< boost::log::expressions::format_terminal< CharT > > > :
Chris@16 114 public mpl::false_
Chris@16 115 {
Chris@16 116 };
Chris@16 117
Chris@16 118 } // namespace result_of
Chris@16 119
Chris@16 120 } // namespace phoenix
Chris@16 121
Chris@16 122 #endif
Chris@16 123
Chris@16 124 } // namespace boost
Chris@16 125
Chris@16 126 #include <boost/log/detail/footer.hpp>
Chris@16 127
Chris@16 128 #endif // BOOST_LOG_EXPRESSIONS_FORMATTERS_FORMAT_HPP_INCLUDED_