streamReader.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Filename: streamReader.h
  2. // Created by: drose (04Aug02)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef STREAMREADER_H
  19. #define STREAMREADER_H
  20. #include "pandabase.h"
  21. #include "numeric_types.h"
  22. #include "littleEndian.h"
  23. #include "bigEndian.h"
  24. ////////////////////////////////////////////////////////////////////
  25. // Class : StreamReader
  26. // Description : A class to read sequential binary data directly from
  27. // an istream. Its interface is similar to
  28. // DatagramIterator by design; see also StreamWriter.
  29. ////////////////////////////////////////////////////////////////////
  30. class EXPCL_PANDAEXPRESS StreamReader {
  31. public:
  32. INLINE StreamReader(istream &in);
  33. PUBLISHED:
  34. INLINE StreamReader(istream *in, bool owns_stream);
  35. INLINE StreamReader(const StreamReader &copy);
  36. INLINE void operator = (const StreamReader &copy);
  37. INLINE ~StreamReader();
  38. INLINE istream *get_istream() const;
  39. INLINE bool get_bool();
  40. INLINE PN_int8 get_int8();
  41. INLINE PN_uint8 get_uint8();
  42. INLINE PN_int16 get_int16();
  43. INLINE PN_int32 get_int32();
  44. INLINE PN_int64 get_int64();
  45. INLINE PN_uint16 get_uint16();
  46. INLINE PN_uint32 get_uint32();
  47. INLINE PN_uint64 get_uint64();
  48. INLINE float get_float32();
  49. INLINE PN_float64 get_float64();
  50. INLINE PN_int16 get_be_int16();
  51. INLINE PN_int32 get_be_int32();
  52. INLINE PN_int64 get_be_int64();
  53. INLINE PN_uint16 get_be_uint16();
  54. INLINE PN_uint32 get_be_uint32();
  55. INLINE PN_uint64 get_be_uint64();
  56. INLINE float get_be_float32();
  57. INLINE PN_float64 get_be_float64();
  58. string get_string();
  59. string get_string32();
  60. string get_z_string();
  61. string get_fixed_string(size_t size);
  62. void skip_bytes(size_t size);
  63. string extract_bytes(size_t size);
  64. string readline();
  65. private:
  66. istream *_in;
  67. bool _owns_stream;
  68. };
  69. #include "streamReader.I"
  70. #endif