00001 // Filename: datagramIterator.h 00002 // Created by: jns (07Feb00) 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 #ifndef DATAGRAMITERATOR_H 00020 #define DATAGRAMITERATOR_H 00021 00022 #include <pandabase.h> 00023 00024 #include "datagram.h" 00025 #include "numeric_types.h" 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : DatagramIterator 00029 // Description : A class to retrieve the individual data elements 00030 // previously stored in a Datagram. Elements may be 00031 // retrieved one at a time; it is up to the caller to 00032 // know the correct type and order of each element. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDAEXPRESS DatagramIterator { 00035 PUBLISHED: 00036 INLINE DatagramIterator(); 00037 INLINE DatagramIterator(const Datagram &datagram, size_t offset = 0); 00038 INLINE DatagramIterator(const DatagramIterator ©); 00039 INLINE void operator = (const DatagramIterator ©); 00040 INLINE ~DatagramIterator(); 00041 00042 INLINE bool get_bool(); 00043 INLINE PN_int8 get_int8(); 00044 INLINE PN_uint8 get_uint8(); 00045 00046 INLINE PN_int16 get_int16(); 00047 INLINE PN_int32 get_int32(); 00048 INLINE PN_int64 get_int64(); 00049 INLINE PN_uint16 get_uint16(); 00050 INLINE PN_uint32 get_uint32(); 00051 INLINE PN_uint64 get_uint64(); 00052 INLINE float get_float32(); 00053 INLINE PN_float64 get_float64(); 00054 00055 INLINE PN_int16 get_be_int16(); 00056 INLINE PN_int32 get_be_int32(); 00057 INLINE PN_int64 get_be_int64(); 00058 INLINE PN_uint16 get_be_uint16(); 00059 INLINE PN_uint32 get_be_uint32(); 00060 INLINE PN_uint64 get_be_uint64(); 00061 INLINE float get_be_float32(); 00062 INLINE PN_float64 get_be_float64(); 00063 00064 string get_string(); 00065 string get_z_string(); 00066 string get_fixed_string(size_t size); 00067 00068 INLINE void skip_bytes(size_t size); 00069 string extract_bytes(size_t size); 00070 00071 INLINE string get_remaining_bytes() const; 00072 INLINE int get_remaining_size() const; 00073 00074 INLINE const Datagram &get_datagram() const; 00075 INLINE size_t get_current_index() const; 00076 00077 private: 00078 const Datagram *_datagram; 00079 size_t _current_index; 00080 }; 00081 00082 #include "datagramIterator.I" 00083 00084 #endif
1.3