Panda3D
Public Member Functions
DCPackData Class Reference

This is a block of data that receives the results of DCPacker. More...

#include "dcPackData.h"

List of all members.

Public Member Functions

void append_data (const char *buffer, size_t size)
 Adds the indicated bytes to the end of the data.
void append_junk (size_t size)
 Adds some uninitialized bytes to the end of the data.
void clear ()
 Empties the contents of the data (without necessarily freeing its allocated memory).
const char * get_data () const
 Returns the beginning of the data buffer.
size_t get_length () const
 Returns the current length of the buffer.
char * get_rewrite_pointer (size_t position, size_t size)
 Returns a pointer into the middle of the data at the indicated point.
string get_string () const
 Returns the data buffer as a string.
char * get_write_pointer (size_t size)
 Adds the indicated number of bytes to the end of the data without initializing them, and returns a pointer to the beginning of the new data.
void rewrite_data (size_t position, const char *buffer, size_t size)
 Changes the data at the indicated position to the given value.
char * take_data ()
 Returns the pointer to the beginning of the data buffer, and transfers ownership of the buffer to the caller.

Detailed Description

This is a block of data that receives the results of DCPacker.

Definition at line 25 of file dcPackData.h.


Member Function Documentation

void DCPackData::append_data ( const char *  buffer,
size_t  size 
) [inline]
void DCPackData::append_junk ( size_t  size) [inline]

Adds some uninitialized bytes to the end of the data.

Definition at line 81 of file dcPackData.I.

Referenced by DCPacker::push().

void DCPackData::clear ( ) [inline]

Empties the contents of the data (without necessarily freeing its allocated memory).

Definition at line 47 of file dcPackData.I.

Referenced by DCPacker::begin_repack(), and DCPacker::clear_data().

const char * DCPackData::get_data ( ) const [inline]

Returns the beginning of the data buffer.

The buffer is not null-terminated, but see also get_string(). This may (or may not) return NULL if the buffer is empty.

This may be used in conjunction with get_length() to copy all of the bytes out of the buffer.

Definition at line 145 of file dcPackData.I.

Referenced by DCPacker::get_data(), DCPacker::get_string(), and DCPacker::output_hex_string().

size_t DCPackData::get_length ( ) const [inline]

Returns the current length of the buffer.

This is the number of useful bytes stored in the buffer, not the amount of memory it takes up.

Definition at line 129 of file dcPackData.I.

Referenced by DCPacker::get_length(), DCPacker::get_string(), DCPacker::output_hex_string(), DCPacker::pop(), DCPacker::push(), and DCPacker::seek().

char * DCPackData::get_rewrite_pointer ( size_t  position,
size_t  size 
) [inline]

Returns a pointer into the middle of the data at the indicated point.

Definition at line 105 of file dcPackData.I.

Referenced by DCPacker::pop().

string DCPackData::get_string ( ) const [inline]

Returns the data buffer as a string.

Also see get_data().

Definition at line 117 of file dcPackData.I.

Referenced by DCPacker::get_string().

char * DCPackData::get_write_pointer ( size_t  size) [inline]
void DCPackData::rewrite_data ( size_t  position,
const char *  buffer,
size_t  size 
) [inline]

Changes the data at the indicated position to the given value.

It is an error if there are not at least position + size bytes in the data.

Definition at line 93 of file dcPackData.I.

char * DCPackData::take_data ( ) [inline]

Returns the pointer to the beginning of the data buffer, and transfers ownership of the buffer to the caller.

The caller is now responsible for ultimately freeing the returned pointer with delete[], if it is non-NULL. This may (or may not) return NULL if the buffer is empty.

This also empties the DCPackData structure, and sets its length to zero (so you should call get_length() before calling this method).

Definition at line 164 of file dcPackData.I.

Referenced by DCPacker::seek(), and DCPacker::take_data().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations