named_scope.hpp 23 KB

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