~ubuntu-branches/ubuntu/trusty/miro/trusty

« back to all changes in this revision

Viewing changes to portable/libtorrent/include/libtorrent/asio/ip/basic_resolver_query.hpp

  • Committer: Daniel Hahler
  • Date: 2010-04-13 18:51:35 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: ubuntu-launchpad@thequod.de-20100413185135-xi24v1diqg8w406x
Merging shared upstream rev into target branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// basic_resolver_query.hpp
3
 
// ~~~~~~~~~~~~~~~~~~~~~~~~
4
 
//
5
 
// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6
 
//
7
 
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8
 
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9
 
//
10
 
 
11
 
#ifndef ASIO_IP_BASIC_RESOLVER_QUERY_HPP
12
 
#define ASIO_IP_BASIC_RESOLVER_QUERY_HPP
13
 
 
14
 
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15
 
# pragma once
16
 
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
 
 
18
 
#include "asio/detail/push_options.hpp"
19
 
 
20
 
#include "asio/detail/push_options.hpp"
21
 
#include <boost/config.hpp>
22
 
#include <string>
23
 
#include "asio/detail/pop_options.hpp"
24
 
 
25
 
#include "asio/detail/socket_ops.hpp"
26
 
#include "asio/ip/resolver_query_base.hpp"
27
 
 
28
 
namespace asio {
29
 
namespace ip {
30
 
 
31
 
/// An query to be passed to a resolver.
32
 
/**
33
 
 * The asio::ip::basic_resolver_query class template describes a query
34
 
 * that can be passed to a resolver.
35
 
 *
36
 
 * @par Thread Safety
37
 
 * @e Distinct @e objects: Safe.@n
38
 
 * @e Shared @e objects: Unsafe.
39
 
 */
40
 
template <typename InternetProtocol>
41
 
class basic_resolver_query
42
 
  : public resolver_query_base
43
 
{
44
 
public:
45
 
  /// The protocol type associated with the endpoint query.
46
 
  typedef InternetProtocol protocol_type;
47
 
 
48
 
  /// Construct with specified service name for any protocol.
49
 
  basic_resolver_query(const std::string& service_name,
50
 
      int flags = passive | address_configured)
51
 
    : hints_(),
52
 
      host_name_(),
53
 
      service_name_(service_name)
54
 
  {
55
 
    typename InternetProtocol::endpoint endpoint;
56
 
    hints_.ai_flags = flags;
57
 
    hints_.ai_family = PF_UNSPEC;
58
 
    hints_.ai_socktype = endpoint.protocol().type();
59
 
    hints_.ai_protocol = endpoint.protocol().protocol();
60
 
    hints_.ai_addrlen = 0;
61
 
    hints_.ai_canonname = 0;
62
 
    hints_.ai_addr = 0;
63
 
    hints_.ai_next = 0;
64
 
  }
65
 
 
66
 
  /// Construct with specified service name for a given protocol.
67
 
  basic_resolver_query(const protocol_type& protocol,
68
 
      const std::string& service_name,
69
 
      int flags = passive | address_configured)
70
 
    : hints_(),
71
 
      host_name_(),
72
 
      service_name_(service_name)
73
 
  {
74
 
    hints_.ai_flags = flags;
75
 
    hints_.ai_family = protocol.family();
76
 
    hints_.ai_socktype = protocol.type();
77
 
    hints_.ai_protocol = protocol.protocol();
78
 
    hints_.ai_addrlen = 0;
79
 
    hints_.ai_canonname = 0;
80
 
    hints_.ai_addr = 0;
81
 
    hints_.ai_next = 0;
82
 
  }
83
 
 
84
 
  /// Construct with specified host name and service name for any protocol.
85
 
  basic_resolver_query(const std::string& host_name,
86
 
      const std::string& service_name, int flags = address_configured)
87
 
    : hints_(),
88
 
      host_name_(host_name),
89
 
      service_name_(service_name)
90
 
  {
91
 
    typename InternetProtocol::endpoint endpoint;
92
 
    hints_.ai_flags = flags;
93
 
    hints_.ai_family = PF_UNSPEC;
94
 
    hints_.ai_socktype = endpoint.protocol().type();
95
 
    hints_.ai_protocol = endpoint.protocol().protocol();
96
 
    hints_.ai_addrlen = 0;
97
 
    hints_.ai_canonname = 0;
98
 
    hints_.ai_addr = 0;
99
 
    hints_.ai_next = 0;
100
 
  }
101
 
 
102
 
  /// Construct with specified host name and service name for a given protocol.
103
 
  basic_resolver_query(const protocol_type& protocol,
104
 
      const std::string& host_name, const std::string& service_name,
105
 
      int flags = address_configured)
106
 
    : hints_(),
107
 
      host_name_(host_name),
108
 
      service_name_(service_name)
109
 
  {
110
 
    hints_.ai_flags = flags;
111
 
    hints_.ai_family = protocol.family();
112
 
    hints_.ai_socktype = protocol.type();
113
 
    hints_.ai_protocol = protocol.protocol();
114
 
    hints_.ai_addrlen = 0;
115
 
    hints_.ai_canonname = 0;
116
 
    hints_.ai_addr = 0;
117
 
    hints_.ai_next = 0;
118
 
  }
119
 
 
120
 
  /// Get the hints associated with the query.
121
 
  const asio::detail::addrinfo_type& hints() const
122
 
  {
123
 
    return hints_;
124
 
  }
125
 
 
126
 
  /// Get the host name associated with the query.
127
 
  std::string host_name() const
128
 
  {
129
 
    return host_name_;
130
 
  }
131
 
 
132
 
  /// Get the service name associated with the query.
133
 
  std::string service_name() const
134
 
  {
135
 
    return service_name_;
136
 
  }
137
 
 
138
 
private:
139
 
  asio::detail::addrinfo_type hints_;
140
 
  std::string host_name_;
141
 
  std::string service_name_;
142
 
};
143
 
 
144
 
} // namespace ip
145
 
} // namespace asio
146
 
 
147
 
#include "asio/detail/pop_options.hpp"
148
 
 
149
 
#endif // ASIO_IP_BASIC_RESOLVER_QUERY_HPP