diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2024-03-06 10:24:46 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2024-03-06 10:24:46 +0100 |
commit | 372a0e99c2f61543d9e14d9933b59d9d1f4cb26e (patch) | |
tree | bbadf39aed0610c8f8f7b41fefff47773b8ac205 /xsd/examples/cxx/tree/compression/compressed-format-target.hxx | |
parent | 23d41842168ac1a1580111b9c5c73500ceee3d57 (diff) | |
parent | 4538829ab86b5a1cd4e845e7eab165029c9d6d46 (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'xsd/examples/cxx/tree/compression/compressed-format-target.hxx')
-rw-r--r-- | xsd/examples/cxx/tree/compression/compressed-format-target.hxx | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/xsd/examples/cxx/tree/compression/compressed-format-target.hxx b/xsd/examples/cxx/tree/compression/compressed-format-target.hxx deleted file mode 100644 index 835b676..0000000 --- a/xsd/examples/cxx/tree/compression/compressed-format-target.hxx +++ /dev/null @@ -1,91 +0,0 @@ -// file : examples/cxx/tree/compression/compressed-format-target.hxx -// copyright : not copyrighted - public domain - -#ifndef COMPRESSED_FORMAT_TARGET_HXX -#define COMPRESSED_FORMAT_TARGET_HXX - -#include <zlib.h> - -#include <iosfwd> -#include <cstddef> // std::size_t -#include <exception> - -#include <xercesc/framework/XMLFormatter.hpp> - -struct compression_failure: std::exception -{ - explicit - compression_failure (int code) - : code_ (code) - { - } - - int - code () const - { - return code_; - } - - const char* - message () const - { - return zError (code_); - } - - virtual const char* - what () const throw (); - -private: - int code_; -}; - -// Xerces-C++ XMLFormatTarget interface implementation with on-the-fly, -// zlib-based compression. -// -class compressed_format_target: public xercesc::XMLFormatTarget -{ -public: - enum compression_type - { - raw, - zlib, - gzip - }; - - compressed_format_target (std::ostream&, compression_type); - - virtual - ~compressed_format_target (); - - virtual void - writeChars (const XMLByte* const buf, - const XMLSize_t size, - xercesc::XMLFormatter* const); - - virtual void - flush (); - - // Close the compressed stream by writing out the zlib or gzip trailer. - // This function is automatically called from the destructor but you - // may want to call it explicitly to be able to catch any exceptions - // that it might throw. - // - void - close (); - -private: - void - write (const char* buf, std::size_t size, bool flush = false); - -private: - std::ostream& os_; - z_stream zs_; - bool closed_; - - static const std::size_t buf_size_ = 65536; - char in_[buf_size_]; - char out_[buf_size_]; - size_t n_; -}; - -#endif // COMPRESSED_FORMAT_TARGET_HXX |