Panda3D
datagram.I
1 // Filename: datagram.I
2 // Created by: drose (06Jun00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 ////////////////////////////////////////////////////////////////////
16 // Function: Datagram::Constructor
17 // Access: Public
18 // Description: Constructs an empty datagram.
19 ////////////////////////////////////////////////////////////////////
20 INLINE Datagram::
22 #ifdef STDFLOAT_DOUBLE
23  _stdfloat_double(true)
24 #else
25  _stdfloat_double(false)
26 #endif
27 {
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: Datagram::Constructor
32 // Access: Public
33 // Description: Constructs a datagram from an existing block of data.
34 ////////////////////////////////////////////////////////////////////
35 INLINE Datagram::
36 Datagram(const void *data, size_t size) :
37 #ifdef STDFLOAT_DOUBLE
38  _stdfloat_double(true)
39 #else
40  _stdfloat_double(false)
41 #endif
42 {
43  append_data(data, size);
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: Datagram::Constructor
48 // Access: Public
49 // Description: Constructs a datagram from an existing block of data.
50 ////////////////////////////////////////////////////////////////////
51 INLINE Datagram::
52 Datagram(const string &data) :
53 #ifdef STDFLOAT_DOUBLE
54  _stdfloat_double(true)
55 #else
56  _stdfloat_double(false)
57 #endif
58 {
59  append_data(data);
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: Datagram::Copy Constructor
64 // Access: Public
65 // Description:
66 ////////////////////////////////////////////////////////////////////
67 INLINE Datagram::
68 Datagram(const Datagram &copy) :
69  _data(copy._data),
70  _stdfloat_double(copy._stdfloat_double)
71 {
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: Datagram::Copy Assignment Operator
76 // Access: Public
77 // Description:
78 ////////////////////////////////////////////////////////////////////
79 INLINE void Datagram::
80 operator = (const Datagram &copy) {
81  _data = copy._data;
82  _stdfloat_double = copy._stdfloat_double;
83 }
84 
85 #ifdef USE_MOVE_SEMANTICS
86 ////////////////////////////////////////////////////////////////////
87 // Function: Datagram::Copy Constructor
88 // Access: Public
89 // Description:
90 ////////////////////////////////////////////////////////////////////
91 INLINE Datagram::
92 Datagram(Datagram &&from) NOEXCEPT :
93  _data(move(from._data)),
94  _stdfloat_double(from._stdfloat_double)
95 {
96 }
97 #endif // USE_MOVE_SEMANTICS
98 
99 #ifdef USE_MOVE_SEMANTICS
100 ////////////////////////////////////////////////////////////////////
101 // Function: Datagram::Move Assignment Operator
102 // Access: Public
103 // Description:
104 ////////////////////////////////////////////////////////////////////
105 INLINE void Datagram::
106 operator = (Datagram &&from) NOEXCEPT {
107  _data = move(from._data);
108  _stdfloat_double = from._stdfloat_double;
109 }
110 #endif // USE_MOVE_SEMANTICS
111 
112 ////////////////////////////////////////////////////////////////////
113 // Function: Datagram::add_bool
114 // Access: Public
115 // Description: Adds a boolean value to the datagram.
116 ////////////////////////////////////////////////////////////////////
117 INLINE void Datagram::
118 add_bool(bool b) {
119  add_uint8(b);
120 }
121 
122 ////////////////////////////////////////////////////////////////////
123 // Function: Datagram::add_int8
124 // Access: Public
125 // Description: Adds a signed 8-bit integer to the datagram.
126 ////////////////////////////////////////////////////////////////////
127 INLINE void Datagram::
128 add_int8(PN_int8 value) {
129  append_data(&value, 1);
130 }
131 
132 ////////////////////////////////////////////////////////////////////
133 // Function: Datagram::add_uint8
134 // Access: Public
135 // Description: Adds an unsigned 8-bit integer to the datagram.
136 ////////////////////////////////////////////////////////////////////
137 INLINE void Datagram::
138 add_uint8(PN_uint8 value) {
139  append_data(&value, 1);
140 }
141 
142 ////////////////////////////////////////////////////////////////////
143 // Function: Datagram::add_int16
144 // Access: Public
145 // Description: Adds a signed 16-bit integer to the datagram.
146 ////////////////////////////////////////////////////////////////////
147 INLINE void Datagram::
148 add_int16(PN_int16 value) {
149  LittleEndian s(&value, sizeof(value));
150  append_data(s.get_data(), sizeof(value));
151 }
152 
153 ////////////////////////////////////////////////////////////////////
154 // Function: Datagram::add_int32
155 // Access: Public
156 // Description: Adds a signed 32-bit integer to the datagram.
157 ////////////////////////////////////////////////////////////////////
158 INLINE void Datagram::
159 add_int32(PN_int32 value) {
160  LittleEndian s(&value, sizeof(value));
161  append_data(s.get_data(), sizeof(value));
162 }
163 
164 ////////////////////////////////////////////////////////////////////
165 // Function: Datagram::add_int64
166 // Access: Public
167 // Description: Adds a signed 64-bit integer to the datagram.
168 ////////////////////////////////////////////////////////////////////
169 INLINE void Datagram::
170 add_int64(PN_int64 value) {
171  LittleEndian s(&value, sizeof(value));
172  append_data(s.get_data(), sizeof(value));
173 }
174 
175 ////////////////////////////////////////////////////////////////////
176 // Function: Datagram::add_uint16
177 // Access: Public
178 // Description: Adds an unsigned 16-bit integer to the datagram.
179 ////////////////////////////////////////////////////////////////////
180 INLINE void Datagram::
181 add_uint16(PN_uint16 value) {
182  LittleEndian s(&value, sizeof(value));
183  append_data(s.get_data(), sizeof(value));
184 }
185 
186 ////////////////////////////////////////////////////////////////////
187 // Function: Datagram::add_uint32
188 // Access: Public
189 // Description: Adds an unsigned 32-bit integer to the datagram.
190 ////////////////////////////////////////////////////////////////////
191 INLINE void Datagram::
192 add_uint32(PN_uint32 value) {
193  LittleEndian s(&value, sizeof(value));
194  append_data(s.get_data(), sizeof(value));
195 }
196 
197 ////////////////////////////////////////////////////////////////////
198 // Function: Datagram::add_uint64
199 // Access: Public
200 // Description: Adds an unsigned 64-bit integer to the datagram.
201 ////////////////////////////////////////////////////////////////////
202 INLINE void Datagram::
203 add_uint64(PN_uint64 value) {
204  LittleEndian s(&value, sizeof(value));
205  append_data(s.get_data(), sizeof(value));
206 }
207 
208 ////////////////////////////////////////////////////////////////////
209 // Function: Datagram::add_float32
210 // Access: Public
211 // Description: Adds a 32-bit single-precision floating-point number
212 // to the datagram. Since this kind of float is not
213 // necessarily portable across different architectures,
214 // special care is required.
215 ////////////////////////////////////////////////////////////////////
216 INLINE void Datagram::
217 add_float32(PN_float32 value) {
218  LittleEndian s(&value, sizeof(value));
219  append_data(s.get_data(), sizeof(value));
220 }
221 
222 ////////////////////////////////////////////////////////////////////
223 // Function: Datagram::add_float64
224 // Access: Public
225 // Description: Adds a 64-bit floating-point number to the datagram.
226 ////////////////////////////////////////////////////////////////////
227 INLINE void Datagram::
228 add_float64(PN_float64 value) {
229  LittleEndian s(&value, sizeof(value));
230  append_data(s.get_data(), sizeof(value));
231 }
232 
233 ////////////////////////////////////////////////////////////////////
234 // Function: Datagram::add_stdfloat
235 // Access: Public
236 // Description: Adds either a 32-bit or a 64-bit floating-point
237 // number, according to set_stdfloat_double().
238 ////////////////////////////////////////////////////////////////////
239 INLINE void Datagram::
240 add_stdfloat(PN_stdfloat value) {
241  if (_stdfloat_double) {
242  add_float64(value);
243  } else {
244  add_float32(value);
245  }
246 }
247 
248 ////////////////////////////////////////////////////////////////////
249 // Function: Datagram::add_be_int16
250 // Access: Public
251 // Description: Adds a signed 16-bit big-endian integer to the
252 // datagram.
253 ////////////////////////////////////////////////////////////////////
254 INLINE void Datagram::
255 add_be_int16(PN_int16 value) {
256  BigEndian s(&value, sizeof(value));
257  append_data(s.get_data(), sizeof(value));
258 }
259 
260 ////////////////////////////////////////////////////////////////////
261 // Function: Datagram::add_be_int32
262 // Access: Public
263 // Description: Adds a signed 32-bit big-endian integer to the
264 // datagram.
265 ////////////////////////////////////////////////////////////////////
266 INLINE void Datagram::
267 add_be_int32(PN_int32 value) {
268  BigEndian s(&value, sizeof(value));
269  append_data(s.get_data(), sizeof(value));
270 }
271 
272 ////////////////////////////////////////////////////////////////////
273 // Function: Datagram::add_be_int64
274 // Access: Public
275 // Description: Adds a signed 64-bit big-endian integer to the
276 // datagram.
277 ////////////////////////////////////////////////////////////////////
278 INLINE void Datagram::
279 add_be_int64(PN_int64 value) {
280  BigEndian s(&value, sizeof(value));
281  append_data(s.get_data(), sizeof(value));
282 }
283 
284 ////////////////////////////////////////////////////////////////////
285 // Function: Datagram::add_be_uint16
286 // Access: Public
287 // Description: Adds an unsigned 16-bit big-endian integer to the
288 // datagram.
289 ////////////////////////////////////////////////////////////////////
290 INLINE void Datagram::
291 add_be_uint16(PN_uint16 value) {
292  BigEndian s(&value, sizeof(value));
293  append_data(s.get_data(), sizeof(value));
294 }
295 
296 ////////////////////////////////////////////////////////////////////
297 // Function: Datagram::add_be_uint32
298 // Access: Public
299 // Description: Adds an unsigned 32-bit big-endian integer to the
300 // datagram.
301 ////////////////////////////////////////////////////////////////////
302 INLINE void Datagram::
303 add_be_uint32(PN_uint32 value) {
304  BigEndian s(&value, sizeof(value));
305  append_data(s.get_data(), sizeof(value));
306 }
307 
308 ////////////////////////////////////////////////////////////////////
309 // Function: Datagram::add_be_uint64
310 // Access: Public
311 // Description: Adds an unsigned 64-bit big-endian integer to the
312 // datagram.
313 ////////////////////////////////////////////////////////////////////
314 INLINE void Datagram::
315 add_be_uint64(PN_uint64 value) {
316  BigEndian s(&value, sizeof(value));
317  append_data(s.get_data(), sizeof(value));
318 }
319 
320 ////////////////////////////////////////////////////////////////////
321 // Function: Datagram::add_be_float32
322 // Access: Public
323 // Description: Adds a 32-bit single-precision big-endian
324 // floating-point number to the datagram.
325 ////////////////////////////////////////////////////////////////////
326 INLINE void Datagram::
327 add_be_float32(PN_float32 value) {
328  BigEndian s(&value, sizeof(value));
329  append_data(s.get_data(), sizeof(value));
330 }
331 
332 ////////////////////////////////////////////////////////////////////
333 // Function: Datagram::add_be_float64
334 // Access: Public
335 // Description: Adds a 64-bit big-endian floating-point number to the
336 // datagram.
337 ////////////////////////////////////////////////////////////////////
338 INLINE void Datagram::
339 add_be_float64(PN_float64 value) {
340  BigEndian s(&value, sizeof(value));
341  append_data(s.get_data(), sizeof(value));
342 }
343 
344 ////////////////////////////////////////////////////////////////////
345 // Function: Datagram::add_string
346 // Access: Public
347 // Description: Adds a variable-length string to the datagram. This
348 // actually adds a count followed by n bytes.
349 ////////////////////////////////////////////////////////////////////
350 INLINE void Datagram::
351 add_string(const string &str) {
352  // The max sendable length for a string is 2^16.
353  nassertv(str.length() <= (PN_uint16)0xffff);
354 
355  // Strings always are preceded by their length
356  add_uint16((PN_uint16)str.length());
357 
358  // Add the string
359  append_data(str);
360 }
361 
362 ////////////////////////////////////////////////////////////////////
363 // Function: Datagram::add_string32
364 // Access: Public
365 // Description: Adds a variable-length string to the datagram, using
366 // a 32-bit length field to allow very long strings.
367 ////////////////////////////////////////////////////////////////////
368 INLINE void Datagram::
369 add_string32(const string &str) {
370  // Strings always are preceded by their length
371  add_uint32((PN_uint32)str.length());
372 
373  // Add the string
374  append_data(str);
375 }
376 
377 ////////////////////////////////////////////////////////////////////
378 // Function: Datagram::add_z_string
379 // Access: Public
380 // Description: Adds a variable-length string to the datagram, as a
381 // NULL-terminated string.
382 ////////////////////////////////////////////////////////////////////
383 INLINE void Datagram::
384 add_z_string(string str) {
385  // We must not have any nested null characters in the string.
386  size_t null_pos = str.find('\0');
387  // Add the string (sans the null character).
388  append_data(str.substr(0, null_pos));
389 
390  // And the null character.
391  add_uint8('\0');
392 }
393 
394 ////////////////////////////////////////////////////////////////////
395 // Function: Datagram::add_fixed_string
396 // Access: Public
397 // Description: Adds a fixed-length string to the datagram. If the
398 // string given is less than the requested size, this
399 // will pad the string out with zeroes; if it is greater
400 // than the requested size, this will silently truncate
401 // the string.
402 ////////////////////////////////////////////////////////////////////
403 INLINE void Datagram::
404 add_fixed_string(const string &str, size_t size) {
405  if (str.length() < size) {
406  append_data(str);
407  pad_bytes(size - str.length());
408 
409  } else { // str.length() >= size
410  append_data(str.substr(0, size));
411  }
412 }
413 
414 ////////////////////////////////////////////////////////////////////
415 // Function: Datagram::append_data
416 // Access: Public
417 // Description: Appends some more raw data to the end of the
418 // datagram.
419 ////////////////////////////////////////////////////////////////////
420 INLINE void Datagram::
421 append_data(const string &data) {
422  append_data(data.data(), data.length());
423 }
424 
425 ////////////////////////////////////////////////////////////////////
426 // Function: Datagram::get_message
427 // Access: Public
428 // Description: Returns the datagram's data as a string.
429 ////////////////////////////////////////////////////////////////////
430 INLINE string Datagram::
431 get_message() const {
432  // Silly special case for gcc 3.2, which can't tolerate string(NULL, 0).
433  if (_data.size() == 0) {
434  return string();
435  } else {
436  return string((const char *)_data.p(), _data.size());
437  }
438 }
439 
440 ////////////////////////////////////////////////////////////////////
441 // Function: Datagram::get_data
442 // Access: Public
443 // Description: Returns a pointer to the beginning of the datagram's
444 // data.
445 ////////////////////////////////////////////////////////////////////
446 INLINE const void *Datagram::
447 get_data() const {
448  return _data.p();
449 }
450 
451 ////////////////////////////////////////////////////////////////////
452 // Function: Datagram::get_length
453 // Access: Public
454 // Description: Returns the number of bytes in the datagram.
455 ////////////////////////////////////////////////////////////////////
456 INLINE size_t Datagram::
457 get_length() const {
458  return _data.size();
459 }
460 
461 ////////////////////////////////////////////////////////////////////
462 // Function: Datagram::set_array
463 // Access: Public
464 // Description: Replaces the data in the Datagram with the data in
465 // the indicated PTA_uchar. This is assignment by
466 // reference: subsequent changes to the Datagram will
467 // also change the source PTA_uchar.
468 ////////////////////////////////////////////////////////////////////
469 INLINE void Datagram::
470 set_array(PTA_uchar data) {
471  _data = data;
472 }
473 
474 ////////////////////////////////////////////////////////////////////
475 // Function: Datagram::copy_array
476 // Access: Public
477 // Description: Replaces the data in the Datagram with a copy of the
478 // data in the indicated CPTA_uchar. Unlike
479 // set_array(), a complete copy is made of the data;
480 // subsequent changes to the Datagram will *not* change
481 // the source CPTA_uchar.
482 ////////////////////////////////////////////////////////////////////
483 INLINE void Datagram::
485  _data.clear();
486  _data.v() = data.v();
487 }
488 
489 ////////////////////////////////////////////////////////////////////
490 // Function: Datagram::get_array
491 // Access: Public
492 // Description: Returns a const pointer to the actual data in
493 // the Datagram.
494 ////////////////////////////////////////////////////////////////////
495 INLINE CPTA_uchar Datagram::
496 get_array() const {
497  return _data;
498 }
499 
500 ////////////////////////////////////////////////////////////////////
501 // Function: Datagram::modify_array
502 // Access: Public
503 // Description: Returns a modifiable pointer to the actual data in
504 // the Datagram.
505 ////////////////////////////////////////////////////////////////////
506 INLINE PTA_uchar Datagram::
508  return _data;
509 }
510 
511 ////////////////////////////////////////////////////////////////////
512 // Function: Datagram::set_stdfloat_double
513 // Access: Public
514 // Description: Changes the stdfloat_double flag, which defines the
515 // operation performed by add_stdfloat() and
516 // DatagramIterator::get_stdfloat(). When this is true,
517 // add_stdfloat() adds a 64-bit floating-point number;
518 // when it is false, it adds a 32-bit floating-point
519 // number. The default is based on the STDFLOAT_DOUBLE
520 // compilation flag.
521 ////////////////////////////////////////////////////////////////////
522 INLINE void Datagram::
523 set_stdfloat_double(bool stdfloat_double) {
524  _stdfloat_double = stdfloat_double;
525 }
526 
527 ////////////////////////////////////////////////////////////////////
528 // Function: Datagram::get_stdfloat_double
529 // Access: Public
530 // Description: Returns the stdfloat_double flag. See
531 // set_stdfloat_double().
532 ////////////////////////////////////////////////////////////////////
533 INLINE bool Datagram::
535  return _stdfloat_double;
536 }
537 
538 ////////////////////////////////////////////////////////////////////
539 // Function: Datagram::operator ==
540 // Access: Public
541 // Description:
542 ////////////////////////////////////////////////////////////////////
543 INLINE bool Datagram::
544 operator == (const Datagram &other) const {
545  if (_data == other._data) {
546  return true;
547  }
548  if (_data != (uchar *)NULL && other._data != (uchar *)NULL) {
549  return _data.v() == other._data.v();
550  }
551  return false;
552 }
553 
554 ////////////////////////////////////////////////////////////////////
555 // Function: Datagram::operator !=
556 // Access: Public
557 // Description:
558 ////////////////////////////////////////////////////////////////////
559 INLINE bool Datagram::
560 operator != (const Datagram &other) const {
561  return !operator == (other);
562 }
563 
564 ////////////////////////////////////////////////////////////////////
565 // Function: Datagram::operator <
566 // Access: Public
567 // Description:
568 ////////////////////////////////////////////////////////////////////
569 INLINE bool Datagram::
570 operator < (const Datagram &other) const {
571  if (_data == other._data) {
572  // Same pointers.
573  return false;
574  }
575 
576  if (_data != (uchar *)NULL && other._data != (uchar *)NULL) {
577  // Different pointers, neither NULL.
578  return _data.v() < other._data.v();
579  }
580 
581  // One of the pointers is NULL, but not the other one.
582  return _data.size() < other._data.size();
583 }
584 
585 INLINE void
586 generic_write_datagram(Datagram &dest, bool value) {
587  dest.add_bool(value);
588 }
589 
590 INLINE void
591 generic_write_datagram(Datagram &dest, int value) {
592  dest.add_int32(value);
593 }
594 
595 INLINE void
596 generic_write_datagram(Datagram &dest, float value) {
597  dest.add_float32(value);
598 }
599 
600 INLINE void
601 generic_write_datagram(Datagram &dest, double value) {
602  dest.add_float64(value);
603 }
604 
605 INLINE void
606 generic_write_datagram(Datagram &dest, const string &value) {
607  dest.add_string(value);
608 }
609 
610 INLINE void
611 generic_write_datagram(Datagram &dest, const wstring &value) {
612  dest.add_wstring(value);
613 }
void add_uint8(PN_uint8 value)
Adds an unsigned 8-bit integer to the datagram.
Definition: datagram.I:138
CPTA_uchar get_array() const
Returns a const pointer to the actual data in the Datagram.
Definition: datagram.I:496
void add_string(const string &str)
Adds a variable-length string to the datagram.
Definition: datagram.I:351
void add_float64(PN_float64 value)
Adds a 64-bit floating-point number to the datagram.
Definition: datagram.I:228
void append_data(const void *data, size_t size)
Appends some more raw data to the end of the datagram.
Definition: datagram.cxx:144
void add_wstring(const wstring &str)
Adds a variable-length wstring to the datagram.
Definition: datagram.cxx:92
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...
Definition: datagram.I:369
void add_int8(PN_int8 value)
Adds a signed 8-bit integer to the datagram.
Definition: datagram.I:128
void add_float32(PN_float32 value)
Adds a 32-bit single-precision floating-point number to the datagram.
Definition: datagram.I:217
Datagram()
Constructs an empty datagram.
Definition: datagram.I:21
bool get_stdfloat_double() const
Returns the stdfloat_double flag.
Definition: datagram.I:534
PTA_uchar modify_array()
Returns a modifiable pointer to the actual data in the Datagram.
Definition: datagram.I:507
void set_array(PTA_uchar data)
Replaces the data in the Datagram with the data in the indicated PTA_uchar.
Definition: datagram.I:470
void pad_bytes(size_t size)
Adds the indicated number of zero bytes to the datagram.
Definition: datagram.cxx:111
void add_be_int64(PN_int64 value)
Adds a signed 64-bit big-endian integer to the datagram.
Definition: datagram.I:279
void add_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
Definition: datagram.I:240
void set_stdfloat_double(bool stdfloat_double)
Changes the stdfloat_double flag, which defines the operation performed by add_stdfloat() and Datagra...
Definition: datagram.I:523
void add_be_float64(PN_float64 value)
Adds a 64-bit big-endian floating-point number to the datagram.
Definition: datagram.I:339
void add_int16(PN_int16 value)
Adds a signed 16-bit integer to the datagram.
Definition: datagram.I:148
void add_be_uint64(PN_uint64 value)
Adds an unsigned 64-bit big-endian integer to the datagram.
Definition: datagram.I:315
void add_bool(bool value)
Adds a boolean value to the datagram.
Definition: datagram.I:118
void add_be_float32(PN_float32 value)
Adds a 32-bit single-precision big-endian floating-point number to the datagram.
Definition: datagram.I:327
const void * get_data() const
Returns the pointer to the first byte of the data, either reversed or nonreversed, as appropriate.
const pvector< Element > & v() const
To access the vector itself, for more direct fiddling with some of the vector&#39;s esoteric functionalit...
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.
Definition: datagram.I:203
void add_be_int32(PN_int32 value)
Adds a signed 32-bit big-endian integer to the datagram.
Definition: datagram.I:267
NativeNumericData and ReversedNumericData work together to provide a sneaky interface for automatical...
void add_uint16(PN_uint16 value)
Adds an unsigned 16-bit integer to the datagram.
Definition: datagram.I:181
void add_uint32(PN_uint32 value)
Adds an unsigned 32-bit integer to the datagram.
Definition: datagram.I:192
void copy_array(CPTA_uchar data)
Replaces the data in the Datagram with a copy of the data in the indicated CPTA_uchar.
Definition: datagram.I:484
void add_fixed_string(const string &str, size_t size)
Adds a fixed-length string to the datagram.
Definition: datagram.I:404
void add_be_uint16(PN_uint16 value)
Adds an unsigned 16-bit big-endian integer to the datagram.
Definition: datagram.I:291
void add_int32(PN_int32 value)
Adds a signed 32-bit integer to the datagram.
Definition: datagram.I:159
void add_be_uint32(PN_uint32 value)
Adds an unsigned 32-bit big-endian integer to the datagram.
Definition: datagram.I:303
string get_message() const
Returns the datagram&#39;s data as a string.
Definition: datagram.I:431
const void * get_data() const
Returns the pointer to the first byte of the data, either reversed or nonreversed, as appropriate.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
void add_z_string(string str)
Adds a variable-length string to the datagram, as a NULL-terminated string.
Definition: datagram.I:384
void add_be_int16(PN_int16 value)
Adds a signed 16-bit big-endian integer to the datagram.
Definition: datagram.I:255
void add_int64(PN_int64 value)
Adds a signed 64-bit integer to the datagram.
Definition: datagram.I:170
size_t get_length() const
Returns the number of bytes in the datagram.
Definition: datagram.I:457
const void * get_data() const
Returns a pointer to the beginning of the datagram&#39;s data.
Definition: datagram.I:447