mini-llvm
0.1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
FileHandle.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
3
#pragma once
4
5
#include <cstdio>
6
#include <utility>
7
8
#include "
mini-llvm/utils/Compiler.h
"
9
#include "
mini-llvm/utils/Path.h
"
10
#include "
mini-llvm/utils/SystemString.h
"
11
12
namespace
mini_llvm
{
13
14
class
MINI_LLVM_EXPORT
FileHandle
{
15
public
:
16
FileHandle
() =
default
;
17
18
explicit
FileHandle
(FILE *handle) : handle_(handle) {}
19
20
FileHandle
(
const
Path
&path,
const
SystemString
&mode);
21
22
~FileHandle
();
23
24
FileHandle
(
const
FileHandle
&) =
delete
;
25
26
FileHandle
(
FileHandle
&&other)
noexcept
{
27
swap
(other);
28
}
29
30
FileHandle
&
operator=
(
FileHandle
other)
noexcept
{
31
swap
(other);
32
return
*
this
;
33
}
34
35
explicit
operator
bool()
const
{
36
return
handle_;
37
}
38
39
FILE *
get
() {
40
return
handle_;
41
}
42
43
const
FILE *
get
()
const
{
44
return
handle_;
45
}
46
47
void
open
(
const
Path
&path,
const
SystemString
&mode);
48
49
void
close
();
50
51
FILE *
release
();
52
53
void
swap
(
FileHandle
&other)
noexcept
{
54
std::swap(handle_, other.handle_);
55
}
56
57
private
:
58
FILE *handle_{};
59
};
60
61
inline
void
swap
(
FileHandle
&lhs,
FileHandle
&rhs)
noexcept
{
62
lhs.swap(rhs);
63
}
64
65
}
// namespace mini_llvm
Compiler.h
MINI_LLVM_EXPORT
#define MINI_LLVM_EXPORT
Definition
Compiler.h:17
Path.h
SystemString.h
mini_llvm::FileHandle
Definition
FileHandle.h:14
mini_llvm::FileHandle::FileHandle
FileHandle(FILE *handle)
Definition
FileHandle.h:18
mini_llvm::FileHandle::FileHandle
FileHandle(FileHandle &&other) noexcept
Definition
FileHandle.h:26
mini_llvm::FileHandle::FileHandle
FileHandle(const FileHandle &)=delete
mini_llvm::FileHandle::operator=
FileHandle & operator=(FileHandle other) noexcept
Definition
FileHandle.h:30
mini_llvm::FileHandle::~FileHandle
~FileHandle()
mini_llvm::FileHandle::close
void close()
mini_llvm::FileHandle::release
FILE * release()
mini_llvm::FileHandle::FileHandle
FileHandle(const Path &path, const SystemString &mode)
mini_llvm::FileHandle::open
void open(const Path &path, const SystemString &mode)
mini_llvm::FileHandle::FileHandle
FileHandle()=default
mini_llvm::FileHandle::swap
void swap(FileHandle &other) noexcept
Definition
FileHandle.h:53
mini_llvm::FileHandle::get
const FILE * get() const
Definition
FileHandle.h:43
mini_llvm::FileHandle::get
FILE * get()
Definition
FileHandle.h:39
mini_llvm::Path
Definition
Path.h:18
mini_llvm::SystemString
Definition
SystemString.h:19
mini_llvm
Definition
GraphColoringAllocator.h:13
mini_llvm::swap
void swap(FileHandle &lhs, FileHandle &rhs) noexcept
Definition
FileHandle.h:61
include
mini-llvm
utils
FileHandle.h
Generated by
1.17.0