Allow inlining more BinaryReader/BinaryWriter functions
This commit is contained in:
parent
d8a70bb795
commit
0f2f98393f
|
@ -22,36 +22,6 @@ using namespace ConversionUtilities;
|
||||||
* \sa For automatic serialization of structs, see https://github.com/Martchus/reflective-rapidjson.
|
* \sa For automatic serialization of structs, see https://github.com/Martchus/reflective-rapidjson.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Constructs a new BinaryReader.
|
|
||||||
* \param stream Specifies the stream to read from.
|
|
||||||
*/
|
|
||||||
BinaryReader::BinaryReader(istream *stream)
|
|
||||||
: m_stream(stream)
|
|
||||||
, m_ownership(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Copies the specified BinaryReader.
|
|
||||||
* \remarks The copy will not take ownership over the stream.
|
|
||||||
*/
|
|
||||||
BinaryReader::BinaryReader(const BinaryReader &other)
|
|
||||||
: m_stream(other.m_stream)
|
|
||||||
, m_ownership(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Destroys the BinaryReader.
|
|
||||||
*/
|
|
||||||
BinaryReader::~BinaryReader()
|
|
||||||
{
|
|
||||||
if (m_ownership) {
|
|
||||||
delete m_stream;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Assigns the stream the reader will read from when calling one of the read-methods.
|
* \brief Assigns the stream the reader will read from when calling one of the read-methods.
|
||||||
*
|
*
|
||||||
|
@ -59,7 +29,7 @@ BinaryReader::~BinaryReader()
|
||||||
* until a stream is assigned.
|
* until a stream is assigned.
|
||||||
*
|
*
|
||||||
* \param stream Specifies the stream to be assigned.
|
* \param stream Specifies the stream to be assigned.
|
||||||
* \param giveOwnership Indicated whether the reader should take ownership (default is false).
|
* \param giveOwnership Specifies whether the reader should take ownership.
|
||||||
*
|
*
|
||||||
* \sa setStream()
|
* \sa setStream()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace IoUtilities {
|
||||||
class CPP_UTILITIES_EXPORT BinaryReader {
|
class CPP_UTILITIES_EXPORT BinaryReader {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BinaryReader(std::istream *stream);
|
BinaryReader(std::istream *stream, bool giveOwnership = false);
|
||||||
BinaryReader(const BinaryReader &other);
|
BinaryReader(const BinaryReader &other);
|
||||||
BinaryReader &operator=(const BinaryReader &rhs) = delete;
|
BinaryReader &operator=(const BinaryReader &rhs) = delete;
|
||||||
~BinaryReader();
|
~BinaryReader();
|
||||||
|
@ -98,6 +98,37 @@ private:
|
||||||
char m_buffer[8];
|
char m_buffer[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a new BinaryReader.
|
||||||
|
* \param stream Specifies the stream to read from.
|
||||||
|
* \param giveOwnership Specifies whether the reader should take ownership.
|
||||||
|
*/
|
||||||
|
inline BinaryReader::BinaryReader(std::istream *stream, bool giveOwnership)
|
||||||
|
: m_stream(stream)
|
||||||
|
, m_ownership(giveOwnership)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Copies the specified BinaryReader.
|
||||||
|
* \remarks The copy will not take ownership over the stream.
|
||||||
|
*/
|
||||||
|
inline BinaryReader::BinaryReader(const BinaryReader &other)
|
||||||
|
: m_stream(other.m_stream)
|
||||||
|
, m_ownership(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Destroys the BinaryReader.
|
||||||
|
*/
|
||||||
|
inline BinaryReader::~BinaryReader()
|
||||||
|
{
|
||||||
|
if (m_ownership) {
|
||||||
|
delete m_stream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Returns a pointer to the stream the reader will read from when calling one of the read-methods.
|
* \brief Returns a pointer to the stream the reader will read from when calling one of the read-methods.
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,36 +16,6 @@ using namespace ConversionUtilities;
|
||||||
* \sa For automatic deserialization of structs, see https://github.com/Martchus/reflective-rapidjson.
|
* \sa For automatic deserialization of structs, see https://github.com/Martchus/reflective-rapidjson.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Constructs a new BinaryWriter.
|
|
||||||
* \param stream Specifies the stream to write to.
|
|
||||||
*/
|
|
||||||
BinaryWriter::BinaryWriter(ostream *stream)
|
|
||||||
: m_stream(stream)
|
|
||||||
, m_ownership(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Copies the specified BinaryWriter.
|
|
||||||
* \remarks The copy will not take ownership over the stream.
|
|
||||||
*/
|
|
||||||
BinaryWriter::BinaryWriter(const BinaryWriter &other)
|
|
||||||
: m_stream(other.m_stream)
|
|
||||||
, m_ownership(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \brief Destroys the BinaryWriter.
|
|
||||||
*/
|
|
||||||
BinaryWriter::~BinaryWriter()
|
|
||||||
{
|
|
||||||
if (m_ownership) {
|
|
||||||
delete m_stream;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Assigns the stream the writer will write to when calling one of the write-methods.
|
* \brief Assigns the stream the writer will write to when calling one of the write-methods.
|
||||||
*
|
*
|
||||||
|
@ -53,7 +23,7 @@ BinaryWriter::~BinaryWriter()
|
||||||
* until a stream is assigned.
|
* until a stream is assigned.
|
||||||
*
|
*
|
||||||
* \param stream Specifies the stream to be assigned.
|
* \param stream Specifies the stream to be assigned.
|
||||||
* \param giveOwnership Indicated whether the reader should take ownership (default is false).
|
* \param giveOwnership Specifies whether the writer should take ownership.
|
||||||
*
|
*
|
||||||
* \sa setStream()
|
* \sa setStream()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace IoUtilities {
|
||||||
|
|
||||||
class CPP_UTILITIES_EXPORT BinaryWriter {
|
class CPP_UTILITIES_EXPORT BinaryWriter {
|
||||||
public:
|
public:
|
||||||
BinaryWriter(std::ostream *stream);
|
BinaryWriter(std::ostream *stream, bool giveOwnership = false);
|
||||||
BinaryWriter(const BinaryWriter &other);
|
BinaryWriter(const BinaryWriter &other);
|
||||||
BinaryWriter &operator=(const BinaryWriter &rhs) = delete;
|
BinaryWriter &operator=(const BinaryWriter &rhs) = delete;
|
||||||
~BinaryWriter();
|
~BinaryWriter();
|
||||||
|
@ -95,6 +95,37 @@ private:
|
||||||
char m_buffer[8];
|
char m_buffer[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Constructs a new BinaryWriter.
|
||||||
|
* \param stream Specifies the stream to write to.
|
||||||
|
* \param giveOwnership Specifies whether the writer should take ownership.
|
||||||
|
*/
|
||||||
|
inline BinaryWriter::BinaryWriter(std::ostream *stream, bool giveOwnership)
|
||||||
|
: m_stream(stream)
|
||||||
|
, m_ownership(giveOwnership)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Copies the specified BinaryWriter.
|
||||||
|
* \remarks The copy will not take ownership over the stream.
|
||||||
|
*/
|
||||||
|
inline BinaryWriter::BinaryWriter(const BinaryWriter &other)
|
||||||
|
: m_stream(other.m_stream)
|
||||||
|
, m_ownership(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Destroys the BinaryWriter.
|
||||||
|
*/
|
||||||
|
inline BinaryWriter::~BinaryWriter()
|
||||||
|
{
|
||||||
|
if (m_ownership) {
|
||||||
|
delete m_stream;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Returns a pointer to the stream the writer will write to when calling one of the write-methods.
|
* \brief Returns a pointer to the stream the writer will write to when calling one of the write-methods.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue