29 if (_buffer !=
nullptr) {
48 set_used_length(_used_length + size);
49 memcpy(_buffer + _used_length - size, buffer, size);
58 set_used_length(_used_length + size);
59 return _buffer + _used_length - size;
67 set_used_length(_used_length + size);
76 nassertv(position + size <= _used_length);
77 memcpy(_buffer + position, buffer, size);
85 nassertr(position + size <= _used_length,
nullptr);
86 return _buffer + position;
94 return std::string(_buffer, _used_length);
130 char *data = _buffer;
char * get_write_pointer(size_t size)
Adds the indicated number of bytes to the end of the data without initializing them,...
void append_data(const char *buffer, size_t size)
Adds the indicated bytes to the end of the data.
void clear()
Empties the contents of the data (without necessarily freeing its allocated memory).
void append_junk(size_t size)
Adds some uninitialized bytes to the end of the data.
std::string get_string() const
Returns the data buffer as a string.
char * take_data()
Returns the pointer to the beginning of the data buffer, and transfers ownership of the buffer to the...
size_t get_length() const
Returns the current length of the buffer.
void rewrite_data(size_t position, const char *buffer, size_t size)
Changes the data at the indicated position to the given value.
const char * get_data() const
Returns the beginning of the data buffer.
char * get_rewrite_pointer(size_t position, size_t size)
Returns a pointer into the middle of the data at the indicated point.