Back to home page

EIC code displayed by LXR

 
 

    


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

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   value_extraction.hpp
0009  * \author Andrey Semashev
0010  * \date   01.03.2008
0011  *
0012  * The header contains implementation of tools for extracting an attribute value
0013  * from the view.
0014  */
0015 
0016 #ifndef BOOST_LOG_ATTRIBUTES_VALUE_EXTRACTION_HPP_INCLUDED_
0017 #define BOOST_LOG_ATTRIBUTES_VALUE_EXTRACTION_HPP_INCLUDED_
0018 
0019 #include <boost/mpl/vector.hpp>
0020 #include <boost/mpl/joint_view.hpp>
0021 #include <boost/mpl/if.hpp>
0022 #include <boost/mpl/eval_if.hpp>
0023 #include <boost/mpl/identity.hpp>
0024 #include <boost/mpl/is_sequence.hpp>
0025 #include <boost/mpl/contains.hpp>
0026 #include <boost/mpl/push_back.hpp>
0027 #include <boost/type_traits/is_same.hpp>
0028 #include <boost/core/enable_if.hpp>
0029 #include <boost/log/detail/config.hpp>
0030 #include <boost/log/exceptions.hpp>
0031 #include <boost/log/core/record.hpp>
0032 #include <boost/log/attributes/attribute_name.hpp>
0033 #include <boost/log/attributes/attribute_value.hpp>
0034 #include <boost/log/attributes/attribute.hpp>
0035 #include <boost/log/attributes/attribute_value_set.hpp>
0036 #include <boost/log/attributes/value_extraction_fwd.hpp>
0037 #include <boost/log/attributes/fallback_policy.hpp>
0038 #include <boost/log/expressions/keyword_fwd.hpp>
0039 #include <boost/log/utility/value_ref.hpp>
0040 #include <boost/log/utility/type_dispatch/static_type_dispatcher.hpp>
0041 #include <boost/log/detail/header.hpp>
0042 
0043 #ifdef BOOST_HAS_PRAGMA_ONCE
0044 #pragma once
0045 #endif
0046 
0047 namespace boost {
0048 
0049 BOOST_LOG_OPEN_NAMESPACE
0050 
0051 namespace result_of {
0052 
0053 /*!
0054  * \brief A metafunction that allows to acquire the result of the value extraction
0055  *
0056  * The metafunction results in a type that is in form of <tt>T const&</tt>, if \c T is
0057  * not an MPL type sequence and <tt>DefaultT</tt> is the same as <tt>T</tt>,
0058  * or <tt>value_ref< TypesT, TagT ></tt> otherwise, with
0059  * \c TypesT being a type sequence comprising the types from sequence \c T and \c DefaultT,
0060  * if it is not present in \c T already.
0061  */
0062 template< typename T, typename DefaultT, typename TagT >
0063 struct extract_or_default
0064 {
0065     typedef typename mpl::eval_if<
0066         mpl::is_sequence< T >,
0067         mpl::eval_if<
0068             mpl::contains< T, DefaultT >,
0069             mpl::identity< T >,
0070             mpl::push_back< T, DefaultT >
0071         >,
0072         mpl::if_<
0073             is_same< T, DefaultT >,
0074             T,
0075             mpl::vector2< T, DefaultT >
0076         >
0077     >::type extracted_type;
0078 
0079     typedef typename mpl::if_<
0080         mpl::is_sequence< extracted_type >,
0081         value_ref< extracted_type, TagT >,
0082         extracted_type const&
0083     >::type type;
0084 };
0085 
0086 /*!
0087  * \brief A metafunction that allows to acquire the result of the value extraction
0088  *
0089  * The metafunction results in a type that is in form of <tt>T const&</tt>, if \c T is
0090  * not an MPL type sequence, or <tt>value_ref< T, TagT ></tt> otherwise. In the latter
0091  * case the value reference shall never be empty.
0092  */
0093 template< typename T, typename TagT >
0094 struct extract_or_throw
0095 {
0096     typedef typename mpl::if_<
0097         mpl::is_sequence< T >,
0098         value_ref< T, TagT >,
0099         T const&
0100     >::type type;
0101 };
0102 
0103 /*!
0104  * \brief A metafunction that allows to acquire the result of the value extraction
0105  *
0106  * The metafunction results in a type that is in form of <tt>value_ref< T, TagT ></tt>.
0107  */
0108 template< typename T, typename TagT >
0109 struct extract
0110 {
0111     typedef value_ref< T, TagT > type;
0112 };
0113 
0114 } // namespace result_of
0115 
0116 namespace aux {
0117 
0118 //! The function object initializes the value reference
0119 template< typename RefT >
0120 struct value_ref_initializer
0121 {
0122     typedef void result_type;
0123 
0124     value_ref_initializer(RefT& ref) : m_ref(ref)
0125     {
0126     }
0127 
0128     template< typename ArgT >
0129     result_type operator() (ArgT const& arg) const
0130     {
0131         m_ref = RefT(arg);
0132     }
0133 
0134 private:
0135     RefT& m_ref;
0136 };
0137 
0138 //! The function unwraps \c value_ref, if possible
0139 template< typename T, typename TagT >
0140 BOOST_FORCEINLINE typename boost::enable_if_c< mpl::is_sequence< T >::value, value_ref< T, TagT > >::type
0141 unwrap_value_ref(value_ref< T, TagT > const& r)
0142 {
0143     return r;
0144 }
0145 
0146 template< typename T, typename TagT >
0147 BOOST_FORCEINLINE typename boost::disable_if_c< mpl::is_sequence< T >::value, T const& >::type
0148 unwrap_value_ref(value_ref< T, TagT > const& r)
0149 {
0150     return r.get();
0151 }
0152 
0153 } // namespace aux
0154 
0155 /*!
0156  * \brief Generic attribute value extractor
0157  *
0158  * Attribute value extractor is a functional object that attempts to find and extract the stored
0159  * attribute value from the attribute values view or a log record. The extracted value is returned
0160  * from the extractor.
0161  */
0162 template< typename T, typename FallbackPolicyT, typename TagT >
0163 class value_extractor :
0164     private FallbackPolicyT
0165 {
0166 public:
0167     //! Fallback policy
0168     typedef FallbackPolicyT fallback_policy;
0169     //! Attribute value types
0170     typedef T value_type;
0171     //! Function object result type
0172     typedef value_ref< value_type, TagT > result_type;
0173 
0174 public:
0175     /*!
0176      * Default constructor
0177      */
0178     BOOST_DEFAULTED_FUNCTION(value_extractor(), {})
0179 
0180     /*!
0181      * Copy constructor
0182      */
0183     value_extractor(value_extractor const& that) : fallback_policy(static_cast< fallback_policy const& >(that))
0184     {
0185     }
0186 
0187     /*!
0188      * Constructor
0189      *
0190      * \param arg Fallback policy constructor argument
0191      */
0192     template< typename U >
0193     explicit value_extractor(U const& arg) : fallback_policy(arg) {}
0194 
0195     /*!
0196      * Extraction operator. Attempts to acquire the stored value of one of the supported types. If extraction succeeds,
0197      * the extracted value is returned.
0198      *
0199      * \param attr The attribute value to extract from.
0200      * \return The extracted value, if extraction succeeded, an empty value otherwise.
0201      */
0202     result_type operator() (attribute_value const& attr) const
0203     {
0204         result_type res;
0205         aux::value_ref_initializer< result_type > initializer(res);
0206         if (!!attr)
0207         {
0208             static_type_dispatcher< value_type > disp(initializer);
0209             if (!attr.dispatch(disp) && !fallback_policy::apply_default(initializer))
0210                 fallback_policy::on_invalid_type(attr.get_type());
0211         }
0212         else if (!fallback_policy::apply_default(initializer))
0213         {
0214             fallback_policy::on_missing_value();
0215         }
0216         return res;
0217     }
0218 
0219     /*!
0220      * Extraction operator. Looks for an attribute value with the specified name
0221      * and tries to acquire the stored value of one of the supported types. If extraction succeeds,
0222      * the extracted value is returned.
0223      *
0224      * \param name Attribute value name.
0225      * \param attrs A set of attribute values in which to look for the specified attribute value.
0226      * \return The extracted value, if extraction succeeded, an empty value otherwise.
0227      */
0228     result_type operator() (attribute_name const& name, attribute_value_set const& attrs) const
0229     {
0230         try
0231         {
0232             attribute_value_set::const_iterator it = attrs.find(name);
0233             if (it != attrs.end())
0234                 return operator() (it->second);
0235             else
0236                 return operator() (attribute_value());
0237         }
0238         catch (exception& e)
0239         {
0240             // Attach the attribute name to the exception
0241             boost::log::aux::attach_attribute_name_info(e, name);
0242             throw;
0243         }
0244     }
0245 
0246     /*!
0247      * Extraction operator. Looks for an attribute value with the specified name
0248      * and tries to acquire the stored value of one of the supported types. If extraction succeeds,
0249      * the extracted value is returned.
0250      *
0251      * \param name Attribute value name.
0252      * \param rec A log record. The attribute value will be sought among those associated with the record.
0253      * \return The extracted value, if extraction succeeded, an empty value otherwise.
0254      */
0255     result_type operator() (attribute_name const& name, record const& rec) const
0256     {
0257         return operator() (name, rec.attribute_values());
0258     }
0259 
0260     /*!
0261      * Extraction operator. Looks for an attribute value with the specified name
0262      * and tries to acquire the stored value of one of the supported types. If extraction succeeds,
0263      * the extracted value is returned.
0264      *
0265      * \param name Attribute value name.
0266      * \param rec A log record view. The attribute value will be sought among those associated with the record.
0267      * \return The extracted value, if extraction succeeded, an empty value otherwise.
0268      */
0269     result_type operator() (attribute_name const& name, record_view const& rec) const
0270     {
0271         return operator() (name, rec.attribute_values());
0272     }
0273 
0274     /*!
0275      * \returns Fallback policy
0276      */
0277     fallback_policy const& get_fallback_policy() const
0278     {
0279         return *static_cast< fallback_policy const* >(this);
0280     }
0281 };
0282 
0283 #if !defined(BOOST_LOG_DOXYGEN_PASS)
0284 #if !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
0285 #define BOOST_LOG_AUX_VOID_DEFAULT = void
0286 #else
0287 #define BOOST_LOG_AUX_VOID_DEFAULT
0288 #endif
0289 #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
0290 
0291 /*!
0292  * The function extracts an attribute value from the view. The user has to explicitly specify the
0293  * type or set of possible types of the attribute value to be extracted.
0294  *
0295  * \param name The name of the attribute value to extract.
0296  * \param attrs A set of attribute values in which to look for the specified attribute value.
0297  * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
0298  */
0299 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
0300 inline typename result_of::extract< T, TagT >::type extract(attribute_name const& name, attribute_value_set const& attrs)
0301 {
0302     value_extractor< T, fallback_to_none, TagT > extractor;
0303     return extractor(name, attrs);
0304 }
0305 
0306 /*!
0307  * The function extracts an attribute value from the view. The user has to explicitly specify the
0308  * type or set of possible types of the attribute value to be extracted.
0309  *
0310  * \param name The name of the attribute value to extract.
0311  * \param rec A log record. The attribute value will be sought among those associated with the record.
0312  * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
0313  */
0314 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
0315 inline typename result_of::extract< T, TagT >::type extract(attribute_name const& name, record const& rec)
0316 {
0317     value_extractor< T, fallback_to_none, TagT > extractor;
0318     return extractor(name, rec);
0319 }
0320 
0321 /*!
0322  * The function extracts an attribute value from the view. The user has to explicitly specify the
0323  * type or set of possible types of the attribute value to be extracted.
0324  *
0325  * \param name The name of the attribute value to extract.
0326  * \param rec A log record view. The attribute value will be sought among those associated with the record.
0327  * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
0328  */
0329 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
0330 inline typename result_of::extract< T, TagT >::type extract(attribute_name const& name, record_view const& rec)
0331 {
0332     value_extractor< T, fallback_to_none, TagT > extractor;
0333     return extractor(name, rec);
0334 }
0335 
0336 /*!
0337  * The function extracts an attribute value from the view. The user has to explicitly specify the
0338  * type or set of possible types of the attribute value to be extracted.
0339  *
0340  * \param value Attribute value.
0341  * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
0342  */
0343 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
0344 inline typename result_of::extract< T, TagT >::type extract(attribute_value const& value)
0345 {
0346     value_extractor< T, fallback_to_none, TagT > extractor;
0347     return extractor(value);
0348 }
0349 
0350 /*!
0351  * The function extracts an attribute value from the view. The user has to explicitly specify the
0352  * type or set of possible types of the attribute value to be extracted.
0353  *
0354  * \param name The name of the attribute value to extract.
0355  * \param attrs A set of attribute values in which to look for the specified attribute value.
0356  * \return The extracted value or a non-empty \c value_ref that refers to the value.
0357  * \throws An exception is thrown if the requested value cannot be extracted.
0358  */
0359 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
0360 inline typename result_of::extract_or_throw< T, TagT >::type extract_or_throw(attribute_name const& name, attribute_value_set const& attrs)
0361 {
0362     value_extractor< T, fallback_to_throw, TagT > extractor;
0363     return aux::unwrap_value_ref(extractor(name, attrs));
0364 }
0365 
0366 /*!
0367  * The function extracts an attribute value from the view. The user has to explicitly specify the
0368  * type or set of possible types of the attribute value to be extracted.
0369  *
0370  * \param name The name of the attribute value to extract.
0371  * \param rec A log record. The attribute value will be sought among those associated with the record.
0372  * \return The extracted value or a non-empty \c value_ref that refers to the value.
0373  * \throws An exception is thrown if the requested value cannot be extracted.
0374  */
0375 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
0376 inline typename result_of::extract_or_throw< T, TagT >::type extract_or_throw(attribute_name const& name, record const& rec)
0377 {
0378     value_extractor< T, fallback_to_throw, TagT > extractor;
0379     return aux::unwrap_value_ref(extractor(name, rec));
0380 }
0381 
0382 /*!
0383  * The function extracts an attribute value from the view. The user has to explicitly specify the
0384  * type or set of possible types of the attribute value to be extracted.
0385  *
0386  * \param name The name of the attribute value to extract.
0387  * \param rec A log record view. The attribute value will be sought among those associated with the record.
0388  * \return The extracted value or a non-empty \c value_ref that refers to the value.
0389  * \throws An exception is thrown if the requested value cannot be extracted.
0390  */
0391 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
0392 inline typename result_of::extract_or_throw< T, TagT >::type extract_or_throw(attribute_name const& name, record_view const& rec)
0393 {
0394     value_extractor< T, fallback_to_throw, TagT > extractor;
0395     return aux::unwrap_value_ref(extractor(name, rec));
0396 }
0397 
0398 /*!
0399  * The function extracts an attribute value from the view. The user has to explicitly specify the
0400  * type or set of possible types of the attribute value to be extracted.
0401  *
0402  * \param value Attribute value.
0403  * \return The extracted value or a non-empty \c value_ref that refers to the value.
0404  * \throws An exception is thrown if the requested value cannot be extracted.
0405  */
0406 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
0407 inline typename result_of::extract_or_throw< T, TagT >::type extract_or_throw(attribute_value const& value)
0408 {
0409     value_extractor< T, fallback_to_throw, TagT > extractor;
0410     return aux::unwrap_value_ref(extractor(value));
0411 }
0412 
0413 /*!
0414  * The function extracts an attribute value from the view. The user has to explicitly specify the
0415  * type or set of possible types of the attribute value to be extracted.
0416  *
0417  * \note Caution must be exercised if the default value is a temporary object. Because the function returns
0418  *       a reference, if the temporary object is destroyed, the reference may become dangling.
0419  *
0420  * \param name The name of the attribute value to extract.
0421  * \param attrs A set of attribute values in which to look for the specified attribute value.
0422  * \param def_val The default value
0423  * \return The extracted value, if found. The default value otherwise.
0424  */
0425 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT, typename DefaultT >
0426 inline typename result_of::extract_or_default< T, DefaultT, TagT >::type
0427 extract_or_default(attribute_name const& name, attribute_value_set const& attrs, DefaultT const& def_val)
0428 {
0429     typedef typename result_of::extract_or_default< T, DefaultT, TagT >::extracted_type extracted_type;
0430     value_extractor< extracted_type, fallback_to_default< DefaultT const& >, TagT > extractor(def_val);
0431     return aux::unwrap_value_ref(extractor(name, attrs));
0432 }
0433 
0434 /*!
0435  * The function extracts an attribute value from the view. The user has to explicitly specify the
0436  * type or set of possible types of the attribute value to be visited.
0437  *
0438  * \note Caution must be exercised if the default value is a temporary object. Because the function returns
0439  *       a reference, if the temporary object is destroyed, the reference may become dangling.
0440  *
0441  * \param name The name of the attribute value to extract.
0442  * \param rec A log record. The attribute value will be sought among those associated with the record.
0443  * \param def_val The default value
0444  * \return The extracted value, if found. The default value otherwise.
0445  */
0446 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT, typename DefaultT >
0447 inline typename result_of::extract_or_default< T, DefaultT, TagT >::type
0448 extract_or_default(attribute_name const& name, record const& rec, DefaultT const& def_val)
0449 {
0450     typedef typename result_of::extract_or_default< T, DefaultT, TagT >::extracted_type extracted_type;
0451     value_extractor< extracted_type, fallback_to_default< DefaultT const& >, TagT > extractor(def_val);
0452     return aux::unwrap_value_ref(extractor(name, rec));
0453 }
0454 
0455 /*!
0456  * The function extracts an attribute value from the view. The user has to explicitly specify the
0457  * type or set of possible types of the attribute value to be visited.
0458  *
0459  * \note Caution must be exercised if the default value is a temporary object. Because the function returns
0460  *       a reference, if the temporary object is destroyed, the reference may become dangling.
0461  *
0462  * \param name The name of the attribute value to extract.
0463  * \param rec A log record view. The attribute value will be sought among those associated with the record.
0464  * \param def_val The default value
0465  * \return The extracted value, if found. The default value otherwise.
0466  */
0467 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT, typename DefaultT >
0468 inline typename result_of::extract_or_default< T, DefaultT, TagT >::type
0469 extract_or_default(attribute_name const& name, record_view const& rec, DefaultT const& def_val)
0470 {
0471     typedef typename result_of::extract_or_default< T, DefaultT, TagT >::extracted_type extracted_type;
0472     value_extractor< extracted_type, fallback_to_default< DefaultT const& >, TagT > extractor(def_val);
0473     return aux::unwrap_value_ref(extractor(name, rec));
0474 }
0475 
0476 /*!
0477  * The function extracts an attribute value from the view. The user has to explicitly specify the
0478  * type or set of possible types of the attribute value to be visited.
0479  *
0480  * \note Caution must be exercised if the default value is a temporary object. Because the function returns
0481  *       a reference, if the temporary object is destroyed, the reference may become dangling.
0482  *
0483  * \param value Attribute value.
0484  * \param def_val The default value
0485  * \return The extracted value, if found. The default value otherwise.
0486  */
0487 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT, typename DefaultT >
0488 inline typename result_of::extract_or_default< T, DefaultT, TagT >::type extract_or_default(attribute_value const& value, DefaultT const& def_val)
0489 {
0490     typedef typename result_of::extract_or_default< T, DefaultT, TagT >::extracted_type extracted_type;
0491     value_extractor< extracted_type, fallback_to_default< DefaultT const& >, TagT > extractor(def_val);
0492     return aux::unwrap_value_ref(extractor(value));
0493 }
0494 
0495 #if defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
0496 
0497 template< typename T >
0498 inline typename result_of::extract< T >::type extract(attribute_name const& name, attribute_value_set const& attrs)
0499 {
0500     value_extractor< T, fallback_to_none > extractor;
0501     return extractor(name, attrs);
0502 }
0503 
0504 template< typename T >
0505 inline typename result_of::extract< T >::type extract(attribute_name const& name, record const& rec)
0506 {
0507     value_extractor< T, fallback_to_none > extractor;
0508     return extractor(name, rec);
0509 }
0510 
0511 template< typename T >
0512 inline typename result_of::extract< T >::type extract(attribute_name const& name, record_view const& rec)
0513 {
0514     value_extractor< T, fallback_to_none > extractor;
0515     return extractor(name, rec);
0516 }
0517 
0518 template< typename T >
0519 inline typename result_of::extract< T >::type extract(attribute_value const& value)
0520 {
0521     value_extractor< T, fallback_to_none > extractor;
0522     return extractor(value);
0523 }
0524 
0525 template< typename T >
0526 inline typename result_of::extract_or_throw< T >::type extract_or_throw(attribute_name const& name, attribute_value_set const& attrs)
0527 {
0528     value_extractor< T, fallback_to_throw > extractor;
0529     return aux::unwrap_value_ref(extractor(name, attrs));
0530 }
0531 
0532 template< typename T >
0533 inline typename result_of::extract_or_throw< T >::type extract_or_throw(attribute_name const& name, record const& rec)
0534 {
0535     value_extractor< T, fallback_to_throw > extractor;
0536     return aux::unwrap_value_ref(extractor(name, rec));
0537 }
0538 
0539 template< typename T >
0540 inline typename result_of::extract_or_throw< T >::type extract_or_throw(attribute_name const& name, record_view const& rec)
0541 {
0542     value_extractor< T, fallback_to_throw > extractor;
0543     return aux::unwrap_value_ref(extractor(name, rec));
0544 }
0545 
0546 template< typename T >
0547 inline typename result_of::extract_or_throw< T >::type extract_or_throw(attribute_value const& value)
0548 {
0549     value_extractor< T, fallback_to_throw > extractor;
0550     return aux::unwrap_value_ref(extractor(value));
0551 }
0552 
0553 template< typename T, typename DefaultT >
0554 inline typename result_of::extract_or_default< T, DefaultT >::type extract_or_default(
0555     attribute_name const& name, attribute_value_set const& attrs, DefaultT const& def_val)
0556 {
0557     typedef typename result_of::extract_or_default< T, DefaultT >::extracted_type extracted_type;
0558     value_extractor< extracted_type, fallback_to_default< DefaultT const& > > extractor(def_val);
0559     return aux::unwrap_value_ref(extractor(name, attrs));
0560 }
0561 
0562 template< typename T, typename DefaultT >
0563 inline typename result_of::extract_or_default< T, DefaultT >::type extract_or_default(
0564     attribute_name const& name, record const& rec, DefaultT const& def_val)
0565 {
0566     typedef typename result_of::extract_or_default< T, DefaultT >::extracted_type extracted_type;
0567     value_extractor< extracted_type, fallback_to_default< DefaultT const& > > extractor(def_val);
0568     return aux::unwrap_value_ref(extractor(name, rec));
0569 }
0570 
0571 template< typename T, typename DefaultT >
0572 inline typename result_of::extract_or_default< T, DefaultT >::type extract_or_default(
0573     attribute_name const& name, record_view const& rec, DefaultT const& def_val)
0574 {
0575     typedef typename result_of::extract_or_default< T, DefaultT >::extracted_type extracted_type;
0576     value_extractor< extracted_type, fallback_to_default< DefaultT const& > > extractor(def_val);
0577     return aux::unwrap_value_ref(extractor(name, rec));
0578 }
0579 
0580 template< typename T, typename DefaultT >
0581 inline typename result_of::extract_or_default< T, DefaultT >::type extract_or_default(attribute_value const& value, DefaultT const& def_val)
0582 {
0583     typedef typename result_of::extract_or_default< T, DefaultT >::extracted_type extracted_type;
0584     value_extractor< extracted_type, fallback_to_default< DefaultT const& > > extractor(def_val);
0585     return aux::unwrap_value_ref(extractor(value));
0586 }
0587 
0588 #endif // defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
0589 
0590 /*!
0591  * The function extracts an attribute value from the view. The user has to explicitly specify the
0592  * type or set of possible types of the attribute value to be extracted.
0593  *
0594  * \param keyword The keyword of the attribute value to extract.
0595  * \param attrs A set of attribute values in which to look for the specified attribute value.
0596  * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
0597  */
0598 template< typename DescriptorT, template< typename > class ActorT >
0599 inline typename result_of::extract< typename DescriptorT::value_type, DescriptorT >::type
0600 extract(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, attribute_value_set const& attrs)
0601 {
0602     value_extractor< typename DescriptorT::value_type, fallback_to_none, DescriptorT > extractor;
0603     return extractor(keyword.get_name(), attrs);
0604 }
0605 
0606 /*!
0607  * The function extracts an attribute value from the view. The user has to explicitly specify the
0608  * type or set of possible types of the attribute value to be extracted.
0609  *
0610  * \param keyword The keyword of the attribute value to extract.
0611  * \param rec A log record. The attribute value will be sought among those associated with the record.
0612  * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
0613  */
0614 template< typename DescriptorT, template< typename > class ActorT >
0615 inline typename result_of::extract< typename DescriptorT::value_type, DescriptorT >::type
0616 extract(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record const& rec)
0617 {
0618     value_extractor< typename DescriptorT::value_type, fallback_to_none, DescriptorT > extractor;
0619     return extractor(keyword.get_name(), rec);
0620 }
0621 
0622 /*!
0623  * The function extracts an attribute value from the view. The user has to explicitly specify the
0624  * type or set of possible types of the attribute value to be extracted.
0625  *
0626  * \param keyword The keyword of the attribute value to extract.
0627  * \param rec A log record view. The attribute value will be sought among those associated with the record.
0628  * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
0629  */
0630 template< typename DescriptorT, template< typename > class ActorT >
0631 inline typename result_of::extract< typename DescriptorT::value_type, DescriptorT >::type
0632 extract(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record_view const& rec)
0633 {
0634     value_extractor< typename DescriptorT::value_type, fallback_to_none, DescriptorT > extractor;
0635     return extractor(keyword.get_name(), rec);
0636 }
0637 
0638 /*!
0639  * The function extracts an attribute value from the view. The user has to explicitly specify the
0640  * type or set of possible types of the attribute value to be extracted.
0641  *
0642  * \param keyword The keyword of the attribute value to extract.
0643  * \param attrs A set of attribute values in which to look for the specified attribute value.
0644  * \return The extracted value or a non-empty \c value_ref that refers to the value.
0645  * \throws An exception is thrown if the requested value cannot be extracted.
0646  */
0647 template< typename DescriptorT, template< typename > class ActorT >
0648 inline typename result_of::extract_or_throw< typename DescriptorT::value_type, DescriptorT >::type
0649 extract_or_throw(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, attribute_value_set const& attrs)
0650 {
0651     value_extractor< typename DescriptorT::value_type, fallback_to_throw, DescriptorT > extractor;
0652     return aux::unwrap_value_ref(extractor(keyword.get_name(), attrs));
0653 }
0654 
0655 /*!
0656  * The function extracts an attribute value from the view. The user has to explicitly specify the
0657  * type or set of possible types of the attribute value to be extracted.
0658  *
0659  * \param keyword The keyword of the attribute value to extract.
0660  * \param rec A log record. The attribute value will be sought among those associated with the record.
0661  * \return The extracted value or a non-empty \c value_ref that refers to the value.
0662  * \throws An exception is thrown if the requested value cannot be extracted.
0663  */
0664 template< typename DescriptorT, template< typename > class ActorT >
0665 inline typename result_of::extract_or_throw< typename DescriptorT::value_type, DescriptorT >::type
0666 extract_or_throw(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record const& rec)
0667 {
0668     value_extractor< typename DescriptorT::value_type, fallback_to_throw, DescriptorT > extractor;
0669     return aux::unwrap_value_ref(extractor(keyword.get_name(), rec));
0670 }
0671 
0672 /*!
0673  * The function extracts an attribute value from the view. The user has to explicitly specify the
0674  * type or set of possible types of the attribute value to be extracted.
0675  *
0676  * \param keyword The keyword of the attribute value to extract.
0677  * \param rec A log record view. The attribute value will be sought among those associated with the record.
0678  * \return The extracted value or a non-empty \c value_ref that refers to the value.
0679  * \throws An exception is thrown if the requested value cannot be extracted.
0680  */
0681 template< typename DescriptorT, template< typename > class ActorT >
0682 inline typename result_of::extract_or_throw< typename DescriptorT::value_type, DescriptorT >::type
0683 extract_or_throw(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record_view const& rec)
0684 {
0685     value_extractor< typename DescriptorT::value_type, fallback_to_throw, DescriptorT > extractor;
0686     return aux::unwrap_value_ref(extractor(keyword.get_name(), rec));
0687 }
0688 
0689 /*!
0690  * The function extracts an attribute value from the view. The user has to explicitly specify the
0691  * type or set of possible types of the attribute value to be extracted.
0692  *
0693  * \note Caution must be exercised if the default value is a temporary object. Because the function returns
0694  *       a reference, if the temporary object is destroyed, the reference may become dangling.
0695  *
0696  * \param keyword The keyword of the attribute value to extract.
0697  * \param attrs A set of attribute values in which to look for the specified attribute value.
0698  * \param def_val The default value
0699  * \return The extracted value, if found. The default value otherwise.
0700  */
0701 template< typename DescriptorT, template< typename > class ActorT, typename DefaultT >
0702 inline typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::type
0703 extract_or_default(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, attribute_value_set const& attrs, DefaultT const& def_val)
0704 {
0705     typedef typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::extracted_type extracted_type;
0706     value_extractor< extracted_type, fallback_to_default< DefaultT const& >, DescriptorT > extractor(def_val);
0707     return aux::unwrap_value_ref(extractor(keyword.get_name(), attrs));
0708 }
0709 
0710 /*!
0711  * The function extracts an attribute value from the view. The user has to explicitly specify the
0712  * type or set of possible types of the attribute value to be visited.
0713  *
0714  * \note Caution must be exercised if the default value is a temporary object. Because the function returns
0715  *       a reference, if the temporary object is destroyed, the reference may become dangling.
0716  *
0717  * \param keyword The keyword of the attribute value to extract.
0718  * \param rec A log record. The attribute value will be sought among those associated with the record.
0719  * \param def_val The default value
0720  * \return The extracted value, if found. The default value otherwise.
0721  */
0722 template< typename DescriptorT, template< typename > class ActorT, typename DefaultT >
0723 inline typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::type
0724 extract_or_default(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record const& rec, DefaultT const& def_val)
0725 {
0726     typedef typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::extracted_type extracted_type;
0727     value_extractor< extracted_type, fallback_to_default< DefaultT const& >, DescriptorT > extractor(def_val);
0728     return aux::unwrap_value_ref(extractor(keyword.get_name(), rec));
0729 }
0730 
0731 /*!
0732  * The function extracts an attribute value from the view. The user has to explicitly specify the
0733  * type or set of possible types of the attribute value to be visited.
0734  *
0735  * \note Caution must be exercised if the default value is a temporary object. Because the function returns
0736  *       a reference, if the temporary object is destroyed, the reference may become dangling.
0737  *
0738  * \param keyword The keyword of the attribute value to extract.
0739  * \param rec A log record view. The attribute value will be sought among those associated with the record.
0740  * \param def_val The default value
0741  * \return The extracted value, if found. The default value otherwise.
0742  */
0743 template< typename DescriptorT, template< typename > class ActorT, typename DefaultT >
0744 inline typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::type
0745 extract_or_default(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record_view const& rec, DefaultT const& def_val)
0746 {
0747     typedef typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::extracted_type extracted_type;
0748     value_extractor< extracted_type, fallback_to_default< DefaultT const& >, DescriptorT > extractor(def_val);
0749     return aux::unwrap_value_ref(extractor(keyword.get_name(), rec));
0750 }
0751 
0752 #if !defined(BOOST_LOG_DOXYGEN_PASS)
0753 
0754 template< typename T, typename TagT >
0755 inline typename result_of::extract< T, TagT >::type attribute_value::extract() const
0756 {
0757     return boost::log::extract< T, TagT >(*this);
0758 }
0759 
0760 template< typename T, typename TagT >
0761 inline typename result_of::extract_or_throw< T, TagT >::type attribute_value::extract_or_throw() const
0762 {
0763     return boost::log::extract_or_throw< T, TagT >(*this);
0764 }
0765 
0766 template< typename T, typename TagT >
0767 inline typename result_of::extract_or_default< T, T, TagT >::type attribute_value::extract_or_default(T const& def_value) const
0768 {
0769     return boost::log::extract_or_default< T, TagT >(*this, def_value);
0770 }
0771 
0772 template< typename T, typename TagT, typename DefaultT >
0773 inline typename result_of::extract_or_default< T, DefaultT, TagT >::type attribute_value::extract_or_default(DefaultT const& def_value) const
0774 {
0775     return boost::log::extract_or_default< T, TagT >(*this, def_value);
0776 }
0777 
0778 #if defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
0779 
0780 template< typename T >
0781 inline typename result_of::extract< T >::type attribute_value::extract() const
0782 {
0783     return boost::log::extract< T >(*this);
0784 }
0785 
0786 template< typename T >
0787 inline typename result_of::extract_or_throw< T >::type attribute_value::extract_or_throw() const
0788 {
0789     return boost::log::extract_or_throw< T >(*this);
0790 }
0791 
0792 template< typename T >
0793 inline typename result_of::extract_or_default< T, T >::type attribute_value::extract_or_default(T const& def_value) const
0794 {
0795     return boost::log::extract_or_default< T >(*this, def_value);
0796 }
0797 
0798 template< typename T, typename DefaultT >
0799 inline typename result_of::extract_or_default< T, DefaultT >::type attribute_value::extract_or_default(DefaultT const& def_value) const
0800 {
0801     return boost::log::extract_or_default< T >(*this, def_value);
0802 }
0803 
0804 #endif // defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
0805 
0806 #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
0807 
0808 #undef BOOST_LOG_AUX_VOID_DEFAULT
0809 
0810 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0811 
0812 } // namespace boost
0813 
0814 #include <boost/log/detail/footer.hpp>
0815 
0816 #endif // BOOST_LOG_ATTRIBUTES_VALUE_EXTRACTION_HPP_INCLUDED_