Skip to content

Commit 00b27b7

Browse files
committed
Client or Server Tag Selector
This change introduces a selector metafunction that takes a tag, and checks whether it is meant to be a client or server tag. The selector metafunction then yields the actual tag found (whether it is a client or server tag) so that it can be used for function tag dispatch purposes.
1 parent 5e47bea commit 00b27b7

File tree

3 files changed

+71
-6
lines changed

3 files changed

+71
-6
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127
2+
#define BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127
3+
4+
// Copyright 2010 Dean Michael Berris.
5+
// Distributed under the Boost Software License, Version 1.0.
6+
// (See accompanying file LICENSE_1_0.txt or copy at
7+
// http://www.boost.org/LICENSE_1_0.txt)
8+
9+
#include <boost/network/protocol/http/support/is_server.hpp>
10+
#include <boost/network/protocol/http/support/is_client.hpp>
11+
#include <boost/mpl/if.hpp>
12+
13+
namespace boost { namespace network { namespace http {
14+
15+
template <class Tag>
16+
struct client_or_server :
17+
mpl::if_<
18+
is_server<Tag>,
19+
tags::server,
20+
typename mpl::if_<
21+
is_client<Tag>,
22+
tags::client,
23+
unsupported_tag<Tag>
24+
>::type
25+
>
26+
{};
27+
28+
29+
} /* http */
30+
31+
} /* network */
32+
33+
} /* boost */
34+
35+
#endif /* BOOST_NETWORK_PROTOCOL_HTTP_SUPPORT_CLIENT_OR_SERVER_HPP_20101127 */
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118
2+
#define BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118
3+
4+
// Copyright 2010 Dean Michael Berris.
5+
// Distributed under the Boost Software License, Version 1.0.
6+
// (See accompanying file LICENSE_1_0.txt or copy at
7+
// http://www.boost.org/LICENSE_1_0.txt)
8+
9+
#include <boost/network/protocol/http/tags.hpp>
10+
#include <boost/type_traits/is_base_of.hpp>
11+
12+
namespace boost { namespace network { namespace http {
13+
14+
template <class Tag>
15+
struct is_client :
16+
is_base_of<
17+
tags::client,
18+
Tag
19+
>
20+
{};
21+
22+
} /* http */
23+
24+
} /* network */
25+
26+
} /* boost */
27+
28+
#endif /* BOOST_NETWORK_PROTOCOL_SUPPORT_IS_CLIENT_HPP_20101118 */
29+

boost/network/protocol/http/tags.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ namespace boost { namespace network { namespace http { namespace tags {
1414
struct keepalive {};
1515
struct simple {};
1616
struct server {};
17+
struct client {};
1718

1819
using namespace boost::network::tags;
1920

2021
template <class Tag>
2122
struct components;
2223

23-
typedef mpl::vector<http, simple, sync, tcp, default_string> http_default_8bit_tcp_resolve_tags;
24-
typedef mpl::vector<http, simple, sync, udp, default_string> http_default_8bit_udp_resolve_tags;
25-
typedef mpl::vector<http, keepalive, sync, tcp, default_string> http_keepalive_8bit_tcp_resolve_tags;
26-
typedef mpl::vector<http, keepalive, sync, udp, default_string> http_keepalive_8bit_udp_resolve_tags;
27-
typedef mpl::vector<http, simple, async, udp, default_string> http_async_8bit_udp_resolve_tags;
28-
typedef mpl::vector<http, simple, async, tcp, default_string> http_async_8bit_tcp_resolve_tags;
24+
typedef mpl::vector<http, client, simple, sync, tcp, default_string> http_default_8bit_tcp_resolve_tags;
25+
typedef mpl::vector<http, client, simple, sync, udp, default_string> http_default_8bit_udp_resolve_tags;
26+
typedef mpl::vector<http, client, keepalive, sync, tcp, default_string> http_keepalive_8bit_tcp_resolve_tags;
27+
typedef mpl::vector<http, client, keepalive, sync, udp, default_string> http_keepalive_8bit_udp_resolve_tags;
28+
typedef mpl::vector<http, client, simple, async, udp, default_string> http_async_8bit_udp_resolve_tags;
29+
typedef mpl::vector<http, client, simple, async, tcp, default_string> http_async_8bit_tcp_resolve_tags;
2930
typedef mpl::vector<http, simple, sync, pod, default_string, server> http_server_tags;
3031
typedef mpl::vector<http, simple, async, pod, default_string, server> http_async_server_tags;
3132

0 commit comments

Comments
 (0)