Panda3D
streamReader.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file streamReader.h
10  * @author drose
11  * @date 2002-08-04
12  */
13 
14 #ifndef STREAMREADER_H
15 #define STREAMREADER_H
16 
17 #include "dtoolbase.h"
18 #include "pnotify.h"
19 #include "numeric_types.h"
20 #include "littleEndian.h"
21 #include "bigEndian.h"
22 #include "vector_uchar.h"
23 
24 /**
25  * A class to read sequential binary data directly from an istream. Its
26  * interface is similar to DatagramIterator by design; see also StreamWriter.
27  */
28 class EXPCL_DTOOL_PRC StreamReader {
29 public:
30  INLINE StreamReader(std::istream &in);
31 PUBLISHED:
32  INLINE explicit StreamReader(std::istream *in, bool owns_stream);
33  INLINE StreamReader(const StreamReader &copy);
34  INLINE void operator = (const StreamReader &copy);
35  INLINE ~StreamReader();
36 
37  INLINE std::istream *get_istream() const;
38  MAKE_PROPERTY(std::istream, get_istream);
39 
40  BLOCKING INLINE bool get_bool();
41  BLOCKING INLINE int8_t get_int8();
42  BLOCKING INLINE uint8_t get_uint8();
43 
44  BLOCKING INLINE int16_t get_int16();
45  BLOCKING INLINE int32_t get_int32();
46  BLOCKING INLINE int64_t get_int64();
47  BLOCKING INLINE uint16_t get_uint16();
48  BLOCKING INLINE uint32_t get_uint32();
49  BLOCKING INLINE uint64_t get_uint64();
50  BLOCKING INLINE float get_float32();
51  BLOCKING INLINE PN_float64 get_float64();
52 
53  BLOCKING INLINE int16_t get_be_int16();
54  BLOCKING INLINE int32_t get_be_int32();
55  BLOCKING INLINE int64_t get_be_int64();
56  BLOCKING INLINE uint16_t get_be_uint16();
57  BLOCKING INLINE uint32_t get_be_uint32();
58  BLOCKING INLINE uint64_t get_be_uint64();
59  BLOCKING INLINE float get_be_float32();
60  BLOCKING INLINE PN_float64 get_be_float64();
61 
62  BLOCKING std::string get_string();
63  BLOCKING std::string get_string32();
64  BLOCKING std::string get_z_string();
65  BLOCKING std::string get_fixed_string(size_t size);
66 
67  BLOCKING void skip_bytes(size_t size);
68  BLOCKING size_t extract_bytes(unsigned char *into, size_t size);
69  EXTENSION(BLOCKING PyObject *extract_bytes(size_t size));
70 
71  EXTENSION(BLOCKING PyObject *readline());
72  EXTENSION(BLOCKING PyObject *readlines());
73 
74 public:
75  BLOCKING vector_uchar extract_bytes(size_t size);
76  BLOCKING std::string readline();
77 
78 private:
79  std::istream *_in;
80  bool _owns_stream;
81 };
82 
83 #include "streamReader.I"
84 
85 #endif
bigEndian.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
numeric_types.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
vector_uchar.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pnotify.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
dtoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
StreamReader
A class to read sequential binary data directly from an istream.
Definition: streamReader.h:28
streamReader.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
littleEndian.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.