Panda3D
ioPtaDatagramShort.cxx
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 ioPtaDatagramShort.cxx
10  * @author jason
11  * @date 2000-06-26
12  */
13 
14 #include "pandabase.h"
15 
16 #include "ioPtaDatagramShort.h"
17 #include "datagram.h"
18 #include "datagramIterator.h"
19 
20 /**
21  *
22  */
23 void IoPtaDatagramShort::
24 write_datagram(BamWriter *, Datagram &dest, CPTA_ushort array) {
25  dest.add_uint32(array.size());
26  for(int i = 0; i < (int)array.size(); ++i) {
27  dest.add_uint16(array[i]);
28  }
29 }
30 
31 /**
32  *
33  */
34 PTA_ushort IoPtaDatagramShort::
35 read_datagram(BamReader *, DatagramIterator &source) {
36  PTA_ushort array;
37 
38  int size = source.get_uint32();
39  for(int i = 0; i < size; ++i) {
40  array.push_back(source.get_uint16());
41  }
42 
43  return array;
44 }
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
Similar to PointerToArray, except that its contents may not be modified.
A class to retrieve the individual data elements previously stored in a Datagram.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
void add_uint32(uint32_t value)
Adds an unsigned 32-bit integer to the datagram.
Definition: datagram.I:94
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
Definition: datagram.I:85
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.