Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | daniel-mar | 1 | |
2 | #ifndef DZRawH |
||
3 | #define DZRawH |
||
4 | //--------------------------------------------------------------------------- |
||
5 | |||
6 | /* DZRaw.H * Copyright (C) 2009 Russell Peters |
||
7 | ************************************************************************ |
||
8 | Copyright (C) 2009, 2010 by Russell J. Peters, Roger Aelbrecht |
||
9 | |||
10 | This file is part of TZipMaster Version 1.9. |
||
11 | |||
12 | TZipMaster is free software: you can redistribute it and/or modify |
||
13 | it under the terms of the GNU Lesser General Public License as published by |
||
14 | the Free Software Foundation, either version 3 of the License, or |
||
15 | (at your option) any later version. |
||
16 | |||
17 | TZipMaster is distributed in the hope that it will be useful, |
||
18 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
20 | GNU Lesser General Public License for more details. |
||
21 | |||
22 | You should have received a copy of the GNU Lesser General Public License |
||
23 | along with TZipMaster. If not, see <http://www.gnu.org/licenses/>. |
||
24 | |||
25 | contact: problems@delphizip.org (include ZipMaster in the subject). |
||
26 | updates: http://www.delphizip.org |
||
27 | DelphiZip maillist subscribe at http://www.freelists.org/list/delphizip |
||
28 | ************************************************************************/ |
||
29 | |||
30 | #pragma pack(push, 1) |
||
31 | union XWord |
||
32 | { |
||
33 | unsigned char b[2]; |
||
34 | unsigned short w; |
||
35 | }; |
||
36 | #pragma pack(pop) |
||
37 | |||
38 | #pragma pack(push, 2) |
||
39 | struct dzraw_imp |
||
40 | { |
||
41 | long refs; // reference counter |
||
42 | WORD capacity; // characters |
||
43 | WORD len; // string length |
||
44 | unsigned char data[8]; // the actual data |
||
45 | }; |
||
46 | #pragma pack(pop) |
||
47 | |||
48 | class DZRawData |
||
49 | { |
||
50 | private: |
||
51 | dzraw_imp* imp; |
||
52 | protected: |
||
53 | dzraw_imp* __fastcall NewImp(unsigned siz); |
||
54 | dzraw_imp* NewImp(const unsigned char* src, int Len, int Space = -1); |
||
55 | void __fastcall Release(void); |
||
56 | int __fastcall IncRefs(void); |
||
57 | int __fastcall DecRefs(void); |
||
58 | public: |
||
59 | __fastcall DZRawData(void): imp(0){}; |
||
60 | __fastcall DZRawData(unsigned size); |
||
61 | __fastcall DZRawData(const DZRawData& other); |
||
62 | __fastcall DZRawData(const unsigned char* str, unsigned len); |
||
63 | __fastcall ~DZRawData(void){Release();} |
||
64 | unsigned __fastcall Capacity(void) const; |
||
65 | unsigned __fastcall Length(void) const; |
||
66 | inline bool IsEmpty(void) const {return !imp || !Length();} |
||
67 | inline void Empty(void) {Release();} |
||
68 | void __fastcall Append(const unsigned char* src, int Len); |
||
69 | void __fastcall Assign(const unsigned char* src, int Len); |
||
70 | const unsigned char* begin(void) const; |
||
71 | inline const unsigned char* data(void) const {return begin();} |
||
72 | const unsigned char* end(void) const; |
||
73 | const unsigned char* Find(WORD tag) const; |
||
74 | unsigned char * __fastcall GetBuffer(unsigned size); |
||
75 | void __fastcall SetLength(unsigned Len = 0); |
||
76 | operator const unsigned char*()const {return begin();} |
||
77 | DZRawData& __fastcall operator =(const DZRawData& other); |
||
78 | DZRawData __fastcall operator +(const DZRawData& other); |
||
79 | DZRawData& __fastcall operator +=(const DZRawData& other); |
||
80 | DZRawData& __fastcall operator +=(unsigned char ch); |
||
81 | DZRawData& __fastcall operator +=(WORD w); |
||
82 | DZRawData __fastcall operator -(WORD tag); |
||
83 | DZRawData& __fastcall operator -=(WORD tag); |
||
84 | WORD __fastcall operator [](unsigned idx) const; |
||
85 | inline bool operator !()const {return IsEmpty();} |
||
86 | }; |
||
87 | |||
88 | |||
89 | #endif |