bit7z 4.1.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bitformat.hpp
1/*
2 * bit7z - A C++ static library to interface with the 7-zip shared libraries.
3 * Copyright (c) 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 BITFORMAT_HPP
11#define BITFORMAT_HPP
12
13#include "bitcompressionmethod.hpp"
14#include "bitdefines.hpp"
15#include "bittypes.hpp"
16
17#include <cstdint>
18
19namespace bit7z {
20
25 MultipleFiles = 1u << 0u,
26 SolidArchive = 1u << 1u,
27 CompressionLevel = 1u << 2u,
28 Encryption = 1u << 3u,
29 HeaderEncryption = 1u << 4u,
30 MultipleMethods = 1u << 5u
31};
32
41constexpr auto operator|( FormatFeatures lhs, FormatFeatures rhs ) noexcept -> FormatFeatures {
42 return static_cast< FormatFeatures >( to_underlying( lhs ) | to_underlying( rhs ) );
43}
44
49
58constexpr auto operator&( FormatFeatures lhs, FormatFeatures rhs ) noexcept -> FormatFeaturesType {
59 return to_underlying( lhs ) & to_underlying( rhs );
60}
61
68class BitInFormat {
69 public:
70 //non-copyable
71 BitInFormat( const BitInFormat& other ) = delete;
72
73 auto operator=( const BitInFormat& other ) -> BitInFormat& = delete;
74
75 //non-movable
76 BitInFormat( BitInFormat&& other ) = delete;
77
78 auto operator=( BitInFormat&& other ) -> BitInFormat& = delete;
79
80 ~BitInFormat() = default;
81
86 constexpr explicit BitInFormat( unsigned char value ) noexcept : mValue( value ) {}
87
91 BIT7Z_NODISCARD auto value() const noexcept -> unsigned char;
92
97 auto operator==( BitInFormat const& other ) const noexcept -> bool;
98
103 auto operator!=( BitInFormat const& other ) const noexcept -> bool;
104
105 private:
106 unsigned char mValue;
107};
108
115class BitInOutFormat final : public BitInFormat {
116 public:
125 constexpr BitInOutFormat(
126 unsigned char value,
127 const tchar* ext,
130 ) noexcept : BitInFormat( value ), mExtension( ext ), mDefaultMethod( defaultMethod ), mFeatures( features ) {}
131
132 //non-copyable
133 BitInOutFormat( const BitInOutFormat& other ) = delete;
134
135 auto operator=( const BitInOutFormat& other ) -> BitInOutFormat& = delete;
136
137 //non-movable
138 BitInOutFormat( BitInOutFormat&& other ) = delete;
139
140 auto operator=( BitInOutFormat&& other ) -> BitInOutFormat& = delete;
141
142 ~BitInOutFormat() = default;
143
147 BIT7Z_NODISCARD
148 auto extension() const noexcept -> const tchar*;
149
153 BIT7Z_NODISCARD
154 auto features() const noexcept -> FormatFeatures;
155
163 BIT7Z_NODISCARD
164 auto hasFeature( FormatFeatures feature ) const noexcept -> bool;
165
169 BIT7Z_NODISCARD
170 auto defaultMethod() const noexcept -> BitCompressionMethod;
171
172 private:
173 const tchar* mExtension;
174 BitCompressionMethod mDefaultMethod;
175 FormatFeatures mFeatures;
176};
177
181namespace BitFormat {
182#ifdef BIT7Z_AUTO_FORMAT
186extern const BitInFormat Auto;
187#endif
188extern const BitInFormat Rar;
189extern const BitInFormat Arj;
190//NOLINTNEXTLINE(*-identifier-length)
191extern const BitInFormat Z;
192extern const BitInFormat Lzh;
193extern const BitInFormat Cab;
194extern const BitInFormat Nsis;
195extern const BitInFormat Lzma;
196extern const BitInFormat Lzma86;
197extern const BitInFormat Ppmd;
198extern const BitInFormat Zstd;
199extern const BitInFormat LVM;
200extern const BitInFormat AVB;
201extern const BitInFormat LP;
202extern const BitInFormat Sparse;
203extern const BitInFormat APFS;
204extern const BitInFormat Vhdx;
205extern const BitInFormat COFF;
206extern const BitInFormat Ext;
207extern const BitInFormat VMDK;
208extern const BitInFormat VDI;
209extern const BitInFormat QCow;
210extern const BitInFormat GPT;
211extern const BitInFormat Rar5;
212extern const BitInFormat IHex;
213extern const BitInFormat Hxs;
214//NOLINTNEXTLINE(*-identifier-length)
215extern const BitInFormat TE;
216extern const BitInFormat UEFIc;
217extern const BitInFormat UEFIs;
218extern const BitInFormat SquashFS;
219extern const BitInFormat CramFS;
220extern const BitInFormat APM;
221extern const BitInFormat Mslz;
222extern const BitInFormat Flv;
223extern const BitInFormat Swf;
224extern const BitInFormat Swfc;
225extern const BitInFormat Ntfs;
226extern const BitInFormat Fat;
227extern const BitInFormat Mbr;
228extern const BitInFormat Vhd;
229//NOLINTNEXTLINE(*-identifier-length)
230extern const BitInFormat Pe;
231extern const BitInFormat Elf;
232extern const BitInFormat Macho;
233extern const BitInFormat Udf;
234extern const BitInFormat Xar;
235extern const BitInFormat Mub;
236extern const BitInFormat Hfs;
237extern const BitInFormat Dmg;
238extern const BitInFormat Compound;
239extern const BitInFormat Iso;
240extern const BitInFormat Chm;
241extern const BitInFormat Split;
242extern const BitInFormat Rpm;
243extern const BitInFormat Deb;
244extern const BitInFormat Cpio;
245
246extern const BitInOutFormat Zip;
247extern const BitInOutFormat BZip2;
248extern const BitInOutFormat SevenZip;
249//NOLINTNEXTLINE(*-identifier-length)
250extern const BitInOutFormat Xz;
251extern const BitInOutFormat Wim;
252extern const BitInOutFormat Tar;
253extern const BitInOutFormat GZip;
254} // namespace BitFormat
255
256#ifdef BIT7Z_AUTO_FORMAT
257#define BIT7Z_DEFAULT_FORMAT = BitFormat::Auto
258#else
259#define BIT7Z_DEFAULT_FORMAT
260#endif
261
262} // namespace bit7z
263
264#endif // BITFORMAT_HPP
The BitInFormat class specifies an extractable archive format.
Definition bitformat.hpp:68
auto value() const noexcept -> unsigned char
constexpr BitInFormat(unsigned char value) noexcept
Constructs a BitInFormat object with the ID value used by the 7z SDK.
Definition bitformat.hpp:86
The BitInOutFormat class specifies a format available for creating new archives and extract old ones.
Definition bitformat.hpp:115
auto defaultMethod() const noexcept -> BitCompressionMethod
auto features() const noexcept -> FormatFeatures
constexpr BitInOutFormat(unsigned char value, const tchar *ext, BitCompressionMethod defaultMethod, FormatFeatures features) noexcept
Constructs a BitInOutFormat object with an ID value, an extension and a set of supported features.
Definition bitformat.hpp:125
auto hasFeature(FormatFeatures feature) const noexcept -> bool
Checks if the format has a specific feature (see FormatFeatures enum).
auto extension() const noexcept -> const tchar *
The namespace that contains a set of archive formats usable with bit7z classes.
Definition bitformat.hpp:181
const BitInFormat Udf
UDF Archive Format.
const BitInFormat Xar
XAR Archive Format.
const BitInFormat Lzh
LZH Archive Format.
const BitInFormat UEFIc
UEFIc Archive Format.
const BitInOutFormat Wim
WIM Archive Format.
const BitInFormat Ext
EXT Archive Format.
const BitInFormat Vhd
VHD Archive Format.
const BitInFormat Z
Z Archive Format.
const BitInFormat Auto
Automatic Format Detection (available only when compiling bit7z using the BIT7Z_AUTO_FORMAT option).
const BitInFormat Mslz
MSLZ Archive Format.
const BitInFormat IHex
IHEX Archive Format.
const BitInFormat Compound
COMPOUND Archive Format.
const BitInFormat COFF
COFF Archive Format.
const BitInFormat Iso
ISO Archive Format.
const BitInFormat VMDK
VMDK Archive Format.
const BitInFormat Chm
CHM Archive Format.
const BitInFormat SquashFS
SquashFS Archive Format.
const BitInFormat Arj
ARJ Archive Format.
const BitInFormat UEFIs
UEFIs Archive Format.
const BitInFormat Rpm
RPM Archive Format.
const BitInFormat Cab
CAB Archive Format.
const BitInFormat AVB
AVB Archive Format.
const BitInOutFormat GZip
GZIP Archive Format.
const BitInFormat Rar
RAR Archive Format.
const BitInFormat Fat
FAT Archive Format.
const BitInFormat APM
APM Archive Format.
const BitInFormat Ntfs
NTFS Archive Format.
const BitInFormat Hxs
HXS Archive Format.
const BitInFormat Rar5
RAR5 Archive Format.
const BitInFormat Zstd
ZSTD Archive Format.
const BitInFormat Elf
ELF Archive Format.
const BitInFormat TE
TE Archive Format.
const BitInOutFormat BZip2
BZIP2 Archive Format.
const BitInFormat Split
SPLIT Archive Format.
const BitInFormat QCow
QCOW Archive Format.
const BitInFormat Vhdx
VHDX Archive Format.
const BitInOutFormat Tar
TAR Archive Format.
const BitInFormat Mub
MUB Archive Format.
const BitInFormat CramFS
CramFS Archive Format.
const BitInFormat Swfc
SWFC Archive Format.
const BitInOutFormat SevenZip
7Z Archive Format
const BitInFormat Sparse
Sparse Archive Format.
const BitInFormat Swf
SWF Archive Format.
const BitInFormat Hfs
HFS Archive Format.
const BitInFormat Macho
MACHO Archive Format.
const BitInFormat Lzma86
LZMA86 Archive Format.
const BitInFormat GPT
GPT Archive Format.
const BitInFormat LP
LP Archive Format.
const BitInFormat Dmg
DMG Archive Format.
const BitInFormat LVM
LVM Archive Format.
const BitInFormat Ppmd
PPMD Archive Format.
const BitInFormat Deb
DEB Archive Format.
const BitInFormat Mbr
MBR Archive Format.
const BitInOutFormat Xz
XZ Archive Format.
const BitInFormat Cpio
CPIO Archive Format.
const BitInFormat Pe
PE Archive Format.
const BitInFormat VDI
VDI Archive Format.
const BitInFormat Flv
FLV Archive Format.
const BitInFormat Nsis
NSIS Archive Format.
const BitInOutFormat Zip
ZIP Archive Format.
const BitInFormat Lzma
LZMA Archive Format.
const BitInFormat APFS
APFS Archive Format.
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:29
FormatFeatures
The FormatFeatures enum specifies the features supported by an archive file format.
Definition bitformat.hpp:24
@ HeaderEncryption
The format can encrypt the file names.
Definition bitformat.hpp:29
@ MultipleFiles
The format can compress/extract multiple files.
Definition bitformat.hpp:25
@ MultipleMethods
The format can use different compression methods.
Definition bitformat.hpp:30
@ Encryption
The format supports archive encryption.
Definition bitformat.hpp:28
@ SolidArchive
The format supports solid archives.
Definition bitformat.hpp:26
@ CompressionLevel
The format is able to use different compression levels.
Definition bitformat.hpp:27
constexpr auto to_underlying(Enum enum_value) noexcept -> underlying_type_t< Enum >
Converts an enumerator to its underlying integer value.
Definition bittypes.hpp:231
char tchar
Definition bittypes.hpp:96
constexpr auto operator|(FormatFeatures lhs, FormatFeatures rhs) noexcept -> FormatFeatures
Computes the bitwise OR of two FormatFeatures values.
Definition bitformat.hpp:41
constexpr auto operator&(FormatFeatures lhs, FormatFeatures rhs) noexcept -> FormatFeaturesType
Computes the bitwise AND of two FormatFeatures values.
Definition bitformat.hpp:58
typename std::underlying_type< Enum >::type underlying_type_t
Alias for the underlying integer type of the given enumeration type.
Definition bittypes.hpp:221
underlying_type_t< FormatFeatures > FormatFeaturesType
The underlying integer type of the FormatFeatures enumeration.
Definition bitformat.hpp:48
BitCompressionMethod
The BitCompressionMethod enum represents the compression methods used by 7z when creating archives.
Definition bitcompressionmethod.hpp:20