ZipExtraData.h
Go to the documentation of this file.
1 
2 // This source file is part of the ZipArchive Library Open Source distribution
3 // and is Copyrighted 2000 - 2022 by Artpol Software - Tadeusz Dracz
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 // For the licensing details refer to the License.txt file.
11 //
12 // Web Site: https://www.artpol-software.com
14 
21 #if !defined(ZIPARCHIVE_ZIPEXTRADATA_DOT_H)
22 #define ZIPARCHIVE_ZIPEXTRADATA_DOT_H
23 
24 #if _MSC_VER > 1000
25 #pragma once
26 #endif
27 
28 #include "ZipExport.h"
29 #include "ZipAutoBuffer.h"
30 #include "ZipExtraField.h"
31 #include "memory.h"
32 #ifdef __ANDROID__
33 #include "string.h"
34 #endif
35 
42 class ZIP_API CZipExtraData
43 {
44  friend class CZipExtraField;
45 public:
46 
50  CZipAutoBuffer m_data;
51 
58  bool m_bHasSize;
59 
61  {
62  m_uHeaderID = 0;
63  m_bHasSize = true;
64  }
65 
66 #pragma warning(suppress: 26495)
67  CZipExtraData(const CZipExtraData& extra)
68  {
69  *this = extra;
70  }
71 
78  CZipExtraData(WORD uHeaderID)
79  {
80  m_uHeaderID = uHeaderID;
81  m_bHasSize = true;
82  }
83 
84  CZipExtraData& operator=(const CZipExtraData& extra)
85  {
86  m_uHeaderID = extra.m_uHeaderID;
87  DWORD uSize = extra.m_data.GetSize();
88  m_data.Allocate(uSize);
89  m_bHasSize = extra.m_bHasSize;
90  if (uSize > 0)
91  memcpy(m_data, extra.m_data, uSize);
92  return *this;
93  }
94  bool operator==(const CZipExtraData& extra)
95  {
96  return m_uHeaderID == extra.m_uHeaderID && m_data.GetSize() == extra.m_data.GetSize() && memcmp(m_data, extra.m_data, m_data.GetSize()) == 0;
97  }
98  bool operator != (const CZipExtraData& extra)
99  {
100  return !(*this == extra);
101  }
102  bool operator > (const CZipExtraData& extra)
103  {
104  return m_uHeaderID > extra.m_uHeaderID;
105  }
106  bool operator < (const CZipExtraData& extra)
107  {
108  return m_uHeaderID < extra.m_uHeaderID;
109  }
110  bool operator >= (const CZipExtraData& extra)
111  {
112  return m_uHeaderID > extra.m_uHeaderID || *this == extra;
113  }
114 
115  bool operator <= (const CZipExtraData& extra)
116  {
117  return m_uHeaderID < extra.m_uHeaderID || *this == extra;
118  }
119 
126  int GetTotalSize() const
127  {
128  return (m_bHasSize ? 4 : 2) + m_data.GetSize();
129  }
130 
137  WORD GetHeaderID() const
138  {
139  return m_uHeaderID;
140  }
141 
142 protected:
143 
156  bool Read(char* buffer, WORD uSize);
157 
167  WORD Write(char* buffer)const;
168 
169 private:
170  WORD m_uHeaderID;
171 };
172 
173 #endif // !defined(ZIPARCHIVE_ZIPEXTRADATA_DOT_H)

The ZipArchive Library Copyright © 2000 - 2022 Artpol Software - Tadeusz Dracz. Generated at Sat Dec 17 2022 19:57:03.