Panda3D
ioPtaDatagramFloat.cxx
1 // Filename: ioPtaDatagramFloat.cxx
2 // Created by: charles (10Jul00)
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 #include "pandabase.h"
16 
17 #include "ioPtaDatagramFloat.h"
18 #include "datagram.h"
19 #include "datagramIterator.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: IoPtaDatagramFloat::write_datagram
23 // Access: Public, Static
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 void IoPtaDatagramFloat::
27 write_datagram(BamWriter *, Datagram &dest, CPTA_stdfloat array) {
28  dest.add_uint32(array.size());
29  for (int i = 0; i < (int)array.size(); ++i) {
30  dest.add_stdfloat(array[i]);
31  }
32 }
33 
34 ////////////////////////////////////////////////////////////////////
35 // Function: IoPtaDatagramFloat::read_datagram
36 // Access: Public, Static
37 // Description:
38 ////////////////////////////////////////////////////////////////////
39 PTA_stdfloat IoPtaDatagramFloat::
40 read_datagram(BamReader *, DatagramIterator &source) {
41  PTA_stdfloat array;
42 
43  int size = source.get_uint32();
44  for (int i = 0; i < size; ++i) {
45  array.push_back(source.get_stdfloat());
46  }
47 
48  return array;
49 }
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
PN_uint32 get_uint32()
Extracts an unsigned 32-bit integer.
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 add_uint32(PN_uint32 value)
Adds an unsigned 32-bit integer to the datagram.
Definition: datagram.I:192
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:43
Similar to PointerToArray, except that its contents may not be modified.