Fix small issues of BinaryReader/BinaryWriter

- fix documentation
- fix useless checks
This commit is contained in:
Martchus 2016-06-08 00:36:01 +02:00
parent 38a9a1e13e
commit 009a2268ec
2 changed files with 18 additions and 20 deletions

View File

@ -17,14 +17,13 @@ using namespace ConversionUtilities;
/*! /*!
* \class IoUtilities::BinaryReader * \class IoUtilities::BinaryReader
* \brief Reads primitive data types from a std::istream using a specified ConversionUtilities::ByteOrder. * \brief Reads primitive data types from a std::istream.
* \remarks Supports both, little endian and big endian.
*/ */
/*! /*!
* \brief Constructs a new BinaryReader. * \brief Constructs a new BinaryReader.
* \param stream Specifies the stream the reader will read from when calling one of the read-methods. * \param stream Specifies the stream to read from.
* \param byteOrder Specifies the byte order used to convert the raw bytes read from the stream
* to the primitive base data type.
*/ */
BinaryReader::BinaryReader(istream *stream) : BinaryReader::BinaryReader(istream *stream) :
m_stream(stream), m_stream(stream),
@ -33,9 +32,8 @@ BinaryReader::BinaryReader(istream *stream) :
{} {}
/*! /*!
* \brief Constructs a copies of the specified BinaryReader. * \brief Copies the specified BinaryReader.
* * \remarks The copy will not take ownership over the stream.
* The copy will not take ownership over the stream.
*/ */
BinaryReader::BinaryReader(const BinaryReader &other) : BinaryReader::BinaryReader(const BinaryReader &other) :
m_stream(other.m_stream), m_stream(other.m_stream),
@ -48,7 +46,7 @@ BinaryReader::BinaryReader(const BinaryReader &other) :
*/ */
BinaryReader::~BinaryReader() BinaryReader::~BinaryReader()
{ {
if(m_stream && m_ownership) { if(m_ownership) {
delete m_stream; delete m_stream;
} }
} }
@ -66,7 +64,7 @@ BinaryReader::~BinaryReader()
*/ */
void BinaryReader::setStream(istream *stream, bool giveOwnership) void BinaryReader::setStream(istream *stream, bool giveOwnership)
{ {
if(m_stream && m_ownership) { if(m_ownership) {
delete m_stream; delete m_stream;
} }
if(stream) { if(stream) {
@ -83,7 +81,8 @@ void BinaryReader::setStream(istream *stream, bool giveOwnership)
* \brief Returns the size of the assigned stream. * \brief Returns the size of the assigned stream.
* *
* The size is determined by seeking to the end of the stream and returning this offset. * The size is determined by seeking to the end of the stream and returning this offset.
* The method will seek back to the previous offset before returning. *
* \remarks The method will seek back to the previous offset before returning.
*/ */
istream::pos_type BinaryReader::readStreamsize() istream::pos_type BinaryReader::readStreamsize()
{ {

View File

@ -11,14 +11,13 @@ using namespace ConversionUtilities;
/*! /*!
* \class IoUtilities::BinaryWriter * \class IoUtilities::BinaryWriter
* \brief Writes primitive data types to a std::ostream using a specified ConversionUtilities::ByteOrder. * \brief Writes primitive data types to a std::ostream.
* \remarks Supports both, little endian and big endian.
*/ */
/*! /*!
* Constructs a new BinaryWriter. * \brief Constructs a new BinaryWriter.
* \param stream Specifies the stream the writer will write to when calling one of the write-methods. * \param stream Specifies the stream to write to.
* \param byteOrder Specifies the byte order used to convert the provided values to the raw bytes
* written to the stream.
*/ */
BinaryWriter::BinaryWriter(ostream *stream) : BinaryWriter::BinaryWriter(ostream *stream) :
m_stream(stream), m_stream(stream),
@ -26,9 +25,8 @@ BinaryWriter::BinaryWriter(ostream *stream) :
{} {}
/*! /*!
* \brief Constructs a copies of the specified BinaryWriter. * \brief Copies the specified BinaryWriter.
* * \remarks The copy will not take ownership over the stream.
* The copy will not take ownership over the stream.
*/ */
BinaryWriter::BinaryWriter(const BinaryWriter &other) : BinaryWriter::BinaryWriter(const BinaryWriter &other) :
m_stream(other.m_stream), m_stream(other.m_stream),
@ -40,7 +38,7 @@ BinaryWriter::BinaryWriter(const BinaryWriter &other) :
*/ */
BinaryWriter::~BinaryWriter() BinaryWriter::~BinaryWriter()
{ {
if(m_stream && m_ownership) { if(m_ownership) {
delete m_stream; delete m_stream;
} }
} }
@ -58,8 +56,9 @@ BinaryWriter::~BinaryWriter()
*/ */
void BinaryWriter::setStream(ostream *stream, bool giveOwnership) void BinaryWriter::setStream(ostream *stream, bool giveOwnership)
{ {
if(m_stream && m_ownership) if(m_ownership) {
delete m_stream; delete m_stream;
}
if(stream) { if(stream) {
m_stream = stream; m_stream = stream;
m_ownership = giveOwnership; m_ownership = giveOwnership;