| 1 |
/* SPDX-License-Identifier: BSL-1.0 OR BSD-3-Clause */ |
| 2 |
|
| 3 |
#ifndef MPT_IO_READ_CALLBACKSTREAM_HPP |
| 4 |
#define MPT_IO_READ_CALLBACKSTREAM_HPP |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include "mpt/base/integer.hpp" |
| 9 |
#include "mpt/base/memory.hpp" |
| 10 |
#include "mpt/base/namespace.hpp" |
| 11 |
|
| 12 |
#include <cstddef> |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
namespace mpt { |
| 17 |
inline namespace MPT_INLINE_NS { |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace IO { |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
template <typename Tstream> |
| 26 |
struct CallbackStreamTemplate { |
| 27 |
enum : int { |
| 28 |
SeekSet = 0, |
| 29 |
SeekCur = 1, |
| 30 |
SeekEnd = 2 |
| 31 |
}; |
| 32 |
Tstream stream; |
| 33 |
std::size_t (*read)(Tstream stream, void * dst, std::size_t bytes); |
| 34 |
int (*seek)(Tstream stream, int64 offset, int whence); |
| 35 |
int64 (*tell)(Tstream stream); |
| 36 |
}; |
| 37 |
|
| 38 |
using CallbackStream = CallbackStreamTemplate<void *>; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
} // namespace IO |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
} // namespace MPT_INLINE_NS |
| 47 |
} // namespace mpt |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
#endif // MPT_IO_READ_CALLBACKSTREAM_HPP |