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