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 value_extraction.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 01.03.2008
|
Chris@16
|
11 *
|
Chris@16
|
12 * The header contains implementation of tools for extracting an attribute value
|
Chris@16
|
13 * from the view.
|
Chris@16
|
14 */
|
Chris@16
|
15
|
Chris@16
|
16 #ifndef BOOST_LOG_ATTRIBUTES_VALUE_EXTRACTION_HPP_INCLUDED_
|
Chris@16
|
17 #define BOOST_LOG_ATTRIBUTES_VALUE_EXTRACTION_HPP_INCLUDED_
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/mpl/vector.hpp>
|
Chris@16
|
20 #include <boost/mpl/joint_view.hpp>
|
Chris@16
|
21 #include <boost/mpl/if.hpp>
|
Chris@16
|
22 #include <boost/mpl/eval_if.hpp>
|
Chris@16
|
23 #include <boost/mpl/identity.hpp>
|
Chris@16
|
24 #include <boost/mpl/is_sequence.hpp>
|
Chris@16
|
25 #include <boost/mpl/contains.hpp>
|
Chris@16
|
26 #include <boost/mpl/push_back.hpp>
|
Chris@16
|
27 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
28 #include <boost/utility/enable_if.hpp>
|
Chris@16
|
29 #include <boost/log/detail/config.hpp>
|
Chris@16
|
30 #include <boost/log/exceptions.hpp>
|
Chris@16
|
31 #include <boost/log/core/record.hpp>
|
Chris@16
|
32 #include <boost/log/attributes/attribute_name.hpp>
|
Chris@16
|
33 #include <boost/log/attributes/attribute_value.hpp>
|
Chris@16
|
34 #include <boost/log/attributes/attribute.hpp>
|
Chris@16
|
35 #include <boost/log/attributes/attribute_value_set.hpp>
|
Chris@16
|
36 #include <boost/log/attributes/value_extraction_fwd.hpp>
|
Chris@16
|
37 #include <boost/log/attributes/fallback_policy.hpp>
|
Chris@16
|
38 #include <boost/log/expressions/keyword_fwd.hpp>
|
Chris@16
|
39 #include <boost/log/utility/value_ref.hpp>
|
Chris@16
|
40 #include <boost/log/utility/type_dispatch/static_type_dispatcher.hpp>
|
Chris@16
|
41 #include <boost/log/detail/header.hpp>
|
Chris@16
|
42
|
Chris@16
|
43 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
44 #pragma once
|
Chris@16
|
45 #endif
|
Chris@16
|
46
|
Chris@16
|
47 namespace boost {
|
Chris@16
|
48
|
Chris@16
|
49 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
50
|
Chris@16
|
51 namespace result_of {
|
Chris@16
|
52
|
Chris@16
|
53 /*!
|
Chris@16
|
54 * \brief A metafunction that allows to acquire the result of the value extraction
|
Chris@16
|
55 *
|
Chris@16
|
56 * The metafunction results in a type that is in form of <tt>T const&</tt>, if \c T is
|
Chris@16
|
57 * not an MPL type sequence and <tt>DefaultT</tt> is the same as <tt>T</tt>,
|
Chris@16
|
58 * or <tt>value_ref< TypesT, TagT ></tt> otherwise, with
|
Chris@16
|
59 * \c TypesT being a type sequence comprising the types from sequence \c T and \c DefaultT,
|
Chris@16
|
60 * if it is not present in \c T already.
|
Chris@16
|
61 */
|
Chris@16
|
62 template< typename T, typename DefaultT, typename TagT >
|
Chris@16
|
63 struct extract_or_default
|
Chris@16
|
64 {
|
Chris@16
|
65 typedef typename mpl::eval_if<
|
Chris@16
|
66 mpl::is_sequence< T >,
|
Chris@16
|
67 mpl::eval_if<
|
Chris@16
|
68 mpl::contains< T, DefaultT >,
|
Chris@16
|
69 mpl::identity< T >,
|
Chris@16
|
70 mpl::push_back< T, DefaultT >
|
Chris@16
|
71 >,
|
Chris@16
|
72 mpl::if_<
|
Chris@16
|
73 is_same< T, DefaultT >,
|
Chris@16
|
74 T,
|
Chris@16
|
75 mpl::vector2< T, DefaultT >
|
Chris@16
|
76 >
|
Chris@16
|
77 >::type extracted_type;
|
Chris@16
|
78
|
Chris@16
|
79 typedef typename mpl::if_<
|
Chris@16
|
80 mpl::is_sequence< extracted_type >,
|
Chris@16
|
81 value_ref< extracted_type, TagT >,
|
Chris@16
|
82 extracted_type const&
|
Chris@16
|
83 >::type type;
|
Chris@16
|
84 };
|
Chris@16
|
85
|
Chris@16
|
86 /*!
|
Chris@16
|
87 * \brief A metafunction that allows to acquire the result of the value extraction
|
Chris@16
|
88 *
|
Chris@16
|
89 * The metafunction results in a type that is in form of <tt>T const&</tt>, if \c T is
|
Chris@16
|
90 * not an MPL type sequence, or <tt>value_ref< T, TagT ></tt> otherwise. In the latter
|
Chris@16
|
91 * case the value reference shall never be empty.
|
Chris@16
|
92 */
|
Chris@16
|
93 template< typename T, typename TagT >
|
Chris@16
|
94 struct extract_or_throw
|
Chris@16
|
95 {
|
Chris@16
|
96 typedef typename mpl::if_<
|
Chris@16
|
97 mpl::is_sequence< T >,
|
Chris@16
|
98 value_ref< T, TagT >,
|
Chris@16
|
99 T const&
|
Chris@16
|
100 >::type type;
|
Chris@16
|
101 };
|
Chris@16
|
102
|
Chris@16
|
103 /*!
|
Chris@16
|
104 * \brief A metafunction that allows to acquire the result of the value extraction
|
Chris@16
|
105 *
|
Chris@16
|
106 * The metafunction results in a type that is in form of <tt>value_ref< T, TagT ></tt>.
|
Chris@16
|
107 */
|
Chris@16
|
108 template< typename T, typename TagT >
|
Chris@16
|
109 struct extract
|
Chris@16
|
110 {
|
Chris@16
|
111 typedef value_ref< T, TagT > type;
|
Chris@16
|
112 };
|
Chris@16
|
113
|
Chris@16
|
114 } // namespace result_of
|
Chris@16
|
115
|
Chris@16
|
116 namespace aux {
|
Chris@16
|
117
|
Chris@16
|
118 //! The function object initializes the value reference
|
Chris@16
|
119 template< typename RefT >
|
Chris@16
|
120 struct value_ref_initializer
|
Chris@16
|
121 {
|
Chris@16
|
122 typedef void result_type;
|
Chris@16
|
123
|
Chris@16
|
124 value_ref_initializer(RefT& ref) : m_ref(ref)
|
Chris@16
|
125 {
|
Chris@16
|
126 }
|
Chris@16
|
127
|
Chris@16
|
128 template< typename ArgT >
|
Chris@16
|
129 result_type operator() (ArgT const& arg) const
|
Chris@16
|
130 {
|
Chris@16
|
131 m_ref = RefT(arg);
|
Chris@16
|
132 }
|
Chris@16
|
133
|
Chris@16
|
134 private:
|
Chris@16
|
135 RefT& m_ref;
|
Chris@16
|
136 };
|
Chris@16
|
137
|
Chris@16
|
138 //! The function unwraps \c value_ref, if possible
|
Chris@16
|
139 template< typename T, typename TagT >
|
Chris@16
|
140 BOOST_FORCEINLINE typename enable_if< mpl::is_sequence< T >, value_ref< T, TagT > >::type
|
Chris@16
|
141 unwrap_value_ref(value_ref< T, TagT > const& r)
|
Chris@16
|
142 {
|
Chris@16
|
143 return r;
|
Chris@16
|
144 }
|
Chris@16
|
145
|
Chris@16
|
146 template< typename T, typename TagT >
|
Chris@16
|
147 BOOST_FORCEINLINE typename disable_if< mpl::is_sequence< T >, T const& >::type
|
Chris@16
|
148 unwrap_value_ref(value_ref< T, TagT > const& r)
|
Chris@16
|
149 {
|
Chris@16
|
150 return r.get();
|
Chris@16
|
151 }
|
Chris@16
|
152
|
Chris@16
|
153 } // namespace aux
|
Chris@16
|
154
|
Chris@16
|
155 /*!
|
Chris@16
|
156 * \brief Generic attribute value extractor
|
Chris@16
|
157 *
|
Chris@16
|
158 * Attribute value extractor is a functional object that attempts to find and extract the stored
|
Chris@16
|
159 * attribute value from the attribute values view or a log record. The extracted value is returned
|
Chris@16
|
160 * from the extractor.
|
Chris@16
|
161 */
|
Chris@16
|
162 template< typename T, typename FallbackPolicyT, typename TagT >
|
Chris@16
|
163 class value_extractor :
|
Chris@16
|
164 private FallbackPolicyT
|
Chris@16
|
165 {
|
Chris@16
|
166 public:
|
Chris@16
|
167 //! Fallback policy
|
Chris@16
|
168 typedef FallbackPolicyT fallback_policy;
|
Chris@16
|
169 //! Attribute value types
|
Chris@16
|
170 typedef T value_type;
|
Chris@16
|
171 //! Function object result type
|
Chris@16
|
172 typedef value_ref< value_type, TagT > result_type;
|
Chris@16
|
173
|
Chris@16
|
174 public:
|
Chris@16
|
175 /*!
|
Chris@16
|
176 * Default constructor
|
Chris@16
|
177 */
|
Chris@16
|
178 BOOST_DEFAULTED_FUNCTION(value_extractor(), {})
|
Chris@16
|
179
|
Chris@16
|
180 /*!
|
Chris@16
|
181 * Copy constructor
|
Chris@16
|
182 */
|
Chris@16
|
183 value_extractor(value_extractor const& that) : fallback_policy(static_cast< fallback_policy const& >(that))
|
Chris@16
|
184 {
|
Chris@16
|
185 }
|
Chris@16
|
186
|
Chris@16
|
187 /*!
|
Chris@16
|
188 * Constructor
|
Chris@16
|
189 *
|
Chris@16
|
190 * \param arg Fallback policy constructor argument
|
Chris@16
|
191 */
|
Chris@16
|
192 template< typename U >
|
Chris@16
|
193 explicit value_extractor(U const& arg) : fallback_policy(arg) {}
|
Chris@16
|
194
|
Chris@16
|
195 /*!
|
Chris@16
|
196 * Extraction operator. Attempts to acquire the stored value of one of the supported types. If extraction succeeds,
|
Chris@16
|
197 * the extracted value is returned.
|
Chris@16
|
198 *
|
Chris@16
|
199 * \param attr The attribute value to extract from.
|
Chris@16
|
200 * \return The extracted value, if extraction succeeded, an empty value otherwise.
|
Chris@16
|
201 */
|
Chris@16
|
202 result_type operator() (attribute_value const& attr) const
|
Chris@16
|
203 {
|
Chris@16
|
204 result_type res;
|
Chris@16
|
205 aux::value_ref_initializer< result_type > initializer(res);
|
Chris@16
|
206 if (!!attr)
|
Chris@16
|
207 {
|
Chris@16
|
208 static_type_dispatcher< value_type > disp(initializer);
|
Chris@16
|
209 if (!attr.dispatch(disp) && !fallback_policy::apply_default(initializer))
|
Chris@16
|
210 fallback_policy::on_invalid_type(attr.get_type());
|
Chris@16
|
211 }
|
Chris@16
|
212 else if (!fallback_policy::apply_default(initializer))
|
Chris@16
|
213 {
|
Chris@16
|
214 fallback_policy::on_missing_value();
|
Chris@16
|
215 }
|
Chris@16
|
216 return res;
|
Chris@16
|
217 }
|
Chris@16
|
218
|
Chris@16
|
219 /*!
|
Chris@16
|
220 * Extraction operator. Looks for an attribute value with the specified name
|
Chris@16
|
221 * and tries to acquire the stored value of one of the supported types. If extraction succeeds,
|
Chris@16
|
222 * the extracted value is returned.
|
Chris@16
|
223 *
|
Chris@16
|
224 * \param name Attribute value name.
|
Chris@16
|
225 * \param attrs A set of attribute values in which to look for the specified attribute value.
|
Chris@16
|
226 * \return The extracted value, if extraction succeeded, an empty value otherwise.
|
Chris@16
|
227 */
|
Chris@16
|
228 result_type operator() (attribute_name const& name, attribute_value_set const& attrs) const
|
Chris@16
|
229 {
|
Chris@16
|
230 try
|
Chris@16
|
231 {
|
Chris@16
|
232 attribute_value_set::const_iterator it = attrs.find(name);
|
Chris@16
|
233 if (it != attrs.end())
|
Chris@16
|
234 return operator() (it->second);
|
Chris@16
|
235 else
|
Chris@16
|
236 return operator() (attribute_value());
|
Chris@16
|
237 }
|
Chris@16
|
238 catch (exception& e)
|
Chris@16
|
239 {
|
Chris@16
|
240 // Attach the attribute name to the exception
|
Chris@16
|
241 boost::log::aux::attach_attribute_name_info(e, name);
|
Chris@16
|
242 throw;
|
Chris@16
|
243 }
|
Chris@16
|
244 }
|
Chris@16
|
245
|
Chris@16
|
246 /*!
|
Chris@16
|
247 * Extraction operator. Looks for an attribute value with the specified name
|
Chris@16
|
248 * and tries to acquire the stored value of one of the supported types. If extraction succeeds,
|
Chris@16
|
249 * the extracted value is returned.
|
Chris@16
|
250 *
|
Chris@16
|
251 * \param name Attribute value name.
|
Chris@16
|
252 * \param rec A log record. The attribute value will be sought among those associated with the record.
|
Chris@16
|
253 * \return The extracted value, if extraction succeeded, an empty value otherwise.
|
Chris@16
|
254 */
|
Chris@16
|
255 result_type operator() (attribute_name const& name, record const& rec) const
|
Chris@16
|
256 {
|
Chris@16
|
257 return operator() (name, rec.attribute_values());
|
Chris@16
|
258 }
|
Chris@16
|
259
|
Chris@16
|
260 /*!
|
Chris@16
|
261 * Extraction operator. Looks for an attribute value with the specified name
|
Chris@16
|
262 * and tries to acquire the stored value of one of the supported types. If extraction succeeds,
|
Chris@16
|
263 * the extracted value is returned.
|
Chris@16
|
264 *
|
Chris@16
|
265 * \param name Attribute value name.
|
Chris@16
|
266 * \param rec A log record view. The attribute value will be sought among those associated with the record.
|
Chris@16
|
267 * \return The extracted value, if extraction succeeded, an empty value otherwise.
|
Chris@16
|
268 */
|
Chris@16
|
269 result_type operator() (attribute_name const& name, record_view const& rec) const
|
Chris@16
|
270 {
|
Chris@16
|
271 return operator() (name, rec.attribute_values());
|
Chris@16
|
272 }
|
Chris@16
|
273
|
Chris@16
|
274 /*!
|
Chris@16
|
275 * \returns Fallback policy
|
Chris@16
|
276 */
|
Chris@16
|
277 fallback_policy const& get_fallback_policy() const
|
Chris@16
|
278 {
|
Chris@16
|
279 return *static_cast< fallback_policy const* >(this);
|
Chris@16
|
280 }
|
Chris@16
|
281 };
|
Chris@16
|
282
|
Chris@16
|
283 #if !defined(BOOST_LOG_DOXYGEN_PASS)
|
Chris@16
|
284 #if !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
|
Chris@16
|
285 #define BOOST_LOG_AUX_VOID_DEFAULT = void
|
Chris@16
|
286 #else
|
Chris@16
|
287 #define BOOST_LOG_AUX_VOID_DEFAULT
|
Chris@16
|
288 #endif
|
Chris@16
|
289 #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
|
Chris@16
|
290
|
Chris@16
|
291 /*!
|
Chris@16
|
292 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
293 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
294 *
|
Chris@16
|
295 * \param name The name of the attribute value to extract.
|
Chris@16
|
296 * \param attrs A set of attribute values in which to look for the specified attribute value.
|
Chris@16
|
297 * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
|
Chris@16
|
298 */
|
Chris@16
|
299 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
|
Chris@16
|
300 inline typename result_of::extract< T, TagT >::type extract(attribute_name const& name, attribute_value_set const& attrs)
|
Chris@16
|
301 {
|
Chris@16
|
302 value_extractor< T, fallback_to_none, TagT > extractor;
|
Chris@16
|
303 return extractor(name, attrs);
|
Chris@16
|
304 }
|
Chris@16
|
305
|
Chris@16
|
306 /*!
|
Chris@16
|
307 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
308 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
309 *
|
Chris@16
|
310 * \param name The name of the attribute value to extract.
|
Chris@16
|
311 * \param rec A log record. The attribute value will be sought among those associated with the record.
|
Chris@16
|
312 * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
|
Chris@16
|
313 */
|
Chris@16
|
314 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
|
Chris@16
|
315 inline typename result_of::extract< T, TagT >::type extract(attribute_name const& name, record const& rec)
|
Chris@16
|
316 {
|
Chris@16
|
317 value_extractor< T, fallback_to_none, TagT > extractor;
|
Chris@16
|
318 return extractor(name, rec);
|
Chris@16
|
319 }
|
Chris@16
|
320
|
Chris@16
|
321 /*!
|
Chris@16
|
322 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
323 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
324 *
|
Chris@16
|
325 * \param name The name of the attribute value to extract.
|
Chris@16
|
326 * \param rec A log record view. The attribute value will be sought among those associated with the record.
|
Chris@16
|
327 * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
|
Chris@16
|
328 */
|
Chris@16
|
329 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
|
Chris@16
|
330 inline typename result_of::extract< T, TagT >::type extract(attribute_name const& name, record_view const& rec)
|
Chris@16
|
331 {
|
Chris@16
|
332 value_extractor< T, fallback_to_none, TagT > extractor;
|
Chris@16
|
333 return extractor(name, rec);
|
Chris@16
|
334 }
|
Chris@16
|
335
|
Chris@16
|
336 /*!
|
Chris@16
|
337 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
338 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
339 *
|
Chris@16
|
340 * \param value Attribute value.
|
Chris@16
|
341 * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
|
Chris@16
|
342 */
|
Chris@16
|
343 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
|
Chris@16
|
344 inline typename result_of::extract< T, TagT >::type extract(attribute_value const& value)
|
Chris@16
|
345 {
|
Chris@16
|
346 value_extractor< T, fallback_to_none, TagT > extractor;
|
Chris@16
|
347 return extractor(value);
|
Chris@16
|
348 }
|
Chris@16
|
349
|
Chris@16
|
350 /*!
|
Chris@16
|
351 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
352 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
353 *
|
Chris@16
|
354 * \param name The name of the attribute value to extract.
|
Chris@16
|
355 * \param attrs A set of attribute values in which to look for the specified attribute value.
|
Chris@16
|
356 * \return The extracted value or a non-empty \c value_ref that refers to the value.
|
Chris@16
|
357 * \throws An exception is thrown if the requested value cannot be extracted.
|
Chris@16
|
358 */
|
Chris@16
|
359 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
|
Chris@16
|
360 inline typename result_of::extract_or_throw< T, TagT >::type extract_or_throw(attribute_name const& name, attribute_value_set const& attrs)
|
Chris@16
|
361 {
|
Chris@16
|
362 value_extractor< T, fallback_to_throw, TagT > extractor;
|
Chris@16
|
363 return aux::unwrap_value_ref(extractor(name, attrs));
|
Chris@16
|
364 }
|
Chris@16
|
365
|
Chris@16
|
366 /*!
|
Chris@16
|
367 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
368 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
369 *
|
Chris@16
|
370 * \param name The name of the attribute value to extract.
|
Chris@16
|
371 * \param rec A log record. The attribute value will be sought among those associated with the record.
|
Chris@16
|
372 * \return The extracted value or a non-empty \c value_ref that refers to the value.
|
Chris@16
|
373 * \throws An exception is thrown if the requested value cannot be extracted.
|
Chris@16
|
374 */
|
Chris@16
|
375 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
|
Chris@16
|
376 inline typename result_of::extract_or_throw< T, TagT >::type extract_or_throw(attribute_name const& name, record const& rec)
|
Chris@16
|
377 {
|
Chris@16
|
378 value_extractor< T, fallback_to_throw, TagT > extractor;
|
Chris@16
|
379 return aux::unwrap_value_ref(extractor(name, rec));
|
Chris@16
|
380 }
|
Chris@16
|
381
|
Chris@16
|
382 /*!
|
Chris@16
|
383 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
384 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
385 *
|
Chris@16
|
386 * \param name The name of the attribute value to extract.
|
Chris@16
|
387 * \param rec A log record view. The attribute value will be sought among those associated with the record.
|
Chris@16
|
388 * \return The extracted value or a non-empty \c value_ref that refers to the value.
|
Chris@16
|
389 * \throws An exception is thrown if the requested value cannot be extracted.
|
Chris@16
|
390 */
|
Chris@16
|
391 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
|
Chris@16
|
392 inline typename result_of::extract_or_throw< T, TagT >::type extract_or_throw(attribute_name const& name, record_view const& rec)
|
Chris@16
|
393 {
|
Chris@16
|
394 value_extractor< T, fallback_to_throw, TagT > extractor;
|
Chris@16
|
395 return aux::unwrap_value_ref(extractor(name, rec));
|
Chris@16
|
396 }
|
Chris@16
|
397
|
Chris@16
|
398 /*!
|
Chris@16
|
399 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
400 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
401 *
|
Chris@16
|
402 * \param value Attribute value.
|
Chris@16
|
403 * \return The extracted value or a non-empty \c value_ref that refers to the value.
|
Chris@16
|
404 * \throws An exception is thrown if the requested value cannot be extracted.
|
Chris@16
|
405 */
|
Chris@16
|
406 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT >
|
Chris@16
|
407 inline typename result_of::extract_or_throw< T, TagT >::type extract_or_throw(attribute_value const& value)
|
Chris@16
|
408 {
|
Chris@16
|
409 value_extractor< T, fallback_to_throw, TagT > extractor;
|
Chris@16
|
410 return aux::unwrap_value_ref(extractor(value));
|
Chris@16
|
411 }
|
Chris@16
|
412
|
Chris@16
|
413 /*!
|
Chris@16
|
414 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
415 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
416 *
|
Chris@16
|
417 * \note Caution must be exercised if the default value is a temporary object. Because the function returns
|
Chris@16
|
418 * a reference, if the temporary object is destroyed, the reference may become dangling.
|
Chris@16
|
419 *
|
Chris@16
|
420 * \param name The name of the attribute value to extract.
|
Chris@16
|
421 * \param attrs A set of attribute values in which to look for the specified attribute value.
|
Chris@16
|
422 * \param def_val The default value
|
Chris@16
|
423 * \return The extracted value, if found. The default value otherwise.
|
Chris@16
|
424 */
|
Chris@16
|
425 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT, typename DefaultT >
|
Chris@16
|
426 inline typename result_of::extract_or_default< T, DefaultT, TagT >::type
|
Chris@16
|
427 extract_or_default(attribute_name const& name, attribute_value_set const& attrs, DefaultT const& def_val)
|
Chris@16
|
428 {
|
Chris@16
|
429 typedef typename result_of::extract_or_default< T, DefaultT, TagT >::extracted_type extracted_type;
|
Chris@16
|
430 value_extractor< extracted_type, fallback_to_default< DefaultT const& >, TagT > extractor(def_val);
|
Chris@16
|
431 return aux::unwrap_value_ref(extractor(name, attrs));
|
Chris@16
|
432 }
|
Chris@16
|
433
|
Chris@16
|
434 /*!
|
Chris@16
|
435 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
436 * type or set of possible types of the attribute value to be visited.
|
Chris@16
|
437 *
|
Chris@16
|
438 * \note Caution must be exercised if the default value is a temporary object. Because the function returns
|
Chris@16
|
439 * a reference, if the temporary object is destroyed, the reference may become dangling.
|
Chris@16
|
440 *
|
Chris@16
|
441 * \param name The name of the attribute value to extract.
|
Chris@16
|
442 * \param rec A log record. The attribute value will be sought among those associated with the record.
|
Chris@16
|
443 * \param def_val The default value
|
Chris@16
|
444 * \return The extracted value, if found. The default value otherwise.
|
Chris@16
|
445 */
|
Chris@16
|
446 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT, typename DefaultT >
|
Chris@16
|
447 inline typename result_of::extract_or_default< T, DefaultT, TagT >::type
|
Chris@16
|
448 extract_or_default(attribute_name const& name, record const& rec, DefaultT const& def_val)
|
Chris@16
|
449 {
|
Chris@16
|
450 typedef typename result_of::extract_or_default< T, DefaultT, TagT >::extracted_type extracted_type;
|
Chris@16
|
451 value_extractor< extracted_type, fallback_to_default< DefaultT const& >, TagT > extractor(def_val);
|
Chris@16
|
452 return aux::unwrap_value_ref(extractor(name, rec));
|
Chris@16
|
453 }
|
Chris@16
|
454
|
Chris@16
|
455 /*!
|
Chris@16
|
456 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
457 * type or set of possible types of the attribute value to be visited.
|
Chris@16
|
458 *
|
Chris@16
|
459 * \note Caution must be exercised if the default value is a temporary object. Because the function returns
|
Chris@16
|
460 * a reference, if the temporary object is destroyed, the reference may become dangling.
|
Chris@16
|
461 *
|
Chris@16
|
462 * \param name The name of the attribute value to extract.
|
Chris@16
|
463 * \param rec A log record view. The attribute value will be sought among those associated with the record.
|
Chris@16
|
464 * \param def_val The default value
|
Chris@16
|
465 * \return The extracted value, if found. The default value otherwise.
|
Chris@16
|
466 */
|
Chris@16
|
467 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT, typename DefaultT >
|
Chris@16
|
468 inline typename result_of::extract_or_default< T, DefaultT, TagT >::type
|
Chris@16
|
469 extract_or_default(attribute_name const& name, record_view const& rec, DefaultT const& def_val)
|
Chris@16
|
470 {
|
Chris@16
|
471 typedef typename result_of::extract_or_default< T, DefaultT, TagT >::extracted_type extracted_type;
|
Chris@16
|
472 value_extractor< extracted_type, fallback_to_default< DefaultT const& >, TagT > extractor(def_val);
|
Chris@16
|
473 return aux::unwrap_value_ref(extractor(name, rec));
|
Chris@16
|
474 }
|
Chris@16
|
475
|
Chris@16
|
476 /*!
|
Chris@16
|
477 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
478 * type or set of possible types of the attribute value to be visited.
|
Chris@16
|
479 *
|
Chris@16
|
480 * \note Caution must be exercised if the default value is a temporary object. Because the function returns
|
Chris@16
|
481 * a reference, if the temporary object is destroyed, the reference may become dangling.
|
Chris@16
|
482 *
|
Chris@16
|
483 * \param value Attribute value.
|
Chris@16
|
484 * \param def_val The default value
|
Chris@16
|
485 * \return The extracted value, if found. The default value otherwise.
|
Chris@16
|
486 */
|
Chris@16
|
487 template< typename T, typename TagT BOOST_LOG_AUX_VOID_DEFAULT, typename DefaultT >
|
Chris@16
|
488 inline typename result_of::extract_or_default< T, DefaultT, TagT >::type extract_or_default(attribute_value const& value, DefaultT const& def_val)
|
Chris@16
|
489 {
|
Chris@16
|
490 typedef typename result_of::extract_or_default< T, DefaultT, TagT >::extracted_type extracted_type;
|
Chris@16
|
491 value_extractor< extracted_type, fallback_to_default< DefaultT const& >, TagT > extractor(def_val);
|
Chris@16
|
492 return aux::unwrap_value_ref(extractor(value));
|
Chris@16
|
493 }
|
Chris@16
|
494
|
Chris@16
|
495 #if defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
|
Chris@16
|
496
|
Chris@16
|
497 template< typename T >
|
Chris@16
|
498 inline typename result_of::extract< T >::type extract(attribute_name const& name, attribute_value_set const& attrs)
|
Chris@16
|
499 {
|
Chris@16
|
500 value_extractor< T, fallback_to_none > extractor;
|
Chris@16
|
501 return extractor(name, attrs);
|
Chris@16
|
502 }
|
Chris@16
|
503
|
Chris@16
|
504 template< typename T >
|
Chris@16
|
505 inline typename result_of::extract< T >::type extract(attribute_name const& name, record const& rec)
|
Chris@16
|
506 {
|
Chris@16
|
507 value_extractor< T, fallback_to_none > extractor;
|
Chris@16
|
508 return extractor(name, rec);
|
Chris@16
|
509 }
|
Chris@16
|
510
|
Chris@16
|
511 template< typename T >
|
Chris@16
|
512 inline typename result_of::extract< T >::type extract(attribute_name const& name, record_view const& rec)
|
Chris@16
|
513 {
|
Chris@16
|
514 value_extractor< T, fallback_to_none > extractor;
|
Chris@16
|
515 return extractor(name, rec);
|
Chris@16
|
516 }
|
Chris@16
|
517
|
Chris@16
|
518 template< typename T >
|
Chris@16
|
519 inline typename result_of::extract< T >::type extract(attribute_value const& value)
|
Chris@16
|
520 {
|
Chris@16
|
521 value_extractor< T, fallback_to_none > extractor;
|
Chris@16
|
522 return extractor(value);
|
Chris@16
|
523 }
|
Chris@16
|
524
|
Chris@16
|
525 template< typename T >
|
Chris@16
|
526 inline typename result_of::extract_or_throw< T >::type extract_or_throw(attribute_name const& name, attribute_value_set const& attrs)
|
Chris@16
|
527 {
|
Chris@16
|
528 value_extractor< T, fallback_to_throw > extractor;
|
Chris@16
|
529 return aux::unwrap_value_ref(extractor(name, attrs));
|
Chris@16
|
530 }
|
Chris@16
|
531
|
Chris@16
|
532 template< typename T >
|
Chris@16
|
533 inline typename result_of::extract_or_throw< T >::type extract_or_throw(attribute_name const& name, record const& rec)
|
Chris@16
|
534 {
|
Chris@16
|
535 value_extractor< T, fallback_to_throw > extractor;
|
Chris@16
|
536 return aux::unwrap_value_ref(extractor(name, rec));
|
Chris@16
|
537 }
|
Chris@16
|
538
|
Chris@16
|
539 template< typename T >
|
Chris@16
|
540 inline typename result_of::extract_or_throw< T >::type extract_or_throw(attribute_name const& name, record_view const& rec)
|
Chris@16
|
541 {
|
Chris@16
|
542 value_extractor< T, fallback_to_throw > extractor;
|
Chris@16
|
543 return aux::unwrap_value_ref(extractor(name, rec));
|
Chris@16
|
544 }
|
Chris@16
|
545
|
Chris@16
|
546 template< typename T >
|
Chris@16
|
547 inline typename result_of::extract_or_throw< T >::type extract_or_throw(attribute_value const& value)
|
Chris@16
|
548 {
|
Chris@16
|
549 value_extractor< T, fallback_to_throw > extractor;
|
Chris@16
|
550 return aux::unwrap_value_ref(extractor(value));
|
Chris@16
|
551 }
|
Chris@16
|
552
|
Chris@16
|
553 template< typename T, typename DefaultT >
|
Chris@16
|
554 inline typename result_of::extract_or_default< T, DefaultT >::type extract_or_default(
|
Chris@16
|
555 attribute_name const& name, attribute_value_set const& attrs, DefaultT const& def_val)
|
Chris@16
|
556 {
|
Chris@16
|
557 typedef typename result_of::extract_or_default< T, DefaultT >::extracted_type extracted_type;
|
Chris@16
|
558 value_extractor< extracted_type, fallback_to_default< DefaultT const& > > extractor(def_val);
|
Chris@16
|
559 return aux::unwrap_value_ref(extractor(name, attrs));
|
Chris@16
|
560 }
|
Chris@16
|
561
|
Chris@16
|
562 template< typename T, typename DefaultT >
|
Chris@16
|
563 inline typename result_of::extract_or_default< T, DefaultT >::type extract_or_default(
|
Chris@16
|
564 attribute_name const& name, record const& rec, DefaultT const& def_val)
|
Chris@16
|
565 {
|
Chris@16
|
566 typedef typename result_of::extract_or_default< T, DefaultT >::extracted_type extracted_type;
|
Chris@16
|
567 value_extractor< extracted_type, fallback_to_default< DefaultT const& > > extractor(def_val);
|
Chris@16
|
568 return aux::unwrap_value_ref(extractor(name, rec));
|
Chris@16
|
569 }
|
Chris@16
|
570
|
Chris@16
|
571 template< typename T, typename DefaultT >
|
Chris@16
|
572 inline typename result_of::extract_or_default< T, DefaultT >::type extract_or_default(
|
Chris@16
|
573 attribute_name const& name, record_view const& rec, DefaultT const& def_val)
|
Chris@16
|
574 {
|
Chris@16
|
575 typedef typename result_of::extract_or_default< T, DefaultT >::extracted_type extracted_type;
|
Chris@16
|
576 value_extractor< extracted_type, fallback_to_default< DefaultT const& > > extractor(def_val);
|
Chris@16
|
577 return aux::unwrap_value_ref(extractor(name, rec));
|
Chris@16
|
578 }
|
Chris@16
|
579
|
Chris@16
|
580 template< typename T, typename DefaultT >
|
Chris@16
|
581 inline typename result_of::extract_or_default< T, DefaultT >::type extract_or_default(attribute_value const& value, DefaultT const& def_val)
|
Chris@16
|
582 {
|
Chris@16
|
583 typedef typename result_of::extract_or_default< T, DefaultT >::extracted_type extracted_type;
|
Chris@16
|
584 value_extractor< extracted_type, fallback_to_default< DefaultT const& > > extractor(def_val);
|
Chris@16
|
585 return aux::unwrap_value_ref(extractor(value));
|
Chris@16
|
586 }
|
Chris@16
|
587
|
Chris@16
|
588 #endif // defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
|
Chris@16
|
589
|
Chris@16
|
590 /*!
|
Chris@16
|
591 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
592 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
593 *
|
Chris@16
|
594 * \param keyword The keyword of the attribute value to extract.
|
Chris@16
|
595 * \param attrs A set of attribute values in which to look for the specified attribute value.
|
Chris@16
|
596 * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
|
Chris@16
|
597 */
|
Chris@16
|
598 template< typename DescriptorT, template< typename > class ActorT >
|
Chris@16
|
599 inline typename result_of::extract< typename DescriptorT::value_type, DescriptorT >::type
|
Chris@16
|
600 extract(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, attribute_value_set const& attrs)
|
Chris@16
|
601 {
|
Chris@16
|
602 value_extractor< typename DescriptorT::value_type, fallback_to_none, DescriptorT > extractor;
|
Chris@16
|
603 return extractor(keyword.get_name(), attrs);
|
Chris@16
|
604 }
|
Chris@16
|
605
|
Chris@16
|
606 /*!
|
Chris@16
|
607 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
608 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
609 *
|
Chris@16
|
610 * \param keyword The keyword of the attribute value to extract.
|
Chris@16
|
611 * \param rec A log record. The attribute value will be sought among those associated with the record.
|
Chris@16
|
612 * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
|
Chris@16
|
613 */
|
Chris@16
|
614 template< typename DescriptorT, template< typename > class ActorT >
|
Chris@16
|
615 inline typename result_of::extract< typename DescriptorT::value_type, DescriptorT >::type
|
Chris@16
|
616 extract(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record const& rec)
|
Chris@16
|
617 {
|
Chris@16
|
618 value_extractor< typename DescriptorT::value_type, fallback_to_none, DescriptorT > extractor;
|
Chris@16
|
619 return extractor(keyword.get_name(), rec);
|
Chris@16
|
620 }
|
Chris@16
|
621
|
Chris@16
|
622 /*!
|
Chris@16
|
623 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
624 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
625 *
|
Chris@16
|
626 * \param keyword The keyword of the attribute value to extract.
|
Chris@16
|
627 * \param rec A log record view. The attribute value will be sought among those associated with the record.
|
Chris@16
|
628 * \return A \c value_ref that refers to the extracted value, if found. An empty value otherwise.
|
Chris@16
|
629 */
|
Chris@16
|
630 template< typename DescriptorT, template< typename > class ActorT >
|
Chris@16
|
631 inline typename result_of::extract< typename DescriptorT::value_type, DescriptorT >::type
|
Chris@16
|
632 extract(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record_view const& rec)
|
Chris@16
|
633 {
|
Chris@16
|
634 value_extractor< typename DescriptorT::value_type, fallback_to_none, DescriptorT > extractor;
|
Chris@16
|
635 return extractor(keyword.get_name(), rec);
|
Chris@16
|
636 }
|
Chris@16
|
637
|
Chris@16
|
638 /*!
|
Chris@16
|
639 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
640 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
641 *
|
Chris@16
|
642 * \param keyword The keyword of the attribute value to extract.
|
Chris@16
|
643 * \param attrs A set of attribute values in which to look for the specified attribute value.
|
Chris@16
|
644 * \return The extracted value or a non-empty \c value_ref that refers to the value.
|
Chris@16
|
645 * \throws An exception is thrown if the requested value cannot be extracted.
|
Chris@16
|
646 */
|
Chris@16
|
647 template< typename DescriptorT, template< typename > class ActorT >
|
Chris@16
|
648 inline typename result_of::extract_or_throw< typename DescriptorT::value_type, DescriptorT >::type
|
Chris@16
|
649 extract_or_throw(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, attribute_value_set const& attrs)
|
Chris@16
|
650 {
|
Chris@16
|
651 value_extractor< typename DescriptorT::value_type, fallback_to_throw, DescriptorT > extractor;
|
Chris@16
|
652 return aux::unwrap_value_ref(extractor(keyword.get_name(), attrs));
|
Chris@16
|
653 }
|
Chris@16
|
654
|
Chris@16
|
655 /*!
|
Chris@16
|
656 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
657 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
658 *
|
Chris@16
|
659 * \param keyword The keyword of the attribute value to extract.
|
Chris@16
|
660 * \param rec A log record. The attribute value will be sought among those associated with the record.
|
Chris@16
|
661 * \return The extracted value or a non-empty \c value_ref that refers to the value.
|
Chris@16
|
662 * \throws An exception is thrown if the requested value cannot be extracted.
|
Chris@16
|
663 */
|
Chris@16
|
664 template< typename DescriptorT, template< typename > class ActorT >
|
Chris@16
|
665 inline typename result_of::extract_or_throw< typename DescriptorT::value_type, DescriptorT >::type
|
Chris@16
|
666 extract_or_throw(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record const& rec)
|
Chris@16
|
667 {
|
Chris@16
|
668 value_extractor< typename DescriptorT::value_type, fallback_to_throw, DescriptorT > extractor;
|
Chris@16
|
669 return aux::unwrap_value_ref(extractor(keyword.get_name(), rec));
|
Chris@16
|
670 }
|
Chris@16
|
671
|
Chris@16
|
672 /*!
|
Chris@16
|
673 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
674 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
675 *
|
Chris@16
|
676 * \param keyword The keyword of the attribute value to extract.
|
Chris@16
|
677 * \param rec A log record view. The attribute value will be sought among those associated with the record.
|
Chris@16
|
678 * \return The extracted value or a non-empty \c value_ref that refers to the value.
|
Chris@16
|
679 * \throws An exception is thrown if the requested value cannot be extracted.
|
Chris@16
|
680 */
|
Chris@16
|
681 template< typename DescriptorT, template< typename > class ActorT >
|
Chris@16
|
682 inline typename result_of::extract_or_throw< typename DescriptorT::value_type, DescriptorT >::type
|
Chris@16
|
683 extract_or_throw(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record_view const& rec)
|
Chris@16
|
684 {
|
Chris@16
|
685 value_extractor< typename DescriptorT::value_type, fallback_to_throw, DescriptorT > extractor;
|
Chris@16
|
686 return aux::unwrap_value_ref(extractor(keyword.get_name(), rec));
|
Chris@16
|
687 }
|
Chris@16
|
688
|
Chris@16
|
689 /*!
|
Chris@16
|
690 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
691 * type or set of possible types of the attribute value to be extracted.
|
Chris@16
|
692 *
|
Chris@16
|
693 * \note Caution must be exercised if the default value is a temporary object. Because the function returns
|
Chris@16
|
694 * a reference, if the temporary object is destroyed, the reference may become dangling.
|
Chris@16
|
695 *
|
Chris@16
|
696 * \param keyword The keyword of the attribute value to extract.
|
Chris@16
|
697 * \param attrs A set of attribute values in which to look for the specified attribute value.
|
Chris@16
|
698 * \param def_val The default value
|
Chris@16
|
699 * \return The extracted value, if found. The default value otherwise.
|
Chris@16
|
700 */
|
Chris@16
|
701 template< typename DescriptorT, template< typename > class ActorT, typename DefaultT >
|
Chris@16
|
702 inline typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::type
|
Chris@16
|
703 extract_or_default(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, attribute_value_set const& attrs, DefaultT const& def_val)
|
Chris@16
|
704 {
|
Chris@16
|
705 typedef typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::extracted_type extracted_type;
|
Chris@16
|
706 value_extractor< extracted_type, fallback_to_default< DefaultT const& >, DescriptorT > extractor(def_val);
|
Chris@16
|
707 return aux::unwrap_value_ref(extractor(keyword.get_name(), attrs));
|
Chris@16
|
708 }
|
Chris@16
|
709
|
Chris@16
|
710 /*!
|
Chris@16
|
711 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
712 * type or set of possible types of the attribute value to be visited.
|
Chris@16
|
713 *
|
Chris@16
|
714 * \note Caution must be exercised if the default value is a temporary object. Because the function returns
|
Chris@16
|
715 * a reference, if the temporary object is destroyed, the reference may become dangling.
|
Chris@16
|
716 *
|
Chris@16
|
717 * \param keyword The keyword of the attribute value to extract.
|
Chris@16
|
718 * \param rec A log record. The attribute value will be sought among those associated with the record.
|
Chris@16
|
719 * \param def_val The default value
|
Chris@16
|
720 * \return The extracted value, if found. The default value otherwise.
|
Chris@16
|
721 */
|
Chris@16
|
722 template< typename DescriptorT, template< typename > class ActorT, typename DefaultT >
|
Chris@16
|
723 inline typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::type
|
Chris@16
|
724 extract_or_default(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record const& rec, DefaultT const& def_val)
|
Chris@16
|
725 {
|
Chris@16
|
726 typedef typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::extracted_type extracted_type;
|
Chris@16
|
727 value_extractor< extracted_type, fallback_to_default< DefaultT const& >, DescriptorT > extractor(def_val);
|
Chris@16
|
728 return aux::unwrap_value_ref(extractor(keyword.get_name(), rec));
|
Chris@16
|
729 }
|
Chris@16
|
730
|
Chris@16
|
731 /*!
|
Chris@16
|
732 * The function extracts an attribute value from the view. The user has to explicitly specify the
|
Chris@16
|
733 * type or set of possible types of the attribute value to be visited.
|
Chris@16
|
734 *
|
Chris@16
|
735 * \note Caution must be exercised if the default value is a temporary object. Because the function returns
|
Chris@16
|
736 * a reference, if the temporary object is destroyed, the reference may become dangling.
|
Chris@16
|
737 *
|
Chris@16
|
738 * \param keyword The keyword of the attribute value to extract.
|
Chris@16
|
739 * \param rec A log record view. The attribute value will be sought among those associated with the record.
|
Chris@16
|
740 * \param def_val The default value
|
Chris@16
|
741 * \return The extracted value, if found. The default value otherwise.
|
Chris@16
|
742 */
|
Chris@16
|
743 template< typename DescriptorT, template< typename > class ActorT, typename DefaultT >
|
Chris@16
|
744 inline typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::type
|
Chris@16
|
745 extract_or_default(expressions::attribute_keyword< DescriptorT, ActorT > const& keyword, record_view const& rec, DefaultT const& def_val)
|
Chris@16
|
746 {
|
Chris@16
|
747 typedef typename result_of::extract_or_default< typename DescriptorT::value_type, DefaultT, DescriptorT >::extracted_type extracted_type;
|
Chris@16
|
748 value_extractor< extracted_type, fallback_to_default< DefaultT const& >, DescriptorT > extractor(def_val);
|
Chris@16
|
749 return aux::unwrap_value_ref(extractor(keyword.get_name(), rec));
|
Chris@16
|
750 }
|
Chris@16
|
751
|
Chris@16
|
752 #if !defined(BOOST_LOG_DOXYGEN_PASS)
|
Chris@16
|
753
|
Chris@16
|
754 template< typename T, typename TagT >
|
Chris@16
|
755 inline typename result_of::extract< T, TagT >::type attribute_value::extract() const
|
Chris@16
|
756 {
|
Chris@16
|
757 return boost::log::extract< T, TagT >(*this);
|
Chris@16
|
758 }
|
Chris@16
|
759
|
Chris@16
|
760 template< typename T, typename TagT >
|
Chris@16
|
761 inline typename result_of::extract_or_throw< T, TagT >::type attribute_value::extract_or_throw() const
|
Chris@16
|
762 {
|
Chris@16
|
763 return boost::log::extract_or_throw< T, TagT >(*this);
|
Chris@16
|
764 }
|
Chris@16
|
765
|
Chris@16
|
766 template< typename T, typename TagT >
|
Chris@16
|
767 inline typename result_of::extract_or_default< T, T, TagT >::type attribute_value::extract_or_default(T const& def_value) const
|
Chris@16
|
768 {
|
Chris@16
|
769 return boost::log::extract_or_default< T, TagT >(*this, def_value);
|
Chris@16
|
770 }
|
Chris@16
|
771
|
Chris@16
|
772 template< typename T, typename TagT, typename DefaultT >
|
Chris@16
|
773 inline typename result_of::extract_or_default< T, DefaultT, TagT >::type attribute_value::extract_or_default(DefaultT const& def_value) const
|
Chris@16
|
774 {
|
Chris@16
|
775 return boost::log::extract_or_default< T, TagT >(*this, def_value);
|
Chris@16
|
776 }
|
Chris@16
|
777
|
Chris@16
|
778 #if defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
|
Chris@16
|
779
|
Chris@16
|
780 template< typename T >
|
Chris@16
|
781 inline typename result_of::extract< T >::type attribute_value::extract() const
|
Chris@16
|
782 {
|
Chris@16
|
783 return boost::log::extract< T >(*this);
|
Chris@16
|
784 }
|
Chris@16
|
785
|
Chris@16
|
786 template< typename T >
|
Chris@16
|
787 inline typename result_of::extract_or_throw< T >::type attribute_value::extract_or_throw() const
|
Chris@16
|
788 {
|
Chris@16
|
789 return boost::log::extract_or_throw< T >(*this);
|
Chris@16
|
790 }
|
Chris@16
|
791
|
Chris@16
|
792 template< typename T >
|
Chris@16
|
793 inline typename result_of::extract_or_default< T, T >::type attribute_value::extract_or_default(T const& def_value) const
|
Chris@16
|
794 {
|
Chris@16
|
795 return boost::log::extract_or_default< T >(*this, def_value);
|
Chris@16
|
796 }
|
Chris@16
|
797
|
Chris@16
|
798 template< typename T, typename DefaultT >
|
Chris@16
|
799 inline typename result_of::extract_or_default< T, DefaultT >::type attribute_value::extract_or_default(DefaultT const& def_value) const
|
Chris@16
|
800 {
|
Chris@16
|
801 return boost::log::extract_or_default< T >(*this, def_value);
|
Chris@16
|
802 }
|
Chris@16
|
803
|
Chris@16
|
804 #endif // defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
|
Chris@16
|
805
|
Chris@16
|
806 #endif // !defined(BOOST_LOG_DOXYGEN_PASS)
|
Chris@16
|
807
|
Chris@16
|
808 #undef BOOST_LOG_AUX_VOID_DEFAULT
|
Chris@16
|
809
|
Chris@16
|
810 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
811
|
Chris@16
|
812 } // namespace boost
|
Chris@16
|
813
|
Chris@16
|
814 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
815
|
Chris@16
|
816 #endif // BOOST_LOG_ATTRIBUTES_VALUE_EXTRACTION_HPP_INCLUDED_
|