00001 // Filename: streamReader.h 00002 // Created by: drose (04Aug02) 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 STREAMREADER_H 00020 #define STREAMREADER_H 00021 00022 #include "pandabase.h" 00023 00024 #include "numeric_types.h" 00025 #include "littleEndian.h" 00026 #include "bigEndian.h" 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : StreamReader 00030 // Description : A class to read sequential binary data directly from 00031 // an istream. Its interface is similar to 00032 // DatagramIterator by design; see also StreamWriter. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDAEXPRESS StreamReader { 00035 public: 00036 INLINE StreamReader(istream &in); 00037 PUBLISHED: 00038 INLINE StreamReader(istream *in, bool owns_stream); 00039 INLINE StreamReader(const StreamReader ©); 00040 INLINE void operator = (const StreamReader ©); 00041 INLINE ~StreamReader(); 00042 00043 INLINE istream *get_istream() const; 00044 00045 INLINE bool get_bool(); 00046 INLINE PN_int8 get_int8(); 00047 INLINE PN_uint8 get_uint8(); 00048 00049 INLINE PN_int16 get_int16(); 00050 INLINE PN_int32 get_int32(); 00051 INLINE PN_int64 get_int64(); 00052 INLINE PN_uint16 get_uint16(); 00053 INLINE PN_uint32 get_uint32(); 00054 INLINE PN_uint64 get_uint64(); 00055 INLINE float get_float32(); 00056 INLINE PN_float64 get_float64(); 00057 00058 INLINE PN_int16 get_be_int16(); 00059 INLINE PN_int32 get_be_int32(); 00060 INLINE PN_int64 get_be_int64(); 00061 INLINE PN_uint16 get_be_uint16(); 00062 INLINE PN_uint32 get_be_uint32(); 00063 INLINE PN_uint64 get_be_uint64(); 00064 INLINE float get_be_float32(); 00065 INLINE PN_float64 get_be_float64(); 00066 00067 string get_string(); 00068 string get_z_string(); 00069 string get_fixed_string(size_t size); 00070 00071 void skip_bytes(size_t size); 00072 string extract_bytes(size_t size); 00073 00074 string readline(); 00075 00076 private: 00077 istream *_in; 00078 bool _owns_stream; 00079 }; 00080 00081 #include "streamReader.I" 00082 00083 #endif