Memory stream class.
More...
#include <PGFstream.h>
List of all members.
Protected Attributes |
UINT8 * | m_buffer |
UINT8 * | m_pos |
| buffer start address and current buffer address
|
UINT8 * | m_eos |
| end of stream (first address beyond written area)
|
size_t | m_size |
| buffer size
|
bool | m_allocated |
| indicates a new allocated buffer
|
Detailed Description
Memory stream class.
A PGF stream subclass for internal memory.
- Author:
- C. Stamm
Definition at line 106 of file PGFstream.h.
Constructor & Destructor Documentation
CPGFMemoryStream::CPGFMemoryStream |
( |
size_t |
size | ) |
|
Constructor
- Parameters:
-
size | Size of new allocated memory buffer |
Allocate memory block of given size
- Parameters:
-
Definition at line 78 of file PGFstream.cpp.
if (!
m_buffer) ReturnWithError(InsufficientMemory);
}
CPGFMemoryStream::CPGFMemoryStream |
( |
UINT8 * |
pBuffer, |
|
|
size_t |
size |
|
) |
| |
Constructor. Use already allocated memory of given size
- Parameters:
-
pBuffer | Memory location |
size | Memory size |
Use already allocated memory of given size
- Parameters:
-
pBuffer | Memory location |
size | Memory size |
Definition at line 89 of file PGFstream.cpp.
virtual CPGFMemoryStream::~CPGFMemoryStream |
( |
| ) |
|
|
inlinevirtual |
Member Function Documentation
const UINT8* CPGFMemoryStream::GetBuffer |
( |
| ) |
const |
|
inline |
UINT8* CPGFMemoryStream::GetBuffer |
( |
| ) |
|
|
inline |
UINT64 CPGFMemoryStream::GetEOS |
( |
| ) |
const |
|
inline |
- Returns:
- relative position of end of stream (= stream length)
Definition at line 147 of file PGFstream.h.
virtual UINT64 CPGFMemoryStream::GetPos |
( |
| ) |
const |
|
inlinevirtual |
Get current stream position.
- Returns:
- Current stream position
Implements CPGFStream.
Definition at line 137 of file PGFstream.h.
size_t CPGFMemoryStream::GetSize |
( |
| ) |
const |
|
inline |
virtual bool CPGFMemoryStream::IsValid |
( |
| ) |
const |
|
inlinevirtual |
Check stream validity.
- Returns:
- True if stream and current position is valid
Implements CPGFStream.
Definition at line 138 of file PGFstream.h.
void CPGFMemoryStream::Read |
( |
int * |
count, |
|
|
void * |
buffer |
|
) |
| |
|
virtual |
Read some bytes from this stream and stores them into a buffer.
- Parameters:
-
count | A pointer to a value containing the number of bytes should be read. After this call it contains the number of read bytes. |
buffer | A memory buffer |
Implements CPGFStream.
Definition at line 148 of file PGFstream.cpp.
{
ASSERT(count);
ASSERT(buffPtr);
memcpy(buffPtr,
m_pos, *count);
} else {
memcpy(buffPtr,
m_pos, *count);
}
}
void CPGFMemoryStream::Reinitialize |
( |
UINT8 * |
pBuffer, |
|
|
size_t |
size |
|
) |
| |
Constructor. Use already allocated memory of given size
- Parameters:
-
pBuffer | Memory location |
size | Memory size |
Use already allocated memory of given size
- Parameters:
-
pBuffer | Memory location |
size | Memory size |
Definition at line 102 of file PGFstream.cpp.
void CPGFMemoryStream::SetEOS |
( |
UINT64 |
length | ) |
|
|
inline |
- Parameters:
-
length | Stream length (= relative position of end of stream) |
Definition at line 149 of file PGFstream.h.
void CPGFMemoryStream::SetPos |
( |
short |
posMode, |
|
|
INT64 |
posOff |
|
) |
| |
|
virtual |
Set stream position either absolute or relative.
- Parameters:
-
posMode | A position mode (FSFromStart, FSFromCurrent, FSFromEnd) |
posOff | A new stream position (absolute positioning) or a position offset (relative positioning) |
Implements CPGFStream.
Definition at line 168 of file PGFstream.cpp.
{
switch(posMode) {
case FSFromStart:
break;
case FSFromCurrent:
break;
case FSFromEnd:
break;
default:
ASSERT(false);
}
ReturnWithError(InvalidStreamPos);
}
void CPGFMemoryStream::Write |
( |
int * |
count, |
|
|
void * |
buffer |
|
) |
| |
|
virtual |
Write some bytes out of a buffer into this stream.
- Parameters:
-
count | A pointer to a value containing the number of bytes should be written. After this call it contains the number of written bytes. |
buffer | A memory buffer |
Implements CPGFStream.
Definition at line 111 of file PGFstream.cpp.
{
ASSERT(count);
ASSERT(buffPtr);
const size_t deltaSize = 0x4000 + *count;
memcpy(
m_pos, buffPtr, *count);
UINT8 *buf_tmp = (UINT8 *)realloc(m_buffer,
m_size + deltaSize);
if (!buf_tmp) {
m_buffer = 0;
ReturnWithError(InsufficientMemory);
} else {
m_buffer = buf_tmp;
}
m_pos = m_buffer + offset;
memcpy(
m_pos, buffPtr, *count);
} else {
ReturnWithError(InsufficientMemory);
}
}
Member Data Documentation
bool CPGFMemoryStream::m_allocated |
|
protected |
indicates a new allocated buffer
Definition at line 111 of file PGFstream.h.
UINT8* CPGFMemoryStream::m_buffer |
|
protected |
UINT8* CPGFMemoryStream::m_eos |
|
protected |
end of stream (first address beyond written area)
Definition at line 109 of file PGFstream.h.
UINT8 * CPGFMemoryStream::m_pos |
|
protected |
buffer start address and current buffer address
Definition at line 108 of file PGFstream.h.
size_t CPGFMemoryStream::m_size |
|
protected |
The documentation for this class was generated from the following files: