nixd
Loading...
Searching...
No Matches
nixd
include
nixd
Support
AutoCloseFD.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <cerrno>
4
5
namespace
nixd::util
{
6
7
/// \brief File Descriptor RAII wrapper
8
class
AutoCloseFD
{
9
public
:
10
using
FDTy
= int;
11
12
private
:
13
static
constexpr
FDTy
ReleasedFD = -EBADF;
14
FDTy
FD;
15
16
public
:
17
AutoCloseFD
(
FDTy
FD);
18
AutoCloseFD
(
const
AutoCloseFD
&) =
delete
;
19
AutoCloseFD
(
AutoCloseFD
&&That)
noexcept
;
20
21
[[nodiscard]]
bool
isReleased
()
const
;
22
static
bool
isReleased
(
FDTy
FD);
23
24
~AutoCloseFD
();
25
26
[[nodiscard]]
FDTy
get
()
const
;
27
void
release
();
28
};
29
30
}
// namespace nixd::util
nixd::util::AutoCloseFD
File Descriptor RAII wrapper.
Definition
AutoCloseFD.h:8
nixd::util::AutoCloseFD::AutoCloseFD
AutoCloseFD(FDTy FD)
Definition
AutoCloseFD.cpp:24
nixd::util::AutoCloseFD::AutoCloseFD
AutoCloseFD(const AutoCloseFD &)=delete
nixd::util::AutoCloseFD::~AutoCloseFD
~AutoCloseFD()
Definition
AutoCloseFD.cpp:7
nixd::util::AutoCloseFD::get
FDTy get() const
Definition
AutoCloseFD.cpp:16
nixd::util::AutoCloseFD::release
void release()
Definition
AutoCloseFD.cpp:18
nixd::util::AutoCloseFD::FDTy
int FDTy
Definition
AutoCloseFD.h:10
nixd::util::AutoCloseFD::isReleased
bool isReleased() const
Definition
AutoCloseFD.cpp:22
nixd::util
Definition
AutoCloseFD.h:5
Generated by
1.12.0