14#ifndef STREAMWRAPPER_H
15#define STREAMWRAPPER_H
25class EXPCL_DTOOL_PRC StreamWrapperBase {
27 INLINE StreamWrapperBase();
28 INLINE StreamWrapperBase(
const StreamWrapperBase ©) =
delete;
35 INLINE
void ref()
const;
36 INLINE
bool unref()
const;
43 mutable AtomicAdjust::Integer _ref_count = 1;
59class EXPCL_DTOOL_PRC IStreamWrapper :
virtual public StreamWrapperBase {
61 INLINE IStreamWrapper(std::istream *stream,
bool owns_pointer);
63 INLINE
explicit IStreamWrapper(std::istream &stream);
70 void read(
char *buffer, std::streamsize num_bytes);
71 void read(
char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes);
72 void read(
char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes,
bool &eof);
73 void seek_read(std::streamsize pos,
char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes,
bool &eof);
78 std::istream *_istream;
86class EXPCL_DTOOL_PRC OStreamWrapper :
virtual public StreamWrapperBase {
88 INLINE OStreamWrapper(std::ostream *stream,
bool owns_pointer,
bool stringstream_hack =
false);
90 INLINE
explicit OStreamWrapper(std::ostream &stream);
97 void write(
const char *buffer, std::streamsize num_bytes);
98 void write(
const char *buffer, std::streamsize num_bytes,
bool &fail);
99 void seek_write(std::streamsize pos,
const char *buffer, std::streamsize num_bytes,
bool &fail);
100 void seek_eof_write(
const char *buffer, std::streamsize num_bytes,
bool &fail);
101 INLINE
bool put(
char c);
105 std::ostream *_ostream;
114 bool _stringstream_hack;
122class EXPCL_DTOOL_PRC StreamWrapper :
public IStreamWrapper,
public OStreamWrapper {
124 INLINE StreamWrapper(std::iostream *stream,
bool owns_pointer,
bool stringstream_hack =
false);
126 INLINE
explicit StreamWrapper(std::iostream &stream);
133 std::iostream *_iostream;
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void seek_read(std::streamsize pos, char *buffer, std::streamsize num_bytes, std::streamsize &read_bytes, bool &eof)
Atomically seeks to a particular offset from the beginning of the file, and reads a number of bytes f...
get_istream
Returns the istream this object is wrapping.
int get()
Atomically reads a single character from the stream.
std::streamsize seek_gpos_eof()
Atomically seeks to EOF and returns the gpos there; that is, returns the file size.
void seek_write(std::streamsize pos, const char *buffer, std::streamsize num_bytes, bool &fail)
Atomically seeks to a particular offset from the beginning of the file, and writes a number of bytes ...
get_ostream
Returns the ostream this object is wrapping.
std::streamsize seek_ppos_eof()
Atomically seeks to EOF and returns the ppos there; that is, returns the file size.
void seek_eof_write(const char *buffer, std::streamsize num_bytes, bool &fail)
Atomically seeks to the end of the file, and writes a number of bytes to the stream.
bool put(char c)
Atomically writes a single character to the stream.
bool unref() const
Decrements the reference count.
void release()
Releases the internal lock.
void acquire()
Acquires the internal lock.
void ref() const
Increments the reference count.
get_iostream
Returns the iostream this object is wrapping.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.