15#include "BorrowedFd.hpp"
62 bool operator==(
OwnedFd const &) const noexcept = delete;
63 bool operator!=(
OwnedFd const &) const noexcept = delete;
65 bool operator==(
int fd) const noexcept {
return _fd == fd; }
66 bool operator==(
BorrowedFd const & fd)
const noexcept {
return _fd == fd.get(); }
68 void swap(
OwnedFd & other)
noexcept;
71 bool isValid() const noexcept {
return _fd != -1; }
75 int get() const noexcept {
return _fd; }
89 void reset(
int newFd = -1) noexcept;
103inline void swap(OwnedFd & fd1, OwnedFd & fd2)
noexcept { fd1.swap(fd2); }
107struct std::formatter<
dfx::FdWatch::OwnedFd> :
public formatter<int>
110 {
return formatter<int>::format(e.
get(), ctx); }
Convenience macros to explicitly control copy and move semantics.
Non-owning wrapper around a file descriptor.
Definition BorrowedFd.hpp:37
Owning RAII wrapper around a file descriptor.
Definition OwnedFd.hpp:36
BorrowedFd borrow() const noexcept
Create a non-owning view of the owned file descriptor.
Definition OwnedFd.hpp:95
void close() noexcept
Close the owned file descriptor.
int get() const noexcept
Get the owned file descriptor.
Definition OwnedFd.hpp:75
OwnedFd() noexcept
Create an invalid OwnedFd.
int release() noexcept
Release ownership of the file descriptor.
void reset(int newFd=-1) noexcept
Replace the owned file descriptor.
bool isValid() const noexcept
Check if this object owns a valid file descriptor.
Definition OwnedFd.hpp:71
Definition SocketClient.hpp:23
OwnedFd makeOwnedFd(int fd) noexcept
Create a OwnedFd that will automatically close the given fd on destruction.
Definition OwnedFd.hpp:102
Definition Message.hpp:21