annotate DEPENDENCIES/generic/include/boost/log/attributes/constant.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 constant.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 15.04.2007
Chris@16 11 *
Chris@16 12 * The header contains implementation of a constant attribute.
Chris@16 13 */
Chris@16 14
Chris@16 15 #ifndef BOOST_LOG_ATTRIBUTES_CONSTANT_HPP_INCLUDED_
Chris@16 16 #define BOOST_LOG_ATTRIBUTES_CONSTANT_HPP_INCLUDED_
Chris@16 17
Chris@16 18 #include <boost/move/core.hpp>
Chris@16 19 #include <boost/move/utility.hpp>
Chris@16 20 #include <boost/type_traits/remove_reference.hpp>
Chris@16 21 #include <boost/log/detail/config.hpp>
Chris@16 22 #include <boost/log/detail/embedded_string_type.hpp>
Chris@16 23 #include <boost/log/attributes/attribute.hpp>
Chris@16 24 #include <boost/log/attributes/attribute_cast.hpp>
Chris@16 25 #include <boost/log/attributes/attribute_value_impl.hpp>
Chris@16 26 #include <boost/log/detail/header.hpp>
Chris@16 27
Chris@16 28 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 29 #pragma once
Chris@16 30 #endif
Chris@16 31
Chris@16 32 namespace boost {
Chris@16 33
Chris@16 34 BOOST_LOG_OPEN_NAMESPACE
Chris@16 35
Chris@16 36 namespace attributes {
Chris@16 37
Chris@16 38 /*!
Chris@16 39 * \brief A class of an attribute that holds a single constant value
Chris@16 40 *
Chris@16 41 * The constant is a simplest and one of the most frequently used types of attributes.
Chris@16 42 * It stores a constant value, which it eventually returns as its value each time
Chris@16 43 * requested.
Chris@16 44 */
Chris@16 45 template< typename T >
Chris@16 46 class constant :
Chris@16 47 public attribute
Chris@16 48 {
Chris@16 49 public:
Chris@16 50 //! Attribute value type
Chris@16 51 typedef T value_type;
Chris@16 52
Chris@16 53 protected:
Chris@16 54 //! Factory implementation
Chris@16 55 class BOOST_SYMBOL_VISIBLE impl :
Chris@16 56 public attribute_value_impl< value_type >
Chris@16 57 {
Chris@16 58 //! Base type
Chris@16 59 typedef attribute_value_impl< value_type > base_type;
Chris@16 60
Chris@16 61 public:
Chris@16 62 /*!
Chris@16 63 * Constructor with the stored value initialization
Chris@16 64 */
Chris@16 65 explicit impl(value_type const& value) : base_type(value) {}
Chris@16 66 /*!
Chris@16 67 * Constructor with the stored value initialization
Chris@16 68 */
Chris@16 69 explicit impl(BOOST_RV_REF(value_type) value) : base_type(boost::move(value)) {}
Chris@16 70 };
Chris@16 71
Chris@16 72 public:
Chris@16 73 /*!
Chris@16 74 * Constructor with the stored value initialization
Chris@16 75 */
Chris@16 76 explicit constant(value_type const& value) : attribute(new impl(value)) {}
Chris@16 77 /*!
Chris@16 78 * Constructor with the stored value initialization
Chris@16 79 */
Chris@16 80 explicit constant(BOOST_RV_REF(value_type) value) : attribute(new impl(boost::move(value))) {}
Chris@16 81 /*!
Chris@16 82 * Constructor for casting support
Chris@16 83 */
Chris@16 84 explicit constant(cast_source const& source) : attribute(source.as< impl >())
Chris@16 85 {
Chris@16 86 }
Chris@16 87
Chris@16 88 /*!
Chris@16 89 * \return Reference to the contained value.
Chris@16 90 */
Chris@16 91 value_type const& get() const
Chris@16 92 {
Chris@16 93 return static_cast< impl* >(this->get_impl())->get();
Chris@16 94 }
Chris@16 95 };
Chris@16 96
Chris@16 97 /*!
Chris@16 98 * The function constructs a \c constant attribute containing the provided value.
Chris@16 99 * The function automatically converts C string arguments to \c std::basic_string objects.
Chris@16 100 */
Chris@16 101 template< typename T >
Chris@16 102 inline constant<
Chris@16 103 typename boost::log::aux::make_embedded_string_type<
Chris@16 104 typename remove_reference< T >::type
Chris@16 105 >::type
Chris@16 106 > make_constant(BOOST_FWD_REF(T) val)
Chris@16 107 {
Chris@16 108 typedef typename boost::log::aux::make_embedded_string_type<
Chris@16 109 typename remove_reference< T >::type
Chris@16 110 >::type value_type;
Chris@16 111 return constant< value_type >(boost::forward< T >(val));
Chris@16 112 }
Chris@16 113
Chris@16 114 } // namespace attributes
Chris@16 115
Chris@16 116 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 117
Chris@16 118 } // namespace boost
Chris@16 119
Chris@16 120 #include <boost/log/detail/footer.hpp>
Chris@16 121
Chris@16 122 #endif // BOOST_LOG_ATTRIBUTES_CONSTANT_HPP_INCLUDED_