Panda3D
Loading...
Searching...
No Matches
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 */
28class EXPCL_DTOOL_PRC StreamReader {
29public:
30 INLINE StreamReader(std::istream &in);
31PUBLISHED:
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(PyObject *extract_bytes(size_t size));
70
71 EXTENSION(PyObject *readline());
72 EXTENSION(PyObject *readlines());
73
74public:
75 BLOCKING vector_uchar extract_bytes(size_t size);
76 BLOCKING std::string readline();
77
78private:
79 std::istream *_in;
80 bool _owns_stream;
81};
82
83#include "streamReader.I"
84
85#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
uint8_t get_uint8()
Extracts an unsigned 8-bit integer.
int32_t get_be_int32()
Extracts a signed big-endian 32-bit integer.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
std::string get_string32()
Extracts a variable-length string with a 32-bit length field.
int16_t get_int16()
Extracts a signed 16-bit integer.
float get_float32()
Extracts a 32-bit single-precision floating-point number.
bool get_bool()
Extracts a boolean value.
uint16_t get_be_uint16()
Extracts an unsigned big-endian 16-bit integer.
int64_t get_be_int64()
Extracts a signed big-endian 64-bit integer.
std::string get_string()
Extracts a variable-length string.
int8_t get_int8()
Extracts a signed 8-bit integer.
uint64_t get_uint64()
Extracts an unsigned 64-bit integer.
PN_float64 get_float64()
Extracts a 64-bit floating-point number.
std::string get_fixed_string(size_t size)
Extracts a fixed-length string.
int32_t get_int32()
Extracts a signed 32-bit integer.
int16_t get_be_int16()
Extracts a signed big-endian 16-bit integer.
std::string readline()
Assumes the stream represents a text file, and extracts one line up to and including the trailing new...
void skip_bytes(size_t size)
Skips over the indicated number of bytes in the stream.
uint64_t get_be_uint64()
Extracts an unsigned big-endian 64-bit integer.
size_t extract_bytes(unsigned char *into, size_t size)
Extracts the indicated number of bytes in the stream into the given character buffer.
PN_float64 get_be_float64()
Extracts a 64-bit big-endian floating-point number.
int64_t get_int64()
Extracts a signed 64-bit integer.
std::string get_z_string()
Extracts a variable-length string, as a NULL-terminated string.
uint32_t get_uint32()
Extracts an unsigned 32-bit integer.
float get_be_float32()
Extracts a 32-bit single-precision big-endian floating-point number.
get_istream
Returns the stream in use.
uint32_t get_be_uint32()
Extracts an unsigned big-endian 32-bit integer.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.