1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * Declares DataStream, abstract class for reading and writing data.
24 * @author The GemRB Project
34 #define GEM_CURRENT_POS 0
35 #define GEM_STREAM_START 1
36 #define GEM_STREAM_END 2
40 * Abstract base for streams, classes for reading and writing data.
43 class GEM_EXPORT DataStream
{
49 char filename
[16]; //8+1+3+1 padded to dword
50 char originalfile
[_MAX_PATH
];
53 virtual ~DataStream(void);
54 virtual int Read(void* dest
, unsigned int len
) = 0;
55 int ReadWord(ieWord
* dest
);
56 int ReadWordSigned (ieWordSigned
* dest
);
57 int ReadDword(ieDword
* dest
);
58 int ReadResRef(ieResRef dest
);
59 virtual int Write(const void* src
, unsigned int len
) = 0;
60 int WriteWord(const ieWord
* src
);
61 int WriteDword(const ieDword
* src
);
62 int WriteResRef(const ieResRef src
);
63 virtual int Seek(int pos
, int startpos
) = 0;
64 unsigned long Remains() const;
65 unsigned long Size() const;
66 unsigned long GetPos() const;
68 /** Returns true if the stream is encrypted */
69 bool CheckEncrypted();
70 void ReadDecrypted(void* buf
, unsigned int size
);
71 virtual int ReadLine(void* buf
, unsigned int maxlen
) = 0;
72 /** Endian Switch setup */
73 static void SetEndianSwitch(int par
);
74 static bool IsEndianSwitch();
77 #endif // ! DATASTREAM_H