ScummVM API documentation
concatstream.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef COMMON_CONCATSTREAM_H
23#define COMMON_CONCATSTREAM_H
24
25#include "common/array.h"
26#include "common/ptr.h"
27#include "common/stream.h"
28
29namespace Common {
30/*
31 * ConcatReadStream provides access to a virtually concatenated stream.
32 *
33 * Manipulating the parent stream directly /will/ mess up a concatstream.
34 *
35 * Assumptions:
36 * - number of streams is small so iterating through array sized by N is cheap
37 * - size of streams doesn't change
38 */
40private:
42 ParentStreamArray _parentStreams;
44 Common::Array<int64> _startOffsets;
45
46 uint32 _totalSize, _linearPos;
47 uint32 _volume, _volumePos;
48 bool _err, _eos;
49public:
51
52 int64 pos() const override { return _linearPos; }
53 int64 size() const override { return _totalSize; }
54 bool eos() const override { return _eos; }
55 bool err() const override { return _err; }
56 void clearErr() override {
57 _err = false;
58 _eos = false;
59 }
60 bool seek(int64 offset, int whence = SEEK_SET) override;
61 uint32 read(void *dataPtr, uint32 dataSize) override;
62 bool seekToVolume(int volume, int64 offset);
63};
64
65}
66
67#endif // COMMON_CONCATSTREAM_H
Definition: array.h:52
Definition: concatstream.h:39
bool eos() const override
Definition: concatstream.h:54
bool seek(int64 offset, int whence=SEEK_SET) override
int64 pos() const override
Definition: concatstream.h:52
void clearErr() override
Definition: concatstream.h:56
uint32 read(void *dataPtr, uint32 dataSize) override
bool err() const override
Definition: concatstream.h:55
int64 size() const override
Definition: concatstream.h:53
Definition: stream.h:745
Definition: algorithm.h:29