annotate DEPENDENCIES/generic/include/boost/log/expressions/formatters/named_scope.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 formatters/named_scope.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 11.11.2012
Chris@16 11 *
Chris@16 12 * The header contains a formatter function for named scope attribute values.
Chris@16 13 */
Chris@16 14
Chris@16 15 #ifndef BOOST_LOG_EXPRESSIONS_FORMATTERS_NAMED_SCOPE_HPP_INCLUDED_
Chris@16 16 #define BOOST_LOG_EXPRESSIONS_FORMATTERS_NAMED_SCOPE_HPP_INCLUDED_
Chris@16 17
Chris@16 18 #include <string>
Chris@16 19 #include <iterator>
Chris@16 20 #include <utility>
Chris@16 21 #include <boost/static_assert.hpp>
Chris@16 22 #include <boost/type_traits/is_same.hpp>
Chris@16 23 #include <boost/move/core.hpp>
Chris@16 24 #include <boost/move/utility.hpp>
Chris@16 25 #include <boost/parameter/binding.hpp>
Chris@16 26 #include <boost/preprocessor/iteration/iterate.hpp>
Chris@16 27 #include <boost/preprocessor/repetition/enum_params.hpp>
Chris@16 28 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
Chris@16 29 #include <boost/phoenix/core/actor.hpp>
Chris@16 30 #include <boost/phoenix/core/terminal_fwd.hpp>
Chris@16 31 #include <boost/phoenix/core/is_nullary.hpp>
Chris@16 32 #include <boost/phoenix/core/environment.hpp>
Chris@16 33 #include <boost/fusion/sequence/intrinsic/at_c.hpp>
Chris@16 34 #include <boost/log/detail/config.hpp>
Chris@16 35 #include <boost/log/attributes/attribute_name.hpp>
Chris@16 36 #include <boost/log/attributes/fallback_policy.hpp>
Chris@16 37 #include <boost/log/attributes/named_scope.hpp>
Chris@16 38 #include <boost/log/attributes/value_visitation.hpp>
Chris@16 39 #include <boost/log/detail/light_function.hpp>
Chris@16 40 #include <boost/log/detail/parameter_tools.hpp>
Chris@16 41 #include <boost/log/detail/custom_terminal_spec.hpp>
Chris@16 42 #include <boost/log/detail/deduce_char_type.hpp>
Chris@16 43 #include <boost/log/detail/attr_output_terminal.hpp>
Chris@16 44 #include <boost/log/expressions/attr_fwd.hpp>
Chris@16 45 #include <boost/log/expressions/keyword_fwd.hpp>
Chris@16 46 #include <boost/log/utility/formatting_ostream.hpp>
Chris@16 47 #include <boost/log/utility/string_literal_fwd.hpp>
Chris@16 48 #include <boost/log/utility/functional/bind.hpp>
Chris@16 49 #include <boost/log/keywords/format.hpp>
Chris@16 50 #include <boost/log/keywords/delimiter.hpp>
Chris@16 51 #include <boost/log/keywords/depth.hpp>
Chris@16 52 #include <boost/log/keywords/iteration.hpp>
Chris@101 53 #include <boost/log/keywords/empty_marker.hpp>
Chris@101 54 #include <boost/log/keywords/incomplete_marker.hpp>
Chris@16 55 #include <boost/log/detail/header.hpp>
Chris@16 56
Chris@16 57 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 58 #pragma once
Chris@16 59 #endif
Chris@16 60
Chris@16 61 namespace boost {
Chris@16 62
Chris@16 63 BOOST_LOG_OPEN_NAMESPACE
Chris@16 64
Chris@16 65 namespace expressions {
Chris@16 66
Chris@16 67 //! Scope iteration directions
Chris@16 68 enum scope_iteration_direction
Chris@16 69 {
Chris@16 70 forward, //!< Iterate through scopes from outermost to innermost
Chris@16 71 reverse //!< Iterate through scopes from innermost to outermost
Chris@16 72 };
Chris@16 73
Chris@16 74 namespace aux {
Chris@16 75
Chris@16 76 #ifdef BOOST_LOG_USE_CHAR
Chris@16 77 //! Parses the named scope format string and constructs the formatter function
Chris@16 78 BOOST_LOG_API boost::log::aux::light_function< void (basic_formatting_ostream< char >&, attributes::named_scope::value_type::value_type const&) >
Chris@16 79 parse_named_scope_format(const char* begin, const char* end);
Chris@16 80 #endif
Chris@16 81
Chris@16 82 #ifdef BOOST_LOG_USE_WCHAR_T
Chris@16 83 //! Parses the named scope format string and constructs the formatter function
Chris@16 84 BOOST_LOG_API boost::log::aux::light_function< void (basic_formatting_ostream< wchar_t >&, attributes::named_scope::value_type::value_type const&) >
Chris@16 85 parse_named_scope_format(const wchar_t* begin, const wchar_t* end);
Chris@16 86 #endif
Chris@16 87
Chris@16 88 //! Parses the named scope format string and constructs the formatter function
Chris@16 89 template< typename CharT >
Chris@16 90 inline boost::log::aux::light_function< void (basic_formatting_ostream< CharT >&, attributes::named_scope::value_type::value_type const&) >
Chris@16 91 parse_named_scope_format(const CharT* format)
Chris@16 92 {
Chris@16 93 return parse_named_scope_format(format, format + std::char_traits< CharT >::length(format));
Chris@16 94 }
Chris@16 95
Chris@16 96 //! Parses the named scope format string and constructs the formatter function
Chris@16 97 template< typename CharT, typename TraitsT, typename AllocatorT >
Chris@16 98 inline boost::log::aux::light_function< void (basic_formatting_ostream< CharT >&, attributes::named_scope::value_type::value_type const&) >
Chris@16 99 parse_named_scope_format(std::basic_string< CharT, TraitsT, AllocatorT > const& format)
Chris@16 100 {
Chris@16 101 const CharT* p = format.c_str();
Chris@16 102 return parse_named_scope_format(p, p + format.size());
Chris@16 103 }
Chris@16 104
Chris@16 105 //! Parses the named scope format string and constructs the formatter function
Chris@16 106 template< typename CharT, typename TraitsT >
Chris@16 107 inline boost::log::aux::light_function< void (basic_formatting_ostream< CharT >&, attributes::named_scope::value_type::value_type const&) >
Chris@16 108 parse_named_scope_format(basic_string_literal< CharT, TraitsT > const& format)
Chris@16 109 {
Chris@16 110 const CharT* p = format.c_str();
Chris@16 111 return parse_named_scope_format(p, p + format.size());
Chris@16 112 }
Chris@16 113
Chris@16 114 template< typename CharT >
Chris@16 115 class format_named_scope_impl
Chris@16 116 {
Chris@16 117 public:
Chris@16 118 //! Function result type
Chris@16 119 typedef void result_type;
Chris@16 120
Chris@16 121 //! Character type
Chris@16 122 typedef CharT char_type;
Chris@16 123 //! String type
Chris@16 124 typedef std::basic_string< char_type > string_type;
Chris@16 125 //! Formatting stream type
Chris@16 126 typedef basic_formatting_ostream< char_type > stream_type;
Chris@16 127 //! Attribute value type
Chris@16 128 typedef attributes::named_scope::value_type value_type;
Chris@16 129 //! Named scope formatter
Chris@16 130 typedef boost::log::aux::light_function< void (stream_type&, value_type::value_type const&) > element_formatter_type;
Chris@16 131
Chris@16 132 private:
Chris@16 133 //! Element formatting function
Chris@16 134 element_formatter_type m_element_formatter;
Chris@16 135 //! Element delimiter
Chris@16 136 string_type m_delimiter;
Chris@101 137 //! Incomplete list marker
Chris@101 138 string_type m_incomplete_marker;
Chris@101 139 //! Empty list marker
Chris@101 140 string_type m_empty_marker;
Chris@16 141 //! Maximum number of elements to output
Chris@16 142 value_type::size_type m_depth;
Chris@16 143 //! Iteration direction
Chris@16 144 scope_iteration_direction m_direction;
Chris@16 145
Chris@16 146 public:
Chris@16 147 //! Initializing constructor
Chris@101 148 format_named_scope_impl
Chris@101 149 (
Chris@101 150 element_formatter_type const& element_formatter,
Chris@101 151 string_type const& delimiter,
Chris@101 152 string_type const& incomplete_marker,
Chris@101 153 string_type const& empty_marker,
Chris@101 154 value_type::size_type depth,
Chris@101 155 scope_iteration_direction direction
Chris@101 156 ) :
Chris@16 157 m_element_formatter(element_formatter),
Chris@16 158 m_delimiter(delimiter),
Chris@101 159 m_incomplete_marker(incomplete_marker),
Chris@101 160 m_empty_marker(empty_marker),
Chris@16 161 m_depth(depth),
Chris@16 162 m_direction(direction)
Chris@16 163 {
Chris@16 164 }
Chris@16 165 //! Copy constructor
Chris@16 166 format_named_scope_impl(format_named_scope_impl const& that) :
Chris@16 167 m_element_formatter(that.m_element_formatter),
Chris@16 168 m_delimiter(that.m_delimiter),
Chris@101 169 m_incomplete_marker(that.m_incomplete_marker),
Chris@101 170 m_empty_marker(that.m_empty_marker),
Chris@16 171 m_depth(that.m_depth),
Chris@16 172 m_direction(that.m_direction)
Chris@16 173 {
Chris@16 174 }
Chris@16 175
Chris@16 176 //! Formatting operator
Chris@16 177 result_type operator() (stream_type& strm, value_type const& scopes) const
Chris@16 178 {
Chris@101 179 if (!scopes.empty())
Chris@101 180 {
Chris@101 181 if (m_direction == expressions::forward)
Chris@101 182 format_forward(strm, scopes);
Chris@101 183 else
Chris@101 184 format_reverse(strm, scopes);
Chris@101 185 }
Chris@16 186 else
Chris@101 187 {
Chris@101 188 strm << m_empty_marker;
Chris@101 189 }
Chris@16 190 }
Chris@16 191
Chris@16 192 private:
Chris@16 193 //! The function performs formatting of the extracted scope stack in forward direction
Chris@16 194 void format_forward(stream_type& strm, value_type const& scopes) const
Chris@16 195 {
Chris@16 196 value_type::const_iterator it, end = scopes.end();
Chris@16 197 if (m_depth > 0)
Chris@16 198 {
Chris@16 199 value_type::size_type const scopes_to_iterate = (std::min)(m_depth, scopes.size());
Chris@16 200 it = scopes.end();
Chris@16 201 std::advance(it, -static_cast< value_type::difference_type >(scopes_to_iterate));
Chris@16 202 }
Chris@16 203 else
Chris@16 204 {
Chris@16 205 it = scopes.begin();
Chris@16 206 }
Chris@16 207
Chris@16 208 if (it != end)
Chris@16 209 {
Chris@16 210 if (it != scopes.begin())
Chris@101 211 strm << m_incomplete_marker;
Chris@16 212
Chris@16 213 m_element_formatter(strm, *it);
Chris@16 214 for (++it; it != end; ++it)
Chris@16 215 {
Chris@16 216 strm << m_delimiter;
Chris@16 217 m_element_formatter(strm, *it);
Chris@16 218 }
Chris@16 219 }
Chris@16 220 }
Chris@16 221 //! The function performs formatting of the extracted scope stack in reverse direction
Chris@16 222 void format_reverse(stream_type& strm, value_type const& scopes) const
Chris@16 223 {
Chris@16 224 value_type::const_reverse_iterator it = scopes.rbegin(), end;
Chris@16 225 if (m_depth > 0)
Chris@16 226 {
Chris@16 227 value_type::size_type const scopes_to_iterate = (std::min)(m_depth, scopes.size());
Chris@16 228 end = it;
Chris@16 229 std::advance(end, static_cast< value_type::difference_type >(scopes_to_iterate));
Chris@16 230 }
Chris@16 231 else
Chris@16 232 {
Chris@16 233 end = scopes.rend();
Chris@16 234 }
Chris@16 235
Chris@16 236 if (it != end)
Chris@16 237 {
Chris@16 238 m_element_formatter(strm, *it);
Chris@16 239 for (++it; it != end; ++it)
Chris@16 240 {
Chris@16 241 strm << m_delimiter;
Chris@16 242 m_element_formatter(strm, *it);
Chris@16 243 }
Chris@16 244
Chris@16 245 if (it != scopes.rend())
Chris@101 246 strm << m_incomplete_marker;
Chris@16 247 }
Chris@16 248 }
Chris@16 249 };
Chris@16 250
Chris@16 251 } // namespace aux
Chris@16 252
Chris@16 253 /*!
Chris@16 254 * Named scope formatter terminal.
Chris@16 255 */
Chris@16 256 template< typename FallbackPolicyT, typename CharT >
Chris@16 257 class format_named_scope_terminal
Chris@16 258 {
Chris@16 259 public:
Chris@16 260 //! Internal typedef for type categorization
Chris@16 261 typedef void _is_boost_log_terminal;
Chris@16 262
Chris@16 263 //! Attribute value type
Chris@16 264 typedef attributes::named_scope::value_type value_type;
Chris@16 265 //! Fallback policy
Chris@16 266 typedef FallbackPolicyT fallback_policy;
Chris@16 267 //! Character type
Chris@16 268 typedef CharT char_type;
Chris@16 269 //! String type
Chris@16 270 typedef std::basic_string< char_type > string_type;
Chris@16 271 //! Formatting stream type
Chris@16 272 typedef basic_formatting_ostream< char_type > stream_type;
Chris@16 273 //! Formatter function
Chris@16 274 typedef aux::format_named_scope_impl< char_type > formatter_function_type;
Chris@16 275
Chris@16 276 //! Function result type
Chris@16 277 typedef string_type result_type;
Chris@16 278
Chris@16 279 private:
Chris@16 280 //! Attribute value visitor invoker
Chris@16 281 typedef value_visitor_invoker< value_type, fallback_policy > visitor_invoker_type;
Chris@16 282
Chris@16 283 private:
Chris@16 284 //! Attribute name
Chris@16 285 attribute_name m_name;
Chris@16 286 //! Formatter function
Chris@16 287 formatter_function_type m_formatter;
Chris@16 288 //! Attribute value visitor invoker
Chris@16 289 visitor_invoker_type m_visitor_invoker;
Chris@16 290
Chris@16 291 public:
Chris@16 292 //! Initializing constructor
Chris@16 293 template< typename FormatT >
Chris@101 294 format_named_scope_terminal
Chris@101 295 (
Chris@101 296 attribute_name const& name,
Chris@101 297 fallback_policy const& fallback,
Chris@101 298 FormatT const& element_format,
Chris@101 299 string_type const& delimiter,
Chris@101 300 string_type const& incomplete_marker,
Chris@101 301 string_type const& empty_marker,
Chris@101 302 value_type::size_type depth,
Chris@101 303 scope_iteration_direction direction
Chris@101 304 ) :
Chris@101 305 m_name(name), m_formatter(aux::parse_named_scope_format(element_format), delimiter, incomplete_marker, empty_marker, depth, direction), m_visitor_invoker(fallback)
Chris@16 306 {
Chris@16 307 }
Chris@16 308 //! Copy constructor
Chris@16 309 format_named_scope_terminal(format_named_scope_terminal const& that) :
Chris@16 310 m_name(that.m_name), m_formatter(that.m_formatter), m_visitor_invoker(that.m_visitor_invoker)
Chris@16 311 {
Chris@16 312 }
Chris@16 313
Chris@16 314 //! Returns attribute name
Chris@16 315 attribute_name get_name() const
Chris@16 316 {
Chris@16 317 return m_name;
Chris@16 318 }
Chris@16 319
Chris@16 320 //! Returns fallback policy
Chris@16 321 fallback_policy const& get_fallback_policy() const
Chris@16 322 {
Chris@16 323 return m_visitor_invoker.get_fallback_policy();
Chris@16 324 }
Chris@16 325
Chris@16 326 //! Retruns formatter function
Chris@16 327 formatter_function_type const& get_formatter_function() const
Chris@16 328 {
Chris@16 329 return m_formatter;
Chris@16 330 }
Chris@16 331
Chris@16 332 //! Invokation operator
Chris@16 333 template< typename ContextT >
Chris@16 334 result_type operator() (ContextT const& ctx)
Chris@16 335 {
Chris@16 336 string_type str;
Chris@16 337 stream_type strm(str);
Chris@16 338 m_visitor_invoker(m_name, fusion::at_c< 0 >(phoenix::env(ctx).args()), binder1st< formatter_function_type&, stream_type& >(m_formatter, strm));
Chris@16 339 strm.flush();
Chris@16 340 return boost::move(str);
Chris@16 341 }
Chris@16 342
Chris@16 343 //! Invokation operator
Chris@16 344 template< typename ContextT >
Chris@16 345 result_type operator() (ContextT const& ctx) const
Chris@16 346 {
Chris@16 347 string_type str;
Chris@16 348 stream_type strm(str);
Chris@16 349 m_visitor_invoker(m_name, fusion::at_c< 0 >(phoenix::env(ctx).args()), binder1st< formatter_function_type const&, stream_type& >(m_formatter, strm));
Chris@16 350 strm.flush();
Chris@16 351 return boost::move(str);
Chris@16 352 }
Chris@16 353
Chris@16 354 BOOST_DELETED_FUNCTION(format_named_scope_terminal())
Chris@16 355 };
Chris@16 356
Chris@16 357 /*!
Chris@16 358 * Named scope formatter actor.
Chris@16 359 */
Chris@16 360 template< typename FallbackPolicyT, typename CharT, template< typename > class ActorT = phoenix::actor >
Chris@16 361 class format_named_scope_actor :
Chris@16 362 public ActorT< format_named_scope_terminal< FallbackPolicyT, CharT > >
Chris@16 363 {
Chris@16 364 public:
Chris@16 365 //! Character type
Chris@16 366 typedef CharT char_type;
Chris@16 367 //! Fallback policy
Chris@16 368 typedef FallbackPolicyT fallback_policy;
Chris@16 369 //! Base terminal type
Chris@16 370 typedef format_named_scope_terminal< fallback_policy, char_type > terminal_type;
Chris@16 371 //! Attribute value type
Chris@16 372 typedef typename terminal_type::value_type value_type;
Chris@16 373 //! Formatter function
Chris@16 374 typedef typename terminal_type::formatter_function_type formatter_function_type;
Chris@16 375
Chris@16 376 //! Base actor type
Chris@16 377 typedef ActorT< terminal_type > base_type;
Chris@16 378
Chris@16 379 public:
Chris@16 380 //! Initializing constructor
Chris@16 381 explicit format_named_scope_actor(base_type const& act) : base_type(act)
Chris@16 382 {
Chris@16 383 }
Chris@16 384
Chris@16 385 /*!
Chris@16 386 * \returns The attribute name
Chris@16 387 */
Chris@16 388 attribute_name get_name() const
Chris@16 389 {
Chris@16 390 return this->proto_expr_.child0.get_name();
Chris@16 391 }
Chris@16 392
Chris@16 393 /*!
Chris@16 394 * \returns Fallback policy
Chris@16 395 */
Chris@16 396 fallback_policy const& get_fallback_policy() const
Chris@16 397 {
Chris@16 398 return this->proto_expr_.child0.get_fallback_policy();
Chris@16 399 }
Chris@16 400
Chris@16 401 /*!
Chris@16 402 * \returns Formatter function
Chris@16 403 */
Chris@16 404 formatter_function_type const& get_formatter_function() const
Chris@16 405 {
Chris@16 406 return this->proto_expr_.child0.get_formatter_function();
Chris@16 407 }
Chris@16 408 };
Chris@16 409
Chris@16 410 #ifndef BOOST_LOG_DOXYGEN_PASS
Chris@16 411
Chris@16 412 #define BOOST_LOG_AUX_OVERLOAD(left_ref, right_ref)\
Chris@16 413 template< typename LeftExprT, typename FallbackPolicyT, typename CharT >\
Chris@16 414 BOOST_FORCEINLINE phoenix::actor< aux::attribute_output_terminal< phoenix::actor< LeftExprT >, attributes::named_scope::value_type, FallbackPolicyT, typename format_named_scope_actor< FallbackPolicyT, CharT >::formatter_function_type > >\
Chris@16 415 operator<< (phoenix::actor< LeftExprT > left_ref left, format_named_scope_actor< FallbackPolicyT, CharT > right_ref right)\
Chris@16 416 {\
Chris@16 417 typedef aux::attribute_output_terminal< phoenix::actor< LeftExprT >, attributes::named_scope::value_type, FallbackPolicyT, typename format_named_scope_actor< FallbackPolicyT, CharT >::formatter_function_type > terminal_type;\
Chris@16 418 phoenix::actor< terminal_type > actor = {{ terminal_type(left, right.get_name(), right.get_formatter_function(), right.get_fallback_policy()) }};\
Chris@16 419 return actor;\
Chris@16 420 }
Chris@16 421
Chris@16 422 #include <boost/log/detail/generate_overloads.hpp>
Chris@16 423
Chris@16 424 #undef BOOST_LOG_AUX_OVERLOAD
Chris@16 425
Chris@16 426 #endif // BOOST_LOG_DOXYGEN_PASS
Chris@16 427
Chris@16 428 namespace aux {
Chris@16 429
Chris@101 430 //! Auxiliary traits to acquire default formatter parameters depending on the character type
Chris@16 431 template< typename CharT >
Chris@101 432 struct default_named_scope_params;
Chris@16 433
Chris@16 434 #ifdef BOOST_LOG_USE_CHAR
Chris@16 435 template< >
Chris@101 436 struct default_named_scope_params< char >
Chris@16 437 {
Chris@101 438 static const char* forward_delimiter() { return "->"; }
Chris@101 439 static const char* reverse_delimiter() { return "<-"; }
Chris@101 440 static const char* incomplete_marker() { return "..."; }
Chris@101 441 static const char* empty_marker() { return ""; }
Chris@16 442 };
Chris@16 443 #endif
Chris@16 444 #ifdef BOOST_LOG_USE_WCHAR_T
Chris@16 445 template< >
Chris@101 446 struct default_named_scope_params< wchar_t >
Chris@16 447 {
Chris@101 448 static const wchar_t* forward_delimiter() { return L"->"; }
Chris@101 449 static const wchar_t* reverse_delimiter() { return L"<-"; }
Chris@101 450 static const wchar_t* incomplete_marker() { return L"..."; }
Chris@101 451 static const wchar_t* empty_marker() { return L""; }
Chris@16 452 };
Chris@16 453 #endif
Chris@16 454
Chris@16 455 template< typename CharT, template< typename > class ActorT, typename FallbackPolicyT, typename ArgsT >
Chris@16 456 BOOST_FORCEINLINE format_named_scope_actor< FallbackPolicyT, CharT, ActorT > format_named_scope(attribute_name const& name, FallbackPolicyT const& fallback, ArgsT const& args)
Chris@16 457 {
Chris@16 458 typedef format_named_scope_actor< FallbackPolicyT, CharT, ActorT > actor_type;
Chris@16 459 typedef typename actor_type::terminal_type terminal_type;
Chris@101 460 typedef default_named_scope_params< CharT > default_params;
Chris@16 461 scope_iteration_direction dir = args[keywords::iteration | expressions::forward];
Chris@101 462 const CharT* default_delimiter = (dir == expressions::forward ? default_params::forward_delimiter() : default_params::reverse_delimiter());
Chris@16 463 typename actor_type::base_type act =
Chris@16 464 {{
Chris@16 465 terminal_type
Chris@16 466 (
Chris@16 467 name,
Chris@16 468 fallback,
Chris@16 469 args[keywords::format],
Chris@16 470 args[keywords::delimiter | default_delimiter],
Chris@101 471 args[keywords::incomplete_marker | default_params::incomplete_marker()],
Chris@101 472 args[keywords::empty_marker | default_params::empty_marker()],
Chris@16 473 args[keywords::depth | static_cast< attributes::named_scope::value_type::size_type >(0)],
Chris@16 474 dir
Chris@16 475 )
Chris@16 476 }};
Chris@16 477 return actor_type(act);
Chris@16 478 }
Chris@16 479
Chris@16 480 } // namespace aux
Chris@16 481
Chris@16 482 /*!
Chris@16 483 * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting
Chris@16 484 * expression (stream output or \c format placeholder filler).
Chris@16 485 *
Chris@16 486 * \param name Attribute name
Chris@16 487 * \param element_format Format string for a single named scope
Chris@16 488 */
Chris@16 489 template< typename CharT >
Chris@16 490 BOOST_FORCEINLINE format_named_scope_actor< fallback_to_none, CharT > format_named_scope(attribute_name const& name, const CharT* element_format)
Chris@16 491 {
Chris@16 492 typedef format_named_scope_actor< fallback_to_none, CharT > actor_type;
Chris@16 493 typedef typename actor_type::terminal_type terminal_type;
Chris@16 494 typename actor_type::base_type act = {{ terminal_type(name, fallback_to_none(), element_format) }};
Chris@16 495 return actor_type(act);
Chris@16 496 }
Chris@16 497
Chris@16 498 /*!
Chris@16 499 * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting
Chris@16 500 * expression (stream output or \c format placeholder filler).
Chris@16 501 *
Chris@16 502 * \param name Attribute name
Chris@16 503 * \param element_format Format string for a single named scope
Chris@16 504 */
Chris@16 505 template< typename CharT >
Chris@16 506 BOOST_FORCEINLINE format_named_scope_actor< fallback_to_none, CharT > format_named_scope(attribute_name const& name, std::basic_string< CharT > const& element_format)
Chris@16 507 {
Chris@16 508 typedef format_named_scope_actor< fallback_to_none, CharT > actor_type;
Chris@16 509 typedef typename actor_type::terminal_type terminal_type;
Chris@16 510 typename actor_type::base_type act = {{ terminal_type(name, fallback_to_none(), element_format) }};
Chris@16 511 return actor_type(act);
Chris@16 512 }
Chris@16 513
Chris@16 514 /*!
Chris@16 515 * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting
Chris@16 516 * expression (stream output or \c format placeholder filler).
Chris@16 517 *
Chris@16 518 * \param keyword Attribute keyword
Chris@16 519 * \param element_format Format string for a single named scope
Chris@16 520 */
Chris@16 521 template< typename DescriptorT, template< typename > class ActorT, typename CharT >
Chris@16 522 BOOST_FORCEINLINE format_named_scope_actor< fallback_to_none, CharT, ActorT >
Chris@16 523 format_named_scope(attribute_keyword< DescriptorT, ActorT > const& keyword, const CharT* element_format)
Chris@16 524 {
Chris@16 525 BOOST_STATIC_ASSERT_MSG((is_same< typename DescriptorT::value_type, attributes::named_scope::value_type >::value),\
Chris@16 526 "Boost.Log: Named scope formatter only accepts attribute values of type attributes::named_scope::value_type.");
Chris@16 527
Chris@16 528 typedef format_named_scope_actor< fallback_to_none, CharT, ActorT > actor_type;
Chris@16 529 typedef typename actor_type::terminal_type terminal_type;
Chris@16 530 typename actor_type::base_type act = {{ terminal_type(keyword.get_name(), fallback_to_none(), element_format) }};
Chris@16 531 return actor_type(act);
Chris@16 532 }
Chris@16 533
Chris@16 534 /*!
Chris@16 535 * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting
Chris@16 536 * expression (stream output or \c format placeholder filler).
Chris@16 537 *
Chris@16 538 * \param keyword Attribute keyword
Chris@16 539 * \param element_format Format string for a single named scope
Chris@16 540 */
Chris@16 541 template< typename DescriptorT, template< typename > class ActorT, typename CharT >
Chris@16 542 BOOST_FORCEINLINE format_named_scope_actor< fallback_to_none, CharT, ActorT >
Chris@16 543 format_named_scope(attribute_keyword< DescriptorT, ActorT > const& keyword, std::basic_string< CharT > const& element_format)
Chris@16 544 {
Chris@16 545 BOOST_STATIC_ASSERT_MSG((is_same< typename DescriptorT::value_type, attributes::named_scope::value_type >::value),\
Chris@16 546 "Boost.Log: Named scope formatter only accepts attribute values of type attributes::named_scope::value_type.");
Chris@16 547
Chris@16 548 typedef format_named_scope_actor< fallback_to_none, CharT, ActorT > actor_type;
Chris@16 549 typedef typename actor_type::terminal_type terminal_type;
Chris@16 550 typename actor_type::base_type act = {{ terminal_type(keyword.get_name(), fallback_to_none(), element_format) }};
Chris@16 551 return actor_type(act);
Chris@16 552 }
Chris@16 553
Chris@16 554 /*!
Chris@16 555 * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting
Chris@16 556 * expression (stream output or \c format placeholder filler).
Chris@16 557 *
Chris@16 558 * \param placeholder Attribute placeholder
Chris@16 559 * \param element_format Format string for a single named scope
Chris@16 560 */
Chris@16 561 template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename CharT >
Chris@16 562 BOOST_FORCEINLINE format_named_scope_actor< FallbackPolicyT, CharT, ActorT >
Chris@16 563 format_named_scope(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& placeholder, const CharT* element_format)
Chris@16 564 {
Chris@16 565 BOOST_STATIC_ASSERT_MSG((is_same< T, attributes::named_scope::value_type >::value),\
Chris@16 566 "Boost.Log: Named scope formatter only accepts attribute values of type attributes::named_scope::value_type.");
Chris@16 567
Chris@16 568 typedef format_named_scope_actor< FallbackPolicyT, CharT, ActorT > actor_type;
Chris@16 569 typedef typename actor_type::terminal_type terminal_type;
Chris@16 570 typename actor_type::base_type act = {{ terminal_type(placeholder.get_name(), placeholder.get_fallback_policy(), element_format) }};
Chris@16 571 return actor_type(act);
Chris@16 572 }
Chris@16 573
Chris@16 574 /*!
Chris@16 575 * The function generates a manipulator node in a template expression. The manipulator must participate in a formatting
Chris@16 576 * expression (stream output or \c format placeholder filler).
Chris@16 577 *
Chris@16 578 * \param placeholder Attribute placeholder
Chris@16 579 * \param element_format Format string for a single named scope
Chris@16 580 */
Chris@16 581 template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename CharT >
Chris@16 582 BOOST_FORCEINLINE format_named_scope_actor< FallbackPolicyT, CharT, ActorT >
Chris@16 583 format_named_scope(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& placeholder, std::basic_string< CharT > const& element_format)
Chris@16 584 {
Chris@16 585 BOOST_STATIC_ASSERT_MSG((is_same< T, attributes::named_scope::value_type >::value),\
Chris@16 586 "Boost.Log: Named scope formatter only accepts attribute values of type attributes::named_scope::value_type.");
Chris@16 587
Chris@16 588 typedef format_named_scope_actor< FallbackPolicyT, CharT, ActorT > actor_type;
Chris@16 589 typedef typename actor_type::terminal_type terminal_type;
Chris@16 590 typename actor_type::base_type act = {{ terminal_type(placeholder.get_name(), placeholder.get_fallback_policy(), element_format) }};
Chris@16 591 return actor_type(act);
Chris@16 592 }
Chris@16 593
Chris@16 594 #if !defined(BOOST_LOG_DOXYGEN_PASS)
Chris@16 595
Chris@16 596 # define BOOST_PP_FILENAME_1 <boost/log/detail/named_scope_fmt_pp.hpp>
Chris@101 597 # define BOOST_PP_ITERATION_LIMITS (1, 6)
Chris@16 598 # include BOOST_PP_ITERATE()
Chris@16 599
Chris@16 600 #else // BOOST_LOG_DOXYGEN_PASS
Chris@16 601
Chris@16 602 /*!
Chris@16 603 * Formatter generator. Construct the named scope formatter with the specified formatting parameters.
Chris@16 604 *
Chris@16 605 * \param name Attribute name
Chris@16 606 * \param args An set of named parameters. Supported parameters:
Chris@16 607 * \li \c format - A format string for named scopes. The string can contain "%n", "%f" and "%l" placeholders for the scope name, file and line number, respectively. This parameter is mandatory.
Chris@16 608 * \li \c delimiter - A string that is used to delimit the formatted scope names. Default: "->" or "<-", depending on the iteration direction.
Chris@101 609 * \li \c incomplete_marker - A string that is used to indicate that the list was printed incomplete because of depth limitation. Default: "...".
Chris@101 610 * \li \c empty_marker - A string that is output in case if the scope list is empty. Default: "", i.e. nothing is output.
Chris@16 611 * \li \c iteration - Iteration direction, see \c scope_iteration_direction enumeration. Default: forward.
Chris@16 612 * \li \c depth - Iteration depth. Default: unlimited.
Chris@16 613 */
Chris@16 614 template< typename... ArgsT >
Chris@16 615 unspecified format_named_scope(attribute_name const& name, ArgsT... const& args);
Chris@16 616
Chris@16 617 /*! \overload */
Chris@16 618 template< typename DescriptorT, template< typename > class ActorT, typename... ArgsT >
Chris@16 619 unspecified format_named_scope(attribute_keyword< DescriptorT, ActorT > const& keyword, ArgsT... const& args);
Chris@16 620
Chris@16 621 /*! \overload */
Chris@16 622 template< typename T, typename FallbackPolicyT, typename TagT, template< typename > class ActorT, typename... ArgsT >
Chris@16 623 unspecified format_named_scope(attribute_actor< T, FallbackPolicyT, TagT, ActorT > const& placeholder, ArgsT... const& args);
Chris@16 624
Chris@16 625 #endif // BOOST_LOG_DOXYGEN_PASS
Chris@16 626
Chris@16 627 } // namespace expressions
Chris@16 628
Chris@16 629 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 630
Chris@16 631 #ifndef BOOST_LOG_DOXYGEN_PASS
Chris@16 632
Chris@16 633 namespace phoenix {
Chris@16 634
Chris@16 635 namespace result_of {
Chris@16 636
Chris@16 637 template< typename FallbackPolicyT, typename CharT >
Chris@16 638 struct is_nullary< custom_terminal< boost::log::expressions::format_named_scope_terminal< FallbackPolicyT, CharT > > > :
Chris@16 639 public mpl::false_
Chris@16 640 {
Chris@16 641 };
Chris@16 642
Chris@16 643 } // namespace result_of
Chris@16 644
Chris@16 645 } // namespace phoenix
Chris@16 646
Chris@16 647 #endif
Chris@16 648
Chris@16 649 } // namespace boost
Chris@16 650
Chris@16 651 #include <boost/log/detail/footer.hpp>
Chris@16 652
Chris@16 653 #endif // BOOST_LOG_EXPRESSIONS_FORMATTERS_NAMED_SCOPE_HPP_INCLUDED_