Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / asio / generic / detail / endpoint.hpp @ 2486

History | View | Annotate | Download (3.3 kB)

1 2486 sjacqu01
//
2 2486 sjacqu01
// generic/detail/endpoint.hpp
3 2486 sjacqu01
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 2486 sjacqu01
//
5 2486 sjacqu01
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 2486 sjacqu01
//
7 2486 sjacqu01
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8 2486 sjacqu01
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 2486 sjacqu01
//
10 2486 sjacqu01
11 2486 sjacqu01
#ifndef BOOST_ASIO_GENERIC_DETAIL_ENDPOINT_HPP
12 2486 sjacqu01
#define BOOST_ASIO_GENERIC_DETAIL_ENDPOINT_HPP
13 2486 sjacqu01
14 2486 sjacqu01
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 2486 sjacqu01
# pragma once
16 2486 sjacqu01
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 2486 sjacqu01
18 2486 sjacqu01
#include <boost/asio/detail/config.hpp>
19 2486 sjacqu01
20 2486 sjacqu01
#include <cstddef>
21 2486 sjacqu01
#include <boost/asio/detail/socket_types.hpp>
22 2486 sjacqu01
23 2486 sjacqu01
#include <boost/asio/detail/push_options.hpp>
24 2486 sjacqu01
25 2486 sjacqu01
namespace boost {
26 2486 sjacqu01
namespace asio {
27 2486 sjacqu01
namespace generic {
28 2486 sjacqu01
namespace detail {
29 2486 sjacqu01
30 2486 sjacqu01
// Helper class for implementing a generic socket endpoint.
31 2486 sjacqu01
class endpoint
32 2486 sjacqu01
{
33 2486 sjacqu01
public:
34 2486 sjacqu01
  // Default constructor.
35 2486 sjacqu01
  BOOST_ASIO_DECL endpoint();
36 2486 sjacqu01
37 2486 sjacqu01
  // Construct an endpoint from the specified raw bytes.
38 2486 sjacqu01
  BOOST_ASIO_DECL endpoint(const void* sock_addr,
39 2486 sjacqu01
      std::size_t sock_addr_size, int sock_protocol);
40 2486 sjacqu01
41 2486 sjacqu01
  // Copy constructor.
42 2486 sjacqu01
  endpoint(const endpoint& other)
43 2486 sjacqu01
    : data_(other.data_),
44 2486 sjacqu01
      size_(other.size_),
45 2486 sjacqu01
      protocol_(other.protocol_)
46 2486 sjacqu01
  {
47 2486 sjacqu01
  }
48 2486 sjacqu01
49 2486 sjacqu01
  // Assign from another endpoint.
50 2486 sjacqu01
  endpoint& operator=(const endpoint& other)
51 2486 sjacqu01
  {
52 2486 sjacqu01
    data_ = other.data_;
53 2486 sjacqu01
    size_ = other.size_;
54 2486 sjacqu01
    protocol_ = other.protocol_;
55 2486 sjacqu01
    return *this;
56 2486 sjacqu01
  }
57 2486 sjacqu01
58 2486 sjacqu01
  // Get the address family associated with the endpoint.
59 2486 sjacqu01
  int family() const
60 2486 sjacqu01
  {
61 2486 sjacqu01
    return data_.base.sa_family;
62 2486 sjacqu01
  }
63 2486 sjacqu01
64 2486 sjacqu01
  // Get the socket protocol associated with the endpoint.
65 2486 sjacqu01
  int protocol() const
66 2486 sjacqu01
  {
67 2486 sjacqu01
    return protocol_;
68 2486 sjacqu01
  }
69 2486 sjacqu01
70 2486 sjacqu01
  // Get the underlying endpoint in the native type.
71 2486 sjacqu01
  boost::asio::detail::socket_addr_type* data()
72 2486 sjacqu01
  {
73 2486 sjacqu01
    return &data_.base;
74 2486 sjacqu01
  }
75 2486 sjacqu01
76 2486 sjacqu01
  // Get the underlying endpoint in the native type.
77 2486 sjacqu01
  const boost::asio::detail::socket_addr_type* data() const
78 2486 sjacqu01
  {
79 2486 sjacqu01
    return &data_.base;
80 2486 sjacqu01
  }
81 2486 sjacqu01
82 2486 sjacqu01
  // Get the underlying size of the endpoint in the native type.
83 2486 sjacqu01
  std::size_t size() const
84 2486 sjacqu01
  {
85 2486 sjacqu01
    return size_;
86 2486 sjacqu01
  }
87 2486 sjacqu01
88 2486 sjacqu01
  // Set the underlying size of the endpoint in the native type.
89 2486 sjacqu01
  BOOST_ASIO_DECL void resize(std::size_t size);
90 2486 sjacqu01
91 2486 sjacqu01
  // Get the capacity of the endpoint in the native type.
92 2486 sjacqu01
  std::size_t capacity() const
93 2486 sjacqu01
  {
94 2486 sjacqu01
    return sizeof(boost::asio::detail::sockaddr_storage_type);
95 2486 sjacqu01
  }
96 2486 sjacqu01
97 2486 sjacqu01
  // Compare two endpoints for equality.
98 2486 sjacqu01
  BOOST_ASIO_DECL friend bool operator==(
99 2486 sjacqu01
      const endpoint& e1, const endpoint& e2);
100 2486 sjacqu01
101 2486 sjacqu01
  // Compare endpoints for ordering.
102 2486 sjacqu01
  BOOST_ASIO_DECL friend bool operator<(
103 2486 sjacqu01
      const endpoint& e1, const endpoint& e2);
104 2486 sjacqu01
105 2486 sjacqu01
private:
106 2486 sjacqu01
  // The underlying socket address.
107 2486 sjacqu01
  union data_union
108 2486 sjacqu01
  {
109 2486 sjacqu01
    boost::asio::detail::socket_addr_type base;
110 2486 sjacqu01
    boost::asio::detail::sockaddr_storage_type generic;
111 2486 sjacqu01
  } data_;
112 2486 sjacqu01
113 2486 sjacqu01
  // The length of the socket address stored in the endpoint.
114 2486 sjacqu01
  std::size_t size_;
115 2486 sjacqu01
116 2486 sjacqu01
  // The socket protocol associated with the endpoint.
117 2486 sjacqu01
  int protocol_;
118 2486 sjacqu01
119 2486 sjacqu01
  // Initialise with a specified memory.
120 2486 sjacqu01
  BOOST_ASIO_DECL void init(const void* sock_addr,
121 2486 sjacqu01
      std::size_t sock_addr_size, int sock_protocol);
122 2486 sjacqu01
};
123 2486 sjacqu01
124 2486 sjacqu01
} // namespace detail
125 2486 sjacqu01
} // namespace generic
126 2486 sjacqu01
} // namespace asio
127 2486 sjacqu01
} // namespace boost
128 2486 sjacqu01
129 2486 sjacqu01
#include <boost/asio/detail/pop_options.hpp>
130 2486 sjacqu01
131 2486 sjacqu01
#if defined(BOOST_ASIO_HEADER_ONLY)
132 2486 sjacqu01
# include <boost/asio/generic/detail/impl/endpoint.ipp>
133 2486 sjacqu01
#endif // defined(BOOST_ASIO_HEADER_ONLY)
134 2486 sjacqu01
135 2486 sjacqu01
#endif // BOOST_ASIO_GENERIC_DETAIL_ENDPOINT_HPP