|
@@ -617,6 +617,18 @@ get_num_unpacked_bytes() const {
|
|
|
return _unpack_p;
|
|
return _unpack_p;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: DCPacker::get_length
|
|
|
|
|
+// Access: Published
|
|
|
|
|
+// Description: 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.
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+INLINE size_t DCPacker::
|
|
|
|
|
+get_length() const {
|
|
|
|
|
+ return _pack_data.get_length();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: DCPacker::get_string
|
|
// Function: DCPacker::get_string
|
|
|
// Access: Published
|
|
// Access: Published
|
|
@@ -629,15 +641,14 @@ get_string() const {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: DCPacker::get_length
|
|
|
|
|
|
|
+// Function: DCPacker::get_string
|
|
|
// Access: Published
|
|
// Access: Published
|
|
|
-// Description: 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.
|
|
|
|
|
|
|
+// Description: Copies the packed data into the indicated string.
|
|
|
|
|
+// Also see get_data().
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-INLINE size_t DCPacker::
|
|
|
|
|
-get_length() const {
|
|
|
|
|
- return _pack_data.get_length();
|
|
|
|
|
|
|
+INLINE void DCPacker::
|
|
|
|
|
+get_string(string &data) const {
|
|
|
|
|
+ data.assign(_pack_data.get_data(), _pack_data.get_length());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
@@ -647,13 +658,34 @@ get_length() const {
|
|
|
// is not null-terminated, but see also get_string().
|
|
// is not null-terminated, but see also get_string().
|
|
|
//
|
|
//
|
|
|
// This may be used in conjunction with get_length() to
|
|
// This may be used in conjunction with get_length() to
|
|
|
-// copy all of the bytes out of the buffer.
|
|
|
|
|
|
|
+// copy all of the bytes out of the buffer. Also see
|
|
|
|
|
+// take_data() to get the packed data without a copy
|
|
|
|
|
+// operation.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE const char *DCPacker::
|
|
INLINE const char *DCPacker::
|
|
|
get_data() const {
|
|
get_data() const {
|
|
|
return _pack_data.get_data();
|
|
return _pack_data.get_data();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: DCPacker::take_data
|
|
|
|
|
+// Access: Public
|
|
|
|
|
+// Description: 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).
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+INLINE char *DCPacker::
|
|
|
|
|
+take_data() {
|
|
|
|
|
+ return _pack_data.take_data();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: DCPacker::append_data
|
|
// Function: DCPacker::append_data
|
|
|
// Access: Public
|
|
// Access: Public
|