From d18a9e917f6cb8e304939a4f861cffd8f6d24bb2 Mon Sep 17 00:00:00 2001 From: skyjake Date: Thu, 22 Nov 2012 09:15:38 +0200 Subject: [PATCH] Refactor|libdeng2: Split the IIOStream interface to IIStream and IOStream Transmitter is now derived from IOStream, which means Socket implements the output stream interface. --- doomsday/libdeng2/data.pri | 5 +- doomsday/libdeng2/include/de/IIStream | 1 + doomsday/libdeng2/include/de/IOStream | 1 + doomsday/libdeng2/include/de/core/log.h | 16 ++-- doomsday/libdeng2/include/de/data/block.h | 10 +-- doomsday/libdeng2/include/de/data/iiostream.h | 58 ++------------ doomsday/libdeng2/include/de/data/iistream.h | 78 +++++++++++++++++++ doomsday/libdeng2/include/de/data/iostream.h | 52 +++++++++++++ doomsday/libdeng2/include/de/data/reader.h | 6 +- doomsday/libdeng2/include/de/data/writer.h | 4 +- .../include/de/filesys/bytearrayfile.h | 6 +- doomsday/libdeng2/include/de/filesys/file.h | 10 +-- .../libdeng2/include/de/filesys/nativefile.h | 7 -- .../libdeng2/include/de/net/transmitter.h | 16 ++-- doomsday/libdeng2/src/data/block.cpp | 4 +- doomsday/libdeng2/src/data/reader.cpp | 16 ++-- doomsday/libdeng2/src/data/writer.cpp | 8 +- .../libdeng2/src/filesys/bytearrayfile.cpp | 6 +- doomsday/libdeng2/src/filesys/file.cpp | 12 +-- doomsday/libdeng2/src/filesys/nativefile.cpp | 14 ++-- doomsday/libdeng2/src/net/transmitter.cpp | 2 +- doomsday/tests/archive/main.cpp | 2 +- 22 files changed, 208 insertions(+), 126 deletions(-) create mode 100644 doomsday/libdeng2/include/de/IIStream create mode 100644 doomsday/libdeng2/include/de/IOStream create mode 100644 doomsday/libdeng2/include/de/data/iistream.h create mode 100644 doomsday/libdeng2/include/de/data/iostream.h diff --git a/doomsday/libdeng2/data.pri b/doomsday/libdeng2/data.pri index 0a3ac69e5a..8028c6606b 100644 --- a/doomsday/libdeng2/data.pri +++ b/doomsday/libdeng2/data.pri @@ -17,6 +17,7 @@ HEADERS += \ include/de/IBlock \ include/de/IByteArray \ include/de/IIOStream \ + include/de/IOStream \ include/de/IReadable \ include/de/ISerializable \ include/de/IWritable \ @@ -56,6 +57,7 @@ HEADERS += \ include/de/data/iblock.h \ include/de/data/ibytearray.h \ include/de/data/iiostream.h \ + include/de/data/iostream.h \ include/de/data/info.h \ include/de/data/ireadable.h \ include/de/data/iserializable.h \ @@ -77,7 +79,8 @@ HEADERS += \ include/de/data/waitable.h \ include/de/data/waitablefifo.h \ include/de/data/writer.h \ - include/de/data/zeroed.h + include/de/data/zeroed.h \ + include/de/data/iistream.h SOURCES += \ src/data/accessorvalue.cpp \ diff --git a/doomsday/libdeng2/include/de/IIStream b/doomsday/libdeng2/include/de/IIStream new file mode 100644 index 0000000000..58ea5df5a6 --- /dev/null +++ b/doomsday/libdeng2/include/de/IIStream @@ -0,0 +1 @@ +#include "data/iistream.h" diff --git a/doomsday/libdeng2/include/de/IOStream b/doomsday/libdeng2/include/de/IOStream new file mode 100644 index 0000000000..da3b94980c --- /dev/null +++ b/doomsday/libdeng2/include/de/IOStream @@ -0,0 +1 @@ +#include "data/iostream.h" diff --git a/doomsday/libdeng2/include/de/core/log.h b/doomsday/libdeng2/include/de/core/log.h index ce802c3b97..740ee7c18e 100644 --- a/doomsday/libdeng2/include/de/core/log.h +++ b/doomsday/libdeng2/include/de/core/log.h @@ -88,7 +88,7 @@ class DENG2_PUBLIC Log * to log which methods are entered and exited, and mark certain points within * methods. Intended only for developers and debug builds. */ - TRACE, + TRACE = 0, /** * Debug messages are intended for normal debugging. They should be enabled @@ -96,7 +96,7 @@ class DENG2_PUBLIC Log * a ZIP archive's file count and size once an archive has been successfully * opened. Intended only for developers and debug builds. */ - DEBUG, + DEBUG = 1, /** * Verbose messages should be used to log technical information that is only @@ -106,40 +106,40 @@ class DENG2_PUBLIC Log * number of log entries, such as an entry about reading the contents of a * file within a ZIP archive (which would be suitable for the DEBUG level). */ - VERBOSE, + VERBOSE = 2, /** * Normal log entries are intended for regular users. An example: message about * which map is being loaded. */ - MESSAGE, + MESSAGE = 3, /** * Info messages are intended for situations that are particularly noteworthy. * An info message should be used for instance when a script has been stopped * because of an uncaught exception occurred during its execution. */ - INFO, + INFO = 4, /** * Warning messages are reserved for recoverable error situations. A warning * might be logged for example when the expected resource could not be found, * and a fallback resource was used instead. */ - WARNING, + WARNING = 5, /** * Error messages are intended for nonrecoverable errors. The error is grave * enough to cause the shutting down of the current game, but the engine can * still remain running. */ - ERROR, + ERROR = 6, /** * Critical messages are intended for fatal errors that cause the engine to be * shut down. */ - CRITICAL, + CRITICAL = 7, MAX_LOG_LEVELS }; diff --git a/doomsday/libdeng2/include/de/data/block.h b/doomsday/libdeng2/include/de/data/block.h index 489e4255fe..9b1dca4855 100644 --- a/doomsday/libdeng2/include/de/data/block.h +++ b/doomsday/libdeng2/include/de/data/block.h @@ -27,7 +27,7 @@ namespace de { -class IIOStream; +class IIStream; /** * Data buffer that implements the byte array interface. @@ -43,22 +43,22 @@ class DENG2_PUBLIC Block : public QByteArray, public IByteArray, public IBlock Block(const QByteArray& byteArray); /** - * Constructs a block by reading the contents of an I/O stream. The block + * Constructs a block by reading the contents of an input stream. The block * will contain all the data that is available immediately; will not wait * for additional data to become available later. * * @param stream Stream to read from. */ - Block(IIOStream& stream); + Block(IIStream& stream); /** - * Constructs a block by reading the contents of a I/O stream in const + * Constructs a block by reading the contents of an input stream in const * mode. The block will contain all the data that is available immediately; * will not wait for additional data to become available later. * * @param stream Stream to read from. */ - Block(const IIOStream& stream); + Block(const IIStream& stream); /** * Construct a new block and copy its contents from the specified diff --git a/doomsday/libdeng2/include/de/data/iiostream.h b/doomsday/libdeng2/include/de/data/iiostream.h index f2ebba169a..62bcc6be35 100644 --- a/doomsday/libdeng2/include/de/data/iiostream.h +++ b/doomsday/libdeng2/include/de/data/iiostream.h @@ -21,68 +21,20 @@ #ifndef LIBDENG2_IIOSTREAM_H #define LIBDENG2_IIOSTREAM_H -#include "../IByteArray" +#include "../IIStream" +#include "../IOStream" namespace de { /** * Interface that allows communication via an input/output stream of bytes. - * - * When reading from a stream, the stream can either be in modifiable - * (non-const) or immutable (const) mode. When reading bytes from a modifiable - * stream, the bytes are then removed from the stream and the next read will - * return a different set of bytes. Immutable streams, on the other hand, can - * be used for peeking ahead into the received data: the bytes are not removed - * from the stream during the read. + * @see IIStream, IOStream */ -class IIOStream +class IIOStream : public IIStream, public IOStream { public: - /// I/O to the stream failed. @ingroup errors - DENG2_ERROR(IOError); - /// Only reading is allowed from the stream. @ingroup errors - DENG2_SUB_ERROR(IOError, ReadOnlyError); - -public: - virtual ~IIOStream() {} - - /** - * Writes an array of bytes to the stream. - * - * @param bytes Byte array to write. - * - * @return Reference to this IIOStream object. - */ - virtual IIOStream& operator << (const IByteArray& bytes) = 0; - - /** - * Reads all the available bytes into the array @a bytes. If there is - * nothing available for reading, nothing is written to @a bytes. The - * stream operates as a modifiable object: once read, the bytes are - * considered to be removed from the stream. - * - * @param bytes Read bytes are stored here. - * - * @return Reference to this IIOStream object. - */ - virtual IIOStream& operator >> (IByteArray& bytes) = 0; - - /** - * Reads all the available bytes into the array @a bytes. If there is - * nothing available for reading, nothing is written to @a bytes. - * - * Immutable streams can be used for peeking ahead into the received data. - * Here the stream operates as a const object: the read bytes are not - * removed from the stream, and a subsequent read will return the same - * bytes, plus any additional bytes that may have been produced in the - * meantime. - * - * @param bytes Read bytes are stored here. - * - * @return Reference to this IIOStream object. - */ - virtual const IIOStream& operator >> (IByteArray& bytes) const = 0; + DENG2_SUB_ERROR(OutputError, ReadOnlyError); }; } // namespace de diff --git a/doomsday/libdeng2/include/de/data/iistream.h b/doomsday/libdeng2/include/de/data/iistream.h new file mode 100644 index 0000000000..9e36e782ed --- /dev/null +++ b/doomsday/libdeng2/include/de/data/iistream.h @@ -0,0 +1,78 @@ +/** + * @file iistream.h + * Input-only stream interface. @ingroup data + * + * @authors Copyright © 2012 Jaakko Keränen + * + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the GNU + * General Public License along with this program; if not, see: + * http://www.gnu.org/licenses + */ + +#ifndef LIBDENG2_IISTREAM_H +#define LIBDENG2_IISTREAM_H + +#include "../IByteArray" + +namespace de { + +/** + * Interface that allows communication via an input stream of bytes. + * + * When reading from the stream, it can either be in modifiable (non-const) or + * immutable (const) mode. When reading bytes from a modifiable stream, the + * bytes are then removed from the stream and the next read will return a + * different set of bytes. Immutable streams, on the other hand, can be used + * for peeking ahead into the received data: the bytes are not removed from the + * stream during the read. + */ +class IIStream +{ +public: + /// Input from the stream failed. @ingroup errors + DENG2_ERROR(InputError); + +public: + virtual ~IIStream() {} + + /** + * Reads all the available bytes into the array @a bytes. If there is + * nothing available for reading, nothing is written to @a bytes. The + * stream operates as a modifiable object: once read, the bytes are + * considered to be removed from the stream. + * + * @param bytes Read bytes are stored here. + * + * @return Reference to this IIStream object. + */ + virtual IIStream& operator >> (IByteArray& bytes) = 0; + + /** + * Reads all the available bytes into the array @a bytes. If there is + * nothing available for reading, nothing is written to @a bytes. + * + * Immutable streams can be used for peeking ahead into the received data. + * Here the stream operates as a const object: the read bytes are not + * removed from the stream, and a subsequent read will return the same + * bytes, plus any additional bytes that may have been produced in the + * meantime. + * + * @param bytes Read bytes are stored here. + * + * @return Reference to this IIStream object. + */ + virtual const IIStream& operator >> (IByteArray& bytes) const = 0; +}; + +} // namespace de + +#endif // LIBDENG2_IISTREAM_H diff --git a/doomsday/libdeng2/include/de/data/iostream.h b/doomsday/libdeng2/include/de/data/iostream.h new file mode 100644 index 0000000000..ec3025fcdb --- /dev/null +++ b/doomsday/libdeng2/include/de/data/iostream.h @@ -0,0 +1,52 @@ +/** + * @file iostream.h + * Output-only stream interface. @ingroup data + * + * @authors Copyright © 2012 Jaakko Keränen + * + * @par License + * GPL: http://www.gnu.org/licenses/gpl.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. This program is distributed in the hope that it + * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. You should have received a copy of the GNU + * General Public License along with this program; if not, see: + * http://www.gnu.org/licenses + */ + +#ifndef LIBDENG2_IOSTREAM_H +#define LIBDENG2_IOSTREAM_H + +#include "../IByteArray" + +namespace de { + +/** + * Interface that allows communication via an output stream of bytes. + */ +class IOStream +{ +public: + /// Output to the stream failed. @ingroup errors + DENG2_ERROR(OutputError); + +public: + virtual ~IOStream() {} + + /** + * Writes an array of bytes to the stream. + * + * @param bytes Byte array to write. + * + * @return Reference to this IOStream object. + */ + virtual IOStream& operator << (const IByteArray& bytes) = 0; +}; + +} // namespace de + +#endif // LIBDENG2_IOSTREAM_H diff --git a/doomsday/libdeng2/include/de/data/reader.h b/doomsday/libdeng2/include/de/data/reader.h index 46af9e2694..0de06aa41e 100644 --- a/doomsday/libdeng2/include/de/data/reader.h +++ b/doomsday/libdeng2/include/de/data/reader.h @@ -30,7 +30,7 @@ class Block; class String; class IReadable; class FixedByteArray; -class IIOStream; +class IIStream; /** * Provides a protocol for reading data from a byte array object (anything with @@ -62,7 +62,7 @@ class DENG2_PUBLIC Reader * @param stream Stream where input is read. * @param byteOrder Byte order to use. */ - Reader(IIOStream& stream, const ByteOrder& byteOrder = littleEndianByteOrder); + Reader(IIStream& stream, const ByteOrder& byteOrder = littleEndianByteOrder); /** * Constructs a new reader that reads from a const stream. @@ -70,7 +70,7 @@ class DENG2_PUBLIC Reader * @param stream Const stream where input is read. * @param byteOrder Byte order to use. */ - Reader(const IIOStream& stream, const ByteOrder& byteOrder = littleEndianByteOrder); + Reader(const IIStream& stream, const ByteOrder& byteOrder = littleEndianByteOrder); //@{ Read a number from the source buffer, in network byte order. Reader& operator >> (char& byte); diff --git a/doomsday/libdeng2/include/de/data/writer.h b/doomsday/libdeng2/include/de/data/writer.h index efc07f0ac8..95936fa910 100644 --- a/doomsday/libdeng2/include/de/data/writer.h +++ b/doomsday/libdeng2/include/de/data/writer.h @@ -31,7 +31,7 @@ class String; class Block; class ByteArrayFile; class FixedByteArray; -class IIOStream; +class IOStream; /** * Provides a protocol for writing data in a specific byte order into a byte @@ -71,7 +71,7 @@ class DENG2_PUBLIC Writer * @param stream Stream to write to. * @param byteOrder Byte order to use. */ - Writer(IIOStream& stream, const ByteOrder& byteOrder = littleEndianByteOrder); + Writer(IOStream& stream, const ByteOrder& byteOrder = littleEndianByteOrder); /** * Constructs a new writer for writing into a byte array file. diff --git a/doomsday/libdeng2/include/de/filesys/bytearrayfile.h b/doomsday/libdeng2/include/de/filesys/bytearrayfile.h index aff982adef..22e84947a3 100644 --- a/doomsday/libdeng2/include/de/filesys/bytearrayfile.h +++ b/doomsday/libdeng2/include/de/filesys/bytearrayfile.h @@ -44,9 +44,9 @@ namespace de public: // Implements IIOStream. - IIOStream& operator << (const IByteArray& bytes); - IIOStream& operator >> (IByteArray& bytes); - const IIOStream& operator >> (IByteArray& bytes) const; + IOStream& operator << (const IByteArray& bytes); + IIStream& operator >> (IByteArray& bytes); + const IIStream& operator >> (IByteArray& bytes) const; }; } diff --git a/doomsday/libdeng2/include/de/filesys/file.h b/doomsday/libdeng2/include/de/filesys/file.h index 6742ed44ef..a118649e84 100644 --- a/doomsday/libdeng2/include/de/filesys/file.h +++ b/doomsday/libdeng2/include/de/filesys/file.h @@ -40,8 +40,8 @@ namespace de * * Implements the IIOStream interface to allow files to receive and send * out a stream of bytes. The default implementation only throws an - * IIOStream::IOError -- it is up to subclasses to implement the stream in - * the context suitable for the concrete file class. + * exception -- it is up to subclasses to implement the stream in the + * context suitable for the concrete file class. * * Note that the constructor of File is protected: only subclasses can be * instantiated. @@ -289,9 +289,9 @@ namespace de void verifyWriteAccess(); // Implements IIOStream. - IIOStream& operator << (const IByteArray& bytes); - IIOStream& operator >> (IByteArray& bytes); - const IIOStream& operator >> (IByteArray& bytes) const; + IOStream& operator << (const IByteArray& bytes); + IIStream& operator >> (IByteArray& bytes); + const IIStream& operator >> (IByteArray& bytes) const; protected: /** diff --git a/doomsday/libdeng2/include/de/filesys/nativefile.h b/doomsday/libdeng2/include/de/filesys/nativefile.h index a01249fba7..a5c0deeae6 100644 --- a/doomsday/libdeng2/include/de/filesys/nativefile.h +++ b/doomsday/libdeng2/include/de/filesys/nativefile.h @@ -36,13 +36,6 @@ namespace de */ class DENG2_PUBLIC NativeFile : public ByteArrayFile { - public: - /// Input from the native file failed. @ingroup errors - DENG2_SUB_ERROR(IOError, NativeInputError); - - /// Output to the native file failed. @ingroup errors - DENG2_SUB_ERROR(IOError, NativeOutputError); - public: /** * Constructs a NativeFile that accesses a file in the native file system diff --git a/doomsday/libdeng2/include/de/net/transmitter.h b/doomsday/libdeng2/include/de/net/transmitter.h index faa4e1f241..5a2112b86a 100644 --- a/doomsday/libdeng2/include/de/net/transmitter.h +++ b/doomsday/libdeng2/include/de/net/transmitter.h @@ -21,6 +21,7 @@ #define LIBDENG2_TRANSMITTER_H #include "../libdeng2.h" +#include "../IOStream" namespace de { @@ -32,7 +33,7 @@ class Packet; * * @ingroup net */ -class DENG2_PUBLIC Transmitter +class DENG2_PUBLIC Transmitter : public IOStream { public: virtual ~Transmitter(); @@ -52,18 +53,19 @@ class DENG2_PUBLIC Transmitter virtual void sendPacket(const Packet& packet); /** - * Sends an array of data. + * Sends a packet. The packet is first serialized and then sent. * - * @param data Data to send. + * @param packet Packet. */ - virtual Transmitter& operator << (const IByteArray& data); + virtual Transmitter& operator << (const Packet& packet); + // Implements IOStream. /** - * Sends a packet. The packet is first serialized and then sent. + * Sends an array of data. * - * @param packet Packet. + * @param data Data to send. */ - virtual Transmitter& operator << (const Packet& packet); + virtual IOStream& operator << (const IByteArray& data); }; } // namespace de diff --git a/doomsday/libdeng2/src/data/block.cpp b/doomsday/libdeng2/src/data/block.cpp index eab7bd428e..917ad90113 100644 --- a/doomsday/libdeng2/src/data/block.cpp +++ b/doomsday/libdeng2/src/data/block.cpp @@ -41,12 +41,12 @@ Block::Block(const QByteArray& byteArray) : QByteArray(byteArray) {} -Block::Block(IIOStream& stream) +Block::Block(IIStream& stream) { stream >> *this; } -Block::Block(const IIOStream& stream) +Block::Block(const IIStream& stream) { stream >> *this; } diff --git a/doomsday/libdeng2/src/data/reader.cpp b/doomsday/libdeng2/src/data/reader.cpp index 7fc4598b74..18e8c70599 100644 --- a/doomsday/libdeng2/src/data/reader.cpp +++ b/doomsday/libdeng2/src/data/reader.cpp @@ -21,7 +21,7 @@ #include "de/String" #include "de/Block" #include "de/ISerializable" -#include "de/IIOStream" +#include "de/IIStream" #include "de/FixedByteArray" #include "de/ByteRefArray" #include "de/data/byteorder.h" @@ -41,8 +41,8 @@ struct Reader::Instance IByteArray::Offset markOffset; // Stream source: - IIOStream* stream; - const IIOStream* constStream; + IIStream* stream; + const IIStream* constStream; dsize numReceivedBytes; Block incoming; ///< Buffer for bytes received so far from the stream. bool marking; ///< @c true, if marking is occurring (mark() called). @@ -53,12 +53,12 @@ struct Reader::Instance stream(0), constStream(0), numReceivedBytes(0), marking(false) {} - Instance(const ByteOrder& order, IIOStream* str) + Instance(const ByteOrder& order, IIStream* str) : convert(order), source(0), offset(0), markOffset(0), stream(str), constStream(0), numReceivedBytes(0), marking(false) {} - Instance(const ByteOrder& order, const IIOStream* str) + Instance(const ByteOrder& order, const IIStream* str) : convert(order), source(0), offset(0), markOffset(0), stream(0), constStream(str), numReceivedBytes(0), marking(false) {} @@ -116,7 +116,7 @@ struct Reader::Instance } else { - throw IIOStream::IOError("Reader::readBytes", + throw IIStream::InputError("Reader::readBytes", QString("Attempted to read %1 bytes from stream while only %2 " "bytes are available").arg(size).arg(incoming.size())); } @@ -155,11 +155,11 @@ Reader::Reader(const IByteArray& source, const ByteOrder& byteOrder, IByteArray: : d(new Instance(byteOrder, &source, offset)) {} -Reader::Reader(IIOStream& stream, const ByteOrder& byteOrder) +Reader::Reader(IIStream& stream, const ByteOrder& byteOrder) : d(new Instance(byteOrder, &stream)) {} -Reader::Reader(const IIOStream& stream, const ByteOrder& byteOrder) +Reader::Reader(const IIStream& stream, const ByteOrder& byteOrder) : d(new Instance(byteOrder, &stream)) {} diff --git a/doomsday/libdeng2/src/data/writer.cpp b/doomsday/libdeng2/src/data/writer.cpp index 4fbf2691f6..5faf6f3870 100644 --- a/doomsday/libdeng2/src/data/writer.cpp +++ b/doomsday/libdeng2/src/data/writer.cpp @@ -21,7 +21,7 @@ #include "de/String" #include "de/Block" #include "de/ISerializable" -#include "de/IIOStream" +#include "de/IOStream" #include "de/FixedByteArray" #include "de/ByteRefArray" #include "de/ByteArrayFile" @@ -34,14 +34,14 @@ struct Writer::Instance { const ByteOrder& convert; IByteArray* destination; - IIOStream* stream; + IOStream* stream; IByteArray::Offset offset; const IByteArray::Offset fixedOffset; Instance(const ByteOrder& order, IByteArray* dest, IByteArray::Offset off) : convert(order), destination(dest), stream(0), offset(off), fixedOffset(0) {} - Instance(const ByteOrder& order, IIOStream* str) + Instance(const ByteOrder& order, IOStream* str) : convert(order), destination(0), stream(str), offset(0), fixedOffset(0) { destination = dynamic_cast(str); @@ -84,7 +84,7 @@ Writer::Writer(IByteArray& destination, IByteArray::Offset offset) : d(new Instance(littleEndianByteOrder, &destination, offset)) {} -Writer::Writer(IIOStream& stream, const ByteOrder& byteOrder) +Writer::Writer(IOStream& stream, const ByteOrder& byteOrder) : d(new Instance(byteOrder, &stream)) {} diff --git a/doomsday/libdeng2/src/filesys/bytearrayfile.cpp b/doomsday/libdeng2/src/filesys/bytearrayfile.cpp index b9eadd6ba5..3a7de78ae1 100644 --- a/doomsday/libdeng2/src/filesys/bytearrayfile.cpp +++ b/doomsday/libdeng2/src/filesys/bytearrayfile.cpp @@ -21,7 +21,7 @@ namespace de { -IIOStream& ByteArrayFile::operator << (const IByteArray& bytes) +IOStream& ByteArrayFile::operator << (const IByteArray& bytes) { // Append the bytes to the end of the file. Block block(bytes); @@ -29,7 +29,7 @@ IIOStream& ByteArrayFile::operator << (const IByteArray& bytes) return *this; } -IIOStream& ByteArrayFile::operator >> (IByteArray& bytes) +IIStream& ByteArrayFile::operator >> (IByteArray& bytes) { // Read the entire contents of the file. Block block(File::size()); @@ -38,7 +38,7 @@ IIOStream& ByteArrayFile::operator >> (IByteArray& bytes) return *this; } -const IIOStream& ByteArrayFile::operator >> (IByteArray& bytes) const +const IIStream& ByteArrayFile::operator >> (IByteArray& bytes) const { // Read the entire contents of the file. Block block(File::size()); diff --git a/doomsday/libdeng2/src/filesys/file.cpp b/doomsday/libdeng2/src/filesys/file.cpp index c140668ccf..4c5c18ac36 100644 --- a/doomsday/libdeng2/src/filesys/file.cpp +++ b/doomsday/libdeng2/src/filesys/file.cpp @@ -171,22 +171,22 @@ void File::verifyWriteAccess() } } -IIOStream& File::operator << (const IByteArray& bytes) +IOStream& File::operator << (const IByteArray& bytes) { DENG2_UNUSED(bytes); - throw IOError("File::operator <<", "File does not access input"); + throw OutputError("File::operator <<", "File does not accept a byte stream"); } -IIOStream& File::operator >> (IByteArray& bytes) +IIStream& File::operator >> (IByteArray& bytes) { DENG2_UNUSED(bytes); - throw IOError("File::operator >>", "File does not produce output"); + throw InputError("File::operator >>", "File does not produce a byte stream"); } -const IIOStream& File::operator >> (IByteArray& bytes) const +const IIStream& File::operator >> (IByteArray& bytes) const { DENG2_UNUSED(bytes); - throw IOError("File::operator >>", "File does not produce output"); + throw InputError("File::operator >>", "File does not produce a byte stream"); } dsize File::size() const diff --git a/doomsday/libdeng2/src/filesys/nativefile.cpp b/doomsday/libdeng2/src/filesys/nativefile.cpp index eb4cb39f51..bbaf8438bb 100644 --- a/doomsday/libdeng2/src/filesys/nativefile.cpp +++ b/doomsday/libdeng2/src/filesys/nativefile.cpp @@ -99,9 +99,9 @@ void NativeFile::set(Offset at, const Byte* values, Size count) out.write(reinterpret_cast(values), count); if(out.error() != QFile::NoError) { - /// @throw NativeOutputError Failure to write to the native file. - throw NativeOutputError("NativeFile::set", "Error writing to file:" + - out.errorString()); + /// @throw OutputError Failure to write to the native file. + throw OutputError("NativeFile::set", "Error writing to file:" + + out.errorString()); } // Update status. Status st = status(); @@ -126,8 +126,8 @@ QFile& NativeFile::input() const { delete _in; _in = 0; - /// @throw NativeInputError Opening the input stream failed. - throw NativeInputError("NativeFile::input", "Failed to read " + _nativePath); + /// @throw InputError Opening the input stream failed. + throw InputError("NativeFile::input", "Failed to read " + _nativePath); } } return *_in; @@ -150,8 +150,8 @@ QFile& NativeFile::output() { delete _out; _out = 0; - /// @throw NativeOutputError Opening the output stream failed. - throw NativeOutputError("NativeFile::output", "Failed to write " + _nativePath); + /// @throw OutputError Opening the output stream failed. + throw OutputError("NativeFile::output", "Failed to write " + _nativePath); } if(mode() & Truncate) { diff --git a/doomsday/libdeng2/src/net/transmitter.cpp b/doomsday/libdeng2/src/net/transmitter.cpp index aa479a183d..6180421f42 100644 --- a/doomsday/libdeng2/src/net/transmitter.cpp +++ b/doomsday/libdeng2/src/net/transmitter.cpp @@ -28,7 +28,7 @@ using namespace de; Transmitter::~Transmitter() {} -Transmitter& Transmitter::operator << (const IByteArray& data) +IOStream& Transmitter::operator << (const IByteArray& data) { send(data); return *this; diff --git a/doomsday/tests/archive/main.cpp b/doomsday/tests/archive/main.cpp index 2b5ee1842f..ae1c930249 100644 --- a/doomsday/tests/archive/main.cpp +++ b/doomsday/tests/archive/main.cpp @@ -61,7 +61,7 @@ int main(int argc, char** argv) File& worldTxt = zip.newFile("world.txt"); Writer(worldTxt) << FixedByteArray(content.toUtf8()); } - catch(const File::IOError&) + catch(const File::OutputError&) { LOG_WARNING("Cannot change files in read-only mode."); }