Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
libdeng2: Predictable size for Vector2/3/4 classes
Should not derive from ISerializable.

This necessitates having serialization operators outside the class.
  • Loading branch information
skyjake committed Nov 27, 2012
1 parent 821a9e9 commit 3b3e952
Show file tree
Hide file tree
Showing 6 changed files with 449 additions and 333 deletions.
13 changes: 13 additions & 0 deletions doomsday/libdeng2/include/de/data/reader.h
Expand Up @@ -24,6 +24,8 @@
#include "../IByteArray"
#include "../ByteOrder"

#include <algorithm>

namespace de {

class Block;
Expand All @@ -46,6 +48,13 @@ class DENG2_PUBLIC Reader
DENG2_ERROR(SeekError);

public:
/**
* Copy constructor.
*
* @param other Reader.
*/
Reader(Reader const &other);

/**
* Constructs a new reader.
*
Expand Down Expand Up @@ -165,6 +174,10 @@ class DENG2_PUBLIC Reader
*/
ByteOrder const &byteOrder() const;

inline void swap(Reader &other) {
std::swap(d, other.d);
}

private:
struct Instance;
Instance *d;
Expand Down
17 changes: 15 additions & 2 deletions doomsday/libdeng2/include/de/data/writer.h
Expand Up @@ -24,6 +24,8 @@
#include "../IByteArray"
#include "../ByteOrder"

#include <algorithm> // std::swap

namespace de {

class IWritable;
Expand Down Expand Up @@ -83,14 +85,21 @@ class DENG2_PUBLIC Writer
Writer(ByteArrayFile &destination, ByteOrder const &byteOrder = littleEndianByteOrder,
IByteArray::Offset offset = 0);

/**
* Copy constructor.
*
* @param other Writer.
*/
Writer(Writer const &other);

/**
* Constructs a new writer that uses the current offset of @a other as its
* zero offset.
*
* @param other Writer.
* @param byteOrder Byte order. Defaults to little-endian.
* @param byteOrder Byte order.
*/
Writer(Writer const &other, ByteOrder const &byteOrder = littleEndianByteOrder);
Writer(Writer const &other, ByteOrder const &byteOrder);

virtual ~Writer();

Expand Down Expand Up @@ -169,6 +178,10 @@ class DENG2_PUBLIC Writer
*/
void seek(dint count);

inline void swap(Writer &other) {
std::swap(d, other.d);
}

private:
struct Instance;
Instance *d;
Expand Down

0 comments on commit 3b3e952

Please sign in to comment.