factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / core / System / DataStream.h
blobe20c1183ee7190a80f20d043cac461b642eb18fc
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.
21 /**
22 * @file DataStream.h
23 * Declares DataStream, abstract class for reading and writing data.
24 * @author The GemRB Project
28 #ifndef DATASTREAM_H
29 #define DATASTREAM_H
31 #include "exports.h"
32 #include "globals.h"
34 #define GEM_CURRENT_POS 0
35 #define GEM_STREAM_START 1
36 #define GEM_STREAM_END 2
38 /**
39 * @class DataStream
40 * Abstract base for streams, classes for reading and writing data.
43 class GEM_EXPORT DataStream {
44 protected:
45 unsigned long Pos;
46 unsigned long size;
47 bool Encrypted;
48 public:
49 char filename[16]; //8+1+3+1 padded to dword
50 char originalfile[_MAX_PATH];
51 public:
52 DataStream(void);
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;
67 void Rewind();
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