Panda3D
datagramBuffer.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file datagramBuffer.I
10  * @author rdb
11  * @date 2017-11-07
12  */
13 
14 /**
15  * Initializes an empty datagram buffer.
16  */
17 INLINE DatagramBuffer::
19  _read_offset(0),
20  _wrote_first_datagram(false),
21  _read_first_datagram(false) {
22 }
23 
24 /**
25  * Initializes the buffer with the given data.
26  */
27 INLINE DatagramBuffer::
28 DatagramBuffer(vector_uchar data) :
29  _data(std::move(data)),
30  _read_offset(0),
31  _wrote_first_datagram(false),
32  _read_first_datagram(false) {
33 }
34 
35 /**
36  * Clears the internal buffer.
37  */
38 INLINE void DatagramBuffer::
39 clear() {
40  _data.clear();
41  _read_offset = 0;
42  _wrote_first_datagram = false;
43  _read_first_datagram = false;
44 }
45 
46 /**
47  * Returns the internal buffer.
48  */
49 INLINE const vector_uchar &DatagramBuffer::
50 get_data() const {
51  return _data;
52 }
53 
54 /**
55  * Replaces the data in the internal buffer.
56  */
57 INLINE void DatagramBuffer::
58 set_data(vector_uchar data) {
59  _data = std::move(data);
60 }
61 
62 /**
63  * Swaps the data in the internal buffer with that of the other buffer.
64  */
65 INLINE void DatagramBuffer::
66 swap_data(vector_uchar &other) {
67  _data.swap(other);
68 }
set_data
Replaces the data in the internal buffer.
void clear()
Clears the internal buffer.
DatagramBuffer()
Initializes an empty datagram buffer.
void swap_data(vector_uchar &other)
Swaps the data in the internal buffer with that of the other buffer.