xref: /aosp_15_r20/external/lzma/CPP/7zip/Archive/7z/7zCompressionMode.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // 7zCompressionMode.h
2 
3 #ifndef ZIP7_INC_7Z_COMPRESSION_MODE_H
4 #define ZIP7_INC_7Z_COMPRESSION_MODE_H
5 
6 #include "../../Common/MethodId.h"
7 #include "../../Common/MethodProps.h"
8 
9 namespace NArchive {
10 namespace N7z {
11 
12 struct CMethodFull: public CMethodProps
13 {
14   CMethodId Id;
15   UInt32 NumStreams;
16   int CodecIndex;
17   UInt32 NumThreads;
18   bool Set_NumThreads;
19 
CMethodFullCMethodFull20   CMethodFull(): CodecIndex(-1), NumThreads(1), Set_NumThreads(false) {}
IsSimpleCoderCMethodFull21   bool IsSimpleCoder() const { return NumStreams == 1; }
22 };
23 
24 struct CBond2
25 {
26   UInt32 OutCoder;
27   UInt32 OutStream;
28   UInt32 InCoder;
29 };
30 
31 struct CCompressionMethodMode
32 {
33   /*
34     if (Bonds.Empty()), then default bonds must be created
35     if (Filter_was_Inserted)
36     {
37       Methods[0] is filter method
38       Bonds don't contain bonds for filter (these bonds must be created)
39     }
40   */
41 
42   CObjectVector<CMethodFull> Methods;
43   CRecordVector<CBond2> Bonds;
44 
IsThereBond_to_CoderCCompressionMethodMode45   bool IsThereBond_to_Coder(unsigned coderIndex) const
46   {
47     FOR_VECTOR(i, Bonds)
48       if (Bonds[i].InCoder == coderIndex)
49         return true;
50     return false;
51   }
52 
53   bool DefaultMethod_was_Inserted;
54   bool Filter_was_Inserted;
55   bool PasswordIsDefined;
56   bool MemoryUsageLimit_WasSet;
57 
58   #ifndef Z7_ST
59   bool NumThreads_WasForced;
60   bool MultiThreadMixer;
61   UInt32 NumThreads;
62   #endif
63 
64   UString Password; // _Wipe
65   UInt64 MemoryUsageLimit;
66 
IsEmptyCCompressionMethodMode67   bool IsEmpty() const { return (Methods.IsEmpty() && !PasswordIsDefined); }
CCompressionMethodModeCCompressionMethodMode68   CCompressionMethodMode():
69         DefaultMethod_was_Inserted(false)
70       , Filter_was_Inserted(false)
71       , PasswordIsDefined(false)
72       , MemoryUsageLimit_WasSet(false)
73       #ifndef Z7_ST
74       , NumThreads_WasForced(false)
75       , MultiThreadMixer(true)
76       , NumThreads(1)
77       #endif
78       , MemoryUsageLimit((UInt64)1 << 30)
79   {}
80 
81 #ifdef Z7_CPP_IS_SUPPORTED_default
82   CCompressionMethodMode(const CCompressionMethodMode &) = default;
83   CCompressionMethodMode& operator =(const CCompressionMethodMode &) = default;
84 #endif
~CCompressionMethodModeCCompressionMethodMode85   ~CCompressionMethodMode() { Password.Wipe_and_Empty(); }
86 };
87 
88 }}
89 
90 #endif
91