Introduction
Downloads
Documentation
Tutorials
Pixie Lite
Forum

Home

StaticBuffer Class Reference
[Containers]

Static memory buffer. More...

List of all members.


Public Member Functions

 StaticBuffer (const DynamicBuffer &buffer)
 StaticBuffer (const void *buffer, int size)
 ~StaticBuffer ()
int GetSize () const
int GetPosition () const
void SetPosition (int position) const
int Read (char *value, int count=1) const
int Read (short *value, int count=1) const
int Read (int *value, int count=1) const
int Read (long *value, int count=1) const
int Read (unsigned char *value, int count=1) const
int Read (unsigned short *value, int count=1) const
int Read (unsigned int *value, int count=1) const
int Read (unsigned long *value, int count=1) const
int Read (float *value, int count=1) const
int Read (double *value, int count=1) const
int Read (bool *value, int count=1) const
const void * GetPointer () const

Detailed Description

Static memory buffer.

Author:
Mattias Gustavsson
The static memory buffer is useful when you want to read data from piece of memory in the same way as you would with a DynamicBuffer. The difference is that with a StaticBuffer, the memory is passed in to the constructor, and no allocation or copying of memory is done. Also, you can't write data to a StaticBuffer, only read.

It is also possible to access the memory directly, but that can be risky as no safety checks are carried out, which opens it up to possible buffer overrun problems.

Definition at line 26 of file StaticBuffer.h.


Constructor & Destructor Documentation

StaticBuffer::StaticBuffer ( const DynamicBuffer buffer  ) 

Constructor

Definition at line 10 of file StaticBuffer.cpp.

StaticBuffer::StaticBuffer ( const void *  buffer,
int  size 
)

Constructor

Definition at line 20 of file StaticBuffer.cpp.

StaticBuffer::~StaticBuffer (  ) 

Destructor

Definition at line 30 of file StaticBuffer.cpp.


Member Function Documentation

int StaticBuffer::GetSize (  )  const

Gets the current size of the buffer

Returns:
The size of the used part of the buffer, in bytes

Definition at line 37 of file StaticBuffer.cpp.

int StaticBuffer::GetPosition (  )  const

Gets the current position for read operations on the buffer. This is the position at which the next subsequent read operation will be done.

Returns:
The current position in the buffer

Definition at line 45 of file StaticBuffer.cpp.

void StaticBuffer::SetPosition ( int  position  )  const

Sets the current position for read operations on the buffer. The next subsequent read operation will be performed at this position.

Parameters:
position The new position of the buffer

Definition at line 53 of file StaticBuffer.cpp.

int StaticBuffer::Read ( char *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of chars from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 93 of file StaticBuffer.cpp.

int StaticBuffer::Read ( short *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of shorts from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 98 of file StaticBuffer.cpp.

int StaticBuffer::Read ( int *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of ints from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 103 of file StaticBuffer.cpp.

int StaticBuffer::Read ( long *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of longs from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 108 of file StaticBuffer.cpp.

int StaticBuffer::Read ( unsigned char *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of unsigned chars from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 113 of file StaticBuffer.cpp.

int StaticBuffer::Read ( unsigned short *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of unsigned shorts from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 118 of file StaticBuffer.cpp.

int StaticBuffer::Read ( unsigned int *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of unsigned ints from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 123 of file StaticBuffer.cpp.

int StaticBuffer::Read ( unsigned long *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of unsigned longs from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 128 of file StaticBuffer.cpp.

int StaticBuffer::Read ( float *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of floats from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 133 of file StaticBuffer.cpp.

int StaticBuffer::Read ( double *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of doubles from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 138 of file StaticBuffer.cpp.

int StaticBuffer::Read ( bool *  value,
int  count = 1 
) const

Reads data from the buffer. Will copy "count" number of bools from the current read position of the buffer to the memory location specified in the "value" pointer

Returns:
The number of elements that where successfully read
Parameters:
value Pointer to the first element to read data into
count Number of elements to read

Definition at line 143 of file StaticBuffer.cpp.

const void * StaticBuffer::GetPointer (  )  const

Used to retrieve a raw pointer to the actual memory that holds the buffer data. Use this carefully, because no checks for buffer overruns or such will be done. Most of the time, the normal Read methods should be used.

Definition at line 61 of file StaticBuffer.cpp.



Pixie University and the Pixie Game Engine is created and managed by Mattias Gustavsson.
Reproduction/republishing of any material on this site without permission is strictly prohibited.