Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QDBusUnixFileDescriptor Class Reference

\inmodule QtDBus More...

#include <qdbusunixfiledescriptor.h>

+ Collaboration diagram for QDBusUnixFileDescriptor:

Public Member Functions

 QDBusUnixFileDescriptor ()
 Constructs a QDBusUnixFileDescriptor without a wrapped file descriptor.
 
 QDBusUnixFileDescriptor (int fileDescriptor)
 Constructs a QDBusUnixFileDescriptor object by copying the fileDescriptor parameter.
 
 QDBusUnixFileDescriptor (const QDBusUnixFileDescriptor &other)
 Constructs a QDBusUnixFileDescriptor object by copying other.
 
QDBusUnixFileDescriptoroperator= (QDBusUnixFileDescriptor &&other) noexcept
 Move-assigns other to this QDBusUnixFileDescriptor.
 
QDBusUnixFileDescriptoroperator= (const QDBusUnixFileDescriptor &other)
 Copies the Unix file descriptor from the other QDBusUnixFileDescriptor object.
 
 ~QDBusUnixFileDescriptor ()
 Destroys this QDBusUnixFileDescriptor object and disposes of the Unix file descriptor that it contained.
 
void swap (QDBusUnixFileDescriptor &other) noexcept
 
bool isValid () const
 Returns true if this Unix file descriptor is valid.
 
int fileDescriptor () const
 Returns the Unix file descriptor contained by this QDBusUnixFileDescriptor object.
 
void setFileDescriptor (int fileDescriptor)
 
void giveFileDescriptor (int fileDescriptor)
 
int takeFileDescriptor ()
 

Static Public Member Functions

static bool isSupported ()
 

Protected Types

typedef QExplicitlySharedDataPointer< QDBusUnixFileDescriptorPrivateData
 

Protected Attributes

Data d
 

Detailed Description

\inmodule QtDBus

Since
4.8

The QDBusUnixFileDescriptor class holds one Unix file descriptor.

The QDBusUnixFileDescriptor class is used to hold one Unix file descriptor for use with the Qt D-Bus module. This allows applications to send and receive Unix file descriptors over the D-Bus connection, mapping automatically to the D-Bus type 'h'.

Objects of type QDBusUnixFileDescriptors can be used also as parameters in signals and slots that get exported to D-Bus by registering with QDBusConnection::registerObject.

QDBusUnixFileDescriptor does not take ownership of the file descriptor. Instead, it will use the Unix system call dup(2) to make a copy of the file descriptor. This file descriptor belongs to the QDBusUnixFileDescriptor object and should not be stored or closed by the user. Instead, you should make your own copy if you need that.

Definition at line 20 of file qdbusunixfiledescriptor.h.

Member Typedef Documentation

◆ Data

Definition at line 44 of file qdbusunixfiledescriptor.h.

Constructor & Destructor Documentation

◆ QDBusUnixFileDescriptor() [1/3]

QDBusUnixFileDescriptor::QDBusUnixFileDescriptor ( )

Constructs a QDBusUnixFileDescriptor without a wrapped file descriptor.

This is equivalent to constructing the object with an invalid file descriptor (like -1).

See also
fileDescriptor(), isValid()

Definition at line 103 of file qdbusunixfiledescriptor.cpp.

◆ QDBusUnixFileDescriptor() [2/3]

QDBusUnixFileDescriptor::QDBusUnixFileDescriptor ( int fileDescriptor)
explicit

Constructs a QDBusUnixFileDescriptor object by copying the fileDescriptor parameter.

The original file descriptor is not touched and must be closed by the user.

Note that the value returned by fileDescriptor() will be different from the fileDescriptor parameter passed.

If the fileDescriptor parameter is not valid, isValid() will return false and fileDescriptor() will return -1.

See also
setFileDescriptor(), fileDescriptor()

Definition at line 121 of file qdbusunixfiledescriptor.cpp.

References fileDescriptor(), and setFileDescriptor().

+ Here is the call graph for this function:

◆ QDBusUnixFileDescriptor() [3/3]

QDBusUnixFileDescriptor::QDBusUnixFileDescriptor ( const QDBusUnixFileDescriptor & other)

Constructs a QDBusUnixFileDescriptor object by copying other.

Definition at line 131 of file qdbusunixfiledescriptor.cpp.

◆ ~QDBusUnixFileDescriptor()

QDBusUnixFileDescriptor::~QDBusUnixFileDescriptor ( )

Destroys this QDBusUnixFileDescriptor object and disposes of the Unix file descriptor that it contained.

Definition at line 157 of file qdbusunixfiledescriptor.cpp.

Member Function Documentation

◆ fileDescriptor()

int QDBusUnixFileDescriptor::fileDescriptor ( ) const

Returns the Unix file descriptor contained by this QDBusUnixFileDescriptor object.

An invalid file descriptor is represented by the value -1.

Note that the file descriptor returned by this function is owned by the QDBusUnixFileDescriptor object and must not be stored past the lifetime of this object. It is ok to use it while this object is valid, but if one wants to store it for longer use, the file descriptor should be cloned using the Unix dup(2), dup2(2) or dup3(2) functions.

See also
isValid()

Definition at line 193 of file qdbusunixfiledescriptor.cpp.

References d, QDBusUnixFileDescriptorPrivate::fd, and QBasicAtomicInteger< T >::loadRelaxed().

Referenced by QDBusUnixFileDescriptor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ giveFileDescriptor()

void QDBusUnixFileDescriptor::giveFileDescriptor ( int fileDescriptor)

Definition at line 293 of file qdbusunixfiledescriptor.cpp.

Referenced by QDBusDemarshaller::toUnixFileDescriptor().

+ Here is the caller graph for this function:

◆ isSupported()

bool QDBusUnixFileDescriptor::isSupported ( )
static

Definition at line 284 of file qdbusunixfiledescriptor.cpp.

◆ isValid()

bool QDBusUnixFileDescriptor::isValid ( ) const

Returns true if this Unix file descriptor is valid.

A valid Unix file descriptor is not -1.

See also
fileDescriptor()

Definition at line 175 of file qdbusunixfiledescriptor.cpp.

References d, QDBusUnixFileDescriptorPrivate::fd, and QBasicAtomicInteger< T >::loadRelaxed().

+ Here is the call graph for this function:

◆ operator=() [1/2]

QDBusUnixFileDescriptor & QDBusUnixFileDescriptor::operator= ( const QDBusUnixFileDescriptor & other)

Copies the Unix file descriptor from the other QDBusUnixFileDescriptor object.

If the current object contained a file descriptor, it will be properly disposed of before.

Definition at line 141 of file qdbusunixfiledescriptor.cpp.

References d, and other().

+ Here is the call graph for this function:

◆ operator=() [2/2]

QDBusUnixFileDescriptor & QDBusUnixFileDescriptor::operator= ( QDBusUnixFileDescriptor && other)
inlinenoexcept

Move-assigns other to this QDBusUnixFileDescriptor.

Definition at line 26 of file qdbusunixfiledescriptor.h.

References other(), and swap().

+ Here is the call graph for this function:

◆ setFileDescriptor()

void QDBusUnixFileDescriptor::setFileDescriptor ( int fileDescriptor)

Definition at line 289 of file qdbusunixfiledescriptor.cpp.

Referenced by QDBusUnixFileDescriptor().

+ Here is the caller graph for this function:

◆ swap()

void QDBusUnixFileDescriptor::swap ( QDBusUnixFileDescriptor & other)
inlinenoexcept
Since
5.0

Swaps this file descriptor instance with other. This function is very fast and never fails.

Definition at line 30 of file qdbusunixfiledescriptor.h.

References d, and other().

+ Here is the call graph for this function:

◆ takeFileDescriptor()

int QDBusUnixFileDescriptor::takeFileDescriptor ( )

Definition at line 297 of file qdbusunixfiledescriptor.cpp.

Member Data Documentation

◆ d

Data QDBusUnixFileDescriptor::d
protected

Definition at line 45 of file qdbusunixfiledescriptor.h.

Referenced by fileDescriptor(), isValid(), and operator=().


The documentation for this class was generated from the following files: