00001 // Filename: ioPtaDatagramFloat.cxx 00002 // Created by: charles (10Jul00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include <pandabase.h> 00020 00021 #include "ioPtaDatagramFloat.h" 00022 #include "datagram.h" 00023 #include "datagramIterator.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: IoPtaDatagramFloat::write_datagram 00027 // Access: Public, Static 00028 // Description: 00029 //////////////////////////////////////////////////////////////////// 00030 void IoPtaDatagramFloat:: 00031 write_datagram(Datagram &dest, CPTA_float array) 00032 { 00033 dest.add_uint32(array.size()); 00034 for (int i = 0; i < (int)array.size(); i++) { 00035 dest.add_float32(array[i]); 00036 } 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function: IoPtaDatagramFloat::read_datagram 00041 // Access: Public, Static 00042 // Description: 00043 //////////////////////////////////////////////////////////////////// 00044 PTA_float IoPtaDatagramFloat:: 00045 read_datagram(DatagramIterator &source) 00046 { 00047 PTA_float array; 00048 00049 int size = source.get_uint32(); 00050 for (int i = 0; i < size; i++) { 00051 array.push_back(source.get_float32()); 00052 } 00053 00054 return array; 00055 }