Hide zlib and expat libs from the user of Poco libraries (replaces #4579) (#4724)

* foundation: Remove unused ucp.h

Nothing use this and it is not even included in Visual Studio project
files. Remove it so it will not confuse any more.

* foundation: Hide zlib from user

Hide zlib completly from user. This way we do not need to publish zlib.h
or zconfig.h.

As we now have two different pointer initalizing in constructor I choose
to use unique pointers so it is more obvious those are safe. I also
choose to use make_unique which default initalize z_stream_t. This makes
code more readable as we do not need to specifie every field of
z_stream_t. It really should not matter much if we initialize couple
field for nothing. If does we should add comment about that. Still
keeping _buffer without inializing as it is quite big.

* xml: Hide expat and ParserEngine from user

Hide expat completly from user. This way we do not need to publish
expat.h or expat_external.h.

I move also headers to orignal locations so diff is smaller compared to
original.

* chore(Foundation): Compression level constants

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
Matej Kenda
2024-10-04 09:50:39 +02:00
committed by GitHub
parent af3b3b1902
commit aab4058bae
24 changed files with 248 additions and 512 deletions

View File

@@ -22,11 +22,8 @@
#include "Poco/BufferedStreamBuf.h"
#include <istream>
#include <ostream>
#if defined(POCO_UNBUNDLED)
#include <zlib.h>
#else
#include "Poco/zlib.h"
#endif
struct z_stream_s;
namespace Poco {
@@ -47,6 +44,17 @@ public:
STREAM_GZIP /// Create a gzip header, use CRC-32 checksum.
};
enum CompressionLevel
/// Constants for compression levels.
/// Note to maintainers: These must be kept in sync with the constants
/// defined by zlib.
{
DEFAULT_COMPRESSION = -1,
NO_COMPRESSION = 0,
BEST_SPEED = 1,
BEST_COMPRESSION = 9
};
DeflatingStreamBuf(std::istream& istr, StreamType type, int level);
/// Creates a DeflatingStreamBuf for compressing data read
/// from the given input stream.
@@ -89,11 +97,11 @@ private:
DEFLATE_BUFFER_SIZE = 32768
};
std::istream* _pIstr;
std::ostream* _pOstr;
char* _buffer;
z_stream _zstr;
bool _eof;
std::istream* _pIstr;
std::ostream* _pOstr;
char* _buffer;
z_stream_s* _pZstr;
bool _eof;
};
@@ -104,7 +112,7 @@ class Foundation_API DeflatingIOS: public virtual std::ios
/// order of the stream buffer and base classes.
{
public:
DeflatingIOS(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
DeflatingIOS(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION);
/// Creates a DeflatingIOS for compressing data passed
/// through and forwarding it to the given output stream.
@@ -115,7 +123,7 @@ public:
/// Please refer to the zlib documentation of deflateInit2() for a description
/// of the windowBits parameter.
DeflatingIOS(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
DeflatingIOS(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION);
/// Creates a DeflatingIOS for compressing data read
/// from the given input stream.
@@ -150,7 +158,7 @@ class Foundation_API DeflatingOutputStream: public std::ostream, public Deflatin
/// ostr.close();
{
public:
DeflatingOutputStream(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
DeflatingOutputStream(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION);
/// Creates a DeflatingOutputStream for compressing data passed
/// through and forwarding it to the given output stream.
@@ -179,7 +187,7 @@ class Foundation_API DeflatingInputStream: public std::istream, public Deflating
/// using zlib's deflate algorithm.
{
public:
DeflatingInputStream(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
DeflatingInputStream(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = DeflatingStreamBuf::DEFAULT_COMPRESSION);
/// Creates a DeflatingIOS for compressing data read
/// from the given input stream.

View File

@@ -22,11 +22,8 @@
#include "Poco/BufferedStreamBuf.h"
#include <istream>
#include <ostream>
#if defined(POCO_UNBUNDLED)
#include <zlib.h>
#else
#include "Poco/zlib.h"
#endif
struct z_stream_s;
namespace Poco {
@@ -92,12 +89,12 @@ private:
INFLATE_BUFFER_SIZE = 32768
};
std::istream* _pIstr;
std::ostream* _pOstr;
char* _buffer;
z_stream _zstr;
bool _eof;
bool _check;
std::istream* _pIstr;
std::ostream* _pOstr;
char* _buffer;
z_stream_s* _pZstr;
bool _eof;
bool _check;
};