annotate DEPENDENCIES/generic/include/boost/log/expressions/keyword.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 keyword.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 29.01.2012
Chris@16 11 *
Chris@16 12 * The header contains attribute keyword declaration.
Chris@16 13 */
Chris@16 14
Chris@16 15 #ifndef BOOST_LOG_EXPRESSIONS_KEYWORD_HPP_INCLUDED_
Chris@16 16 #define BOOST_LOG_EXPRESSIONS_KEYWORD_HPP_INCLUDED_
Chris@16 17
Chris@16 18 #include <boost/ref.hpp>
Chris@16 19 #include <boost/proto/extends.hpp>
Chris@16 20 #include <boost/proto/make_expr.hpp>
Chris@16 21 #include <boost/phoenix/core/actor.hpp>
Chris@16 22 #include <boost/phoenix/core/domain.hpp>
Chris@16 23 #include <boost/phoenix/core/environment.hpp>
Chris@16 24 #include <boost/fusion/sequence/intrinsic/at.hpp>
Chris@16 25 #include <boost/preprocessor/cat.hpp>
Chris@16 26 #include <boost/log/detail/config.hpp>
Chris@16 27 #include <boost/log/detail/custom_terminal_spec.hpp>
Chris@16 28 #include <boost/log/expressions/keyword_fwd.hpp>
Chris@16 29 #include <boost/log/expressions/is_keyword_descriptor.hpp>
Chris@16 30 #include <boost/log/expressions/attr.hpp>
Chris@16 31 #include <boost/log/attributes/attribute_name.hpp>
Chris@16 32 #include <boost/log/attributes/value_extraction.hpp>
Chris@16 33 #include <boost/log/attributes/fallback_policy.hpp>
Chris@16 34 #include <boost/log/detail/header.hpp>
Chris@16 35
Chris@16 36 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 37 #pragma once
Chris@16 38 #endif
Chris@16 39
Chris@16 40 namespace boost {
Chris@16 41
Chris@16 42 BOOST_LOG_OPEN_NAMESPACE
Chris@16 43
Chris@16 44 namespace expressions {
Chris@16 45
Chris@16 46 /*!
Chris@16 47 * This class implements an expression template keyword. It is used to start template expressions involving attribute values.
Chris@16 48 */
Chris@16 49 template< typename DescriptorT, template< typename > class ActorT >
Chris@16 50 struct attribute_keyword
Chris@16 51 {
Chris@16 52 //! Self type
Chris@16 53 typedef attribute_keyword this_type;
Chris@16 54 //! Attribute descriptor type
Chris@16 55 typedef DescriptorT descriptor_type;
Chris@16 56
Chris@16 57 BOOST_PROTO_BASIC_EXTENDS(typename proto::terminal< descriptor_type >::type, this_type, phoenix::phoenix_domain)
Chris@16 58
Chris@16 59 //! Attribute value type
Chris@16 60 typedef typename descriptor_type::value_type value_type;
Chris@16 61
Chris@16 62 //! Returns attribute name
Chris@16 63 static attribute_name get_name() { return descriptor_type::get_name(); }
Chris@16 64
Chris@16 65 //! Expression with cached attribute name
Chris@16 66 typedef attribute_actor<
Chris@16 67 value_type,
Chris@16 68 fallback_to_none,
Chris@16 69 descriptor_type,
Chris@16 70 ActorT
Chris@16 71 > or_none_result_type;
Chris@16 72
Chris@16 73 //! Generates an expression that extracts the attribute value or a default value
Chris@16 74 static or_none_result_type or_none()
Chris@16 75 {
Chris@16 76 typedef typename or_none_result_type::terminal_type result_terminal;
Chris@16 77 typename or_none_result_type::base_type act = {{ result_terminal(get_name()) }};
Chris@16 78 return or_none_result_type(act);
Chris@16 79 }
Chris@16 80
Chris@16 81 //! Expression with cached attribute name
Chris@16 82 typedef attribute_actor<
Chris@16 83 value_type,
Chris@16 84 fallback_to_throw,
Chris@16 85 descriptor_type,
Chris@16 86 ActorT
Chris@16 87 > or_throw_result_type;
Chris@16 88
Chris@16 89 //! Generates an expression that extracts the attribute value or throws an exception
Chris@16 90 static or_throw_result_type or_throw()
Chris@16 91 {
Chris@16 92 typedef typename or_throw_result_type::terminal_type result_terminal;
Chris@16 93 typename or_throw_result_type::base_type act = {{ result_terminal(get_name()) }};
Chris@16 94 return or_throw_result_type(act);
Chris@16 95 }
Chris@16 96
Chris@16 97 //! Generates an expression that extracts the attribute value or a default value
Chris@16 98 template< typename DefaultT >
Chris@16 99 static attribute_actor<
Chris@16 100 value_type,
Chris@16 101 fallback_to_default< DefaultT >,
Chris@16 102 descriptor_type,
Chris@16 103 ActorT
Chris@16 104 > or_default(DefaultT const& def_val)
Chris@16 105 {
Chris@16 106 typedef attribute_actor<
Chris@16 107 value_type,
Chris@16 108 fallback_to_default< DefaultT >,
Chris@16 109 descriptor_type,
Chris@16 110 ActorT
Chris@16 111 > or_default_result_type;
Chris@16 112 typedef typename or_default_result_type::terminal_type result_terminal;
Chris@16 113 typename or_default_result_type::base_type act = {{ result_terminal(get_name(), def_val) }};
Chris@16 114 return or_default_result_type(act);
Chris@16 115 }
Chris@16 116 };
Chris@16 117
Chris@16 118 } // namespace expressions
Chris@16 119
Chris@16 120 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 121
Chris@16 122 #ifndef BOOST_LOG_DOXYGEN_PASS
Chris@16 123
Chris@16 124 namespace proto {
Chris@16 125
Chris@16 126 namespace detail {
Chris@16 127
Chris@16 128 // This hack is needed in order to cache attribute name into the expression terminal when the template
Chris@16 129 // expression is constructed. The standard way through a custom domain doesn't work because phoenix::actor
Chris@16 130 // is bound to phoenix_domain.
Chris@16 131 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
Chris@16 132 struct protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
Chris@16 133 {
Chris@16 134 typedef boost::log::expressions::attribute_keyword< DescriptorT, ActorT > keyword_type;
Chris@16 135 typedef typename keyword_type::or_none_result_type result_type;
Chris@16 136
Chris@16 137 result_type operator() (keyword_type const& keyword) const
Chris@16 138 {
Chris@16 139 return keyword.or_none();
Chris@16 140 }
Chris@16 141 };
Chris@16 142
Chris@16 143 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
Chris@16 144 struct protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >&, DomainT > :
Chris@16 145 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
Chris@16 146 {
Chris@16 147 };
Chris@16 148
Chris@16 149 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
Chris@16 150 struct protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT > const&, DomainT > :
Chris@16 151 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
Chris@16 152 {
Chris@16 153 };
Chris@16 154
Chris@16 155 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
Chris@16 156 struct protoify< boost::reference_wrapper< boost::log::expressions::attribute_keyword< DescriptorT, ActorT > >, DomainT > :
Chris@16 157 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
Chris@16 158 {
Chris@16 159 };
Chris@16 160
Chris@16 161 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
Chris@16 162 struct protoify< boost::reference_wrapper< boost::log::expressions::attribute_keyword< DescriptorT, ActorT > > const, DomainT > :
Chris@16 163 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
Chris@16 164 {
Chris@16 165 };
Chris@16 166
Chris@16 167 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
Chris@16 168 struct protoify< boost::reference_wrapper< const boost::log::expressions::attribute_keyword< DescriptorT, ActorT > >, DomainT > :
Chris@16 169 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
Chris@16 170 {
Chris@16 171 };
Chris@16 172
Chris@16 173 template< typename DescriptorT, template< typename > class ActorT, typename DomainT >
Chris@16 174 struct protoify< boost::reference_wrapper< const boost::log::expressions::attribute_keyword< DescriptorT, ActorT > > const, DomainT > :
Chris@16 175 public protoify< boost::log::expressions::attribute_keyword< DescriptorT, ActorT >, DomainT >
Chris@16 176 {
Chris@16 177 };
Chris@16 178
Chris@16 179 } // namespace detail
Chris@16 180
Chris@16 181 } // namespace proto
Chris@16 182
Chris@16 183 #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
Chris@16 184
Chris@16 185 } // namespace boost
Chris@16 186
Chris@16 187 #ifndef BOOST_LOG_DOXYGEN_PASS
Chris@16 188
Chris@16 189 #define BOOST_LOG_ATTRIBUTE_KEYWORD_TYPE_IMPL(keyword_, name_, value_type_, tag_ns_)\
Chris@16 190 namespace tag_ns_\
Chris@16 191 {\
Chris@16 192 struct keyword_ :\
Chris@16 193 public ::boost::log::expressions::keyword_descriptor\
Chris@16 194 {\
Chris@16 195 typedef value_type_ value_type;\
Chris@16 196 static ::boost::log::attribute_name get_name() { return ::boost::log::attribute_name(name_); }\
Chris@16 197 };\
Chris@16 198 }\
Chris@16 199 typedef ::boost::log::expressions::attribute_keyword< tag_ns_::keyword_ > BOOST_PP_CAT(keyword_, _type);
Chris@16 200
Chris@16 201 #define BOOST_LOG_ATTRIBUTE_KEYWORD_IMPL(keyword_, name_, value_type_, tag_ns_)\
Chris@16 202 BOOST_LOG_ATTRIBUTE_KEYWORD_TYPE_IMPL(keyword_, name_, value_type_, tag_ns_)\
Chris@16 203 const BOOST_PP_CAT(keyword_, _type) keyword_ = {};
Chris@16 204
Chris@16 205 #endif // BOOST_LOG_DOXYGEN_PASS
Chris@16 206
Chris@16 207 /*!
Chris@16 208 * \brief The macro declares an attribute keyword type
Chris@16 209 *
Chris@16 210 * The macro should be used at a namespace scope. It expands into an attribute keyword type definition, including the
Chris@16 211 * \c tag namespace and the keyword tag type within which has the following layout:
Chris@16 212 *
Chris@16 213 * \code
Chris@16 214 * namespace tag
Chris@16 215 * {
Chris@16 216 * struct keyword_ :
Chris@16 217 * public boost::log::expressions::keyword_descriptor
Chris@16 218 * {
Chris@16 219 * typedef value_type_ value_type;
Chris@16 220 * static boost::log::attribute_name get_name();
Chris@16 221 * };
Chris@16 222 * }
Chris@16 223 *
Chris@16 224 * typedef boost::log::expressions::attribute_keyword< tag::keyword_ > keyword_type;
Chris@16 225 * \endcode
Chris@16 226 *
Chris@16 227 * The \c get_name method returns the attribute name.
Chris@16 228 *
Chris@16 229 * \note This macro only defines the type of the keyword. To also define the keyword object, use
Chris@16 230 * the \c BOOST_LOG_ATTRIBUTE_KEYWORD macro instead.
Chris@16 231 *
Chris@16 232 * \param keyword_ Keyword name
Chris@16 233 * \param name_ Attribute name string
Chris@16 234 * \param value_type_ Attribute value type
Chris@16 235 */
Chris@16 236 #define BOOST_LOG_ATTRIBUTE_KEYWORD_TYPE(keyword_, name_, value_type_)\
Chris@16 237 BOOST_LOG_ATTRIBUTE_KEYWORD_TYPE_IMPL(keyword_, name_, value_type_, tag)
Chris@16 238
Chris@16 239 /*!
Chris@16 240 * \brief The macro declares an attribute keyword
Chris@16 241 *
Chris@16 242 * The macro provides definitions similar to \c BOOST_LOG_ATTRIBUTE_KEYWORD_TYPE and additionally
Chris@16 243 * defines the keyword object.
Chris@16 244 *
Chris@16 245 * \param keyword_ Keyword name
Chris@16 246 * \param name_ Attribute name string
Chris@16 247 * \param value_type_ Attribute value type
Chris@16 248 */
Chris@16 249 #define BOOST_LOG_ATTRIBUTE_KEYWORD(keyword_, name_, value_type_)\
Chris@16 250 BOOST_LOG_ATTRIBUTE_KEYWORD_IMPL(keyword_, name_, value_type_, tag)
Chris@16 251
Chris@16 252 #include <boost/log/detail/footer.hpp>
Chris@16 253
Chris@16 254 #if defined(BOOST_LOG_TRIVIAL_HPP_INCLUDED_)
Chris@16 255 #include <boost/log/detail/trivial_keyword.hpp>
Chris@16 256 #endif
Chris@16 257
Chris@16 258 #endif // BOOST_LOG_EXPRESSIONS_KEYWORD_HPP_INCLUDED_