Skip to content

Commit

Permalink
libdeng2: Default byte order for de::Reader and de::Writer is little-…
Browse files Browse the repository at this point in the history
…endian

For compatibility with earlier conventions, libdeng2's Reader and Writer
classes default to little-endian byte order.
  • Loading branch information
skyjake committed Mar 25, 2012
1 parent a3a2394 commit cc8e7cf
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
3 changes: 3 additions & 0 deletions doomsday/libdeng2/include/de/data/block.h
Expand Up @@ -65,6 +65,9 @@ class DENG2_PUBLIC Block : public QByteArray, public IByteArray, public IBlock

/// Appends a block after this one.
Block& operator += (const Block& other);

/// Copies the contents of another block.
Block& operator = (const Block& other);
};

} // namespace de
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/include/de/data/reader.h
Expand Up @@ -48,7 +48,7 @@ class DENG2_PUBLIC Reader
* (big-endian) byte order.
* @param offset Offset in @a source where to start reading.
*/
Reader(const IByteArray& source, const ByteOrder& byteOrder = bigEndianByteOrder,
Reader(const IByteArray& source, const ByteOrder& byteOrder = littleEndianByteOrder,
IByteArray::Offset offset = 0);

//@{ Read a number from the source buffer, in network byte order.
Expand Down
11 changes: 5 additions & 6 deletions doomsday/libdeng2/include/de/data/writer.h
Expand Up @@ -44,15 +44,14 @@ class DENG2_PUBLIC Writer
* Constructs a new writer.
*
* @param destination Byte array to write to.
* @param byteOrder Byte order to use. The byte order defaults to network
* (big-endian) byte order.
* @param byteOrder Byte order to use. The byte order defaults to little-endian byte order.
* @param offset Offset in @a destination where to start writing.
*/
Writer(IByteArray& destination, const ByteOrder& byteOrder = bigEndianByteOrder,
Writer(IByteArray& destination, const ByteOrder& byteOrder = littleEndianByteOrder,
IByteArray::Offset offset = 0);

/**
* Constructs a new writer (with big-endian byte order).
* Constructs a new writer (with little-endian byte order).
*
* @param destination Byte array to write to.
* @param offset Offset in @a destination where to start writing.
Expand All @@ -64,9 +63,9 @@ class DENG2_PUBLIC Writer
* zero offset.
*
* @param other Writer.
* @param byteOrder Byte order. Defaults to big-endian.
* @param byteOrder Byte order. Defaults to little-endian.
*/
Writer(const Writer& other, const ByteOrder& byteOrder = bigEndianByteOrder);
Writer(const Writer& other, const ByteOrder& byteOrder = littleEndianByteOrder);

//@{ Write a number to the destination buffer, in the chosen byte order.
Writer& operator << (const char& byte);
Expand Down
6 changes: 6 additions & 0 deletions doomsday/libdeng2/src/data/block.cpp
Expand Up @@ -102,6 +102,12 @@ Block& Block::operator += (const Block& other)
return *this;
}

Block& Block::operator = (const Block& other)
{
*static_cast<QByteArray*>(this) = static_cast<QByteArray&>(other);
return *this;
}

void Block::clear()
{
QByteArray::clear();
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/src/data/writer.cpp
Expand Up @@ -32,7 +32,7 @@ Writer::Writer(IByteArray& destination, const ByteOrder& byteOrder, IByteArray::
{}

Writer::Writer(IByteArray& destination, IByteArray::Offset offset)
: _destination(destination), _offset(offset), _fixedOffset(0), _convert(bigEndianByteOrder)
: _destination(destination), _offset(offset), _fixedOffset(0), _convert(littleEndianByteOrder)
{}

Writer::Writer(const Writer& other, const ByteOrder& byteOrder)
Expand Down

0 comments on commit cc8e7cf

Please sign in to comment.