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