File indexing completed on 2025-01-18 09:39:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_UTILITY_MANIPULATORS_ADD_VALUE_HPP_INCLUDED_
0016 #define BOOST_LOG_UTILITY_MANIPULATORS_ADD_VALUE_HPP_INCLUDED_
0017
0018 #include <boost/type_traits/is_scalar.hpp>
0019 #include <boost/type_traits/remove_cv.hpp>
0020 #include <boost/type_traits/remove_reference.hpp>
0021 #include <boost/type_traits/conditional.hpp>
0022 #include <boost/log/detail/config.hpp>
0023 #include <boost/log/detail/embedded_string_type.hpp>
0024 #include <boost/log/attributes/attribute_name.hpp>
0025 #include <boost/log/attributes/attribute_value_impl.hpp>
0026 #include <boost/log/expressions/keyword_fwd.hpp>
0027 #include <boost/log/sources/record_ostream.hpp>
0028 #include <boost/log/detail/header.hpp>
0029
0030 #ifdef BOOST_HAS_PRAGMA_ONCE
0031 #pragma once
0032 #endif
0033
0034 #ifdef _MSC_VER
0035 #pragma warning(push)
0036
0037
0038 #pragma warning(disable: 4413)
0039
0040
0041 #pragma warning(disable: 4172)
0042 #endif
0043
0044 namespace boost {
0045
0046 BOOST_LOG_OPEN_NAMESPACE
0047
0048
0049 template< typename RefT >
0050 class add_value_manip
0051 {
0052 public:
0053
0054 typedef RefT reference_type;
0055
0056 typedef typename remove_cv< typename remove_reference< reference_type >::type >::type value_type;
0057
0058 private:
0059
0060
0061
0062 typedef typename remove_reference< reference_type >::type& lvalue_reference_type;
0063
0064 typedef typename conditional<
0065 is_scalar< value_type >::value,
0066 value_type,
0067 lvalue_reference_type
0068 >::type stored_type;
0069
0070 typedef typename conditional<
0071 is_scalar< value_type >::value,
0072 value_type,
0073 reference_type
0074 >::type get_value_result_type;
0075
0076 private:
0077
0078 stored_type m_value;
0079
0080 attribute_name m_name;
0081
0082 public:
0083
0084 add_value_manip(attribute_name const& name, reference_type value) : m_value(static_cast< lvalue_reference_type >(value)), m_name(name)
0085 {
0086 }
0087
0088
0089 attribute_name get_name() const { return m_name; }
0090
0091 get_value_result_type get_value() const { return static_cast< get_value_result_type >(m_value); }
0092 };
0093
0094
0095 template< typename CharT, typename RefT >
0096 inline basic_record_ostream< CharT >& operator<< (basic_record_ostream< CharT >& strm, add_value_manip< RefT > const& manip)
0097 {
0098 typedef typename aux::make_embedded_string_type< typename add_value_manip< RefT >::value_type >::type value_type;
0099 attribute_value value(new attributes::attribute_value_impl< value_type >(manip.get_value()));
0100 strm.get_record().attribute_values().insert(manip.get_name(), value);
0101 return strm;
0102 }
0103
0104
0105 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
0106
0107 template< typename T >
0108 inline add_value_manip< T&& > add_value(attribute_name const& name, T&& value)
0109 {
0110 return add_value_manip< T&& >(name, static_cast< T&& >(value));
0111 }
0112
0113
0114 template< typename DescriptorT, template< typename > class ActorT >
0115 inline add_value_manip< typename DescriptorT::value_type&& >
0116 add_value(expressions::attribute_keyword< DescriptorT, ActorT > const&, typename DescriptorT::value_type&& value)
0117 {
0118 typedef typename DescriptorT::value_type value_type;
0119 return add_value_manip< value_type&& >(DescriptorT::get_name(), static_cast< value_type&& >(value));
0120 }
0121
0122
0123 template< typename DescriptorT, template< typename > class ActorT >
0124 inline add_value_manip< typename DescriptorT::value_type& >
0125 add_value(expressions::attribute_keyword< DescriptorT, ActorT > const&, typename DescriptorT::value_type& value)
0126 {
0127 return add_value_manip< typename DescriptorT::value_type& >(DescriptorT::get_name(), value);
0128 }
0129
0130
0131 template< typename DescriptorT, template< typename > class ActorT >
0132 inline add_value_manip< typename DescriptorT::value_type const& >
0133 add_value(expressions::attribute_keyword< DescriptorT, ActorT > const&, typename DescriptorT::value_type const& value)
0134 {
0135 return add_value_manip< typename DescriptorT::value_type const& >(DescriptorT::get_name(), value);
0136 }
0137
0138 #else
0139
0140 template< typename T >
0141 inline add_value_manip< T const& > add_value(attribute_name const& name, T const& value)
0142 {
0143 return add_value_manip< T const& >(name, value);
0144 }
0145
0146 template< typename DescriptorT, template< typename > class ActorT >
0147 inline add_value_manip< typename DescriptorT::value_type const& >
0148 add_value(expressions::attribute_keyword< DescriptorT, ActorT > const&, typename DescriptorT::value_type const& value)
0149 {
0150 return add_value_manip< typename DescriptorT::value_type const& >(DescriptorT::get_name(), value);
0151 }
0152
0153 #endif
0154
0155 BOOST_LOG_CLOSE_NAMESPACE
0156
0157 }
0158
0159 #ifdef _MSC_VER
0160 #pragma warning(pop)
0161 #endif
0162
0163 #include <boost/log/detail/footer.hpp>
0164
0165 #endif