wrapperlib.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031
00032 #ifndef WRAPPERLIB_HPP
00033 #define WRAPPERLIB_HPP
00034
00035 #include "../my_config.h"
00036
00037 extern "C"
00038 {
00039 #if HAVE_ZLIB_H && LIBZ_AVAILABLE
00040 #include <zlib.h>
00041 #endif
00042
00043 #if HAVE_BZLIB_H && LIBBZ2_AVAILABLE
00044 #include <bzlib.h>
00045 #endif
00046 }
00047
00048 #include "integers.hpp"
00049
00050 namespace libdar
00051 {
00052
00053 const int WR_OK = 0;
00054 const int WR_MEM_ERROR = 1;
00055 const int WR_VERSION_ERROR = 2;
00056 const int WR_STREAM_ERROR = 3;
00057 const int WR_DATA_ERROR = 4;
00058 const int WR_NO_FLUSH = 5;
00059 const int WR_BUF_ERROR = 6;
00060 const int WR_STREAM_END = 7;
00061 const int WR_FINISH = 8;
00062
00063 enum wrapperlib_mode { zlib_mode, bzlib_mode };
00064
00066
00070
00071 class wrapperlib
00072 {
00073 public:
00074 wrapperlib(wrapperlib_mode mode);
00075 wrapperlib(const wrapperlib & ref);
00076 wrapperlib & operator = (const wrapperlib & ref);
00077 ~wrapperlib();
00078
00079 void set_next_in(const char *x) { return (this->*x_set_next_in)(x); };
00080 void set_avail_in(U_I x) { return (this->*x_set_avail_in)(x); };
00081 U_I get_avail_in() const { return (this->*x_get_avail_in)(); };
00082 U_64 get_total_in() const { return (this->*x_get_total_in)(); };
00083
00084 void set_next_out(char *x) { return (this->*x_set_next_out)(x); };
00085 char *get_next_out() const { return (this->*x_get_next_out)(); };
00086 void set_avail_out(U_I x) { return (this->*x_set_avail_out)(x); };
00087 U_I get_avail_out() const { return (this->*x_get_avail_out)(); };
00088 U_64 get_total_out() const { return (this->*x_get_total_out)(); };
00089
00090 S_I compressInit(U_I compression_level) { level = compression_level; return (this->*x_compressInit)(compression_level); };
00091 S_I decompressInit() { return (this->*x_decompressInit)(); };
00092 S_I compressEnd() { return (this->*x_compressEnd)(); };
00093 S_I decompressEnd() { return (this->*x_decompressEnd)(); };
00094 S_I compress(S_I flag) { return (this->*x_compress)(flag); };
00095 S_I decompress(S_I flag) { return (this->*x_decompress)(flag);};
00096 S_I compressReset();
00097 S_I decompressReset();
00098
00099 private:
00100 #if LIBZ_AVAILABLE
00101 z_stream *z_ptr;
00102 #endif
00103 #if LIBBZ2_AVAILABLE
00104 bz_stream *bz_ptr;
00105 #endif
00106 S_I level;
00107
00108 void (wrapperlib::*x_set_next_in)(const char *x);
00109 void (wrapperlib::*x_set_avail_in)(U_I x);
00110 U_I (wrapperlib::*x_get_avail_in)() const;
00111 U_64 (wrapperlib::*x_get_total_in)() const;
00112
00113 void (wrapperlib::*x_set_next_out)(char *x);
00114 char *(wrapperlib::*x_get_next_out)() const;
00115 void (wrapperlib::*x_set_avail_out)(U_I x);
00116 U_I (wrapperlib::*x_get_avail_out)() const;
00117 U_64 (wrapperlib::*x_get_total_out)() const;
00118
00119 S_I (wrapperlib::*x_compressInit)(U_I compression_level);
00120 S_I (wrapperlib::*x_decompressInit)();
00121 S_I (wrapperlib::*x_compressEnd)();
00122 S_I (wrapperlib::*x_decompressEnd)();
00123 S_I (wrapperlib::*x_compress)(S_I flag);
00124 S_I (wrapperlib::*x_decompress)(S_I flag);
00125
00126
00127
00128 #if LIBZ_AVAILABLE
00129 S_I z_compressInit(U_I compression_level);
00130 S_I z_decompressInit();
00131 S_I z_compressEnd();
00132 S_I z_decompressEnd();
00133 S_I z_compress(S_I flag);
00134 S_I z_decompress(S_I flag);
00135 void z_set_next_in(const char *x);
00136 void z_set_avail_in(U_I x);
00137 U_I z_get_avail_in() const;
00138 U_64 z_get_total_in() const;
00139 void z_set_next_out(char *x);
00140 char *z_get_next_out() const;
00141 void z_set_avail_out(U_I x);
00142 U_I z_get_avail_out() const;
00143 U_64 z_get_total_out() const;
00144 #endif
00145
00146
00147 #if LIBBZ2_AVAILABLE
00148 S_I bz_compressInit(U_I compression_level);
00149 S_I bz_decompressInit();
00150 S_I bz_compressEnd();
00151 S_I bz_decompressEnd();
00152 S_I bz_compress(S_I flag);
00153 S_I bz_decompress(S_I flag);
00154 void bz_set_next_in(const char *x);
00155 void bz_set_avail_in(U_I x);
00156 U_I bz_get_avail_in() const;
00157 U_64 bz_get_total_in() const;
00158 void bz_set_next_out(char *x);
00159 char *bz_get_next_out() const;
00160 void bz_set_avail_out(U_I x);
00161 U_I bz_get_avail_out() const;
00162 U_64 bz_get_total_out() const;
00163 #endif
00164 };
00165
00166 }
00167
00168 #endif