22 #ifdef STDFLOAT_DOUBLE
23 _stdfloat_double(true)
25 _stdfloat_double(false)
37 #ifdef STDFLOAT_DOUBLE
38 _stdfloat_double(true)
40 _stdfloat_double(false)
53 #ifdef STDFLOAT_DOUBLE
54 _stdfloat_double(true)
56 _stdfloat_double(false)
70 _stdfloat_double(copy._stdfloat_double)
79 INLINE
void Datagram::
82 _stdfloat_double = copy._stdfloat_double;
85 #ifdef USE_MOVE_SEMANTICS
93 _data(move(from._data)),
94 _stdfloat_double(from._stdfloat_double)
97 #endif // USE_MOVE_SEMANTICS
99 #ifdef USE_MOVE_SEMANTICS
105 INLINE
void Datagram::
106 operator = (
Datagram &&from) NOEXCEPT {
107 _data = move(from._data);
108 _stdfloat_double = from._stdfloat_double;
110 #endif // USE_MOVE_SEMANTICS
241 if (_stdfloat_double) {
353 nassertv(str.length() <= (PN_uint16)0xffff);
386 size_t null_pos = str.find(
'\0');
405 if (str.length() < size) {
433 if (_data.size() == 0) {
436 return string((
const char *)_data.p(), _data.size());
486 _data.v() = data.
v();
524 _stdfloat_double = stdfloat_double;
535 return _stdfloat_double;
543 INLINE
bool Datagram::
544 operator == (
const Datagram &other)
const {
545 if (_data == other._data) {
548 if (_data != (uchar *)NULL && other._data != (uchar *)NULL) {
549 return _data.v() == other._data.v();
559 INLINE
bool Datagram::
560 operator != (
const Datagram &other)
const {
561 return !operator == (other);
569 INLINE
bool Datagram::
570 operator < (
const Datagram &other)
const {
571 if (_data == other._data) {
576 if (_data != (uchar *)NULL && other._data != (uchar *)NULL) {
578 return _data.v() < other._data.v();
582 return _data.size() < other._data.size();
586 generic_write_datagram(
Datagram &dest,
bool value) {
591 generic_write_datagram(
Datagram &dest,
int value) {
596 generic_write_datagram(
Datagram &dest,
float value) {
601 generic_write_datagram(
Datagram &dest,
double value) {
606 generic_write_datagram(
Datagram &dest,
const string &value) {
611 generic_write_datagram(
Datagram &dest,
const wstring &value) {
const pvector< Element > & v() const
To access the vector itself, for more direct fiddling with some of the vector's esoteric functionalit...
void add_uint8(PN_uint8 value)
Adds an unsigned 8-bit integer to the datagram.
string get_message() const
Returns the datagram's data as a string.
void add_string(const string &str)
Adds a variable-length string to the datagram.
void add_float64(PN_float64 value)
Adds a 64-bit floating-point number to the datagram.
void append_data(const void *data, size_t size)
Appends some more raw data to the end of the datagram.
void add_wstring(const wstring &str)
Adds a variable-length wstring to the datagram.
void add_string32(const string &str)
Adds a variable-length string to the datagram, using a 32-bit length field to allow very long strings...
void add_int8(PN_int8 value)
Adds a signed 8-bit integer to the datagram.
void add_float32(PN_float32 value)
Adds a 32-bit single-precision floating-point number to the datagram.
bool get_stdfloat_double() const
Returns the stdfloat_double flag.
Datagram()
Constructs an empty datagram.
const void * get_data() const
Returns the pointer to the first byte of the data, either reversed or nonreversed, as appropriate.
PTA_uchar modify_array()
Returns a modifiable pointer to the actual data in the Datagram.
void set_array(PTA_uchar data)
Replaces the data in the Datagram with the data in the indicated PTA_uchar.
size_t get_length() const
Returns the number of bytes in the datagram.
void pad_bytes(size_t size)
Adds the indicated number of zero bytes to the datagram.
void add_be_int64(PN_int64 value)
Adds a signed 64-bit big-endian integer to the datagram.
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
void set_stdfloat_double(bool stdfloat_double)
Changes the stdfloat_double flag, which defines the operation performed by add_stdfloat() and Datagra...
void add_be_float64(PN_float64 value)
Adds a 64-bit big-endian floating-point number to the datagram.
void add_int16(PN_int16 value)
Adds a signed 16-bit integer to the datagram.
void add_be_uint64(PN_uint64 value)
Adds an unsigned 64-bit big-endian integer to the datagram.
void add_bool(bool value)
Adds a boolean value to the datagram.
void add_be_float32(PN_float32 value)
Adds a 32-bit single-precision big-endian floating-point number to the datagram.
NativeNumericData and ReversedNumericData work together to provide a sneaky interface for automatical...
void add_uint64(PN_uint64 value)
Adds an unsigned 64-bit integer to the datagram.
void add_be_int32(PN_int32 value)
Adds a signed 32-bit big-endian integer to the datagram.
NativeNumericData and ReversedNumericData work together to provide a sneaky interface for automatical...
CPTA_uchar get_array() const
Returns a const pointer to the actual data in the Datagram.
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
void add_uint32(PN_uint32 value)
Adds an unsigned 32-bit integer 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 add_fixed_string(const string &str, size_t size)
Adds a fixed-length string to the datagram.
void add_be_uint16(PN_uint16 value)
Adds an unsigned 16-bit big-endian integer to the datagram.
const void * get_data() const
Returns a pointer to the beginning of the datagram's data.
void add_int32(PN_int32 value)
Adds a signed 32-bit integer to the datagram.
void add_be_uint32(PN_uint32 value)
Adds an unsigned 32-bit big-endian integer to the datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
void add_z_string(string str)
Adds a variable-length string to the datagram, as a NULL-terminated string.
void add_be_int16(PN_int16 value)
Adds a signed 16-bit big-endian integer to the datagram.
void add_int64(PN_int64 value)
Adds a signed 64-bit integer to the datagram.
const void * get_data() const
Returns the pointer to the first byte of the data, either reversed or nonreversed, as appropriate.