1 /*
2  * HLLib
3  * Copyright (C) 2006-2010 Ryan Gregg
4 
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later
9  * version.
10  */
11 
12 #ifndef MEMORYSTREAM_H
13 #define MEMORYSTREAM_H
14 
15 #include "stdafx.h"
16 #include "Stream.h"
17 
18 namespace HLLib
19 {
20 	namespace Streams
21 	{
22 		class HLLIB_API CMemoryStream : public IStream
23 		{
24 		private:
25 			hlBool bOpened;
26 			hlUInt uiMode;
27 
28 			hlVoid *lpData;
29 			hlULongLong uiBufferSize;
30 
31 			hlULongLong uiPointer;
32 			hlULongLong uiLength;
33 
34 		public:
35 			CMemoryStream(hlVoid *lpData, hlULongLong uiBufferSize);
36 			~CMemoryStream();
37 
38 			virtual HLStreamType GetType() const;
39 
40 			const hlVoid *GetBuffer() const;
41 			hlULongLong GetBufferSize() const;
42 			virtual const hlChar *GetFileName() const;
43 
44 			virtual hlBool GetOpened() const;
45 			virtual hlUInt GetMode() const;
46 
47 			virtual hlBool Open(hlUInt uiMode);
48 			virtual hlVoid Close();
49 
50 			virtual hlULongLong GetStreamSize() const;
51 			virtual hlULongLong GetStreamPointer() const;
52 
53 			virtual hlULongLong Seek(hlLongLong iOffset, HLSeekMode eSeekMode);
54 
55 			virtual hlBool Read(hlChar &cChar);
56 			virtual hlUInt Read(hlVoid *lpData, hlUInt uiBytes);
57 
58 			virtual hlBool Write(hlChar iChar);
59 			virtual hlUInt Write(const hlVoid *lpData, hlUInt uiBytes);
60 		};
61 	}
62 }
63 
64 #endif
65