summaryrefslogtreecommitdiff
path: root/gio/src/unixfdlist.hg
blob: 6fa6bfb0a18928b47d6413a3b4f150f5909d50bb (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
/* Copyright (C) 2010 The giomm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(giommconfig.h)

#include <glibmm/object.h>

_DEFS(giomm,gio)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gio
{

/** UnixFDList - An object containing a set of UNIX file descriptors.
 * A UnixFDList contains a list of file descriptors. It owns the file
 * descriptors that it contains, closing them when finalized.
 *
 * It may be wrapped in a UnixFDMessage and sent over a Socket in the
 * G_SOCKET_ADDRESS_UNIX family by using Gio::Socket::send() and received
 * using Gio::Socket::receive().
 *
 * @ingroup NetworkIO
 * @newin{2,28}
 */
class GIOMM_API UnixFDList : public Glib::Object
{
  _CLASS_GOBJECT(UnixFDList, GUnixFDList, G_UNIX_FD_LIST, Glib::Object, GObject, , , GIOMM_API)
  _GTKMMPROC_WIN32_NO_WRAP

protected:
  _CTOR_DEFAULT
  _IGNORE(g_unix_fd_list_new)

  explicit UnixFDList(const std::vector<int>&  fds);

  explicit UnixFDList(const std::vector<int>&  fds, int n_fds);
  _IGNORE(g_unix_fd_list_new_from_array)

public:
  _WRAP_METHOD_DOCS_ONLY(g_unix_fd_list_new)
  _WRAP_CREATE()

  /** Creates a new UnixFDList containing the file descriptors given in @a
   * fds.  The file descriptors become the property of the new list and may no
   * longer be used by the caller. The array itself is owned by the caller.
   *
   * Each file descriptor in the array should be set to close-on-exec.
   * @param fds The list of file descriptors to use for creation.
   * @return A new UnixFDList.
   */
  _WRAP_CREATE(const std::vector<int>&  fds)

  _WRAP_METHOD_DOCS_ONLY(g_unix_fd_list_new_from_array)
  _WRAP_CREATE(const std::vector<int>&  fds, int n_fds)

  _WRAP_METHOD(int get_length() const, g_unix_fd_list_get_length)
  _WRAP_METHOD(int get(int index) const, g_unix_fd_list_get, errthrow "Gio::Error")

  /** Returns the array of file descriptors that is contained in this object.
   *
   * After this call, the descriptors remain the property of the list. The
   * caller must not close them. The array is valid only until list is changed
   * in any way.
   * @return The list of file descriptors.
   *
   * @newin{2,28}
   */
  const std::vector<int> peek_fds() const;
  _IGNORE(g_unix_fd_list_peek_fds)

  /** Returns the array of file descriptors that is contained in this object.
   *
   * After this call, the descriptors are no longer contained in the list.
   * Further calls will return an empty list (unless more descriptors have
   * been added).
   *
   * The caller is responsible for closing all of the file descriptors. The
   * file descriptors in the array are set to close-on-exec.
   * @return The list of file descriptors.
   *
   * @newin{2,28}
   */
  std::vector<int> steal_fds();
  _IGNORE(g_unix_fd_list_steal_fds)

  _WRAP_METHOD_DOCS_ONLY(g_unix_fd_list_append)
  ///@throw Glib::Error.
  _WRAP_METHOD(int append(int fd), g_unix_fd_list_append, errthrow "Gio::Error")
};

} // namespace Gio