File tree Expand file tree Collapse file tree 2 files changed +90
-0
lines changed Expand file tree Collapse file tree 2 files changed +90
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ // Copyright Dean Michael Berris 2007.
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
+ #ifndef __NETWORK_MESSAGE_DIRECTIVES_SOURCE_HPP__
8
+ #define __NETWORK_MESSAGE_DIRECTIVES_SOURCE_HPP__
9
+
10
+ /* * header.hpp
11
+ *
12
+ * Defines the types involved and the semantics of adding
13
+ * source information into message objects.
14
+ *
15
+ * WARNING: DO NOT INCLUDE THIS HEADER DIRECTLY. THIS REQUIRES
16
+ * TYPES TO BE DEFINED FROM EARLIER FILES THAT INCLUDE THIS
17
+ * HEADER.
18
+ */
19
+ namespace boost { namespace network {
20
+
21
+ namespace impl {
22
+ template <class Tag >
23
+ struct source_directive : public detail ::directive_base<Tag> {
24
+ typedef Tag tag;
25
+
26
+ explicit source_directive ( std::string const & source)
27
+ : _source(source)
28
+ { };
29
+
30
+ void operator () (basic_message<tag> & msg) const {
31
+ msg.source () = _source;
32
+ };
33
+
34
+ private:
35
+
36
+ mutable std::string _source;
37
+ };
38
+ } // namespace impl
39
+
40
+ inline impl::source_directive<tags::default_>
41
+ source (std::string const & source_) {
42
+ return impl::source_directive<tags::default_>(source_);
43
+ };
44
+
45
+ }; // namespace network
46
+
47
+ }; // namespace boost
48
+
49
+ #endif // __NETWORK_MESSAGE_DIRECTIVES_SOURCE_HPP__
50
+
Original file line number Diff line number Diff line change
1
+
2
+ // Copyright Dean Michael Berris 2007.
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
+ #ifndef __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__
8
+ #define __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__
9
+
10
+ namespace boost { namespace network {
11
+
12
+ namespace impl {
13
+ template <class Tag >
14
+ struct source_wrapper : public detail ::wrapper_base<Tag> {
15
+ typedef Tag tag;
16
+ typedef basic_message<tag> message_type;
17
+
18
+ explicit source_wrapper (basic_message<tag> & message_)
19
+ : detail::wrapper_base<tag>(message_)
20
+ { };
21
+
22
+ operator std::string () const {
23
+ return std::string (detail::wrapper_base<tag>::_message.source ());
24
+ };
25
+ };
26
+ }; // namespace impl
27
+
28
+ template <class Tag >
29
+ inline std::string
30
+ source (basic_message<Tag> & message_) {
31
+ return impl::source_wrapper<Tag>(message_);
32
+ };
33
+
34
+ }; // namespace network
35
+
36
+ }; // namespace boost
37
+
38
+ #endif // __NETWORK_MESSAGE_WRAPPERS_SOURCE_HPP__
39
+
40
+
You can’t perform that action at this time.
0 commit comments