mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
dtool: add StreamReader/StreamWriter move ctor and assignment ops
This commit is contained in:
parent
269d3db290
commit
5d6b4f4a77
@ -43,7 +43,18 @@ StreamReader(const StreamReader ©) :
|
||||
}
|
||||
|
||||
/**
|
||||
* The copy constructor does not copy ownership of the stream.
|
||||
* The move constructor steals ownership of the stream.
|
||||
*/
|
||||
INLINE StreamReader::
|
||||
StreamReader(StreamReader &&from) noexcept :
|
||||
_in(from._in),
|
||||
_owns_stream(from._owns_stream)
|
||||
{
|
||||
from._owns_stream = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The copy assignment operator does not copy ownership of the stream.
|
||||
*/
|
||||
INLINE void StreamReader::
|
||||
operator = (const StreamReader ©) {
|
||||
@ -54,6 +65,19 @@ operator = (const StreamReader ©) {
|
||||
_owns_stream = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The move assignment operator steals ownership of the stream.
|
||||
*/
|
||||
INLINE void StreamReader::
|
||||
operator = (StreamReader &&from) noexcept {
|
||||
if (_owns_stream) {
|
||||
delete _in;
|
||||
}
|
||||
_in = from._in;
|
||||
_owns_stream = from._owns_stream;
|
||||
from._owns_stream = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -31,7 +31,9 @@ public:
|
||||
PUBLISHED:
|
||||
INLINE explicit StreamReader(std::istream *in, bool owns_stream);
|
||||
INLINE StreamReader(const StreamReader ©);
|
||||
INLINE StreamReader(StreamReader &&from) noexcept;
|
||||
INLINE void operator = (const StreamReader ©);
|
||||
INLINE void operator = (StreamReader &&from) noexcept;
|
||||
INLINE ~StreamReader();
|
||||
|
||||
INLINE std::istream *get_istream() const;
|
||||
|
@ -51,7 +51,21 @@ StreamWriter(const StreamWriter ©) :
|
||||
}
|
||||
|
||||
/**
|
||||
* The copy constructor does not copy ownership of the stream.
|
||||
* The move constructor steals ownership of the stream.
|
||||
*/
|
||||
INLINE StreamWriter::
|
||||
StreamWriter(StreamWriter &&from) noexcept :
|
||||
#ifdef HAVE_PYTHON
|
||||
softspace(0),
|
||||
#endif
|
||||
_out(from._out),
|
||||
_owns_stream(from._owns_stream)
|
||||
{
|
||||
from._owns_stream = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The copy assignment operator does not copy ownership of the stream.
|
||||
*/
|
||||
INLINE void StreamWriter::
|
||||
operator = (const StreamWriter ©) {
|
||||
@ -62,6 +76,19 @@ operator = (const StreamWriter ©) {
|
||||
_owns_stream = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The move assignment operator steals ownership of the stream.
|
||||
*/
|
||||
INLINE void StreamWriter::
|
||||
operator = (StreamWriter &&from) noexcept {
|
||||
if (_owns_stream) {
|
||||
delete _out;
|
||||
}
|
||||
_out = from._out;
|
||||
_owns_stream = from._owns_stream;
|
||||
from._owns_stream = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -32,7 +32,9 @@ public:
|
||||
PUBLISHED:
|
||||
INLINE explicit StreamWriter(std::ostream *out, bool owns_stream);
|
||||
INLINE StreamWriter(const StreamWriter ©);
|
||||
INLINE StreamWriter(StreamWriter &&from) noexcept;
|
||||
INLINE void operator = (const StreamWriter ©);
|
||||
INLINE void operator = (StreamWriter &&from) noexcept;
|
||||
INLINE ~StreamWriter();
|
||||
|
||||
INLINE std::ostream *get_ostream() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user