Debian Codegraph @

lib/IOOps.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Descent Developers
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #pragma once
19
20 #include <cstdint>
21 #include <istream>
22 #include <ostream>
23
24 #include "byteswap.h"cxx . . $ `<file>/lib/byteswap.h`/
25
26 namespace D3cxx . . $ D3/ {
27
28 template <class T, typename = stdcxx . . $ std/::enable_if_t<stdcxx . . $ std/::is_arithmetic_v<T>>>
29 static inline stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &bin_writecxx . . $ D3/bin_write(b9bf9de5c7808980).(stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &output, T value, bool is_little_endian = true,
30 size_t n = sizeof(T)) {
31 value = is_little_endian ? convert_lecxx . . $ D3/convert_le(ada6a8422704cf8a).(value) : convert_becxx . . $ D3/convert_be(ada6a8422704cf8a).(value);
32 output.writecxx . . $ std/basic_ostream#write(3c866fa06c201852).(reinterpret_cast<const char *>(&value), n);
33
34 return output;
35 }
36
37 template <class T, typename = stdcxx . . $ std/::enable_if_t<stdcxx . . $ std/::is_arithmetic_v<T>>>
38 static inline stdcxx . . $ std/::istreamcxx . . $ std/istream# &bin_readcxx . . $ D3/bin_read(66ff81923e1a8aa0).(stdcxx . . $ std/::istreamcxx . . $ std/istream# &input, T &value, bool is_little_endian = true, size_t n = sizeof(T)) {
39 input.readcxx . . $ std/basic_istream#read(ec7d6f01d31dcb96).(reinterpret_cast<char *>(&value), n);
40 value = is_little_endian ? convert_lecxx . . $ D3/convert_le(ada6a8422704cf8a).(value) : convert_becxx . . $ D3/convert_be(ada6a8422704cf8a).(value);
41
42 return input;
43 }
44
45 } // namespace D3