formatter.hpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  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 formatter.hpp
  9. * \author Andrey Semashev
  10. * \date 13.07.2012
  11. *
  12. * The header contains a formatter function object definition.
  13. */
  14. #ifndef BOOST_LOG_EXPRESSIONS_FORMATTER_HPP_INCLUDED_
  15. #define BOOST_LOG_EXPRESSIONS_FORMATTER_HPP_INCLUDED_
  16. #include <locale>
  17. #include <ostream>
  18. #include <boost/ref.hpp>
  19. #include <boost/move/core.hpp>
  20. #include <boost/move/utility_core.hpp>
  21. #if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  22. #include <boost/type_traits/is_same.hpp>
  23. #include <boost/type_traits/remove_cv.hpp>
  24. #include <boost/log/detail/sfinae_tools.hpp>
  25. #endif
  26. #include <boost/log/detail/config.hpp>
  27. #include <boost/log/detail/light_function.hpp>
  28. #include <boost/log/attributes/attribute_value_set.hpp>
  29. #include <boost/log/attributes/value_visitation.hpp>
  30. #include <boost/log/core/record_view.hpp>
  31. #include <boost/log/utility/formatting_ostream.hpp>
  32. #include <boost/log/utility/functional/bind_output.hpp>
  33. #include <boost/log/expressions/message.hpp>
  34. #include <boost/log/detail/header.hpp>
  35. #ifdef BOOST_HAS_PRAGMA_ONCE
  36. #pragma once
  37. #endif
  38. namespace boost {
  39. BOOST_LOG_OPEN_NAMESPACE
  40. namespace expressions {
  41. namespace aux {
  42. // This reference class is a workaround for a Boost.Phoenix bug: https://svn.boost.org/trac/boost/ticket/9363
  43. // It is needed to pass output streams by non-const reference to function objects wrapped in phoenix::bind and phoenix::function.
  44. // It's an implementation detail and will be removed when Boost.Phoenix is fixed.
  45. template< typename StreamT >
  46. class stream_ref :
  47. public reference_wrapper< StreamT >
  48. {
  49. public:
  50. typedef typename StreamT::char_type char_type;
  51. typedef typename StreamT::traits_type traits_type;
  52. typedef typename StreamT::allocator_type allocator_type;
  53. typedef typename StreamT::streambuf_type streambuf_type;
  54. typedef typename StreamT::string_type string_type;
  55. typedef typename StreamT::ostream_type ostream_type;
  56. typedef typename StreamT::pos_type pos_type;
  57. typedef typename StreamT::off_type off_type;
  58. typedef typename StreamT::int_type int_type;
  59. typedef typename StreamT::failure failure;
  60. typedef typename StreamT::fmtflags fmtflags;
  61. typedef typename StreamT::iostate iostate;
  62. typedef typename StreamT::openmode openmode;
  63. typedef typename StreamT::seekdir seekdir;
  64. typedef typename StreamT::Init Init;
  65. typedef typename StreamT::event event;
  66. typedef typename StreamT::event_callback event_callback;
  67. typedef typename StreamT::sentry sentry;
  68. static BOOST_CONSTEXPR_OR_CONST fmtflags boolalpha = StreamT::boolalpha;
  69. static BOOST_CONSTEXPR_OR_CONST fmtflags dec = StreamT::dec;
  70. static BOOST_CONSTEXPR_OR_CONST fmtflags fixed = StreamT::fixed;
  71. static BOOST_CONSTEXPR_OR_CONST fmtflags hex = StreamT::hex;
  72. static BOOST_CONSTEXPR_OR_CONST fmtflags internal = StreamT::internal;
  73. static BOOST_CONSTEXPR_OR_CONST fmtflags left = StreamT::left;
  74. static BOOST_CONSTEXPR_OR_CONST fmtflags oct = StreamT::oct;
  75. static BOOST_CONSTEXPR_OR_CONST fmtflags right = StreamT::right;
  76. static BOOST_CONSTEXPR_OR_CONST fmtflags scientific = StreamT::scientific;
  77. static BOOST_CONSTEXPR_OR_CONST fmtflags showbase = StreamT::showbase;
  78. static BOOST_CONSTEXPR_OR_CONST fmtflags showpoint = StreamT::showpoint;
  79. static BOOST_CONSTEXPR_OR_CONST fmtflags skipws = StreamT::skipws;
  80. static BOOST_CONSTEXPR_OR_CONST fmtflags unitbuf = StreamT::unitbuf;
  81. static BOOST_CONSTEXPR_OR_CONST fmtflags uppercase = StreamT::uppercase;
  82. static BOOST_CONSTEXPR_OR_CONST fmtflags adjustfield = StreamT::adjustfield;
  83. static BOOST_CONSTEXPR_OR_CONST fmtflags basefield = StreamT::basefield;
  84. static BOOST_CONSTEXPR_OR_CONST fmtflags floatfield = StreamT::floatfield;
  85. static BOOST_CONSTEXPR_OR_CONST iostate badbit = StreamT::badbit;
  86. static BOOST_CONSTEXPR_OR_CONST iostate eofbit = StreamT::eofbit;
  87. static BOOST_CONSTEXPR_OR_CONST iostate failbit = StreamT::failbit;
  88. static BOOST_CONSTEXPR_OR_CONST iostate goodbit = StreamT::goodbit;
  89. static BOOST_CONSTEXPR_OR_CONST openmode app = StreamT::app;
  90. static BOOST_CONSTEXPR_OR_CONST openmode ate = StreamT::ate;
  91. static BOOST_CONSTEXPR_OR_CONST openmode binary = StreamT::binary;
  92. static BOOST_CONSTEXPR_OR_CONST openmode in = StreamT::in;
  93. static BOOST_CONSTEXPR_OR_CONST openmode out = StreamT::out;
  94. static BOOST_CONSTEXPR_OR_CONST openmode trunc = StreamT::trunc;
  95. static BOOST_CONSTEXPR_OR_CONST seekdir beg = StreamT::beg;
  96. static BOOST_CONSTEXPR_OR_CONST seekdir cur = StreamT::cur;
  97. static BOOST_CONSTEXPR_OR_CONST seekdir end = StreamT::end;
  98. static BOOST_CONSTEXPR_OR_CONST event erase_event = StreamT::erase_event;
  99. static BOOST_CONSTEXPR_OR_CONST event imbue_event = StreamT::imbue_event;
  100. static BOOST_CONSTEXPR_OR_CONST event copyfmt_event = StreamT::copyfmt_event;
  101. BOOST_FORCEINLINE explicit stream_ref(StreamT& strm) : reference_wrapper< StreamT >(strm)
  102. {
  103. }
  104. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  105. template< typename T >
  106. BOOST_FORCEINLINE StreamT& operator<< (T&& val) const
  107. {
  108. StreamT& strm = this->get();
  109. strm << static_cast< T&& >(val);
  110. return strm;
  111. }
  112. #if defined(BOOST_MSVC) && BOOST_MSVC < 1800
  113. // MSVC 10 and 11 generate broken code for the perfect forwarding version above if T is an array type (e.g. a string literal)
  114. template< typename T, unsigned int N >
  115. BOOST_FORCEINLINE StreamT& operator<< (T (&val)[N]) const
  116. {
  117. StreamT& strm = this->get();
  118. strm << val;
  119. return strm;
  120. }
  121. #endif
  122. #else
  123. template< typename T >
  124. BOOST_FORCEINLINE StreamT& operator<< (T& val) const
  125. {
  126. StreamT& strm = this->get();
  127. strm << val;
  128. return strm;
  129. }
  130. template< typename T >
  131. BOOST_FORCEINLINE StreamT& operator<< (T const& val) const
  132. {
  133. StreamT& strm = this->get();
  134. strm << val;
  135. return strm;
  136. }
  137. #endif
  138. BOOST_FORCEINLINE void attach(string_type& str) const { this->get().attach(str); }
  139. BOOST_FORCEINLINE void detach() const { this->get().detach(); }
  140. BOOST_FORCEINLINE string_type const& str() const { return this->get().str(); }
  141. BOOST_FORCEINLINE ostream_type& stream() const { return this->get().stream(); }
  142. BOOST_FORCEINLINE fmtflags flags() const { return this->get().flags(); }
  143. BOOST_FORCEINLINE fmtflags flags(fmtflags f) const { return this->get().flags(f); }
  144. BOOST_FORCEINLINE fmtflags setf(fmtflags f) const { return this->get().setf(f); }
  145. BOOST_FORCEINLINE fmtflags setf(fmtflags f, fmtflags mask) const { return this->get().setf(f, mask); }
  146. BOOST_FORCEINLINE void unsetf(fmtflags f) const { this->get().unsetf(f); }
  147. BOOST_FORCEINLINE std::streamsize precision() const { return this->get().precision(); }
  148. BOOST_FORCEINLINE std::streamsize precision(std::streamsize p) const { return this->get().precision(p); }
  149. BOOST_FORCEINLINE std::streamsize width() const { return this->get().width(); }
  150. BOOST_FORCEINLINE std::streamsize width(std::streamsize w) const { return this->get().width(w); }
  151. BOOST_FORCEINLINE std::locale getloc() const { return this->get().getloc(); }
  152. BOOST_FORCEINLINE std::locale imbue(std::locale const& loc) const { return this->get().imbue(loc); }
  153. static BOOST_FORCEINLINE int xalloc() { return StreamT::xalloc(); }
  154. BOOST_FORCEINLINE long& iword(int index) const { return this->get().iword(index); }
  155. BOOST_FORCEINLINE void*& pword(int index) const { return this->get().pword(index); }
  156. BOOST_FORCEINLINE void register_callback(event_callback fn, int index) const { this->get().register_callback(fn, index); }
  157. static BOOST_FORCEINLINE bool sync_with_stdio(bool sync = true) { return StreamT::sync_with_stdio(sync); }
  158. BOOST_EXPLICIT_OPERATOR_BOOL()
  159. BOOST_FORCEINLINE bool operator! () const { return !this->get(); }
  160. BOOST_FORCEINLINE iostate rdstate() const { return this->get().rdstate(); }
  161. BOOST_FORCEINLINE void clear(iostate state = goodbit) const { this->get().clear(state); }
  162. BOOST_FORCEINLINE void setstate(iostate state) const { this->get().setstate(state); }
  163. BOOST_FORCEINLINE bool good() const { return this->get().good(); }
  164. BOOST_FORCEINLINE bool eof() const { return this->get().eof(); }
  165. BOOST_FORCEINLINE bool fail() const { return this->get().fail(); }
  166. BOOST_FORCEINLINE bool bad() const { return this->get().bad(); }
  167. BOOST_FORCEINLINE iostate exceptions() const { return this->get().exceptions(); }
  168. BOOST_FORCEINLINE void exceptions(iostate s) const { this->get().exceptions(s); }
  169. BOOST_FORCEINLINE ostream_type* tie() const { return this->get().tie(); }
  170. BOOST_FORCEINLINE ostream_type* tie(ostream_type* strm) const { return this->get().tie(strm); }
  171. BOOST_FORCEINLINE streambuf_type* rdbuf() const { return this->get().rdbuf(); }
  172. BOOST_FORCEINLINE StreamT& copyfmt(std::basic_ios< char_type, traits_type >& rhs) const { return this->get().copyfmt(rhs); }
  173. BOOST_FORCEINLINE StreamT& copyfmt(StreamT& rhs) const { return this->get().copyfmt(rhs); }
  174. BOOST_FORCEINLINE char_type fill() const { return this->get().fill(); }
  175. BOOST_FORCEINLINE char_type fill(char_type ch) const { return this->get().fill(ch); }
  176. BOOST_FORCEINLINE char narrow(char_type ch, char def) const { return this->get().narrow(ch, def); }
  177. BOOST_FORCEINLINE char_type widen(char ch) const { return this->get().widen(ch); }
  178. BOOST_FORCEINLINE StreamT& flush() const { return this->get().flush(); }
  179. BOOST_FORCEINLINE pos_type tellp() const { return this->get().tellp(); }
  180. BOOST_FORCEINLINE StreamT& seekp(pos_type pos) const { return this->get().seekp(pos); }
  181. BOOST_FORCEINLINE StreamT& seekp(off_type off, std::ios_base::seekdir dir) const { return this->get().seekp(off, dir); }
  182. template< typename CharT >
  183. BOOST_FORCEINLINE typename boost::log::aux::enable_if_streamable_char_type< CharT, StreamT& >::type
  184. put(CharT c) const { return this->get().put(c); }
  185. template< typename CharT >
  186. BOOST_FORCEINLINE typename boost::log::aux::enable_if_streamable_char_type< CharT, StreamT& >::type
  187. write(const CharT* p, std::streamsize size) const { return this->get().write(p, size); }
  188. };
  189. template< typename StreamT >
  190. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::boolalpha;
  191. template< typename StreamT >
  192. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::dec;
  193. template< typename StreamT >
  194. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::fixed;
  195. template< typename StreamT >
  196. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::hex;
  197. template< typename StreamT >
  198. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::internal;
  199. template< typename StreamT >
  200. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::left;
  201. template< typename StreamT >
  202. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::oct;
  203. template< typename StreamT >
  204. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::right;
  205. template< typename StreamT >
  206. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::scientific;
  207. template< typename StreamT >
  208. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::showbase;
  209. template< typename StreamT >
  210. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::showpoint;
  211. template< typename StreamT >
  212. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::skipws;
  213. template< typename StreamT >
  214. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::unitbuf;
  215. template< typename StreamT >
  216. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::uppercase;
  217. template< typename StreamT >
  218. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::adjustfield;
  219. template< typename StreamT >
  220. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::basefield;
  221. template< typename StreamT >
  222. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::fmtflags stream_ref< StreamT >::floatfield;
  223. template< typename StreamT >
  224. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::badbit;
  225. template< typename StreamT >
  226. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::eofbit;
  227. template< typename StreamT >
  228. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::failbit;
  229. template< typename StreamT >
  230. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::iostate stream_ref< StreamT >::goodbit;
  231. template< typename StreamT >
  232. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::app;
  233. template< typename StreamT >
  234. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::ate;
  235. template< typename StreamT >
  236. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::binary;
  237. template< typename StreamT >
  238. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::in;
  239. template< typename StreamT >
  240. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::out;
  241. template< typename StreamT >
  242. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::openmode stream_ref< StreamT >::trunc;
  243. template< typename StreamT >
  244. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::seekdir stream_ref< StreamT >::beg;
  245. template< typename StreamT >
  246. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::seekdir stream_ref< StreamT >::cur;
  247. template< typename StreamT >
  248. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::seekdir stream_ref< StreamT >::end;
  249. template< typename StreamT >
  250. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::event stream_ref< StreamT >::erase_event;
  251. template< typename StreamT >
  252. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::event stream_ref< StreamT >::imbue_event;
  253. template< typename StreamT >
  254. BOOST_CONSTEXPR_OR_CONST typename stream_ref< StreamT >::event stream_ref< StreamT >::copyfmt_event;
  255. //! Default log record message formatter
  256. struct message_formatter
  257. {
  258. typedef void result_type;
  259. message_formatter() : m_MessageName(expressions::tag::message::get_name())
  260. {
  261. }
  262. template< typename StreamT >
  263. BOOST_FORCEINLINE result_type operator() (record_view const& rec, StreamT& strm) const
  264. {
  265. boost::log::visit< expressions::tag::message::value_type >(m_MessageName, rec, boost::log::bind_output(strm));
  266. }
  267. private:
  268. const attribute_name m_MessageName;
  269. };
  270. } // namespace aux
  271. } // namespace expressions
  272. /*!
  273. * Log record formatter function wrapper.
  274. */
  275. template< typename CharT >
  276. class basic_formatter
  277. {
  278. typedef basic_formatter this_type;
  279. BOOST_COPYABLE_AND_MOVABLE(this_type)
  280. public:
  281. //! Result type
  282. typedef void result_type;
  283. //! Character type
  284. typedef CharT char_type;
  285. //! Output stream type
  286. typedef basic_formatting_ostream< char_type > stream_type;
  287. private:
  288. //! Filter function type
  289. typedef boost::log::aux::light_function< void (record_view const&, expressions::aux::stream_ref< stream_type >) > formatter_type;
  290. private:
  291. //! Formatter function
  292. formatter_type m_Formatter;
  293. public:
  294. /*!
  295. * Default constructor. Creates a formatter that only outputs log message.
  296. */
  297. basic_formatter() : m_Formatter(expressions::aux::message_formatter())
  298. {
  299. }
  300. /*!
  301. * Copy constructor
  302. */
  303. basic_formatter(basic_formatter const& that) : m_Formatter(that.m_Formatter)
  304. {
  305. }
  306. /*!
  307. * Move constructor. The moved-from formatter is left in an unspecified state.
  308. */
  309. basic_formatter(BOOST_RV_REF(this_type) that) BOOST_NOEXCEPT : m_Formatter(boost::move(that.m_Formatter))
  310. {
  311. }
  312. /*!
  313. * Initializing constructor. Creates a formatter which will invoke the specified function object.
  314. */
  315. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  316. template< typename FunT >
  317. basic_formatter(FunT&& fun) : m_Formatter(boost::forward< FunT >(fun))
  318. {
  319. }
  320. #elif !defined(BOOST_MSVC) || BOOST_MSVC >= 1600
  321. template< typename FunT >
  322. basic_formatter(FunT const& fun, typename boost::disable_if_c< move_detail::is_rv< FunT >::value, boost::log::aux::sfinae_dummy >::type = boost::log::aux::sfinae_dummy()) : m_Formatter(fun)
  323. {
  324. }
  325. #else
  326. // MSVC 9 and older blows up in unexpected ways if we use SFINAE to disable constructor instantiation
  327. template< typename FunT >
  328. basic_formatter(FunT const& fun) : m_Formatter(fun)
  329. {
  330. }
  331. template< typename FunT >
  332. basic_formatter(rv< FunT >& fun) : m_Formatter(fun)
  333. {
  334. }
  335. template< typename FunT >
  336. basic_formatter(rv< FunT > const& fun) : m_Formatter(static_cast< FunT const& >(fun))
  337. {
  338. }
  339. basic_formatter(rv< this_type > const& that) : m_Formatter(that.m_Formatter)
  340. {
  341. }
  342. #endif
  343. /*!
  344. * Move assignment. The moved-from formatter is left in an unspecified state.
  345. */
  346. basic_formatter& operator= (BOOST_RV_REF(this_type) that) BOOST_NOEXCEPT
  347. {
  348. m_Formatter.swap(that.m_Formatter);
  349. return *this;
  350. }
  351. /*!
  352. * Copy assignment.
  353. */
  354. basic_formatter& operator= (BOOST_COPY_ASSIGN_REF(this_type) that)
  355. {
  356. m_Formatter = that.m_Formatter;
  357. return *this;
  358. }
  359. /*!
  360. * Initializing assignment. Sets the specified function object to the formatter.
  361. */
  362. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  363. template< typename FunT >
  364. basic_formatter& operator= (FunT&& fun)
  365. {
  366. this_type(boost::forward< FunT >(fun)).swap(*this);
  367. return *this;
  368. }
  369. #else
  370. template< typename FunT >
  371. typename boost::disable_if_c< is_same< typename remove_cv< FunT >::type, this_type >::value, this_type& >::type
  372. operator= (FunT const& fun)
  373. {
  374. this_type(fun).swap(*this);
  375. return *this;
  376. }
  377. #endif
  378. /*!
  379. * Formatting operator.
  380. *
  381. * \param rec A log record to format.
  382. * \param strm A stream to put the formatted characters to.
  383. */
  384. result_type operator() (record_view const& rec, stream_type& strm) const
  385. {
  386. m_Formatter(rec, expressions::aux::stream_ref< stream_type >(strm));
  387. }
  388. /*!
  389. * Resets the formatter to the default. The default formatter only outputs message text.
  390. */
  391. void reset()
  392. {
  393. m_Formatter = expressions::aux::message_formatter();
  394. }
  395. /*!
  396. * Swaps two formatters
  397. */
  398. void swap(basic_formatter& that) BOOST_NOEXCEPT
  399. {
  400. m_Formatter.swap(that.m_Formatter);
  401. }
  402. };
  403. template< typename CharT >
  404. inline void swap(basic_formatter< CharT >& left, basic_formatter< CharT >& right) BOOST_NOEXCEPT
  405. {
  406. left.swap(right);
  407. }
  408. #ifdef BOOST_LOG_USE_CHAR
  409. typedef basic_formatter< char > formatter;
  410. #endif
  411. #ifdef BOOST_LOG_USE_WCHAR_T
  412. typedef basic_formatter< wchar_t > wformatter;
  413. #endif
  414. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  415. } // namespace boost
  416. #include <boost/log/detail/footer.hpp>
  417. #endif // BOOST_LOG_EXPRESSIONS_FORMATTER_HPP_INCLUDED_