38class EXPCL_PANDA_EXPRESS Datagram :
public TypedObject {
40 INLINE Datagram() =
default;
41 INLINE Datagram(
const void *data,
size_t size);
42 INLINE
explicit Datagram(vector_uchar data);
43 Datagram(
const Datagram ©) =
default;
44 Datagram(Datagram &&from)
noexcept =
default;
47 Datagram &operator = (
const Datagram ©) =
default;
48 Datagram &operator = (Datagram &&from)
noexcept =
default;
78 INLINE
void add_string(
const std::string &str);
84 INLINE
void add_blob(
const vector_uchar &);
92 void assign(
const void *data,
size_t size);
99 EXTENSION(INLINE PyObject *__bytes__()
const);
100 EXTENSION(PyObject *__reduce__()
const);
112 INLINE
bool operator == (
const Datagram &other)
const;
113 INLINE
bool operator != (
const Datagram &other)
const;
114 INLINE
bool operator < (
const Datagram &other)
const;
116 void output(std::ostream &out)
const;
117 void write(std::ostream &out,
unsigned int indent=0)
const;
122#ifdef STDFLOAT_DOUBLE
123 bool _stdfloat_double =
true;
125 bool _stdfloat_double =
false;
136 TypedObject::get_class_type());
139 return get_class_type();
154generic_write_datagram(
Datagram &dest,
bool value);
156generic_write_datagram(
Datagram &dest,
int value);
158generic_write_datagram(
Datagram &dest,
float value);
160generic_write_datagram(
Datagram &dest,
double value);
162generic_write_datagram(
Datagram &dest,
const std::string &value);
164generic_write_datagram(
Datagram &dest,
const std::wstring &value);
166generic_write_datagram(
Datagram &dest,
const vector_uchar &value);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_be_uint64(uint64_t value)
Adds an unsigned 64-bit big-endian integer to the datagram.
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
void add_be_uint32(uint32_t value)
Adds an unsigned 32-bit big-endian integer to the datagram.
void add_be_int64(int64_t value)
Adds a signed 64-bit big-endian integer to the datagram.
void output(std::ostream &out) const
Write a string representation of this instance to <out>.
void write(std::ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
void set_stdfloat_double(bool stdfloat_double)
Changes the stdfloat_double flag, which defines the operation performed by add_stdfloat() and Datagra...
void add_z_string(const std::string &str)
Adds a variable-length string to the datagram, as a NULL-terminated string.
void add_be_uint16(uint16_t value)
Adds an unsigned 16-bit big-endian integer to the datagram.
size_t get_length() const
Returns the number of bytes in the datagram.
bool get_stdfloat_double() const
Returns the stdfloat_double flag.
void add_be_int32(int32_t value)
Adds a signed 32-bit big-endian integer to the datagram.
void add_wstring(const std::wstring &str)
Adds a variable-length wstring to the datagram.
void assign(const void *data, size_t size)
Replaces the datagram's data with the indicated block.
void add_be_float32(PN_float32 value)
Adds a 32-bit single-precision big-endian floating-point number to the datagram.
void add_int16(int16_t value)
Adds a signed 16-bit integer to the datagram.
void add_fixed_string(const std::string &str, size_t size)
Adds a fixed-length string to the datagram.
void add_float32(PN_float32 value)
Adds a 32-bit single-precision floating-point number to the datagram.
CPTA_uchar get_array() const
Returns a const pointer to the actual data in the Datagram.
void add_int32(int32_t value)
Adds a signed 32-bit integer to the datagram.
void add_uint8(uint8_t value)
Adds an unsigned 8-bit integer to the datagram.
void add_string32(const std::string &str)
Adds a variable-length string to the datagram, using a 32-bit length field to allow very long strings...
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void add_be_int16(int16_t value)
Adds a signed 16-bit big-endian integer to the datagram.
std::string get_message() const
Returns the datagram's data as a string.
void add_be_float64(PN_float64 value)
Adds a 64-bit big-endian floating-point number to the datagram.
void copy_array(CPTA_uchar data)
Replaces the data in the Datagram with a copy of the data in the indicated CPTA_uchar.
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 add_bool(bool value)
Adds a boolean value to the datagram.
virtual void clear()
Resets the datagram to empty, in preparation for building up a new datagram.
void append_data(const void *data, size_t size)
Appends some more raw data to the end of the datagram.
void set_array(PTA_uchar data)
Replaces the data in the Datagram with the data in the indicated PTA_uchar.
void add_blob(const vector_uchar &)
Adds a variable-length binary blob to the datagram.
void pad_bytes(size_t size)
Adds the indicated number of zero bytes to the datagram.
PTA_uchar modify_array()
Returns a modifiable pointer to the actual data in the Datagram.
void add_uint64(uint64_t value)
Adds an unsigned 64-bit integer to the datagram.
void add_int64(int64_t value)
Adds a signed 64-bit integer to the datagram.
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
void add_string(const std::string &str)
Adds a variable-length string to the datagram.
void add_blob32(const vector_uchar &)
Adds a variable-length binary blob to the datagram, using a 32-bit length field to allow very long bl...
void add_float64(PN_float64 value)
Adds a 64-bit floating-point number to the datagram.
const void * get_data() const
Returns a pointer to the beginning of the datagram's data.
void add_int8(int8_t value)
Adds a signed 8-bit integer to the datagram.
TypeHandle is the identifier used to differentiate C++ class types.
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.