Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
XMemFile.h
1// XMemFile.h: interface for the CXFile class.
2//
3//////////////////////////////////////////////////////////////////////
4
5#if !defined(CXMEMFILE_INCLUDE_H)
6#define CXMEMFILE_INCLUDE_H
7
8#ifdef _MSC_VER
9#pragma once
10#endif // _MSC_VER
11
12#include "XFile.h"
13
14BEGIN_MOOTOOLS_NAMESPACE
15
16 ////////////////////////////////////////////////////////////////////////////////////////////////
17 // CXMemFile class
18 //
19 class DLL_TOOLSFUNCTION CXMemFile : public CXFile
20 {
21 DECLARE_DYNAMIC_XOBJECT(CXMemFile)
22
23 protected:
24 typedef enum
25 {
26 DefaultGrowSize = 2048,
27 } Constants;
28
29 public:
30 // Constructors
31 explicit CXMemFile(unsigned int nGrowBytes = DefaultGrowSize, bool allowException = true);
32 CXMemFile(const unsigned char *lpBuffer, fileuint nBufferSize, bool deleteMemory, bool allowException = true);
33
34 public:
35 virtual ~CXMemFile();
36 #ifdef _DEBUG
37 virtual void Dump() const;
38 #endif
39
40 virtual fileuint GetPosition() const;
41 virtual fileuint Seek(longint offset, CXFile::SeekPosition nFrom);
42 virtual bool SetLength(fileuint dwNewLen);
43 virtual unsigned int Read(void* buffer, unsigned int maxByteToRead);
44 virtual void Write(const void* buffer, unsigned int byteToWrite);
45
46 virtual void Abort();
47 virtual void Flush();
48 virtual void Close();
49
50 virtual fileuint GetLength() const;
51
52 // Buffer access
53 void Attach(const unsigned char *lpBuffer, fileuint nBufferSize, bool deleteMemory); // The memory is considered as read only if deleteMemory = false
54 const unsigned char *GetBuffer() const { return buffer; };
55 unsigned char *Detach(); // Detach buffer from the file (which become empty)
56
57 static unsigned char *Alloc(SIZET nBytes);
58 static void Free(unsigned char *lpMem);
59
60 protected:
61 SIZET growCount;
62 SIZET bufferSize, fileSize, filePosition;
63 unsigned char *buffer;
64 bool deleteBuffer, sendException;
65
66 void InitMemFile();
67 virtual SIZET BufferCommand(unsigned int bufferCommand, SIZET nCount = 0, unsigned char **ppBufStart = NULL, unsigned char **ppBufMax = NULL);
68
69 // Memory allocation
70 unsigned char *Realloc(unsigned char *lpMem, SIZET nBytes);
71 unsigned char *Memcpy(unsigned char *lpMemTarget, const unsigned char *lpMemSource, SIZET nBytes);
72 void Free();
73
74 virtual bool GrowBuffer(SIZET dwNewLen);
75 };
76
77END_MOOTOOLS_NAMESPACE
78
79#endif // !defined(CXMEMFILE_INCLUDE_H)
CXFile is the base class for different kind of file (CXStdioFile, CXMemFile...)
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
CXFile is the base class for CXStdioFile, CXStdioFileEx, CXMemFile.
Definition XFile.h:42
Definition XMemFile.h:20