bit7z 4.0.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bitabstractarchivecreator.hpp
1/*
2 * bit7z - A C++ static library to interface with the 7-zip shared libraries.
3 * Copyright (c) 2014-2023 Riccardo Ostani - All Rights Reserved.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef BITABSTRACTARCHIVECREATOR_HPP
11#define BITABSTRACTARCHIVECREATOR_HPP
12
13#include <map>
14#include <memory>
15
16#include "bitabstractarchivehandler.hpp"
17#include "bitcompressionlevel.hpp"
18#include "bitcompressionmethod.hpp"
19#include "bitformat.hpp"
20#include "bitinputarchive.hpp"
21
22struct IOutStream;
23struct ISequentialOutStream;
24
25namespace bit7z {
26
27using std::ostream;
28
29class ArchiveProperties;
30
34enum struct UpdateMode {
35 None,
36 Append,
37 Update,
38 BIT7Z_DEPRECATED_ENUMERATOR( Overwrite, Update, "Since v4.0; please use the UpdateMode::Update enumerator." )
39};
40
45 public:
47
49
50 auto operator=( const BitAbstractArchiveCreator& ) -> BitAbstractArchiveCreator& = delete;
51
52 auto operator=( BitAbstractArchiveCreator&& ) -> BitAbstractArchiveCreator& = delete;
53
54 ~BitAbstractArchiveCreator() override = default;
55
59 BIT7Z_NODISCARD auto format() const noexcept -> const BitInFormat& override;
60
64 BIT7Z_NODISCARD auto compressionFormat() const noexcept -> const BitInOutFormat&;
65
69 BIT7Z_NODISCARD auto cryptHeaders() const noexcept -> bool;
70
74 BIT7Z_NODISCARD auto compressionLevel() const noexcept -> BitCompressionLevel;
75
79 BIT7Z_NODISCARD auto compressionMethod() const noexcept -> BitCompressionMethod;
80
84 BIT7Z_NODISCARD auto dictionarySize() const noexcept -> uint32_t;
85
89 BIT7Z_NODISCARD auto wordSize() const noexcept -> uint32_t;
90
94 BIT7Z_NODISCARD auto solidMode() const noexcept -> bool;
95
99 BIT7Z_NODISCARD auto updateMode() const noexcept -> UpdateMode;
100
105 BIT7Z_NODISCARD auto volumeSize() const noexcept -> uint64_t;
106
111 BIT7Z_NODISCARD auto threadsCount() const noexcept -> uint32_t;
112
116 BIT7Z_NODISCARD auto storeSymbolicLinks() const noexcept -> bool;
117
135 void setPassword( const tstring& password ) override;
136
161
168
175
182
188 void setWordSize( uint32_t wordSize );
189
198 void setSolidMode( bool solidMode ) noexcept;
199
208 virtual void setUpdateMode( UpdateMode mode );
209
220 BIT7Z_DEPRECATED_MSG( "Since v4.0; please use the overloaded function that takes an UpdateMode enumerator." )
221 void setUpdateMode( bool canUpdate );
222
230 void setVolumeSize( uint64_t volumeSize ) noexcept;
231
237 void setThreadsCount( uint32_t threadsCount ) noexcept;
238
244 void setStoreSymbolicLinks( bool storeSymlinks ) noexcept;
245
255 template< std::size_t N, typename T, typename = typename std::enable_if< std::is_integral< T >::value >::type >
256 void setFormatProperty( const wchar_t (&name)[N], T value ) noexcept { // NOLINT(*-avoid-c-arrays)
257 mExtraProperties[ name ] = value;
258 }
259
272 template< std::size_t N, typename T, typename = typename std::enable_if< !std::is_integral< T >::value >::type >
273 void setFormatProperty( const wchar_t (&name)[N], const T& value ) noexcept { // NOLINT(*-avoid-c-arrays)
274 mExtraProperties[ name ] = value;
275 }
276
277 protected:
279 const BitInOutFormat& format,
280 tstring password = {},
282
283 BIT7Z_NODISCARD auto archiveProperties() const -> ArchiveProperties;
284
285 friend class BitOutputArchive;
286
287 private:
288 const BitInOutFormat& mFormat;
289
290 UpdateMode mUpdateMode;
291 BitCompressionLevel mCompressionLevel;
292 BitCompressionMethod mCompressionMethod;
293 uint32_t mDictionarySize;
294 uint32_t mWordSize;
295 bool mCryptHeaders;
296 bool mSolidMode;
297 uint64_t mVolumeSize;
298 uint32_t mThreadsCount;
299 bool mStoreSymbolicLinks;
300 std::map< std::wstring, BitPropVariant > mExtraProperties;
301};
302
303} // namespace bit7z
304
305#endif // BITABSTRACTARCHIVECREATOR_HPP
The Bit7zLibrary class allows accessing the basic functionalities provided by the 7z DLLs.
Definition bit7zlibrary.hpp:56
Abstract class representing a generic archive creator.
Definition bitabstractarchivecreator.hpp:44
void setVolumeSize(uint64_t volumeSize) noexcept
Sets the volumeSize (in bytes) of the output archive volumes.
void setPassword(const tstring &password) override
Sets up a password for the output archives.
void setCompressionMethod(BitCompressionMethod method)
Sets the compression method to be used when creating/updating an archive.
void setFormatProperty(const wchar_t(&name)[N], const T &value) noexcept
Sets a property for the output archive format as described by the 7-zip documentation (e....
Definition bitabstractarchivecreator.hpp:273
auto dictionarySize() const noexcept -> uint32_t
auto compressionFormat() const noexcept -> const BitInOutFormat &
void setWordSize(uint32_t wordSize)
Sets the word size to be used when creating/updating an archive.
void setDictionarySize(uint32_t dictionarySize)
Sets the dictionary size to be used when creating/updating an archive.
auto compressionLevel() const noexcept -> BitCompressionLevel
auto volumeSize() const noexcept -> uint64_t
void setSolidMode(bool solidMode) noexcept
Sets whether to use solid compression or not.
auto cryptHeaders() const noexcept -> bool
auto solidMode() const noexcept -> bool
auto wordSize() const noexcept -> uint32_t
auto format() const noexcept -> const BitInFormat &override
void setStoreSymbolicLinks(bool storeSymlinks) noexcept
Sets whether the creator will store symbolic links as links in the output archive.
auto storeSymbolicLinks() const noexcept -> bool
virtual void setUpdateMode(UpdateMode mode)
Sets whether and how the creator can update existing archives or not.
void setThreadsCount(uint32_t threadsCount) noexcept
Sets the number of threads to be used when creating/updating an archive.
void setCompressionLevel(BitCompressionLevel level) noexcept
Sets the compression level to be used when creating/updating an archive.
auto compressionMethod() const noexcept -> BitCompressionMethod
void setFormatProperty(const wchar_t(&name)[N], T value) noexcept
Sets a property for the output archive format as described by the 7-zip documentation (e....
Definition bitabstractarchivecreator.hpp:256
auto threadsCount() const noexcept -> uint32_t
auto updateMode() const noexcept -> UpdateMode
Abstract class representing a generic archive handler.
Definition bitabstractarchivehandler.hpp:74
auto password() const -> tstring
The BitInFormat class specifies an extractable archive format.
Definition bitformat.hpp:58
The BitInOutFormat class specifies a format available for creating new archives and extract old ones.
Definition bitformat.hpp:105
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:30
BitCompressionLevel
The BitCompressionLevel enum represents the compression level used by 7z when creating archives.
Definition bitcompressionlevel.hpp:19
BitCompressionMethod
The BitCompressionMethod enum represents the compression methods used by 7z when creating archives.
Definition bitcompressionmethod.hpp:18
UpdateMode
Enumeration representing how an archive creator should deal when the output archive already exists.
Definition bitabstractarchivecreator.hpp:34
@ Update
New items whose path already exists in the archive will overwrite the old ones, other will be appende...
@ Append
The creator will append the new items to the existing archive.
@ None
The creator will throw an exception (unless the OverwriteMode is not None).