-
Notifications
You must be signed in to change notification settings - Fork 1
/
outfile.hpp
55 lines (49 loc) · 1.72 KB
/
outfile.hpp
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
// *************************************************************************
// This file is part of AcidMUD by Steaphan Greene
//
// Copyright 1999-2022 Steaphan Greene <[email protected]>
//
// AcidMUD is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// AcidMUD 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with AcidMUD (see the file named "COPYING");
// If not, see <http://www.gnu.org/licenses/>.
//
// *************************************************************************
#ifndef OUTFILE_HPP
#define OUTFILE_HPP
#include <filesystem>
#include <string>
// Replace with C++20 std::format, when widely available
#define FMT_HEADER_ONLY
#include <fmt/format.h>
class outfile {
public:
outfile() = delete;
outfile(const outfile&) = delete;
outfile(outfile&&) = delete;
void operator=(const outfile&) = delete;
void operator=(outfile&&) = delete;
explicit outfile(const std::u8string_view& filename);
operator bool() const;
void append(const std::u8string_view& mes);
template <typename... Args>
void append(const std::u8string_view& mes, Args&&... args)
requires(sizeof...(args) >= 1)
{
append(fmt::vformat(mes, fmt::make_args_checked<Args...>(mes, args...)));
};
~outfile();
private:
std::u8string buffer;
int fd;
};
#endif // OUTFILE_HPP