|
| 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_TRANSFORMERS_TO_UPPER_HPP__ |
| 8 | +#define __NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ |
| 9 | + |
| 10 | +#include <boost/algorithm/string.hpp> |
| 11 | + |
| 12 | +/** to_upper.hpp |
| 13 | + * |
| 14 | + * Implements the to_upper transformer. This applies |
| 15 | + * the to_upper string algorithm to a string, which |
| 16 | + * is selected by the appropriate selector. |
| 17 | + * |
| 18 | + * This defines a type, to be applied using template |
| 19 | + * metaprogramming on the selected string target. |
| 20 | + */ |
| 21 | +namespace boost { namespace network { |
| 22 | + |
| 23 | + namespace impl { |
| 24 | + |
| 25 | + template <class Selector> |
| 26 | + struct to_upper_transformer { }; |
| 27 | + |
| 28 | + template <> |
| 29 | + struct to_upper_transformer<selectors::source_selector> { |
| 30 | + template <class Tag> |
| 31 | + void operator() (basic_message<Tag> & message_) const { |
| 32 | + boost::to_upper(message_.source()); |
| 33 | + }; |
| 34 | + |
| 35 | + protected: |
| 36 | + ~to_upper_transformer() { }; |
| 37 | + }; |
| 38 | + |
| 39 | + template <> |
| 40 | + struct to_upper_transformer<selectors::destination_selector> { |
| 41 | + template <class Tag> |
| 42 | + void operator() (basic_message<Tag> & message_) const { |
| 43 | + boost::to_upper(message_.destination()); |
| 44 | + }; |
| 45 | + |
| 46 | + protected: |
| 47 | + ~to_upper_transformer() { }; |
| 48 | + }; |
| 49 | + |
| 50 | + }; // namespace impl |
| 51 | + |
| 52 | + struct to_upper_placeholder { |
| 53 | + template <class Selector> |
| 54 | + struct type : public impl::to_upper_transformer<Selector> { }; |
| 55 | + } ; |
| 56 | + |
| 57 | + extern to_upper_placeholder to_upper_; |
| 58 | + |
| 59 | +}; // namespace network |
| 60 | + |
| 61 | +}; // namespace boost |
| 62 | + |
| 63 | +#endif // __NETWORK_MESSAGE_TRANSFORMERS_TO_UPPER_HPP__ |
| 64 | + |
0 commit comments