| Disk ARchive 2.8.5 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
xz_module.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2026 Denis Corbin
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18//
19// to contact the author, see the AUTHOR file
20/*********************************************************************/
21
26
27#ifndef XZ_MODULE_HPP
28#define XZ_MODULE_HPP
29
30 extern "C"
31{
32#if HAVE_LZMA_H
33#include <lzma.h>
34#endif
35}
36
37#include "../my_config.h"
38
39#include "compress_module.hpp"
40#include "infinint.hpp"
41
42 namespace libdar
43{
44
47
48 class xz_module: public compress_module
49 {
50 public:
51 xz_module(U_I compression_level = 9);
52 xz_module(const xz_module & ref) { setup(ref.level); };
53 xz_module(xz_module && ref) noexcept = default;
54 xz_module & operator = (const xz_module & ref) { end_process(); setup(ref.level); return *this; };
55 xz_module & operator = (xz_module && ref) noexcept = default;
56 virtual ~xz_module() { end_process(); };
57
58 // inherited from compress_module interface
59
60 virtual compression get_algo() const override { return compression::xz; };
61
62 virtual U_I get_max_compressing_size() const override;
63
64 virtual U_I get_min_size_to_compress(U_I clear_size) const override;
65
66 virtual U_I compress_data(const char *normal,
67 const U_I normal_size,
68 char *zip_buf,
69 U_I zip_buf_size) const override;
70
71 virtual U_I uncompress_data(const char *zip_buf,
72 const U_I zip_buf_size,
73 char *normal,
74 U_I normal_size) const override;
75
76
77 virtual std::unique_ptr<compress_module> clone() const override;
78
79 private:
80 U_I level;
81#if LIBLZMA_AVAILABLE
82 mutable lzma_stream lzma_str;
83#endif
84
85 void setup(U_I compression_level);
86 void init_decompr() const;
87 void init_compr() const;
88 void end_process() const;
89 };
90
92
93} // end of namespace
94
95#endif
compress_module.hpp
provides abstracted interface of per-block compression/decompression
libdar::compression
compression
the different compression algorithm available
Definition compression.hpp:46
libdar::compression::xz
@ xz
lzma compression (streamed)
Definition compression.hpp:51
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47