45 const char *message = (
const char *)
get_data();
47 for (
size_t line = 0; line < num_bytes; line += 16) {
49 sprintf(hex,
"%04x ", ((
unsigned int )line));
50 for (
unsigned int ind = 0; ind <
indent; ind++) {
56 for (p = line; p < line + 16; p++) {
59 sprintf(hex,
" %02x", ((
unsigned int)message[p]) & 0xff);
66 for (p = line; p < line + 16 && p < num_bytes; p++) {
69 if (isgraph((
unsigned char)message[p]) || message[p] ==
' ') {
70 out << (char)message[p];
89 std::wstring::const_iterator ci;
90 for (ci = str.begin(); ci != str.end(); ++ci) {
100 nassertv((
int)size >= 0);
102 if (_data ==
nullptr) {
104 _data = PTA_uchar::empty_array(0);
106 }
else if (_data.get_ref_count() != 1) {
108 PTA_uchar new_data = PTA_uchar::empty_array(0);
109 new_data.v() = _data.v();
120 _data.push_back(
'\0');
130 nassertv((
int)size >= 0);
132 if (_data ==
nullptr) {
134 _data = PTA_uchar::empty_array(0);
136 }
else if (_data.get_ref_count() != 1) {
138 PTA_uchar new_data = PTA_uchar::empty_array(0);
139 new_data.v() = _data.v();
151 _data.v().insert(_data.v().end(), (
const unsigned char *)data,
152 (
const unsigned char *)data + size);
160 nassertv((
int)size >= 0);
162 _data = PTA_uchar::empty_array(0);
163 _data.v().insert(_data.v().end(), (
const unsigned char *)data,
164 (
const unsigned char *)data + size);
184 out<<
""<<
"Datagram:\n";
void dump_hex(std::ostream &out, unsigned int indent=0) const
Writes a representation of the entire datagram contents, as a sequence of hex (and ASCII) values.
void append_data(const void *data, size_t size)
Appends some more raw data to the end of the datagram.
void output(std::ostream &out) const
Write a string representation of this instance to <out>.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void clear()
Resets the datagram to empty, in preparation for building up a new datagram.
void assign(const void *data, size_t size)
Replaces the datagram's data with the indicated block.
void add_wstring(const std::wstring &str)
Adds a variable-length wstring to the datagram.
void pad_bytes(size_t size)
Adds the indicated number of zero bytes to the datagram.
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void write(std::ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
TypeHandle is the identifier used to differentiate C++ class types.
size_t get_length() const
Returns the number of bytes in the datagram.
const void * get_data() const
Returns a pointer to the beginning of the datagram's data.