Move ZlibDecompressor to libshared

* This will be used to implement compressed http streams
* Remove the custom BDataOutput class, and use BDataIO instead, for
easier integration with existing code.
This commit is contained in:
Adrien Destugues
2014-02-11 12:06:38 +01:00
parent 9f11100be5
commit 9af2105d36
37 changed files with 131 additions and 148 deletions
@@ -1 +0,0 @@
#include <../private/package/hpkg/ZlibCompressionBase.h>
@@ -1 +0,0 @@
#include <../private/package/hpkg/ZlibDecompressor.h>
@@ -0,0 +1 @@
#include <../private/shared/ZlibCompressionBase.h>
@@ -0,0 +1 @@
#include <../private/shared/ZlibDecompressor.h>
@@ -6,6 +6,7 @@
#define _PACKAGE__HPKG__DATA_OUTPUT_H_
#include <DataIO.h>
#include <SupportDefs.h>
@@ -14,21 +15,15 @@ namespace BPackageKit {
namespace BHPKG {
class BDataOutput {
public:
virtual ~BDataOutput();
virtual status_t WriteData(const void* buffer, size_t size) = 0;
};
class BBufferDataOutput : public BDataOutput {
class BBufferDataOutput : public BDataIO {
public:
BBufferDataOutput(void* buffer, size_t size);
size_t BytesWritten() const { return fBytesWritten; }
virtual status_t WriteData(const void* buffer, size_t size);
virtual status_t Write(const void* buffer, size_t size);
virtual ssize_t Read(void* buffer, size_t size)
{ return B_NOT_SUPPORTED; }
private:
void* fBuffer;
+5 -5
View File
@@ -9,14 +9,14 @@
#include <SupportDefs.h>
class BDataIO;
namespace BPackageKit {
namespace BHPKG {
class BDataOutput;
class BDataReader {
public:
virtual ~BDataReader();
@@ -33,7 +33,7 @@ public:
virtual status_t ReadData(off_t offset, void* buffer,
size_t size);
virtual status_t ReadDataToOutput(off_t offset, size_t size,
BDataOutput* output) = 0;
BDataIO* output) = 0;
};
@@ -73,7 +73,7 @@ public:
virtual status_t ReadData(off_t offset, void* buffer,
size_t size);
virtual status_t ReadDataToOutput(off_t offset, size_t size,
BDataOutput* output);
BDataIO* output);
private:
const void* fData;
+3 -3
View File
@@ -7,7 +7,7 @@
#define _PACKAGE__HPKG__PRIVATE__DATA_WRITERS_H_
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/BufferDataOutput.h>
#include <package/hpkg/ZlibCompressor.h>
@@ -59,7 +59,7 @@ private:
};
class ZlibDataWriter : public AbstractDataWriter, private BDataOutput {
class ZlibDataWriter : public AbstractDataWriter, private BDataIO {
public:
ZlibDataWriter(AbstractDataWriter* dataWriter);
@@ -71,7 +71,7 @@ public:
private:
// BDataOutput
virtual status_t WriteData(const void* buffer, size_t size);
virtual status_t Write(const void* buffer, size_t size);
private:
AbstractDataWriter* fDataWriter;
@@ -49,7 +49,7 @@ public:
// BAbstractBufferedDataReader
virtual status_t ReadDataToOutput(off_t offset, size_t size,
BDataOutput* output);
BDataIO* output);
public:
static const size_t kChunkSize = 64 * 1024;
@@ -10,7 +10,7 @@
#include <package/hpkg/HPKGDefsPrivate.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/BufferDataOutput.h>
#include <package/hpkg/DataWriters.h>
#include <package/hpkg/PackageWriter.h>
#include <package/hpkg/Strings.h>
@@ -8,7 +8,10 @@
#include <zlib.h>
#include <package/hpkg/ZlibCompressionBase.h>
#include <ZlibCompressionBase.h>
class BDataIO;
namespace BPackageKit {
@@ -16,15 +19,12 @@ namespace BPackageKit {
namespace BHPKG {
class BDataOutput;
namespace BPrivate {
class ZlibCompressor : public ZlibCompressionBase {
class ZlibCompressor : public ::BPrivate::ZlibCompressionBase {
public:
ZlibCompressor(BDataOutput* output);
ZlibCompressor(BDataIO* output);
~ZlibCompressor();
status_t Init(int compressionLevel = Z_BEST_COMPRESSION);
@@ -39,7 +39,7 @@ public:
private:
z_stream fStream;
BDataOutput* fOutput;
BDataIO* fOutput;
bool fStreamInitialized;
};
@@ -2,17 +2,13 @@
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSION_BASE_H_
#define _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSION_BASE_H_
#ifndef _PRIVATE__ZLIB_COMPRESSION_BASE_H_
#define _PRIVATE__ZLIB_COMPRESSION_BASE_H_
#include <SupportDefs.h>
namespace BPackageKit {
namespace BHPKG {
namespace BPrivate {
@@ -24,9 +20,4 @@ public:
} // namespace BPrivate
} // namespace BHPKG
} // namespace BPackageKit
#endif // _PACKAGE__HPKG__PRIVATE__ZLIB_COMPRESSION_BASE_H_
#endif // _PRIVATE__ZLIB_COMPRESSION_BASE_H_
@@ -2,21 +2,16 @@
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _PACKAGE__HPKG__PRIVATE__ZLIB_DECOMPRESSOR_H_
#define _PACKAGE__HPKG__PRIVATE__ZLIB_DECOMPRESSOR_H_
#ifndef _PRIVATE__ZLIB_DECOMPRESSOR_H_
#define _PRIVATE__ZLIB_DECOMPRESSOR_H_
#include <zlib.h>
#include <package/hpkg/ZlibCompressionBase.h>
#include <ZlibCompressionBase.h>
namespace BPackageKit {
namespace BHPKG {
class BDataOutput;
class BDataIO;
namespace BPrivate {
@@ -24,7 +19,7 @@ namespace BPrivate {
class ZlibDecompressor : public ZlibCompressionBase {
public:
ZlibDecompressor(BDataOutput* output);
ZlibDecompressor(BDataIO* output);
~ZlibDecompressor();
status_t Init();
@@ -39,7 +34,7 @@ public:
private:
z_stream fStream;
BDataOutput* fOutput;
BDataIO* fOutput;
bool fStreamInitialized;
bool fFinished;
};
@@ -47,9 +42,4 @@ private:
} // namespace BPrivate
} // namespace BHPKG
} // namespace BPackageKit
#endif // _PACKAGE__HPKG__PRIVATE__ZLIB_DECOMPRESSOR_H_