]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CMemoryFile.h
Reduce IrrCompileConfig usage to files that actually need it
[irrlicht.git] / source / Irrlicht / CMemoryFile.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __C_MEMORY_READ_FILE_H_INCLUDED__\r
6 #define __C_MEMORY_READ_FILE_H_INCLUDED__\r
7 \r
8 #include "IMemoryReadFile.h"\r
9 #include "IWriteFile.h"\r
10 #include "irrString.h"\r
11 \r
12 namespace irr\r
13 {\r
14 \r
15 namespace io\r
16 {\r
17 \r
18         /*!\r
19                 Class for reading from memory.\r
20         */\r
21         class CMemoryReadFile : public IMemoryReadFile\r
22         {\r
23         public:\r
24 \r
25                 //! Constructor\r
26                 CMemoryReadFile(const void* memory, long len, const io::path& fileName, bool deleteMemoryWhenDropped);\r
27 \r
28                 //! Destructor\r
29                 virtual ~CMemoryReadFile();\r
30 \r
31                 //! returns how much was read\r
32                 size_t read(void* buffer, size_t sizeToRead) override;\r
33 \r
34                 //! changes position in file, returns true if successful\r
35                 bool seek(long finalPos, bool relativeMovement = false) override;\r
36 \r
37                 //! returns size of file\r
38                 long getSize() const override;\r
39 \r
40                 //! returns where in the file we are.\r
41                 long getPos() const override;\r
42 \r
43                 //! returns name of file\r
44                 const io::path& getFileName() const override;\r
45 \r
46                 //! Get the type of the class implementing this interface\r
47                 EREAD_FILE_TYPE getType() const override\r
48                 {\r
49                         return ERFT_MEMORY_READ_FILE;\r
50                 }\r
51 \r
52                 //! Get direct access to internal buffer\r
53                 const void *getBuffer() const override\r
54                 {\r
55                         return Buffer;\r
56                 }\r
57 \r
58         private:\r
59 \r
60                 const void *Buffer;\r
61                 long Len;\r
62                 long Pos;\r
63                 io::path Filename;\r
64                 bool deleteMemoryWhenDropped;\r
65         };\r
66 \r
67         /*!\r
68                 Class for writing to memory.\r
69         */\r
70         class CMemoryWriteFile : public IWriteFile\r
71         {\r
72         public:\r
73 \r
74                 //! Constructor\r
75                 CMemoryWriteFile(void* memory, long len, const io::path& fileName, bool deleteMemoryWhenDropped);\r
76 \r
77                 //! Destructor\r
78                 virtual ~CMemoryWriteFile();\r
79 \r
80                 //! returns how much was written\r
81                 size_t write(const void* buffer, size_t sizeToWrite) override;\r
82 \r
83                 //! changes position in file, returns true if successful\r
84                 bool seek(long finalPos, bool relativeMovement = false) override;\r
85 \r
86                 //! returns where in the file we are.\r
87                 long getPos() const override;\r
88 \r
89                 //! returns name of file\r
90                 const io::path& getFileName() const override;\r
91 \r
92                 bool flush() override;\r
93 \r
94         private:\r
95 \r
96                 void *Buffer;\r
97                 long Len;\r
98                 long Pos;\r
99                 io::path Filename;\r
100                 bool deleteMemoryWhenDropped;\r
101         };\r
102 \r
103 } // end namespace io\r
104 } // end namespace irr\r
105 \r
106 #endif\r
107 \r