Panda3D

Loading...
Searching...
No Matches
Public Member Functions | List of all members
DCPackData Class Reference

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

`#include "dcPackData.h"`

## 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.
std::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 22 of file dcPackData.h.

## Constructor & Destructor Documentation

## ◆ DCPackData()

DCPackData::DCPackData | ( |  | ) |
| inline

Definition at line 17 of file dcPackData.I.

## ◆ ~DCPackData()

DCPackData::~DCPackData | ( |  | ) |
| inline

Definition at line 27 of file dcPackData.I.

## Member Function Documentation

## ◆ append_data()

void DCPackData::append_data | ( | const char * | buffer,
|  | size_t | size )
| inline

Adds the indicated bytes to the end of the data.

Definition at line 46 of file dcPackData.I.

Referenced by DCArrayParameter::pack_blob(), DCSimpleParameter::pack_blob(), DCArrayParameter::pack_default_value(), DCField::pack_default_value(), DCSimpleParameter::pack_default_value(), DCSwitch::pack_default_value(), DCArrayParameter::pack_string(), and DCSimpleParameter::pack_string().

## ◆ append_junk()

void DCPackData::append_junk | ( | size_t | size | ) |
| inline

Adds some uninitialized bytes to the end of the data.

Definition at line 65 of file dcPackData.I.

## ◆ clear()

void DCPackData::clear | ( |  | ) |
| inline

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

Definition at line 38 of file dcPackData.I.

## ◆ get_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 114 of file dcPackData.I.

## ◆ get_length()

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 101 of file dcPackData.I.

## ◆ get_rewrite_pointer()

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 83 of file dcPackData.I.

## ◆ get_string()

std::string DCPackData::get_string | ( |  | ) | const
| inline

Returns the data buffer as a string.

Also see get_data().

Definition at line 92 of file dcPackData.I.

## ◆ get_write_pointer()

char * DCPackData::get_write_pointer | ( | size_t | size | ) |
| inline

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.

Definition at line 56 of file dcPackData.I.

Referenced by DCArrayParameter::pack_blob(), DCSimpleParameter::pack_blob(), DCSimpleParameter::pack_double(), DCSimpleParameter::pack_int(), DCSimpleParameter::pack_int64(), DCArrayParameter::pack_string(), DCSimpleParameter::pack_string(), DCSimpleParameter::pack_uint(), and DCSimpleParameter::pack_uint64().

## ◆ rewrite_data()

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 74 of file dcPackData.I.

## ◆ take_data()

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 128 of file dcPackData.I.

The documentation for this class was generated from the following files:

- direct/src/dcparser/dcPackData.h
- direct/src/dcparser/dcPackData.cxx
- direct/src/dcparser/dcPackData.I