Debian Codegraph @

src/mpt/io_read/filecursor_traits_memory.hpp

raw
1 /* SPDX-License-Identifier: BSL-1.0 OR BSD-3-Clause */
2
3 #ifndef MPT_IO_READ_FILECURSOR_TRAITS_MEMORY_HPP
4 #define MPT_IO_READ_FILECURSOR_TRAITS_MEMORY_HPP
5
6
7
8 #include "mpt/base/memory.hpp"
9 #include "mpt/base/namespace.hpp"
10 #include "mpt/base/span.hpp"
11 #include "mpt/io_read/filedata.hpp"
12 #include "mpt/io_read/filedata_memory.hpp"
13
14 #include <cstddef>
15
16
17
18 namespace mpt {
19 inline namespace MPT_INLINE_NS {
20
21
22
23 namespace IO {
24
25
26
27 class FileCursorTraitsMemory {
28
29 public:
30 using pos_type = FileDataMemory::pos_type;
31
32 using data_type = FileDataMemory;
33 using ref_data_type = const FileDataMemory &;
34 using shared_data_type = const FileDataMemory &;
35 using value_data_type = FileDataMemory;
36
37 static shared_data_type get_shared(const data_type & data) {
38 return data;
39 }
40 static ref_data_type get_ref(const data_type & data) {
41 return data;
42 }
43
44 static value_data_type make_data() {
45 return mpt::const_byte_span();
46 }
47 static value_data_type make_data(mpt::const_byte_span data) {
48 return data;
49 }
50
51 static value_data_type make_chunk(shared_data_type data, pos_type position, pos_type size) {
52 return mpt::as_span(data.GetRawData() + static_cast<std::size_t>(position), static_cast<std::size_t>(size));
53 }
54 };
55
56
57
58 } // namespace IO
59
60
61
62 } // namespace MPT_INLINE_NS
63 } // namespace mpt
64
65
66
67 #endif // MPT_IO_READ_FILECURSOR_TRAITS_MEMORY_HPP