1 #ifndef MSP_IO_SLICE_H_
2 #define MSP_IO_SLICE_H_
10 Presents a part of seekable I/O object as if it was a complete object. This
11 allows in-place access to embedded resources where the loader expects to
12 receive a complete file.
14 When a Slice is created, its read/write offset is placed at the beginning of
15 its range. If the offset of the underlying object is changed, the Slice will
16 restore it before the next access. This enables multiple Slices to be created
17 on top of the same object.
19 class Slice: public Seekable, public sigc::trackable
23 SeekOffset start_offset = 0;
24 SeekOffset length = 0;
25 SeekOffset position = 0;
26 bool sync_position = true;
29 Slice(Seekable &, SeekOffset, SeekOffset);
31 void set_block(bool) override;
32 void set_inherit(bool) override;
37 unsigned prepare_op(unsigned, Mode);
39 std::size_t do_write(const char *, std::size_t) override;
40 std::size_t do_read(char *, std::size_t) override;
43 std::size_t put(char) override;
46 const Handle &get_handle(Mode) override;
48 SeekOffset seek(SeekOffset, SeekType) override;
49 SeekOffset tell() const override { return position; }