Panda3D
|
00001 // Filename: streamReader.h 00002 // Created by: drose (04Aug02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef STREAMREADER_H 00016 #define STREAMREADER_H 00017 00018 #include "dtoolbase.h" 00019 #include "pnotify.h" 00020 #include "numeric_types.h" 00021 #include "littleEndian.h" 00022 #include "bigEndian.h" 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : StreamReader 00026 // Description : A class to read sequential binary data directly from 00027 // an istream. Its interface is similar to 00028 // DatagramIterator by design; see also StreamWriter. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_DTOOLCONFIG StreamReader { 00031 public: 00032 INLINE StreamReader(istream &in); 00033 PUBLISHED: 00034 INLINE StreamReader(istream *in, bool owns_stream); 00035 INLINE StreamReader(const StreamReader ©); 00036 INLINE void operator = (const StreamReader ©); 00037 INLINE ~StreamReader(); 00038 00039 INLINE istream *get_istream() const; 00040 00041 BLOCKING INLINE bool get_bool(); 00042 BLOCKING INLINE PN_int8 get_int8(); 00043 BLOCKING INLINE PN_uint8 get_uint8(); 00044 00045 BLOCKING INLINE PN_int16 get_int16(); 00046 BLOCKING INLINE PN_int32 get_int32(); 00047 BLOCKING INLINE PN_int64 get_int64(); 00048 BLOCKING INLINE PN_uint16 get_uint16(); 00049 BLOCKING INLINE PN_uint32 get_uint32(); 00050 BLOCKING INLINE PN_uint64 get_uint64(); 00051 BLOCKING INLINE float get_float32(); 00052 BLOCKING INLINE PN_float64 get_float64(); 00053 00054 BLOCKING INLINE PN_int16 get_be_int16(); 00055 BLOCKING INLINE PN_int32 get_be_int32(); 00056 BLOCKING INLINE PN_int64 get_be_int64(); 00057 BLOCKING INLINE PN_uint16 get_be_uint16(); 00058 BLOCKING INLINE PN_uint32 get_be_uint32(); 00059 BLOCKING INLINE PN_uint64 get_be_uint64(); 00060 BLOCKING INLINE float get_be_float32(); 00061 BLOCKING INLINE PN_float64 get_be_float64(); 00062 00063 BLOCKING string get_string(); 00064 BLOCKING string get_string32(); 00065 BLOCKING string get_z_string(); 00066 BLOCKING string get_fixed_string(size_t size); 00067 00068 BLOCKING void skip_bytes(size_t size); 00069 BLOCKING string extract_bytes(size_t size); 00070 00071 BLOCKING string readline(); 00072 00073 private: 00074 istream *_in; 00075 bool _owns_stream; 00076 }; 00077 00078 #include "streamReader.I" 00079 00080 #endif