Panda3D
 All Classes Functions Variables Enumerations
streamReader.h
1 // Filename: streamReader.h
2 // Created by: drose (04Aug02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef STREAMREADER_H
16 #define STREAMREADER_H
17 
18 #include "dtoolbase.h"
19 #include "pnotify.h"
20 #include "numeric_types.h"
21 #include "littleEndian.h"
22 #include "bigEndian.h"
23 
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_DTOOLCONFIG 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 
39  INLINE istream *get_istream() const;
40 
41  BLOCKING INLINE bool get_bool();
42  BLOCKING INLINE PN_int8 get_int8();
43  BLOCKING INLINE PN_uint8 get_uint8();
44 
45  BLOCKING INLINE PN_int16 get_int16();
46  BLOCKING INLINE PN_int32 get_int32();
47  BLOCKING INLINE PN_int64 get_int64();
48  BLOCKING INLINE PN_uint16 get_uint16();
49  BLOCKING INLINE PN_uint32 get_uint32();
50  BLOCKING INLINE PN_uint64 get_uint64();
51  BLOCKING INLINE float get_float32();
52  BLOCKING INLINE PN_float64 get_float64();
53 
54  BLOCKING INLINE PN_int16 get_be_int16();
55  BLOCKING INLINE PN_int32 get_be_int32();
56  BLOCKING INLINE PN_int64 get_be_int64();
57  BLOCKING INLINE PN_uint16 get_be_uint16();
58  BLOCKING INLINE PN_uint32 get_be_uint32();
59  BLOCKING INLINE PN_uint64 get_be_uint64();
60  BLOCKING INLINE float get_be_float32();
61  BLOCKING INLINE PN_float64 get_be_float64();
62 
63  BLOCKING string get_string();
64  BLOCKING string get_string32();
65  BLOCKING string get_z_string();
66  BLOCKING string get_fixed_string(size_t size);
67 
68  BLOCKING void skip_bytes(size_t size);
69  BLOCKING string extract_bytes(size_t size);
70  BLOCKING size_t extract_bytes(unsigned char *into, size_t size);
71 
72  BLOCKING string readline();
73  EXTENSION(BLOCKING PyObject *readlines());
74 
75 private:
76  istream *_in;
77  bool _owns_stream;
78 };
79 
80 #include "streamReader.I"
81 
82 #endif
A class to read sequential binary data directly from an istream.
Definition: streamReader.h:30