source: appstream-generator/build/girepo/gio/InetSocketAddress.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 4.3 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.InetSocketAddress;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.InetAddress;
26private import gio.SocketAddress;
27private import glib.ConstructionException;
28private import glib.Str;
29private import gobject.ObjectG;
30
31
32/**
33 * An IPv4 or IPv6 socket address; that is, the combination of a
34 * #GInetAddress and a port number.
35 */
36public class InetSocketAddress : SocketAddress
37{
38        /** the main Gtk struct */
39        protected GInetSocketAddress* gInetSocketAddress;
40
41        /** Get the main Gtk struct */
42        public GInetSocketAddress* getInetSocketAddressStruct()
43        {
44                return gInetSocketAddress;
45        }
46
47        /** the main Gtk struct as a void* */
48        protected override void* getStruct()
49        {
50                return cast(void*)gInetSocketAddress;
51        }
52
53        protected override void setStruct(GObject* obj)
54        {
55                gInetSocketAddress = cast(GInetSocketAddress*)obj;
56                super.setStruct(obj);
57        }
58
59        /**
60         * Sets our main struct and passes it to the parent class.
61         */
62        public this (GInetSocketAddress* gInetSocketAddress, bool ownedRef = false)
63        {
64                this.gInetSocketAddress = gInetSocketAddress;
65                super(cast(GSocketAddress*)gInetSocketAddress, ownedRef);
66        }
67
68
69        /** */
70        public static GType getType()
71        {
72                return g_inet_socket_address_get_type();
73        }
74
75        /**
76         * Creates a new #GInetSocketAddress for @address and @port.
77         *
78         * Params:
79         *     address = a #GInetAddress
80         *     port = a port number
81         *
82         * Returns: a new #GInetSocketAddress
83         *
84         * Since: 2.22
85         *
86         * Throws: ConstructionException GTK+ fails to create the object.
87         */
88        public this(InetAddress address, ushort port)
89        {
90                auto p = g_inet_socket_address_new((address is null) ? null : address.getInetAddressStruct(), port);
91               
92                if(p is null)
93                {
94                        throw new ConstructionException("null returned by new");
95                }
96               
97                this(cast(GInetSocketAddress*) p, true);
98        }
99
100        /**
101         * Creates a new #GInetSocketAddress for @address and @port.
102         *
103         * If @address is an IPv6 address, it can also contain a scope ID
104         * (separated from the address by a "<literal>%</literal>").
105         *
106         * Params:
107         *     address = the string form of an IP address
108         *     port = a port number
109         *
110         * Returns: a new #GInetSocketAddress, or %NULL if @address cannot be
111         *     parsed.
112         *
113         * Since: 2.40
114         *
115         * Throws: ConstructionException GTK+ fails to create the object.
116         */
117        public this(string address, uint port)
118        {
119                auto p = g_inet_socket_address_new_from_string(Str.toStringz(address), port);
120               
121                if(p is null)
122                {
123                        throw new ConstructionException("null returned by new_from_string");
124                }
125               
126                this(cast(GInetSocketAddress*) p, true);
127        }
128
129        /**
130         * Gets @address's #GInetAddress.
131         *
132         * Returns: the #GInetAddress for @address, which must be
133         *     g_object_ref()'d if it will be stored
134         *
135         * Since: 2.22
136         */
137        public InetAddress getAddress()
138        {
139                auto p = g_inet_socket_address_get_address(gInetSocketAddress);
140               
141                if(p is null)
142                {
143                        return null;
144                }
145               
146                return ObjectG.getDObject!(InetAddress)(cast(GInetAddress*) p);
147        }
148
149        /**
150         * Gets the `sin6_flowinfo` field from @address,
151         * which must be an IPv6 address.
152         *
153         * Returns: the flowinfo field
154         *
155         * Since: 2.32
156         */
157        public uint getFlowinfo()
158        {
159                return g_inet_socket_address_get_flowinfo(gInetSocketAddress);
160        }
161
162        /**
163         * Gets @address's port.
164         *
165         * Returns: the port for @address
166         *
167         * Since: 2.22
168         */
169        public ushort getPort()
170        {
171                return g_inet_socket_address_get_port(gInetSocketAddress);
172        }
173
174        /**
175         * Gets the `sin6_scope_id` field from @address,
176         * which must be an IPv6 address.
177         *
178         * Returns: the scope id field
179         *
180         * Since: 2.32
181         */
182        public uint getScopeId()
183        {
184                return g_inet_socket_address_get_scope_id(gInetSocketAddress);
185        }
186}
Note: See TracBrowser for help on using the repository browser.