15 #include "streamReader.h"
16 #include "memoryHook.h"
26 nassertr(!_in->eof() && !_in->fail(), string());
31 char *buffer = (
char *)alloca(size);
32 _in->read(buffer, size);
33 size_t read_bytes = _in->gcount();
34 return string(buffer, read_bytes);
45 nassertr(!_in->eof() && !_in->fail(), string());
50 char *buffer = (
char *)PANDA_MALLOC_ARRAY(size);
51 _in->read(buffer, size);
52 size_t read_bytes = _in->gcount();
53 string result(buffer, read_bytes);
54 PANDA_FREE_ARRAY(buffer);
66 nassertr(!_in->eof() && !_in->fail(), string());
70 while (!_in->eof() && !_in->fail() && ch !=
'\0') {
87 nassertr(!_in->eof() && !_in->fail(), string());
89 char *buffer = (
char *)alloca(size);
90 _in->read(buffer, size);
91 size_t read_bytes = _in->gcount();
92 string result(buffer, read_bytes);
94 size_t zero_byte = result.find(
'\0');
95 return result.substr(0, zero_byte);
106 nassertv(!_in->eof() && !_in->fail());
107 nassertv((
int)size >= 0);
124 if (_in->eof() || _in->fail()) {
128 char *buffer = (
char *)alloca(size);
129 _in->read(buffer, size);
130 size_t read_bytes = _in->gcount();
131 return string(buffer, read_bytes);
145 if (_in->eof() || _in->fail()) {
149 _in->read((
char *)into, size);
150 return _in->gcount();
169 while (!_in->eof() && !_in->fail()) {
string get_string()
Extracts a variable-length string.
string extract_bytes(size_t size)
Extracts the indicated number of bytes in the stream and returns them as a string.
PN_uint32 get_uint32()
Extracts an unsigned 32-bit integer.
string get_fixed_string(size_t size)
Extracts a fixed-length string.
string get_z_string()
Extracts a variable-length string, as a NULL-terminated string.
PN_uint16 get_uint16()
Extracts an unsigned 16-bit integer.
string get_string32()
Extracts a variable-length string with a 32-bit length field.
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.