1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
////////////////////////////////////////////////////////////////////////////////
// This source file is part of the ZipArchive library source distribution and
// is Copyrighted 2000 - 2007 by Artpol Software - Tadeusz Dracz
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// For the licensing details refer to the License.txt file.
//
// Web Site: http://www.artpol-software.com
////////////////////////////////////////////////////////////////////////////////
#ifndef ZIPARCHIVE_ZIPCOLLECTIONS_DOT_H
#error Do not include this file directly. Include ZipCollections.h instead
#endif
#if _MSC_VER > 1000
#pragma warning( push )
#pragma warning (disable:4786) // 'identifier' : identifier was truncated to 'number' characters in the debug information
#endif
#include <afxtempl.h>
#define ZIP_ARRAY_SIZE_TYPE INT_PTR
typedef CStringArray CZipStringArray;
template <class TYPE>
class CZipArray : public CArray<TYPE, TYPE>
{
public:
typedef int (*CompareFunction)(const void* pArg1, const void* pArg2);
private:
static int CompareAsc(const void *pArg1, const void *pArg2)
{
TYPE w1 = *(TYPE*)pArg1;
TYPE w2 = *(TYPE*)pArg2;
return w1 == w2 ? 0 :(w2 > w1 ? - 1 : 1);
}
static int CompareDesc(const void *pArg1, const void *pArg2)
{
TYPE w1 = *(TYPE*)pArg1;
TYPE w2 = *(TYPE*)pArg2;
return w1 == w2 ? 0 :(w1 > w2 ? - 1 : 1);
}
public:
void Sort(bool bAscending)
{
Sort(bAscending ? CompareAsc : CompareDesc);
}
void Sort(CompareFunction pFunction)
{
INT_PTR uSize = GetSize();
if (!uSize) // if ommitted operator [] will fail if empty
return;
qsort((void*)&((*this)[0]), (size_t)uSize , sizeof(TYPE), pFunction);
}
};
template<class TYPE>
class CZipPtrList : public CTypedPtrList<CPtrList, TYPE>
{
public:
typedef POSITION iterator;
typedef POSITION const_iterator;
bool IteratorValid(const iterator &iter) const
{
return iter != NULL;
}
};
template<class KEY, class VALUE>
class CZipMap : public CMap<KEY, KEY, VALUE, VALUE>
{
public:
typedef POSITION iterator;
typedef POSITION const_iterator;
bool IteratorValid(const iterator &iter) const
{
return iter != NULL;
}
};
#if _MSC_VER > 1000
#pragma warning( pop )
#endif
|