blob: 9f101f247887e0cd36fba92f890267790bf0c5cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef PPAPI_CPP_NET_ADDRESS_H_
#define PPAPI_CPP_NET_ADDRESS_H_
#include "ppapi/c/ppb_net_address.h"
#include "ppapi/cpp/pass_ref.h"
#include "ppapi/cpp/resource.h"
#include "ppapi/cpp/var.h"
namespace pp {
class InstanceHandle;
/// The <code>NetAddress</code> class represents a network address.
class NetAddress : public Resource {
public:
/// Default constructor for creating an is_null() <code>NetAddress</code>
/// object.
NetAddress();
/// A constructor used when you have received a <code>PP_Resource</code> as a
/// return value that has had 1 ref added for you.
///
/// @param[in] resource A <code>PPB_NetAddress</code> resource.
NetAddress(PassRef, PP_Resource resource);
/// A constructor used to create a <code>NetAddress</code> object with the
/// specified IPv4 address.
///
/// @param[in] instance The instance with which this resource will be
/// associated.
/// @param[in] ipv4_addr An IPv4 address.
NetAddress(const InstanceHandle& instance,
const PP_NetAddress_IPv4& ipv4_addr);
/// A constructor used to create a <code>NetAddress</code> object with the
/// specified IPv6 address.
///
/// @param[in] instance The instance with which this resource will be
/// associated.
/// @param[in] ipv6_addr An IPv6 address.
NetAddress(const InstanceHandle& instance,
const PP_NetAddress_IPv6& ipv6_addr);
/// The copy constructor for <code>NetAddress</code>.
///
/// @param[in] other A reference to another <code>NetAddress</code>.
NetAddress(const NetAddress& other);
/// The destructor.
virtual ~NetAddress();
/// The assignment operator for <code>NetAddress</code>.
///
/// @param[in] other A reference to another <code>NetAddress</code>.
///
/// @return A reference to this <code>NetAddress</code> object.
NetAddress& operator=(const NetAddress& other);
/// Static function for determining whether the browser supports the
/// <code>PPB_NetAddress</code> interface.
///
/// @return true if the interface is available, false otherwise.
static bool IsAvailable();
/// Gets the address family.
///
/// @return The address family on success;
/// <code>PP_NETADDRESS_FAMILY_UNSPECIFIED</code> on failure.
PP_NetAddress_Family GetFamily() const;
/// Returns a human-readable description of the network address. The
/// description is in the form of host [ ":" port ] and conforms to
/// http://tools.ietf.org/html/rfc3986#section-3.2 for IPv4 and IPv6 addresses
/// (e.g., "192.168.0.1", "192.168.0.1:99", or "[::1]:80").
///
/// @param[in] include_port Whether to include the port number in the
/// description.
///
/// @return A string <code>Var</code> on success; an undefined
/// <code>Var</code> on failure.
Var DescribeAsString(bool include_port) const;
/// Fills a <code>PP_NetAddress_IPv4</code> structure if the network address
/// is of <code>PP_NETADDRESS_FAMILY_IPV4</code> address family.
/// Note that passing a network address of
/// <code>PP_NETADDRESS_FAMILY_IPV6</code> address family will fail even if
/// the address is an IPv4-mapped IPv6 address.
///
/// @param[out] ipv4_addr A <code>PP_NetAddress_IPv4</code> structure to store
/// the result.
///
/// @return A boolean value indicating whether the operation succeeded.
bool DescribeAsIPv4Address(PP_NetAddress_IPv4* ipv4_addr) const;
/// Fills a <code>PP_NetAddress_IPv6</code> structure if the network address
/// is of <code>PP_NETADDRESS_FAMILY_IPV6</code> address family.
/// Note that passing a network address of
/// <code>PP_NETADDRESS_FAMILY_IPV4</code> address family will fail - this
/// method doesn't map it to an IPv6 address.
///
/// @param[out] ipv6_addr A <code>PP_NetAddress_IPv6</code> structure to store
/// the result.
///
/// @return A boolean value indicating whether the operation succeeded.
bool DescribeAsIPv6Address(PP_NetAddress_IPv6* ipv6_addr) const;
};
} // namespace pp
#endif // PPAPI_CPP_NET_ADDRESS_H_
|