| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef _FX_UTILS | 7 #ifndef _FX_UTILS |
| 8 #define _FX_UTILS | 8 #define _FX_UTILS |
| 9 class CFX_ThreadLock; | 9 class CFX_ThreadLock; |
| 10 class CFX_BaseArray; | 10 class CFX_BaseArray; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 CFX_ThreadLock(); | 27 CFX_ThreadLock(); |
| 28 virtual ~CFX_ThreadLock(); | 28 virtual ~CFX_ThreadLock(); |
| 29 void Lock(); | 29 void Lock(); |
| 30 void Unlock(); | 30 void Unlock(); |
| 31 private: | 31 private: |
| 32 FX_LPVOID m_pData; | 32 FX_LPVOID m_pData; |
| 33 }; | 33 }; |
| 34 class CFX_BaseArray : public CFX_Target | 34 class CFX_BaseArray : public CFX_Target |
| 35 { | 35 { |
| 36 protected: | 36 protected: |
| 37 CFX_BaseArray(FX_INT32 iGrowSize, FX_INT32 iBlockSize); | 37 CFX_BaseArray(int32_t iGrowSize, int32_t iBlockSize); |
| 38 ~CFX_BaseArray(); | 38 ~CFX_BaseArray(); |
| 39 FX_INT32» GetSize() const; | 39 int32_t» GetSize() const; |
| 40 FX_INT32» GetBlockSize() const; | 40 int32_t» GetBlockSize() const; |
| 41 FX_LPBYTE» AddSpaceTo(FX_INT32 index); | 41 FX_LPBYTE» AddSpaceTo(int32_t index); |
| 42 FX_LPBYTE» GetAt(FX_INT32 index) const; | 42 FX_LPBYTE» GetAt(int32_t index) const; |
| 43 FX_LPBYTE GetBuffer() const; | 43 FX_LPBYTE GetBuffer() const; |
| 44 FX_INT32» Append(const CFX_BaseArray &src, FX_INT32 iStart = 0, FX_INT32 i
Count = -1); | 44 int32_t» Append(const CFX_BaseArray &src, int32_t iStart = 0, int32_t iCo
unt = -1); |
| 45 FX_INT32» Copy(const CFX_BaseArray &src, FX_INT32 iStart = 0, FX_INT32 iCo
unt = -1); | 45 int32_t» Copy(const CFX_BaseArray &src, int32_t iStart = 0, int32_t iCoun
t = -1); |
| 46 FX_INT32» RemoveLast(FX_INT32 iCount = -1); | 46 int32_t» RemoveLast(int32_t iCount = -1); |
| 47 void RemoveAll(FX_BOOL bLeaveMemory = FALSE); | 47 void RemoveAll(FX_BOOL bLeaveMemory = FALSE); |
| 48 FX_LPVOID m_pData; | 48 FX_LPVOID m_pData; |
| 49 }; | 49 }; |
| 50 template<class baseType> | 50 template<class baseType> |
| 51 class CFX_BaseArrayTemplate : public CFX_BaseArray | 51 class CFX_BaseArrayTemplate : public CFX_BaseArray |
| 52 { | 52 { |
| 53 public: | 53 public: |
| 54 CFX_BaseArrayTemplate(FX_INT32 iGrowSize = 100) : CFX_BaseArray(iGrowSize, s
izeof(baseType)) {} | 54 CFX_BaseArrayTemplate(int32_t iGrowSize = 100) : CFX_BaseArray(iGrowSize, si
zeof(baseType)) {} |
| 55 CFX_BaseArrayTemplate(FX_INT32 iGrowSize, FX_INT32 iBlockSize) : CFX_BaseArr
ay(iGrowSize, iBlockSize) {} | 55 CFX_BaseArrayTemplate(int32_t iGrowSize, int32_t iBlockSize) : CFX_BaseArray
(iGrowSize, iBlockSize) {} |
| 56 FX_INT32» GetSize() const | 56 int32_t» GetSize() const |
| 57 { | 57 { |
| 58 return CFX_BaseArray::GetSize(); | 58 return CFX_BaseArray::GetSize(); |
| 59 } | 59 } |
| 60 FX_INT32» GetBlockSize() const | 60 int32_t» GetBlockSize() const |
| 61 { | 61 { |
| 62 return CFX_BaseArray::GetBlockSize(); | 62 return CFX_BaseArray::GetBlockSize(); |
| 63 } | 63 } |
| 64 baseType* AddSpace() | 64 baseType* AddSpace() |
| 65 { | 65 { |
| 66 return (baseType*)CFX_BaseArray::AddSpaceTo(CFX_BaseArray::GetSize()); | 66 return (baseType*)CFX_BaseArray::AddSpaceTo(CFX_BaseArray::GetSize()); |
| 67 } | 67 } |
| 68 FX_INT32» Add(const baseType &element) | 68 int32_t» Add(const baseType &element) |
| 69 { | 69 { |
| 70 FX_INT32 index = CFX_BaseArray::GetSize(); | 70 int32_t index = CFX_BaseArray::GetSize(); |
| 71 *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element; | 71 *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element; |
| 72 return index; | 72 return index; |
| 73 } | 73 } |
| 74 baseType* GetBuffer() const | 74 baseType* GetBuffer() const |
| 75 { | 75 { |
| 76 return (baseType*)CFX_BaseArray::GetBuffer(); | 76 return (baseType*)CFX_BaseArray::GetBuffer(); |
| 77 } | 77 } |
| 78 baseType&» GetAt(FX_INT32 index) const | 78 baseType&» GetAt(int32_t index) const |
| 79 { | 79 { |
| 80 return *(baseType*)CFX_BaseArray::GetAt(index); | 80 return *(baseType*)CFX_BaseArray::GetAt(index); |
| 81 } | 81 } |
| 82 baseType*» GetPtrAt(FX_INT32 index) const | 82 baseType*» GetPtrAt(int32_t index) const |
| 83 { | 83 { |
| 84 return (baseType*)CFX_BaseArray::GetAt(index); | 84 return (baseType*)CFX_BaseArray::GetAt(index); |
| 85 } | 85 } |
| 86 void» » SetAt(FX_INT32 index, const baseType &element) | 86 void» » SetAt(int32_t index, const baseType &element) |
| 87 { | 87 { |
| 88 *(baseType*)CFX_BaseArray::GetAt(index) = element; | 88 *(baseType*)CFX_BaseArray::GetAt(index) = element; |
| 89 } | 89 } |
| 90 void» » SetAtGrow(FX_INT32 index, const baseType &element) | 90 void» » SetAtGrow(int32_t index, const baseType &element) |
| 91 { | 91 { |
| 92 *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element; | 92 *(baseType*)CFX_BaseArray::AddSpaceTo(index) = element; |
| 93 } | 93 } |
| 94 FX_INT32» Append(const CFX_BaseArrayTemplate &src, FX_INT32 iStart = 0, FX
_INT32 iCount = -1) | 94 int32_t» Append(const CFX_BaseArrayTemplate &src, int32_t iStart = 0, int
32_t iCount = -1) |
| 95 { | 95 { |
| 96 return CFX_BaseArray::Append(src, iStart, iCount); | 96 return CFX_BaseArray::Append(src, iStart, iCount); |
| 97 } | 97 } |
| 98 FX_INT32» Copy(const CFX_BaseArrayTemplate &src, FX_INT32 iStart = 0, FX_I
NT32 iCount = -1) | 98 int32_t» Copy(const CFX_BaseArrayTemplate &src, int32_t iStart = 0, int32
_t iCount = -1) |
| 99 { | 99 { |
| 100 return CFX_BaseArray::Copy(src, iStart, iCount); | 100 return CFX_BaseArray::Copy(src, iStart, iCount); |
| 101 } | 101 } |
| 102 FX_INT32» RemoveLast(FX_INT32 iCount = -1) | 102 int32_t» RemoveLast(int32_t iCount = -1) |
| 103 { | 103 { |
| 104 return CFX_BaseArray::RemoveLast(iCount); | 104 return CFX_BaseArray::RemoveLast(iCount); |
| 105 } | 105 } |
| 106 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) | 106 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) |
| 107 { | 107 { |
| 108 CFX_BaseArray::RemoveAll(bLeaveMemory); | 108 CFX_BaseArray::RemoveAll(bLeaveMemory); |
| 109 } | 109 } |
| 110 }; | 110 }; |
| 111 typedef CFX_BaseArrayTemplate<FX_LPVOID> CFDE_PtrArray; | 111 typedef CFX_BaseArrayTemplate<FX_LPVOID> CFDE_PtrArray; |
| 112 typedef CFX_BaseArrayTemplate<FX_DWORD> CFDE_DWordArray; | 112 typedef CFX_BaseArrayTemplate<FX_DWORD> CFDE_DWordArray; |
| 113 typedef CFX_BaseArrayTemplate<FX_WORD> CFDE_WordArray; | 113 typedef CFX_BaseArrayTemplate<FX_WORD> CFDE_WordArray; |
| 114 template<class baseType> | 114 template<class baseType> |
| 115 class CFX_ObjectBaseArrayTemplate : public CFX_BaseArray | 115 class CFX_ObjectBaseArrayTemplate : public CFX_BaseArray |
| 116 { | 116 { |
| 117 public: | 117 public: |
| 118 CFX_ObjectBaseArrayTemplate(FX_INT32 iGrowSize = 100) : CFX_BaseArray(iGrowS
ize, sizeof(baseType)) {} | 118 CFX_ObjectBaseArrayTemplate(int32_t iGrowSize = 100) : CFX_BaseArray(iGrowSi
ze, sizeof(baseType)) {} |
| 119 ~CFX_ObjectBaseArrayTemplate() | 119 ~CFX_ObjectBaseArrayTemplate() |
| 120 { | 120 { |
| 121 RemoveAll(FALSE); | 121 RemoveAll(FALSE); |
| 122 } | 122 } |
| 123 FX_INT32» GetSize() const | 123 int32_t» GetSize() const |
| 124 { | 124 { |
| 125 return CFX_BaseArray::GetSize(); | 125 return CFX_BaseArray::GetSize(); |
| 126 } | 126 } |
| 127 FX_INT32» GetBlockSize() const | 127 int32_t» GetBlockSize() const |
| 128 { | 128 { |
| 129 return CFX_BaseArray::GetBlockSize(); | 129 return CFX_BaseArray::GetBlockSize(); |
| 130 } | 130 } |
| 131 FX_INT32» Add(const baseType &element) | 131 int32_t» Add(const baseType &element) |
| 132 { | 132 { |
| 133 FX_INT32 index = CFX_BaseArray::GetSize(); | 133 int32_t index = CFX_BaseArray::GetSize(); |
| 134 baseType *p = (baseType*)CFX_BaseArray::AddSpaceTo(index); | 134 baseType *p = (baseType*)CFX_BaseArray::AddSpaceTo(index); |
| 135 FXTARGET_New ((void*)p)baseType(element); | 135 FXTARGET_New ((void*)p)baseType(element); |
| 136 return index; | 136 return index; |
| 137 } | 137 } |
| 138 baseType&» GetAt(FX_INT32 index) const | 138 baseType&» GetAt(int32_t index) const |
| 139 { | 139 { |
| 140 return *(baseType*)CFX_BaseArray::GetAt(index); | 140 return *(baseType*)CFX_BaseArray::GetAt(index); |
| 141 } | 141 } |
| 142 baseType*» GetPtrAt(FX_INT32 index) const | 142 baseType*» GetPtrAt(int32_t index) const |
| 143 { | 143 { |
| 144 return (baseType*)CFX_BaseArray::GetAt(index); | 144 return (baseType*)CFX_BaseArray::GetAt(index); |
| 145 } | 145 } |
| 146 FX_INT32» Append(const CFX_ObjectBaseArrayTemplate &src, FX_INT32 iStart =
0, FX_INT32 iCount = -1) | 146 int32_t» Append(const CFX_ObjectBaseArrayTemplate &src, int32_t iStart =
0, int32_t iCount = -1) |
| 147 { | 147 { |
| 148 FXSYS_assert(GetBlockSize() == src.GetBlockSize()); | 148 FXSYS_assert(GetBlockSize() == src.GetBlockSize()); |
| 149 if (iCount == 0) { | 149 if (iCount == 0) { |
| 150 return 0; | 150 return 0; |
| 151 } | 151 } |
| 152 FX_INT32 iSize = src.GetSize(); | 152 int32_t iSize = src.GetSize(); |
| 153 FXSYS_assert(iStart > -1 && iStart < iSize); | 153 FXSYS_assert(iStart > -1 && iStart < iSize); |
| 154 if (iCount < 0) { | 154 if (iCount < 0) { |
| 155 iCount = iSize; | 155 iCount = iSize; |
| 156 } | 156 } |
| 157 if (iStart + iCount > iSize) { | 157 if (iStart + iCount > iSize) { |
| 158 iCount = iSize - iStart; | 158 iCount = iSize - iStart; |
| 159 } | 159 } |
| 160 if (iCount < 1) { | 160 if (iCount < 1) { |
| 161 return 0; | 161 return 0; |
| 162 } | 162 } |
| 163 iSize = CFX_BaseArray::GetSize(); | 163 iSize = CFX_BaseArray::GetSize(); |
| 164 CFX_BaseArray::AddSpaceTo(iSize + iCount - 1); | 164 CFX_BaseArray::AddSpaceTo(iSize + iCount - 1); |
| 165 FX_LPBYTE *pStart = CFX_BaseArray::GetAt(iSize); | 165 FX_LPBYTE *pStart = CFX_BaseArray::GetAt(iSize); |
| 166 FX_INT32 iBlockSize = CFX_BaseArray::GetBlockSize(); | 166 int32_t iBlockSize = CFX_BaseArray::GetBlockSize(); |
| 167 iSize = iStart + iCount; | 167 iSize = iStart + iCount; |
| 168 for (FX_INT32 i = iStart; i < iSize; i ++) { | 168 for (int32_t i = iStart; i < iSize; i ++) { |
| 169 FXTARGET_NewWith ((void*)pStart)baseType(src.GetAt(i)); | 169 FXTARGET_NewWith ((void*)pStart)baseType(src.GetAt(i)); |
| 170 pStart += iBlockSize; | 170 pStart += iBlockSize; |
| 171 } | 171 } |
| 172 return iCount; | 172 return iCount; |
| 173 } | 173 } |
| 174 FX_INT32» Copy(const CFX_ObjectBaseArrayTemplate &src, FX_INT32 iStart = 0
, FX_INT32 iCount = -1) | 174 int32_t» Copy(const CFX_ObjectBaseArrayTemplate &src, int32_t iStart = 0,
int32_t iCount = -1) |
| 175 { | 175 { |
| 176 FXSYS_assert(GetBlockSize() == src.GetBlockSize()); | 176 FXSYS_assert(GetBlockSize() == src.GetBlockSize()); |
| 177 if (iCount == 0) { | 177 if (iCount == 0) { |
| 178 return 0; | 178 return 0; |
| 179 } | 179 } |
| 180 FX_INT32 iSize = src.GetSize(); | 180 int32_t iSize = src.GetSize(); |
| 181 FXSYS_assert(iStart > -1 && iStart < iSize); | 181 FXSYS_assert(iStart > -1 && iStart < iSize); |
| 182 if (iCount < 0) { | 182 if (iCount < 0) { |
| 183 iCount = iSize; | 183 iCount = iSize; |
| 184 } | 184 } |
| 185 if (iStart + iCount > iSize) { | 185 if (iStart + iCount > iSize) { |
| 186 iCount = iSize - iStart; | 186 iCount = iSize - iStart; |
| 187 } | 187 } |
| 188 if (iCount < 1) { | 188 if (iCount < 1) { |
| 189 return 0; | 189 return 0; |
| 190 } | 190 } |
| 191 RemoveAll(TRUE); | 191 RemoveAll(TRUE); |
| 192 CFX_BaseArray::AddSpaceTo(iCount - 1); | 192 CFX_BaseArray::AddSpaceTo(iCount - 1); |
| 193 FX_LPBYTE *pStart = CFX_BaseArray::GetAt(0); | 193 FX_LPBYTE *pStart = CFX_BaseArray::GetAt(0); |
| 194 FX_INT32 iBlockSize = CFX_BaseArray::GetBlockSize(); | 194 int32_t iBlockSize = CFX_BaseArray::GetBlockSize(); |
| 195 iSize = iStart + iCount; | 195 iSize = iStart + iCount; |
| 196 for (FX_INT32 i = iStart; i < iSize; i ++) { | 196 for (int32_t i = iStart; i < iSize; i ++) { |
| 197 FXTARGET_New ((void*)pStart)baseType(src.GetAt(i)); | 197 FXTARGET_New ((void*)pStart)baseType(src.GetAt(i)); |
| 198 pStart += iBlockSize; | 198 pStart += iBlockSize; |
| 199 } | 199 } |
| 200 return iCount; | 200 return iCount; |
| 201 } | 201 } |
| 202 FX_INT32» RemoveLast(FX_INT32 iCount = -1) | 202 int32_t» RemoveLast(int32_t iCount = -1) |
| 203 { | 203 { |
| 204 FX_INT32 iSize = CFX_BaseArray::GetSize(); | 204 int32_t iSize = CFX_BaseArray::GetSize(); |
| 205 if (iCount < 0 || iCount > iSize) { | 205 if (iCount < 0 || iCount > iSize) { |
| 206 iCount = iSize; | 206 iCount = iSize; |
| 207 } | 207 } |
| 208 if (iCount == 0) { | 208 if (iCount == 0) { |
| 209 return iSize; | 209 return iSize; |
| 210 } | 210 } |
| 211 for (FX_INT32 i = iSize - iCount; i < iSize; i ++) { | 211 for (int32_t i = iSize - iCount; i < iSize; i ++) { |
| 212 ((baseType*)GetPtrAt(i))->~baseType(); | 212 ((baseType*)GetPtrAt(i))->~baseType(); |
| 213 } | 213 } |
| 214 return CFX_BaseArray::RemoveLast(iCount); | 214 return CFX_BaseArray::RemoveLast(iCount); |
| 215 } | 215 } |
| 216 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) | 216 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) |
| 217 { | 217 { |
| 218 FX_INT32 iSize = CFX_BaseArray::GetSize(); | 218 int32_t iSize = CFX_BaseArray::GetSize(); |
| 219 for (FX_INT32 i = 0; i < iSize; i ++) { | 219 for (int32_t i = 0; i < iSize; i ++) { |
| 220 ((baseType*)GetPtrAt(i))->~baseType(); | 220 ((baseType*)GetPtrAt(i))->~baseType(); |
| 221 } | 221 } |
| 222 CFX_BaseArray::RemoveAll(bLeaveMemory); | 222 CFX_BaseArray::RemoveAll(bLeaveMemory); |
| 223 } | 223 } |
| 224 }; | 224 }; |
| 225 class CFX_BaseMassArray : public CFX_Target | 225 class CFX_BaseMassArray : public CFX_Target |
| 226 { | 226 { |
| 227 protected: | 227 protected: |
| 228 CFX_BaseMassArray(FX_INT32 iChunkSize, FX_INT32 iBlockSize); | 228 CFX_BaseMassArray(int32_t iChunkSize, int32_t iBlockSize); |
| 229 ~CFX_BaseMassArray(); | 229 ~CFX_BaseMassArray(); |
| 230 FX_INT32» GetSize() const; | 230 int32_t» GetSize() const; |
| 231 FX_LPBYTE» AddSpaceTo(FX_INT32 index); | 231 FX_LPBYTE» AddSpaceTo(int32_t index); |
| 232 FX_LPBYTE» GetAt(FX_INT32 index) const; | 232 FX_LPBYTE» GetAt(int32_t index) const; |
| 233 FX_INT32» Append(const CFX_BaseMassArray &src, FX_INT32 iStart = 0, FX_INT
32 iCount = -1); | 233 int32_t» Append(const CFX_BaseMassArray &src, int32_t iStart = 0, int32_t
iCount = -1); |
| 234 FX_INT32» Copy(const CFX_BaseMassArray &src, FX_INT32 iStart = 0, FX_INT32
iCount = -1); | 234 int32_t» Copy(const CFX_BaseMassArray &src, int32_t iStart = 0, int32_t i
Count = -1); |
| 235 FX_INT32» RemoveLast(FX_INT32 iCount = -1); | 235 int32_t» RemoveLast(int32_t iCount = -1); |
| 236 void RemoveAll(FX_BOOL bLeaveMemory = FALSE); | 236 void RemoveAll(FX_BOOL bLeaveMemory = FALSE); |
| 237 CFX_BaseMassArrayImp* m_pData; | 237 CFX_BaseMassArrayImp* m_pData; |
| 238 }; | 238 }; |
| 239 template<class baseType> | 239 template<class baseType> |
| 240 class CFX_MassArrayTemplate : public CFX_BaseMassArray | 240 class CFX_MassArrayTemplate : public CFX_BaseMassArray |
| 241 { | 241 { |
| 242 public: | 242 public: |
| 243 CFX_MassArrayTemplate(FX_INT32 iChunkSize = 100) : CFX_BaseMassArray(iChunkS
ize, sizeof(baseType)) {} | 243 CFX_MassArrayTemplate(int32_t iChunkSize = 100) : CFX_BaseMassArray(iChunkSi
ze, sizeof(baseType)) {} |
| 244 CFX_MassArrayTemplate(FX_INT32 iChunkSize, FX_INT32 iBlockSize) : CFX_BaseMa
ssArray(iChunkSize, iBlockSize) {} | 244 CFX_MassArrayTemplate(int32_t iChunkSize, int32_t iBlockSize) : CFX_BaseMass
Array(iChunkSize, iBlockSize) {} |
| 245 FX_INT32» GetSize() const | 245 int32_t» GetSize() const |
| 246 { | 246 { |
| 247 return CFX_BaseMassArray::GetSize(); | 247 return CFX_BaseMassArray::GetSize(); |
| 248 } | 248 } |
| 249 baseType* AddSpace() | 249 baseType* AddSpace() |
| 250 { | 250 { |
| 251 return (baseType*)CFX_BaseMassArray::AddSpaceTo(CFX_BaseMassArray::GetSi
ze()); | 251 return (baseType*)CFX_BaseMassArray::AddSpaceTo(CFX_BaseMassArray::GetSi
ze()); |
| 252 } | 252 } |
| 253 FX_INT32» Add(const baseType &element) | 253 int32_t» Add(const baseType &element) |
| 254 { | 254 { |
| 255 FX_INT32 index = CFX_BaseMassArray::GetSize(); | 255 int32_t index = CFX_BaseMassArray::GetSize(); |
| 256 *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element; | 256 *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element; |
| 257 return index; | 257 return index; |
| 258 } | 258 } |
| 259 baseType&» GetAt(FX_INT32 index) const | 259 baseType&» GetAt(int32_t index) const |
| 260 { | 260 { |
| 261 return *(baseType*)CFX_BaseMassArray::GetAt(index); | 261 return *(baseType*)CFX_BaseMassArray::GetAt(index); |
| 262 } | 262 } |
| 263 baseType*» GetPtrAt(FX_INT32 index) const | 263 baseType*» GetPtrAt(int32_t index) const |
| 264 { | 264 { |
| 265 return (baseType*)CFX_BaseMassArray::GetAt(index); | 265 return (baseType*)CFX_BaseMassArray::GetAt(index); |
| 266 } | 266 } |
| 267 void» » SetAt(FX_INT32 index, const baseType &element) | 267 void» » SetAt(int32_t index, const baseType &element) |
| 268 { | 268 { |
| 269 *(baseType*)CFX_BaseMassArray::GetAt(index) = element; | 269 *(baseType*)CFX_BaseMassArray::GetAt(index) = element; |
| 270 } | 270 } |
| 271 void» » SetAtGrow(FX_INT32 index, const baseType &element) | 271 void» » SetAtGrow(int32_t index, const baseType &element) |
| 272 { | 272 { |
| 273 *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element; | 273 *(baseType*)CFX_BaseMassArray::AddSpaceTo(index) = element; |
| 274 } | 274 } |
| 275 FX_INT32» Append(const CFX_MassArrayTemplate &src, FX_INT32 iStart = 0, FX
_INT32 iCount = -1) | 275 int32_t» Append(const CFX_MassArrayTemplate &src, int32_t iStart = 0, int
32_t iCount = -1) |
| 276 { | 276 { |
| 277 return CFX_BaseMassArray::Append(src, iStart, iCount); | 277 return CFX_BaseMassArray::Append(src, iStart, iCount); |
| 278 } | 278 } |
| 279 FX_INT32» Copy(const CFX_MassArrayTemplate &src, FX_INT32 iStart = 0, FX_I
NT32 iCount = -1) | 279 int32_t» Copy(const CFX_MassArrayTemplate &src, int32_t iStart = 0, int32
_t iCount = -1) |
| 280 { | 280 { |
| 281 return CFX_BaseMassArray::Copy(src, iStart, iCount); | 281 return CFX_BaseMassArray::Copy(src, iStart, iCount); |
| 282 } | 282 } |
| 283 FX_INT32» RemoveLast(FX_INT32 iCount = -1) | 283 int32_t» RemoveLast(int32_t iCount = -1) |
| 284 { | 284 { |
| 285 return CFX_BaseMassArray::RemoveLast(iCount); | 285 return CFX_BaseMassArray::RemoveLast(iCount); |
| 286 } | 286 } |
| 287 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) | 287 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) |
| 288 { | 288 { |
| 289 CFX_BaseMassArray::RemoveAll(bLeaveMemory); | 289 CFX_BaseMassArray::RemoveAll(bLeaveMemory); |
| 290 } | 290 } |
| 291 }; | 291 }; |
| 292 typedef CFX_MassArrayTemplate<FX_LPVOID> CFX_PtrMassArray; | 292 typedef CFX_MassArrayTemplate<FX_LPVOID> CFX_PtrMassArray; |
| 293 typedef CFX_MassArrayTemplate<FX_INT32>»» CFX_Int32MassArray; | 293 typedef CFX_MassArrayTemplate<int32_t>» » CFX_Int32MassArray; |
| 294 typedef CFX_MassArrayTemplate<FX_DWORD> CFX_DWordMassArray; | 294 typedef CFX_MassArrayTemplate<FX_DWORD> CFX_DWordMassArray; |
| 295 typedef CFX_MassArrayTemplate<FX_WORD> CFX_WordMassArray; | 295 typedef CFX_MassArrayTemplate<FX_WORD> CFX_WordMassArray; |
| 296 typedef CFX_MassArrayTemplate<CFX_Rect> CFX_RectMassArray; | 296 typedef CFX_MassArrayTemplate<CFX_Rect> CFX_RectMassArray; |
| 297 typedef CFX_MassArrayTemplate<CFX_RectF> CFX_RectFMassArray; | 297 typedef CFX_MassArrayTemplate<CFX_RectF> CFX_RectFMassArray; |
| 298 template<class baseType> | 298 template<class baseType> |
| 299 class CFX_ObjectMassArrayTemplate : public CFX_BaseMassArray | 299 class CFX_ObjectMassArrayTemplate : public CFX_BaseMassArray |
| 300 { | 300 { |
| 301 public: | 301 public: |
| 302 CFX_ObjectMassArrayTemplate(FX_INT32 iChunkSize = 100) : CFX_BaseMassArray(i
ChunkSize, sizeof(baseType)) {} | 302 CFX_ObjectMassArrayTemplate(int32_t iChunkSize = 100) : CFX_BaseMassArray(iC
hunkSize, sizeof(baseType)) {} |
| 303 ~CFX_ObjectMassArrayTemplate() | 303 ~CFX_ObjectMassArrayTemplate() |
| 304 { | 304 { |
| 305 RemoveAll(FALSE); | 305 RemoveAll(FALSE); |
| 306 } | 306 } |
| 307 FX_INT32» GetSize() const | 307 int32_t» GetSize() const |
| 308 { | 308 { |
| 309 return CFX_BaseMassArray::GetSize(); | 309 return CFX_BaseMassArray::GetSize(); |
| 310 } | 310 } |
| 311 FX_INT32» Add(const baseType &element) | 311 int32_t» Add(const baseType &element) |
| 312 { | 312 { |
| 313 FX_INT32 index = CFX_BaseMassArray::GetSize(); | 313 int32_t index = CFX_BaseMassArray::GetSize(); |
| 314 baseType *p = (baseType*)CFX_BaseMassArray::AddSpaceTo(index); | 314 baseType *p = (baseType*)CFX_BaseMassArray::AddSpaceTo(index); |
| 315 FXTARGET_New ((void*)p)baseType(element); | 315 FXTARGET_New ((void*)p)baseType(element); |
| 316 return index; | 316 return index; |
| 317 } | 317 } |
| 318 baseType&» GetAt(FX_INT32 index) const | 318 baseType&» GetAt(int32_t index) const |
| 319 { | 319 { |
| 320 return *(baseType*)CFX_BaseMassArray::GetAt(index); | 320 return *(baseType*)CFX_BaseMassArray::GetAt(index); |
| 321 } | 321 } |
| 322 baseType*» GetPtrAt(FX_INT32 index) const | 322 baseType*» GetPtrAt(int32_t index) const |
| 323 { | 323 { |
| 324 return (baseType*)CFX_BaseMassArray::GetAt(index); | 324 return (baseType*)CFX_BaseMassArray::GetAt(index); |
| 325 } | 325 } |
| 326 FX_INT32» Append(const CFX_ObjectMassArrayTemplate &src, FX_INT32 iStart =
0, FX_INT32 iCount = -1) | 326 int32_t» Append(const CFX_ObjectMassArrayTemplate &src, int32_t iStart =
0, int32_t iCount = -1) |
| 327 { | 327 { |
| 328 if (iCount == 0) { | 328 if (iCount == 0) { |
| 329 return CFX_BaseMassArray::GetSize(); | 329 return CFX_BaseMassArray::GetSize(); |
| 330 } | 330 } |
| 331 FX_INT32 iSize = src.GetSize(); | 331 int32_t iSize = src.GetSize(); |
| 332 FXSYS_assert(iStart > -1 && iStart < iSize); | 332 FXSYS_assert(iStart > -1 && iStart < iSize); |
| 333 if (iCount < 0) { | 333 if (iCount < 0) { |
| 334 iCount = iSize; | 334 iCount = iSize; |
| 335 } | 335 } |
| 336 FX_INT32 iEnd = iStart + iCount; | 336 int32_t iEnd = iStart + iCount; |
| 337 if (iEnd > iSize) { | 337 if (iEnd > iSize) { |
| 338 iEnd = iSize; | 338 iEnd = iSize; |
| 339 } | 339 } |
| 340 for (FX_INT32 i = iStart; i < iEnd; i ++) { | 340 for (int32_t i = iStart; i < iEnd; i ++) { |
| 341 Add(src.GetAt(i)); | 341 Add(src.GetAt(i)); |
| 342 } | 342 } |
| 343 return CFX_BaseMassArray::GetSize(); | 343 return CFX_BaseMassArray::GetSize(); |
| 344 } | 344 } |
| 345 FX_INT32» Copy(const CFX_ObjectMassArrayTemplate &src, FX_INT32 iStart = 0
, FX_INT32 iCount = -1) | 345 int32_t» Copy(const CFX_ObjectMassArrayTemplate &src, int32_t iStart = 0,
int32_t iCount = -1) |
| 346 { | 346 { |
| 347 if (iCount == 0) { | 347 if (iCount == 0) { |
| 348 return CFX_BaseMassArray::GetSize(); | 348 return CFX_BaseMassArray::GetSize(); |
| 349 } | 349 } |
| 350 FX_INT32 iSize = src.GetSize(); | 350 int32_t iSize = src.GetSize(); |
| 351 FXSYS_assert(iStart > -1 && iStart < iSize); | 351 FXSYS_assert(iStart > -1 && iStart < iSize); |
| 352 if (iCount < 0) { | 352 if (iCount < 0) { |
| 353 iCount = iSize; | 353 iCount = iSize; |
| 354 } | 354 } |
| 355 FX_INT32 iEnd = iStart + iCount; | 355 int32_t iEnd = iStart + iCount; |
| 356 if (iEnd > iSize) { | 356 if (iEnd > iSize) { |
| 357 iEnd = iSize; | 357 iEnd = iSize; |
| 358 } | 358 } |
| 359 RemoveAll(TRUE); | 359 RemoveAll(TRUE); |
| 360 for (FX_INT32 i = iStart; i < iEnd; i ++) { | 360 for (int32_t i = iStart; i < iEnd; i ++) { |
| 361 Add(src.GetAt(i)); | 361 Add(src.GetAt(i)); |
| 362 } | 362 } |
| 363 return CFX_BaseMassArray::GetSize(); | 363 return CFX_BaseMassArray::GetSize(); |
| 364 } | 364 } |
| 365 FX_INT32» RemoveLast(FX_INT32 iCount = -1) | 365 int32_t» RemoveLast(int32_t iCount = -1) |
| 366 { | 366 { |
| 367 FX_INT32 iSize = CFX_BaseMassArray::GetSize(); | 367 int32_t iSize = CFX_BaseMassArray::GetSize(); |
| 368 if (iCount < 0 || iCount > iSize) { | 368 if (iCount < 0 || iCount > iSize) { |
| 369 iCount = iSize; | 369 iCount = iSize; |
| 370 } | 370 } |
| 371 if (iCount == 0) { | 371 if (iCount == 0) { |
| 372 return iSize; | 372 return iSize; |
| 373 } | 373 } |
| 374 for (FX_INT32 i = iSize - iCount; i < iSize; i ++) { | 374 for (int32_t i = iSize - iCount; i < iSize; i ++) { |
| 375 ((baseType*)GetPtrAt(i))->~baseType(); | 375 ((baseType*)GetPtrAt(i))->~baseType(); |
| 376 } | 376 } |
| 377 return CFX_BaseMassArray::RemoveLast(iCount); | 377 return CFX_BaseMassArray::RemoveLast(iCount); |
| 378 } | 378 } |
| 379 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) | 379 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) |
| 380 { | 380 { |
| 381 FX_INT32 iSize = CFX_BaseMassArray::GetSize(); | 381 int32_t iSize = CFX_BaseMassArray::GetSize(); |
| 382 for (FX_INT32 i = 0; i < iSize; i ++) { | 382 for (int32_t i = 0; i < iSize; i ++) { |
| 383 ((baseType*)GetPtrAt(i))->~baseType(); | 383 ((baseType*)GetPtrAt(i))->~baseType(); |
| 384 } | 384 } |
| 385 CFX_BaseMassArray::RemoveAll(bLeaveMemory); | 385 CFX_BaseMassArray::RemoveAll(bLeaveMemory); |
| 386 } | 386 } |
| 387 }; | 387 }; |
| 388 class CFX_BaseDiscreteArray : public CFX_Target | 388 class CFX_BaseDiscreteArray : public CFX_Target |
| 389 { | 389 { |
| 390 protected: | 390 protected: |
| 391 CFX_BaseDiscreteArray(FX_INT32 iChunkSize, FX_INT32 iBlockSize); | 391 CFX_BaseDiscreteArray(int32_t iChunkSize, int32_t iBlockSize); |
| 392 ~CFX_BaseDiscreteArray(); | 392 ~CFX_BaseDiscreteArray(); |
| 393 FX_LPBYTE» AddSpaceTo(FX_INT32 index); | 393 FX_LPBYTE» AddSpaceTo(int32_t index); |
| 394 FX_LPBYTE» GetAt(FX_INT32 index) const; | 394 FX_LPBYTE» GetAt(int32_t index) const; |
| 395 void RemoveAll(); | 395 void RemoveAll(); |
| 396 FX_LPVOID m_pData; | 396 FX_LPVOID m_pData; |
| 397 }; | 397 }; |
| 398 template<class baseType> | 398 template<class baseType> |
| 399 class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray | 399 class CFX_DiscreteArrayTemplate : public CFX_BaseDiscreteArray |
| 400 { | 400 { |
| 401 public: | 401 public: |
| 402 CFX_DiscreteArrayTemplate(FX_INT32 iChunkSize = 100) : CFX_BaseDiscreteArray
(iChunkSize, sizeof(baseType)) {} | 402 CFX_DiscreteArrayTemplate(int32_t iChunkSize = 100) : CFX_BaseDiscreteArray(
iChunkSize, sizeof(baseType)) {} |
| 403 baseType&» GetAt(FX_INT32 index, const baseType &defValue) const | 403 baseType&» GetAt(int32_t index, const baseType &defValue) const |
| 404 { | 404 { |
| 405 baseType *p = (baseType*)CFX_BaseDiscreteArray::GetAt(index); | 405 baseType *p = (baseType*)CFX_BaseDiscreteArray::GetAt(index); |
| 406 return p == NULL ? (baseType&)defValue : *p; | 406 return p == NULL ? (baseType&)defValue : *p; |
| 407 } | 407 } |
| 408 baseType*» GetPtrAt(FX_INT32 index) const | 408 baseType*» GetPtrAt(int32_t index) const |
| 409 { | 409 { |
| 410 return (baseType*)CFX_BaseDiscreteArray::GetAt(index); | 410 return (baseType*)CFX_BaseDiscreteArray::GetAt(index); |
| 411 } | 411 } |
| 412 void» » SetAtGrow(FX_INT32 index, const baseType &element) | 412 void» » SetAtGrow(int32_t index, const baseType &element) |
| 413 { | 413 { |
| 414 *(baseType*)CFX_BaseDiscreteArray::AddSpaceTo(index) = element; | 414 *(baseType*)CFX_BaseDiscreteArray::AddSpaceTo(index) = element; |
| 415 } | 415 } |
| 416 void RemoveAll() | 416 void RemoveAll() |
| 417 { | 417 { |
| 418 CFX_BaseDiscreteArray::RemoveAll(); | 418 CFX_BaseDiscreteArray::RemoveAll(); |
| 419 } | 419 } |
| 420 }; | 420 }; |
| 421 typedef CFX_DiscreteArrayTemplate<FX_LPVOID> CFX_PtrDiscreteArray; | 421 typedef CFX_DiscreteArrayTemplate<FX_LPVOID> CFX_PtrDiscreteArray; |
| 422 typedef CFX_DiscreteArrayTemplate<FX_DWORD> CFX_DWordDiscreteArray; | 422 typedef CFX_DiscreteArrayTemplate<FX_DWORD> CFX_DWordDiscreteArray; |
| 423 typedef CFX_DiscreteArrayTemplate<FX_WORD> CFX_WordDiscreteArray; | 423 typedef CFX_DiscreteArrayTemplate<FX_WORD> CFX_WordDiscreteArray; |
| 424 class CFX_BaseStack : public CFX_Target | 424 class CFX_BaseStack : public CFX_Target |
| 425 { | 425 { |
| 426 protected: | 426 protected: |
| 427 CFX_BaseStack(FX_INT32 iChunkSize, FX_INT32 iBlockSize); | 427 CFX_BaseStack(int32_t iChunkSize, int32_t iBlockSize); |
| 428 ~CFX_BaseStack(); | 428 ~CFX_BaseStack(); |
| 429 FX_LPBYTE Push(); | 429 FX_LPBYTE Push(); |
| 430 void Pop(); | 430 void Pop(); |
| 431 FX_LPBYTE GetTopElement() const; | 431 FX_LPBYTE GetTopElement() const; |
| 432 FX_INT32» GetSize() const; | 432 int32_t» GetSize() const; |
| 433 FX_LPBYTE» GetAt(FX_INT32 index) const; | 433 FX_LPBYTE» GetAt(int32_t index) const; |
| 434 void RemoveAll(FX_BOOL bLeaveMemory = FALSE); | 434 void RemoveAll(FX_BOOL bLeaveMemory = FALSE); |
| 435 CFX_BaseMassArrayImp* m_pData; | 435 CFX_BaseMassArrayImp* m_pData; |
| 436 }; | 436 }; |
| 437 template<class baseType> | 437 template<class baseType> |
| 438 class CFX_StackTemplate : public CFX_BaseStack | 438 class CFX_StackTemplate : public CFX_BaseStack |
| 439 { | 439 { |
| 440 public: | 440 public: |
| 441 CFX_StackTemplate(FX_INT32 iChunkSize = 100) : CFX_BaseStack(iChunkSize, siz
eof(baseType)) {} | 441 CFX_StackTemplate(int32_t iChunkSize = 100) : CFX_BaseStack(iChunkSize, size
of(baseType)) {} |
| 442 FX_INT32» Push(const baseType &element) | 442 int32_t» Push(const baseType &element) |
| 443 { | 443 { |
| 444 FX_INT32 index = CFX_BaseStack::GetSize(); | 444 int32_t index = CFX_BaseStack::GetSize(); |
| 445 *(baseType*)CFX_BaseStack::Push() = element; | 445 *(baseType*)CFX_BaseStack::Push() = element; |
| 446 return index; | 446 return index; |
| 447 } | 447 } |
| 448 void Pop() | 448 void Pop() |
| 449 { | 449 { |
| 450 CFX_BaseStack::Pop(); | 450 CFX_BaseStack::Pop(); |
| 451 } | 451 } |
| 452 baseType* GetTopElement() const | 452 baseType* GetTopElement() const |
| 453 { | 453 { |
| 454 return (baseType*)CFX_BaseStack::GetTopElement(); | 454 return (baseType*)CFX_BaseStack::GetTopElement(); |
| 455 } | 455 } |
| 456 FX_INT32» GetSize() const | 456 int32_t» GetSize() const |
| 457 { | 457 { |
| 458 return CFX_BaseStack::GetSize(); | 458 return CFX_BaseStack::GetSize(); |
| 459 } | 459 } |
| 460 baseType*» GetAt(FX_INT32 index) const | 460 baseType*» GetAt(int32_t index) const |
| 461 { | 461 { |
| 462 return (baseType*)CFX_BaseStack::GetAt(index); | 462 return (baseType*)CFX_BaseStack::GetAt(index); |
| 463 } | 463 } |
| 464 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) | 464 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) |
| 465 { | 465 { |
| 466 CFX_BaseStack::RemoveAll(bLeaveMemory); | 466 CFX_BaseStack::RemoveAll(bLeaveMemory); |
| 467 } | 467 } |
| 468 }; | 468 }; |
| 469 typedef CFX_StackTemplate<FX_LPVOID> CFX_PtrStack; | 469 typedef CFX_StackTemplate<FX_LPVOID> CFX_PtrStack; |
| 470 typedef CFX_StackTemplate<FX_DWORD> CFX_DWordStack; | 470 typedef CFX_StackTemplate<FX_DWORD> CFX_DWordStack; |
| 471 typedef CFX_StackTemplate<FX_WORD> CFX_WordStack; | 471 typedef CFX_StackTemplate<FX_WORD> CFX_WordStack; |
| 472 typedef CFX_StackTemplate<FX_INT32>» CFX_Int32Stack; | 472 typedef CFX_StackTemplate<int32_t>» CFX_Int32Stack; |
| 473 template<class baseType> | 473 template<class baseType> |
| 474 class CFX_ObjectStackTemplate : public CFX_BaseStack | 474 class CFX_ObjectStackTemplate : public CFX_BaseStack |
| 475 { | 475 { |
| 476 public: | 476 public: |
| 477 CFX_ObjectStackTemplate(FX_INT32 iChunkSize = 100) : CFX_BaseStack(iChunkSiz
e, sizeof(baseType)) {} | 477 CFX_ObjectStackTemplate(int32_t iChunkSize = 100) : CFX_BaseStack(iChunkSize
, sizeof(baseType)) {} |
| 478 ~CFX_ObjectStackTemplate() | 478 ~CFX_ObjectStackTemplate() |
| 479 { | 479 { |
| 480 RemoveAll(); | 480 RemoveAll(); |
| 481 } | 481 } |
| 482 FX_INT32» Push(const baseType &element) | 482 int32_t» Push(const baseType &element) |
| 483 { | 483 { |
| 484 FX_INT32 index = CFX_BaseStack::GetSize(); | 484 int32_t index = CFX_BaseStack::GetSize(); |
| 485 baseType *p = (baseType*)CFX_BaseStack::Push(); | 485 baseType *p = (baseType*)CFX_BaseStack::Push(); |
| 486 FXTARGET_New ((void*)p)baseType(element); | 486 FXTARGET_New ((void*)p)baseType(element); |
| 487 return index; | 487 return index; |
| 488 } | 488 } |
| 489 void Pop() | 489 void Pop() |
| 490 { | 490 { |
| 491 baseType *p = (baseType*)CFX_BaseStack::GetTopElement(); | 491 baseType *p = (baseType*)CFX_BaseStack::GetTopElement(); |
| 492 if (p != NULL) { | 492 if (p != NULL) { |
| 493 p->~baseType(); | 493 p->~baseType(); |
| 494 } | 494 } |
| 495 CFX_BaseStack::Pop(); | 495 CFX_BaseStack::Pop(); |
| 496 } | 496 } |
| 497 baseType* GetTopElement() const | 497 baseType* GetTopElement() const |
| 498 { | 498 { |
| 499 return (baseType*)CFX_BaseStack::GetTopElement(); | 499 return (baseType*)CFX_BaseStack::GetTopElement(); |
| 500 } | 500 } |
| 501 FX_INT32» GetSize() const | 501 int32_t» GetSize() const |
| 502 { | 502 { |
| 503 return CFX_BaseStack::GetSize(); | 503 return CFX_BaseStack::GetSize(); |
| 504 } | 504 } |
| 505 baseType*» GetAt(FX_INT32 index) const | 505 baseType*» GetAt(int32_t index) const |
| 506 { | 506 { |
| 507 return (baseType*)CFX_BaseStack::GetAt(index); | 507 return (baseType*)CFX_BaseStack::GetAt(index); |
| 508 } | 508 } |
| 509 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) | 509 void RemoveAll(FX_BOOL bLeaveMemory = FALSE) |
| 510 { | 510 { |
| 511 FX_INT32 iSize = CFX_BaseStack::GetSize(); | 511 int32_t iSize = CFX_BaseStack::GetSize(); |
| 512 for (FX_INT32 i = 0; i < iSize; i ++) { | 512 for (int32_t i = 0; i < iSize; i ++) { |
| 513 ((baseType*)CFX_BaseStack::GetAt(i))->~baseType(); | 513 ((baseType*)CFX_BaseStack::GetAt(i))->~baseType(); |
| 514 } | 514 } |
| 515 CFX_BaseStack::RemoveAll(bLeaveMemory); | 515 CFX_BaseStack::RemoveAll(bLeaveMemory); |
| 516 } | 516 } |
| 517 FX_INT32» Copy(const CFX_ObjectStackTemplate &src, FX_INT32 iStart = 0, FX
_INT32 iCount = -1) | 517 int32_t» Copy(const CFX_ObjectStackTemplate &src, int32_t iStart = 0, int
32_t iCount = -1) |
| 518 { | 518 { |
| 519 if (iCount == 0) { | 519 if (iCount == 0) { |
| 520 return CFX_BaseStack::GetSize(); | 520 return CFX_BaseStack::GetSize(); |
| 521 } | 521 } |
| 522 FX_INT32 iSize = src.GetSize(); | 522 int32_t iSize = src.GetSize(); |
| 523 FXSYS_assert(iStart > -1 && iStart < iSize); | 523 FXSYS_assert(iStart > -1 && iStart < iSize); |
| 524 if (iCount < 0) { | 524 if (iCount < 0) { |
| 525 iCount = iSize; | 525 iCount = iSize; |
| 526 } | 526 } |
| 527 FX_INT32 iEnd = iStart + iCount; | 527 int32_t iEnd = iStart + iCount; |
| 528 if (iEnd > iSize) { | 528 if (iEnd > iSize) { |
| 529 iEnd = iSize; | 529 iEnd = iSize; |
| 530 } | 530 } |
| 531 RemoveAll(TRUE); | 531 RemoveAll(TRUE); |
| 532 for (FX_INT32 i = iStart; i < iEnd; i ++) { | 532 for (int32_t i = iStart; i < iEnd; i ++) { |
| 533 Push(*src.GetAt(i)); | 533 Push(*src.GetAt(i)); |
| 534 } | 534 } |
| 535 return CFX_BaseStack::GetSize(); | 535 return CFX_BaseStack::GetSize(); |
| 536 } | 536 } |
| 537 }; | 537 }; |
| 538 template<class baseType> | 538 template<class baseType> |
| 539 class CFX_CPLTreeNode : public CFX_Target | 539 class CFX_CPLTreeNode : public CFX_Target |
| 540 { | 540 { |
| 541 public: | 541 public: |
| 542 typedef CFX_CPLTreeNode<baseType> CPLTreeNode; | 542 typedef CFX_CPLTreeNode<baseType> CPLTreeNode; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 } | 652 } |
| 653 default: | 653 default: |
| 654 break; | 654 break; |
| 655 } | 655 } |
| 656 return NULL; | 656 return NULL; |
| 657 } | 657 } |
| 658 void SetParentNode(CPLTreeNode *pNode) | 658 void SetParentNode(CPLTreeNode *pNode) |
| 659 { | 659 { |
| 660 m_pParentNode = pNode; | 660 m_pParentNode = pNode; |
| 661 } | 661 } |
| 662 FX_INT32 CountChildNodes() const | 662 int32_t CountChildNodes() const |
| 663 { | 663 { |
| 664 FX_INT32 iCount = 0; | 664 int32_t iCount = 0; |
| 665 CPLTreeNode *pNode = m_pChildNode; | 665 CPLTreeNode *pNode = m_pChildNode; |
| 666 while (pNode) { | 666 while (pNode) { |
| 667 iCount ++; | 667 iCount ++; |
| 668 pNode = pNode->m_pNextNode; | 668 pNode = pNode->m_pNextNode; |
| 669 } | 669 } |
| 670 return iCount; | 670 return iCount; |
| 671 } | 671 } |
| 672 CPLTreeNode* GetChildNode(FX_INT32 iIndex) const | 672 CPLTreeNode* GetChildNode(int32_t iIndex) const |
| 673 { | 673 { |
| 674 FX_INT32 iCount = 0; | 674 int32_t iCount = 0; |
| 675 CPLTreeNode *pNode = m_pChildNode; | 675 CPLTreeNode *pNode = m_pChildNode; |
| 676 while (pNode) { | 676 while (pNode) { |
| 677 if (iIndex == iCount) { | 677 if (iIndex == iCount) { |
| 678 return pNode; | 678 return pNode; |
| 679 } | 679 } |
| 680 iCount ++; | 680 iCount ++; |
| 681 pNode = pNode->m_pNextNode; | 681 pNode = pNode->m_pNextNode; |
| 682 } | 682 } |
| 683 return NULL; | 683 return NULL; |
| 684 } | 684 } |
| 685 FX_INT32 GetNodeIndex() const | 685 int32_t GetNodeIndex() const |
| 686 { | 686 { |
| 687 FX_INT32 index = 0; | 687 int32_t index = 0; |
| 688 CPLTreeNode *pNode = m_pPrevNode; | 688 CPLTreeNode *pNode = m_pPrevNode; |
| 689 while (pNode != NULL) { | 689 while (pNode != NULL) { |
| 690 index ++; | 690 index ++; |
| 691 pNode = pNode->m_pPrevNode; | 691 pNode = pNode->m_pPrevNode; |
| 692 } | 692 } |
| 693 return index; | 693 return index; |
| 694 } | 694 } |
| 695 FX_BOOL IsParentNode(const CPLTreeNode *pNode) const | 695 FX_BOOL IsParentNode(const CPLTreeNode *pNode) const |
| 696 { | 696 { |
| 697 CPLTreeNode *pParent = m_pParentNode; | 697 CPLTreeNode *pParent = m_pParentNode; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 715 m_pChildNode = pNode; | 715 m_pChildNode = pNode; |
| 716 } | 716 } |
| 717 void SetPrevNode(CPLTreeNode *pNode) | 717 void SetPrevNode(CPLTreeNode *pNode) |
| 718 { | 718 { |
| 719 m_pPrevNode = pNode; | 719 m_pPrevNode = pNode; |
| 720 } | 720 } |
| 721 void SetNextNode(CPLTreeNode *pNode) | 721 void SetNextNode(CPLTreeNode *pNode) |
| 722 { | 722 { |
| 723 m_pNextNode = pNode; | 723 m_pNextNode = pNode; |
| 724 } | 724 } |
| 725 FX_INT32 GetNodeLevel() const | 725 int32_t GetNodeLevel() const |
| 726 { | 726 { |
| 727 FX_INT32 iLevel = 0; | 727 int32_t iLevel = 0; |
| 728 CPLTreeNode *pNode = (CPLTreeNode*)this; | 728 CPLTreeNode *pNode = (CPLTreeNode*)this; |
| 729 while ((pNode = pNode->m_pParentNode) != NULL) { | 729 while ((pNode = pNode->m_pParentNode) != NULL) { |
| 730 iLevel ++; | 730 iLevel ++; |
| 731 } | 731 } |
| 732 return iLevel; | 732 return iLevel; |
| 733 } | 733 } |
| 734 FX_BOOL IsRootNode() const | 734 FX_BOOL IsRootNode() const |
| 735 { | 735 { |
| 736 return m_pParentNode == NULL; | 736 return m_pParentNode == NULL; |
| 737 } | 737 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 CPLTreeNode *pLast = pParent->GetNode(CPLTreeNode::LastChild); | 789 CPLTreeNode *pLast = pParent->GetNode(CPLTreeNode::LastChild); |
| 790 pChild->SetPrevNode(pLast); | 790 pChild->SetPrevNode(pLast); |
| 791 pLast->SetNextNode(pChild); | 791 pLast->SetNextNode(pChild); |
| 792 } | 792 } |
| 793 return pChild; | 793 return pChild; |
| 794 } | 794 } |
| 795 protected: | 795 protected: |
| 796 CPLTreeNode m_Root; | 796 CPLTreeNode m_Root; |
| 797 }; | 797 }; |
| 798 #endif | 798 #endif |
| OLD | NEW |