Panda3D
Loading...
Searching...
No Matches
ioPtaDatagramFloat.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 ioPtaDatagramFloat.cxx
10 * @author charles
11 * @date 2000-07-10
12 */
13
14#include "pandabase.h"
15
16#include "ioPtaDatagramFloat.h"
17#include "datagram.h"
18#include "datagramIterator.h"
19
20/**
21 *
22 */
23void IoPtaDatagramFloat::
24write_datagram(BamWriter *, Datagram &dest, CPTA_stdfloat array) {
25 dest.add_uint32(array.size());
26 for (int i = 0; i < (int)array.size(); ++i) {
27 dest.add_stdfloat(array[i]);
28 }
29}
30
31/**
32 *
33 */
34PTA_stdfloat IoPtaDatagramFloat::
35read_datagram(BamReader *, DatagramIterator &source) {
36 PTA_stdfloat array;
37
38 int size = source.get_uint32();
39 for (int i = 0; i < size; ++i) {
40 array.push_back(source.get_stdfloat());
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.
PN_stdfloat get_stdfloat()
Extracts either a 32-bit or a 64-bit floating-point number, according to Datagram::set_stdfloat_doubl...
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_stdfloat(PN_stdfloat value)
Adds either a 32-bit or a 64-bit floating-point number, according to set_stdfloat_double().
Definition datagram.I:133
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.