message.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 message.hpp
  9. * \author Andrey Semashev
  10. * \date 13.07.2012
  11. *
  12. * The header contains log message keyword declaration.
  13. */
  14. #ifndef BOOST_LOG_EXPRESSIONS_MESSAGE_HPP_INCLUDED_
  15. #define BOOST_LOG_EXPRESSIONS_MESSAGE_HPP_INCLUDED_
  16. #include <string>
  17. #include <boost/mpl/vector.hpp>
  18. #include <boost/log/detail/config.hpp>
  19. #include <boost/log/detail/default_attribute_names.hpp>
  20. #include <boost/log/expressions/keyword.hpp>
  21. #include <boost/log/expressions/is_keyword_descriptor.hpp>
  22. #include <boost/log/attributes/attribute_name.hpp>
  23. #include <boost/log/detail/header.hpp>
  24. #ifdef BOOST_HAS_PRAGMA_ONCE
  25. #pragma once
  26. #endif
  27. namespace boost {
  28. BOOST_LOG_OPEN_NAMESPACE
  29. namespace expressions {
  30. namespace tag {
  31. /*!
  32. * Generic log message attribute descriptor.
  33. */
  34. struct message :
  35. public keyword_descriptor
  36. {
  37. // The attribute value type here is not essential since message attributes are not intended to be created via the keyword
  38. typedef void attribute_type;
  39. #if defined(BOOST_LOG_USE_CHAR) && defined(BOOST_LOG_USE_WCHAR_T)
  40. typedef mpl::vector2< std::string, std::wstring > value_type;
  41. #elif defined(BOOST_LOG_USE_CHAR)
  42. typedef std::string value_type;
  43. #elif defined(BOOST_LOG_USE_WCHAR_T)
  44. typedef std::wstring value_type;
  45. #endif
  46. static attribute_name get_name() { return boost::log::aux::default_attribute_names::message(); }
  47. };
  48. #if defined(BOOST_LOG_USE_CHAR)
  49. /*!
  50. * Narrow character log message attribute descriptor.
  51. */
  52. struct smessage :
  53. public keyword_descriptor
  54. {
  55. // The attribute value type here is not essential since message attributes are not intended to be created via the keyword
  56. typedef void attribute_type;
  57. typedef std::string value_type;
  58. static attribute_name get_name() { return boost::log::aux::default_attribute_names::message(); }
  59. };
  60. #endif
  61. #if defined(BOOST_LOG_USE_WCHAR_T)
  62. /*!
  63. * Wide character log message attribute descriptor.
  64. */
  65. struct wmessage :
  66. public keyword_descriptor
  67. {
  68. // The attribute value type here is not essential since message attributes are not intended to be created via the keyword
  69. typedef void attribute_type;
  70. typedef std::wstring value_type;
  71. static attribute_name get_name() { return boost::log::aux::default_attribute_names::message(); }
  72. };
  73. #endif
  74. } // namespace tag
  75. /*!
  76. * Generic message keyword type.
  77. */
  78. typedef attribute_keyword< tag::message > message_type;
  79. /*!
  80. * Generic message keyword.
  81. */
  82. BOOST_INLINE_VARIABLE const message_type message = {};
  83. #if defined(BOOST_LOG_USE_CHAR)
  84. /*!
  85. * Narrow message keyword type.
  86. */
  87. typedef attribute_keyword< tag::smessage > smessage_type;
  88. /*!
  89. * Narrow message keyword.
  90. */
  91. BOOST_INLINE_VARIABLE const smessage_type smessage = {};
  92. #endif
  93. #if defined(BOOST_LOG_USE_WCHAR_T)
  94. /*!
  95. * Wide message keyword type.
  96. */
  97. typedef attribute_keyword< tag::wmessage > wmessage_type;
  98. /*!
  99. * Wide message keyword.
  100. */
  101. BOOST_INLINE_VARIABLE const wmessage_type wmessage = {};
  102. #endif
  103. } // namespace expressions
  104. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  105. } // namespace boost
  106. #include <boost/log/detail/footer.hpp>
  107. #endif // BOOST_LOG_EXPRESSIONS_MESSAGE_HPP_INCLUDED_