00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef DATAGRAMITERATOR_H
00016 #define DATAGRAMITERATOR_H
00017
00018 #include "pandabase.h"
00019
00020 #include "datagram.h"
00021 #include "numeric_types.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030 class EXPCL_PANDAEXPRESS DatagramIterator {
00031 public:
00032 INLINE void assign(Datagram &datagram, size_t offset = 0);
00033 PUBLISHED:
00034 INLINE DatagramIterator();
00035 INLINE DatagramIterator(const Datagram &datagram, size_t offset = 0);
00036 INLINE DatagramIterator(const DatagramIterator ©);
00037 INLINE void operator = (const DatagramIterator ©);
00038 INLINE ~DatagramIterator();
00039
00040 INLINE bool get_bool();
00041 INLINE PN_int8 get_int8();
00042 INLINE PN_uint8 get_uint8();
00043
00044 INLINE PN_int16 get_int16();
00045 INLINE PN_int32 get_int32();
00046 INLINE PN_int64 get_int64();
00047 INLINE PN_uint16 get_uint16();
00048 INLINE PN_uint32 get_uint32();
00049 INLINE PN_uint64 get_uint64();
00050 INLINE float get_float32();
00051 INLINE PN_float64 get_float64();
00052
00053 INLINE PN_int16 get_be_int16();
00054 INLINE PN_int32 get_be_int32();
00055 INLINE PN_int64 get_be_int64();
00056 INLINE PN_uint16 get_be_uint16();
00057 INLINE PN_uint32 get_be_uint32();
00058 INLINE PN_uint64 get_be_uint64();
00059 INLINE float get_be_float32();
00060 INLINE PN_float64 get_be_float64();
00061
00062 string get_string();
00063 string get_string32();
00064 string get_z_string();
00065 string get_fixed_string(size_t size);
00066 wstring get_wstring();
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 void output(ostream &out) const;
00078 void write(ostream &out, unsigned int indent=0) const;
00079
00080 private:
00081 const Datagram *_datagram;
00082 size_t _current_index;
00083 };
00084
00085
00086
00087
00088
00089
00090 INLINE void
00091 generic_read_datagram(bool &result, DatagramIterator &source);
00092 INLINE void
00093 generic_read_datagram(int &result, DatagramIterator &source);
00094 INLINE void
00095 generic_read_datagram(float &result, DatagramIterator &source);
00096 INLINE void
00097 generic_read_datagram(double &result, DatagramIterator &source);
00098 INLINE void
00099 generic_read_datagram(string &result, DatagramIterator &source);
00100 INLINE void
00101 generic_read_datagram(wstring &result, DatagramIterator &source);
00102
00103 #include "datagramIterator.I"
00104
00105 #endif