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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
/***************************************************************************
ioprocs.h
I/O interfaces
***************************************************************************/
#ifndef MAME_LIB_UTIL_IOPROCS_H
#define MAME_LIB_UTIL_IOPROCS_H
#pragma once
#include "utilfwd.h"
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <memory>
#include <system_error>
// FIXME: make a proper place for OSD forward declarations
class osd_file;
namespace util {
class read_stream
{
public:
using ptr = std::unique_ptr<read_stream>;
virtual ~read_stream() = default;
virtual std::error_condition read(void *buffer, std::size_t length, std::size_t &actual) noexcept = 0;
};
class write_stream
{
public:
using ptr = std::unique_ptr<write_stream>;
virtual ~write_stream() = default;
virtual std::error_condition finalize() noexcept = 0;
virtual std::error_condition flush() noexcept = 0;
virtual std::error_condition write(void const *buffer, std::size_t length, std::size_t &actual) noexcept = 0;
};
class read_write_stream : public virtual read_stream, public virtual write_stream
{
public:
using ptr = std::unique_ptr<read_write_stream>;
};
class random_access
{
public:
virtual ~random_access() = default;
virtual std::error_condition seek(std::int64_t offset, int whence) noexcept = 0;
virtual std::error_condition tell(std::uint64_t &result) noexcept = 0;
virtual std::error_condition length(std::uint64_t &result) noexcept = 0;
};
class random_read : public virtual read_stream, public virtual random_access
{
public:
using ptr = std::unique_ptr<random_read>;
virtual std::error_condition read_at(std::uint64_t offset, void *buffer, std::size_t length, std::size_t &actual) noexcept = 0;
};
class random_write : public virtual write_stream, public virtual random_access
{
public:
using ptr = std::unique_ptr<random_write>;
virtual std::error_condition write_at(std::uint64_t offset, void const *buffer, std::size_t length, std::size_t &actual) noexcept = 0;
};
class random_read_write : public read_write_stream, public virtual random_read, public virtual random_write
{
public:
using ptr = std::unique_ptr<random_read_write>;
};
random_read::ptr ram_read(void const *data, std::size_t size) noexcept;
random_read::ptr ram_read(void const *data, std::size_t size, std::uint8_t filler) noexcept;
random_read::ptr ram_read_copy(void const *data, std::size_t size) noexcept;
random_read::ptr ram_read_copy(void const *data, std::size_t size, std::uint8_t filler) noexcept;
random_read::ptr stdio_read(FILE *file) noexcept;
random_read::ptr stdio_read(FILE *file, std::uint8_t filler) noexcept;
random_read::ptr stdio_read_noclose(FILE *file) noexcept;
random_read::ptr stdio_read_noclose(FILE *file, std::uint8_t filler) noexcept;
random_read_write::ptr stdio_read_write(FILE *file) noexcept;
random_read_write::ptr stdio_read_write(FILE *file, std::uint8_t filler) noexcept;
random_read_write::ptr stdio_read_write_noclose(FILE *file) noexcept;
random_read_write::ptr stdio_read_write_noclose(FILE *file, std::uint8_t filler) noexcept;
random_read::ptr osd_file_read(std::unique_ptr<osd_file> &&file) noexcept;
random_read::ptr osd_file_read(osd_file &file) noexcept;
random_read_write::ptr osd_file_read_write(std::unique_ptr<osd_file> &&file) noexcept;
random_read_write::ptr osd_file_read_write(osd_file &file) noexcept;
random_read::ptr core_file_read(std::unique_ptr<core_file> &&file) noexcept;
random_read::ptr core_file_read(std::unique_ptr<core_file> &&file, std::uint8_t filler) noexcept;
random_read::ptr core_file_read(core_file &file) noexcept;
random_read::ptr core_file_read(core_file &file, std::uint8_t filler) noexcept;
random_read_write::ptr core_file_read_write(std::unique_ptr<core_file> &&file) noexcept;
random_read_write::ptr core_file_read_write(std::unique_ptr<core_file> &&file, std::uint8_t filler) noexcept;
random_read_write::ptr core_file_read_write(core_file &file) noexcept;
random_read_write::ptr core_file_read_write(core_file &file, std::uint8_t filler) noexcept;
} // namespace util
#endif // MAME_LIB_UTIL_IOPROCS_H
|