ZipExtraData.h
Go to the documentation of this file.
1 
2 // This source file is part of the ZipArchive library source distribution and
3 // is Copyrighted 2000 - 2013 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: http://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  CZipExtraData(const CZipExtraData& extra)
67  {
68  *this = extra;
69  }
70 
77  CZipExtraData(WORD uHeaderID)
78  {
79  m_uHeaderID = uHeaderID;
80  m_bHasSize = true;
81  }
82 
83  CZipExtraData& operator=(const CZipExtraData& extra)
84  {
85  m_uHeaderID = extra.m_uHeaderID;
86  DWORD uSize = extra.m_data.GetSize();
87  m_data.Allocate(uSize);
88  m_bHasSize = extra.m_bHasSize;
89  if (uSize > 0)
90  memcpy(m_data, extra.m_data, uSize);
91  return *this;
92  }
93  bool operator==(const CZipExtraData& extra)
94  {
95  return m_uHeaderID == extra.m_uHeaderID && m_data.GetSize() == extra.m_data.GetSize() && memcmp(m_data, extra.m_data, m_data.GetSize()) == 0;
96  }
97  bool operator != (const CZipExtraData& extra)
98  {
99  return !(*this == extra);
100  }
101  bool operator > (const CZipExtraData& extra)
102  {
103  return m_uHeaderID > extra.m_uHeaderID;
104  }
105  bool operator < (const CZipExtraData& extra)
106  {
107  return m_uHeaderID < extra.m_uHeaderID;
108  }
109  bool operator >= (const CZipExtraData& extra)
110  {
111  return m_uHeaderID > extra.m_uHeaderID || *this == extra;
112  }
113 
114  bool operator <= (const CZipExtraData& extra)
115  {
116  return m_uHeaderID < extra.m_uHeaderID || *this == extra;
117  }
118 
125  int GetTotalSize() const
126  {
127  return (m_bHasSize ? 4 : 2) + m_data.GetSize();
128  }
129 
136  WORD GetHeaderID() const
137  {
138  return m_uHeaderID;
139  }
140 
141 protected:
142 
155  bool Read(char* buffer, WORD uSize);
156 
166  WORD Write(char* buffer)const;
167 
168 private:
169  WORD m_uHeaderID;
170 };
171 
172 #endif // !defined(ZIPARCHIVE_ZIPEXTRADATA_DOT_H)

The ZipArchive Library Copyright © 2000 - 2013 Artpol Software - Tadeusz Dracz. Generated at Fri Dec 13 2013 00:05:37.