| 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_BASIC_H_ | 7 #ifndef _FX_BASIC_H_ |
| 8 #define _FX_BASIC_H_ | 8 #define _FX_BASIC_H_ |
| 9 #ifndef _STDINT_H_ | |
| 10 #define _STDINT_H_ | |
| 11 #include <stdint.h> | |
| 12 #endif | |
| 13 #ifndef _FX_SYSTEM_H_ | 9 #ifndef _FX_SYSTEM_H_ |
| 14 #include "fx_system.h" | 10 #include "fx_system.h" |
| 15 #endif | 11 #endif |
| 16 #ifndef _FX_MEMORY_H_ | 12 #ifndef _FX_MEMORY_H_ |
| 17 #include "fx_memory.h" | 13 #include "fx_memory.h" |
| 18 #endif | 14 #endif |
| 19 #ifndef _FX_STRING_H_ | 15 #ifndef _FX_STRING_H_ |
| 20 #include "fx_string.h" | 16 #include "fx_string.h" |
| 21 #endif | 17 #endif |
| 22 #ifndef _FX_STREAM_H_ | 18 #ifndef _FX_STREAM_H_ |
| 23 #include "fx_stream.h" | 19 #include "fx_stream.h" |
| 24 #endif | 20 #endif |
| 25 | |
| 26 class CFX_BinaryBuf : public CFX_Object | 21 class CFX_BinaryBuf : public CFX_Object |
| 27 { | 22 { |
| 28 public: | 23 public: |
| 29 | 24 CFX_BinaryBuf(); |
| 30 CFX_BinaryBuf(IFX_Allocator* pAllocator = NULL); | 25 CFX_BinaryBuf(FX_STRSIZE size); |
| 31 | |
| 32 CFX_BinaryBuf(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL); | |
| 33 | 26 |
| 34 ~CFX_BinaryBuf(); | 27 ~CFX_BinaryBuf(); |
| 35 | 28 |
| 36 void Clear(); | 29 void Clear(); |
| 37 | 30 |
| 38 void EstimateSize(FX_STRSIZE size, FX
_STRSIZE alloc_step = 0); | 31 void EstimateSize(FX_STRSIZE size, FX
_STRSIZE alloc_step = 0); |
| 39 | 32 |
| 40 void AppendBlock(const void* pBuf, FX
_STRSIZE size); | 33 void AppendBlock(const void* pBuf, FX
_STRSIZE size); |
| 41 | 34 |
| 42 void AppendFill(FX_BYTE byte, FX_STRS
IZE count); | 35 void AppendFill(FX_BYTE byte, FX_STRS
IZE count); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 68 { | 61 { |
| 69 return m_pBuffer; | 62 return m_pBuffer; |
| 70 } | 63 } |
| 71 | 64 |
| 72 FX_STRSIZE GetSize() const | 65 FX_STRSIZE GetSize() const |
| 73 { | 66 { |
| 74 return m_DataSize; | 67 return m_DataSize; |
| 75 } | 68 } |
| 76 | 69 |
| 77 CFX_ByteStringC GetByteString() const; | 70 CFX_ByteStringC GetByteString() const; |
| 78 void GetByteStringL(CFX_ByteStringL &
str) const; | |
| 79 | 71 |
| 80 void DetachBuffer(); | 72 void DetachBuffer(); |
| 81 | |
| 82 IFX_Allocator* m_pAllocator; | |
| 83 protected: | 73 protected: |
| 84 | 74 |
| 85 FX_STRSIZE m_AllocStep; | 75 FX_STRSIZE m_AllocStep; |
| 86 | 76 |
| 87 FX_LPBYTE m_pBuffer; | 77 FX_LPBYTE m_pBuffer; |
| 88 | 78 |
| 89 FX_STRSIZE m_DataSize; | 79 FX_STRSIZE m_DataSize; |
| 90 | 80 |
| 91 FX_STRSIZE m_AllocSize; | 81 FX_STRSIZE m_AllocSize; |
| 92 | 82 |
| 93 void ExpandBuf(FX_STRSIZE size); | 83 void ExpandBuf(FX_STRSIZE size); |
| 94 }; | 84 }; |
| 95 class CFX_ByteTextBuf : public CFX_BinaryBuf | 85 class CFX_ByteTextBuf : public CFX_BinaryBuf |
| 96 { | 86 { |
| 97 public: | 87 public: |
| 98 | 88 |
| 99 CFX_ByteTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator
) {} | |
| 100 | |
| 101 void operator = (FX_BSTR str); | 89 void operator = (FX_BSTR str); |
| 102 | 90 |
| 103 void AppendChar(int ch) | 91 void AppendChar(int ch) |
| 104 { | 92 { |
| 105 AppendByte((FX_BYTE)ch); | 93 AppendByte((FX_BYTE)ch); |
| 106 } | 94 } |
| 107 | 95 |
| 108 CFX_ByteTextBuf& operator << (int i); | 96 CFX_ByteTextBuf& operator << (int i); |
| 109 | 97 |
| 110 CFX_ByteTextBuf& operator << (FX_DWORD i); | 98 CFX_ByteTextBuf& operator << (FX_DWORD i); |
| 111 | 99 |
| 112 CFX_ByteTextBuf& operator << (double f); | 100 CFX_ByteTextBuf& operator << (double f); |
| 113 | 101 |
| 114 CFX_ByteTextBuf& operator << (FX_BSTR lpsz); | 102 CFX_ByteTextBuf& operator << (FX_BSTR lpsz); |
| 115 | 103 |
| 116 CFX_ByteTextBuf& operator << (const CFX_ByteTextBuf& buf); | 104 CFX_ByteTextBuf& operator << (const CFX_ByteTextBuf& buf); |
| 117 | 105 |
| 118 FX_STRSIZE GetLength() const | 106 FX_STRSIZE GetLength() const |
| 119 { | 107 { |
| 120 return m_DataSize; | 108 return m_DataSize; |
| 121 } | 109 } |
| 122 }; | 110 }; |
| 123 class CFX_WideTextBuf : public CFX_BinaryBuf | 111 class CFX_WideTextBuf : public CFX_BinaryBuf |
| 124 { | 112 { |
| 125 public: | 113 public: |
| 126 | 114 |
| 127 CFX_WideTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator
) {} | |
| 128 | |
| 129 void operator = (FX_LPCWSTR lpsz); | 115 void operator = (FX_LPCWSTR lpsz); |
| 130 | 116 |
| 131 void operator = (FX_WSTR str); | 117 void operator = (FX_WSTR str); |
| 132 | 118 |
| 133 void AppendChar(FX_WCHAR wch); | 119 void AppendChar(FX_WCHAR wch); |
| 134 | 120 |
| 135 CFX_WideTextBuf& operator << (int i); | 121 CFX_WideTextBuf& operator << (int i); |
| 136 | 122 |
| 137 CFX_WideTextBuf& operator << (double f); | 123 CFX_WideTextBuf& operator << (double f); |
| 138 | 124 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 152 { | 138 { |
| 153 return (FX_LPWSTR)m_pBuffer; | 139 return (FX_LPWSTR)m_pBuffer; |
| 154 } | 140 } |
| 155 | 141 |
| 156 void Delete(int start_index, int coun
t) | 142 void Delete(int start_index, int coun
t) |
| 157 { | 143 { |
| 158 CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), count * sizeof(FX_
WCHAR)); | 144 CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), count * sizeof(FX_
WCHAR)); |
| 159 } | 145 } |
| 160 | 146 |
| 161 CFX_WideStringC GetWideString() const; | 147 CFX_WideStringC GetWideString() const; |
| 162 void GetWideStringL(CFX_WideStringL&
wideText) const; | |
| 163 }; | 148 }; |
| 164 class CFX_ArchiveSaver : public CFX_Object | 149 class CFX_ArchiveSaver : public CFX_Object |
| 165 { | 150 { |
| 166 public: | 151 public: |
| 167 | 152 CFX_ArchiveSaver() : m_pStream(NULL) {} |
| 168 CFX_ArchiveSaver(IFX_Allocator* pAllocator = NULL) : m_SavingBuf(pAllocator)
, m_pStream(NULL) {} | |
| 169 | 153 |
| 170 CFX_ArchiveSaver& operator << (FX_BYTE i); | 154 CFX_ArchiveSaver& operator << (FX_BYTE i); |
| 171 | 155 |
| 172 CFX_ArchiveSaver& operator << (int i); | 156 CFX_ArchiveSaver& operator << (int i); |
| 173 | 157 |
| 174 CFX_ArchiveSaver& operator << (FX_DWORD i); | 158 CFX_ArchiveSaver& operator << (FX_DWORD i); |
| 175 | 159 |
| 176 CFX_ArchiveSaver& operator << (FX_FLOAT i); | 160 CFX_ArchiveSaver& operator << (FX_FLOAT i); |
| 177 | 161 |
| 178 CFX_ArchiveSaver& operator << (double i); | 162 CFX_ArchiveSaver& operator << (double i); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 216 |
| 233 FX_DWORD m_LoadingPos; | 217 FX_DWORD m_LoadingPos; |
| 234 | 218 |
| 235 FX_LPCBYTE m_pLoadingBuf; | 219 FX_LPCBYTE m_pLoadingBuf; |
| 236 | 220 |
| 237 FX_DWORD m_LoadingSize; | 221 FX_DWORD m_LoadingSize; |
| 238 }; | 222 }; |
| 239 class IFX_BufferArchive | 223 class IFX_BufferArchive |
| 240 { | 224 { |
| 241 public: | 225 public: |
| 242 | 226 IFX_BufferArchive(FX_STRSIZE size); |
| 243 IFX_BufferArchive(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL); | |
| 244 | 227 |
| 245 | 228 |
| 246 virtual void Clear(); | 229 virtual void Clear(); |
| 247 | 230 |
| 248 | 231 |
| 249 FX_BOOL Flush(); | 232 FX_BOOL Flush(); |
| 250 | 233 |
| 251 | 234 |
| 252 FX_INT32 AppendBlock(const void* pBuf, size_t siz
e); | 235 FX_INT32 AppendBlock(const void* pBuf, size_t siz
e); |
| 253 | 236 |
| 254 FX_INT32 AppendByte(FX_BYTE byte); | 237 FX_INT32 AppendByte(FX_BYTE byte); |
| 255 | 238 |
| 256 FX_INT32 AppendDWord(FX_DWORD i); | 239 FX_INT32 AppendDWord(FX_DWORD i); |
| 257 | 240 |
| 258 | 241 |
| 259 FX_INT32 AppendString(FX_BSTR lpsz); | 242 FX_INT32 AppendString(FX_BSTR lpsz); |
| 260 | 243 |
| 261 protected: | 244 protected: |
| 262 | 245 |
| 263 virtual FX_BOOL DoWork(const void* pBuf, size_t size) =
0; | 246 virtual FX_BOOL DoWork(const void* pBuf, size_t size) =
0; |
| 264 | 247 |
| 265 | |
| 266 IFX_Allocator* m_pAllocator; | |
| 267 | |
| 268 FX_STRSIZE m_BufSize; | 248 FX_STRSIZE m_BufSize; |
| 269 | 249 |
| 270 FX_LPBYTE m_pBuffer; | 250 FX_LPBYTE m_pBuffer; |
| 271 | 251 |
| 272 FX_STRSIZE m_Length; | 252 FX_STRSIZE m_Length; |
| 273 }; | 253 }; |
| 274 class CFX_FileBufferArchive : public IFX_BufferArchive, public CFX_Object | 254 class CFX_FileBufferArchive : public IFX_BufferArchive, public CFX_Object |
| 275 { | 255 { |
| 276 public: | 256 public: |
| 277 CFX_FileBufferArchive(FX_STRSIZE size = 32768, IFX_Allocator* pAllocator = N
ULL); | 257 CFX_FileBufferArchive(FX_STRSIZE size = 32768); |
| 278 ~CFX_FileBufferArchive(); | 258 ~CFX_FileBufferArchive(); |
| 279 virtual void Clear(); | 259 virtual void Clear(); |
| 280 | 260 |
| 281 FX_BOOL AttachFile(IFX_StreamWrite *pFil
e, FX_BOOL bTakeover = FALSE); | 261 FX_BOOL AttachFile(IFX_StreamWrite *pFil
e, FX_BOOL bTakeover = FALSE); |
| 282 | 262 |
| 283 FX_BOOL AttachFile(FX_LPCWSTR filename); | 263 FX_BOOL AttachFile(FX_LPCWSTR filename); |
| 284 | 264 |
| 285 FX_BOOL AttachFile(FX_LPCSTR filename); | 265 FX_BOOL AttachFile(FX_LPCSTR filename); |
| 286 private: | 266 private: |
| 287 | 267 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 298 | 278 |
| 299 CFX_WideString (*m_GetWideString)(CFX_CharMap* pMap, const CFX_ByteStri
ng& bstr); | 279 CFX_WideString (*m_GetWideString)(CFX_CharMap* pMap, const CFX_ByteStri
ng& bstr); |
| 300 | 280 |
| 301 CFX_ByteString (*m_GetByteString)(CFX_CharMap* pMap, const CFX_WideStri
ng& wstr); | 281 CFX_ByteString (*m_GetByteString)(CFX_CharMap* pMap, const CFX_WideStri
ng& wstr); |
| 302 | 282 |
| 303 FX_INT32 (*m_GetCodePage)(); | 283 FX_INT32 (*m_GetCodePage)(); |
| 304 }; | 284 }; |
| 305 class CFX_UTF8Decoder | 285 class CFX_UTF8Decoder |
| 306 { | 286 { |
| 307 public: | 287 public: |
| 308 | 288 CFX_UTF8Decoder() |
| 309 CFX_UTF8Decoder(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator) | |
| 310 { | 289 { |
| 311 m_PendingBytes = 0; | 290 m_PendingBytes = 0; |
| 312 } | 291 } |
| 313 | 292 |
| 314 void Clear(); | 293 void Clear(); |
| 315 | 294 |
| 316 void Input(FX_BYTE byte); | 295 void Input(FX_BYTE byte); |
| 317 | 296 |
| 318 void AppendChar(FX_DWORD ch); | 297 void AppendChar(FX_DWORD ch); |
| 319 | 298 |
| 320 void ClearStatus() | 299 void ClearStatus() |
| 321 { | 300 { |
| 322 m_PendingBytes = 0; | 301 m_PendingBytes = 0; |
| 323 } | 302 } |
| 324 | 303 |
| 325 CFX_WideStringC GetResult() const | 304 CFX_WideStringC GetResult() const |
| 326 { | 305 { |
| 327 return m_Buffer.GetWideString(); | 306 return m_Buffer.GetWideString(); |
| 328 } | 307 } |
| 329 void GetResult(CFX_WideStringL &result) const | |
| 330 { | |
| 331 m_Buffer.GetWideStringL(result); | |
| 332 } | |
| 333 protected: | 308 protected: |
| 334 | 309 |
| 335 int m_PendingBytes; | 310 int m_PendingBytes; |
| 336 | 311 |
| 337 FX_DWORD m_PendingChar; | 312 FX_DWORD m_PendingChar; |
| 338 | 313 |
| 339 CFX_WideTextBuf m_Buffer; | 314 CFX_WideTextBuf m_Buffer; |
| 340 }; | 315 }; |
| 341 class CFX_UTF8Encoder | 316 class CFX_UTF8Encoder |
| 342 { | 317 { |
| 343 public: | 318 public: |
| 344 | 319 CFX_UTF8Encoder() |
| 345 CFX_UTF8Encoder(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator) | |
| 346 { | 320 { |
| 347 m_UTF16First = 0; | 321 m_UTF16First = 0; |
| 348 } | 322 } |
| 349 | 323 |
| 350 void Input(FX_WCHAR unicode); | 324 void Input(FX_WCHAR unicode); |
| 351 | 325 |
| 352 void AppendStr(FX_BSTR str) | 326 void AppendStr(FX_BSTR str) |
| 353 { | 327 { |
| 354 m_UTF16First = 0; | 328 m_UTF16First = 0; |
| 355 m_Buffer << str; | 329 m_Buffer << str; |
| 356 } | 330 } |
| 357 | 331 |
| 358 CFX_ByteStringC GetResult() const | 332 CFX_ByteStringC GetResult() const |
| 359 { | 333 { |
| 360 return m_Buffer.GetByteString(); | 334 return m_Buffer.GetByteString(); |
| 361 } | 335 } |
| 362 void GetResult(CFX_ByteStringL &result) const | |
| 363 { | |
| 364 m_Buffer.GetByteStringL(result); | |
| 365 } | |
| 366 protected: | 336 protected: |
| 367 | 337 |
| 368 CFX_ByteTextBuf m_Buffer; | 338 CFX_ByteTextBuf m_Buffer; |
| 369 | 339 |
| 370 FX_DWORD m_UTF16First; | 340 FX_DWORD m_UTF16First; |
| 371 }; | 341 }; |
| 372 CFX_ByteString FX_UrlEncode(const CFX_WideString& wsUrl); | 342 CFX_ByteString FX_UrlEncode(const CFX_WideString& wsUrl); |
| 373 CFX_WideString FX_UrlDecode(const CFX_ByteString& bsUrl); | 343 CFX_WideString FX_UrlDecode(const CFX_ByteString& bsUrl); |
| 374 CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI); | 344 CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI); |
| 375 CFX_WideString FX_DecodeURI(const CFX_ByteString& bsURI); | 345 CFX_WideString FX_DecodeURI(const CFX_ByteString& bsURI); |
| 376 class CFX_BasicArray : public CFX_Object | 346 class CFX_BasicArray : public CFX_Object |
| 377 { | 347 { |
| 378 public: | |
| 379 | |
| 380 IFX_Allocator* m_pAllocator; | |
| 381 protected: | 348 protected: |
| 382 | 349 CFX_BasicArray(int unit_size); |
| 383 CFX_BasicArray(int unit_size, IFX_Allocator* pAllocator = NULL); | |
| 384 | 350 |
| 385 ~CFX_BasicArray(); | 351 ~CFX_BasicArray(); |
| 386 | 352 |
| 387 FX_BOOL SetSize(int nNewSize, int nGrowBy); | 353 FX_BOOL SetSize(int nNewSize, int nGrowBy); |
| 388 | 354 |
| 389 FX_BOOL Append(const CFX_BasicArray& src); | 355 FX_BOOL Append(const CFX_BasicArray& src); |
| 390 | 356 |
| 391 FX_BOOL Copy(const CFX_BasicArray& src); | 357 FX_BOOL Copy(const CFX_BasicArray& src); |
| 392 | 358 |
| 393 FX_LPBYTE InsertSpaceAt(int nIndex, int nCount); | 359 FX_LPBYTE InsertSpaceAt(int nIndex, int nCount); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 406 int m_nMaxSize; | 372 int m_nMaxSize; |
| 407 | 373 |
| 408 int m_nGrowBy; | 374 int m_nGrowBy; |
| 409 | 375 |
| 410 int m_nUnitSize; | 376 int m_nUnitSize; |
| 411 }; | 377 }; |
| 412 template<class TYPE> | 378 template<class TYPE> |
| 413 class CFX_ArrayTemplate : public CFX_BasicArray | 379 class CFX_ArrayTemplate : public CFX_BasicArray |
| 414 { | 380 { |
| 415 public: | 381 public: |
| 416 | 382 CFX_ArrayTemplate() : CFX_BasicArray(sizeof(TYPE)) {} |
| 417 CFX_ArrayTemplate(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(
TYPE), pAllocator) {} | |
| 418 | 383 |
| 419 int GetSize() const | 384 int GetSize() const |
| 420 { | 385 { |
| 421 return m_nSize; | 386 return m_nSize; |
| 422 } | 387 } |
| 423 | 388 |
| 424 int GetUpperBound() const | 389 int GetUpperBound() const |
| 425 { | 390 { |
| 426 return m_nSize - 1; | 391 return m_nSize - 1; |
| 427 } | 392 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray; | 538 typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray; |
| 574 typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray; | 539 typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray; |
| 575 typedef CFX_ArrayTemplate<void*> CFX_PtrArray; | 540 typedef CFX_ArrayTemplate<void*> CFX_PtrArray; |
| 576 typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray; | 541 typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray; |
| 577 typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray; | 542 typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray; |
| 578 typedef CFX_ArrayTemplate<FX_INT32> CFX_Int32Array; | 543 typedef CFX_ArrayTemplate<FX_INT32> CFX_Int32Array; |
| 579 template <class ObjectClass> | 544 template <class ObjectClass> |
| 580 class CFX_ObjectArray : public CFX_BasicArray | 545 class CFX_ObjectArray : public CFX_BasicArray |
| 581 { | 546 { |
| 582 public: | 547 public: |
| 583 | 548 CFX_ObjectArray() : CFX_BasicArray(sizeof(ObjectClass)) {} |
| 584 CFX_ObjectArray(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(Ob
jectClass), pAllocator) {} | |
| 585 | 549 |
| 586 ~CFX_ObjectArray() | 550 ~CFX_ObjectArray() |
| 587 { | 551 { |
| 588 RemoveAll(); | 552 RemoveAll(); |
| 589 } | 553 } |
| 590 | 554 |
| 591 void Add(const ObjectClass& data) | 555 void Add(const ObjectClass& data) |
| 592 { | 556 { |
| 593 new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data); | 557 new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data); |
| 594 } | 558 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 ((ObjectClass*)GetDataPtr(i))->~ObjectClass(); | 654 ((ObjectClass*)GetDataPtr(i))->~ObjectClass(); |
| 691 } | 655 } |
| 692 CFX_BasicArray::SetSize(0, -1); | 656 CFX_BasicArray::SetSize(0, -1); |
| 693 } | 657 } |
| 694 }; | 658 }; |
| 695 typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray; | 659 typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray; |
| 696 typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray; | 660 typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray; |
| 697 class CFX_BaseSegmentedArray : public CFX_Object | 661 class CFX_BaseSegmentedArray : public CFX_Object |
| 698 { | 662 { |
| 699 public: | 663 public: |
| 700 | 664 CFX_BaseSegmentedArray(int unit_size = 1, int segment_units = 512, int index
_size = 8); |
| 701 CFX_BaseSegmentedArray(int unit_size = 1, int segment_units = 512, int index
_size = 8, IFX_Allocator* pAllocator = NULL); | |
| 702 | 665 |
| 703 ~CFX_BaseSegmentedArray(); | 666 ~CFX_BaseSegmentedArray(); |
| 704 | 667 |
| 705 void SetUnitSize(int unit_size, int segment_units, int index_size = 8
); | 668 void SetUnitSize(int unit_size, int segment_units, int index_size = 8
); |
| 706 | 669 |
| 707 void* Add(); | 670 void* Add(); |
| 708 | 671 |
| 709 void* GetAt(int index) const; | 672 void* GetAt(int index) const; |
| 710 | 673 |
| 711 void RemoveAll(); | 674 void RemoveAll(); |
| 712 | 675 |
| 713 void Delete(int index, int count = 1); | 676 void Delete(int index, int count = 1); |
| 714 | 677 |
| 715 int GetSize() const | 678 int GetSize() const |
| 716 { | 679 { |
| 717 return m_DataSize; | 680 return m_DataSize; |
| 718 } | 681 } |
| 719 | 682 |
| 720 int GetSegmentSize() const | 683 int GetSegmentSize() const |
| 721 { | 684 { |
| 722 return m_SegmentSize; | 685 return m_SegmentSize; |
| 723 } | 686 } |
| 724 | 687 |
| 725 int GetUnitSize() const | 688 int GetUnitSize() const |
| 726 { | 689 { |
| 727 return m_UnitSize; | 690 return m_UnitSize; |
| 728 } | 691 } |
| 729 | 692 |
| 730 void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* par
am) const; | 693 void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* par
am) const; |
| 731 | |
| 732 IFX_Allocator* m_pAllocator; | |
| 733 private: | 694 private: |
| 734 | 695 |
| 735 int m_UnitSize; | 696 int m_UnitSize; |
| 736 | 697 |
| 737 short m_SegmentSize; | 698 short m_SegmentSize; |
| 738 | 699 |
| 739 FX_BYTE m_IndexSize; | 700 FX_BYTE m_IndexSize; |
| 740 | 701 |
| 741 FX_BYTE m_IndexDepth; | 702 FX_BYTE m_IndexDepth; |
| 742 | 703 |
| 743 int m_DataSize; | 704 int m_DataSize; |
| 744 | 705 |
| 745 void* m_pIndex; | 706 void* m_pIndex; |
| 746 void** GetIndex(int seg_index) const; | 707 void** GetIndex(int seg_index) const; |
| 747 void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*cal
lback)(void* param, void* pData), void* param) const; | 708 void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*cal
lback)(void* param, void* pData), void* param) const; |
| 748 void* IterateSegment(FX_LPCBYTE pSegment, int count, FX_BOOL (*callbac
k)(void* param, void* pData), void* param) const; | 709 void* IterateSegment(FX_LPCBYTE pSegment, int count, FX_BOOL (*callbac
k)(void* param, void* pData), void* param) const; |
| 749 }; | 710 }; |
| 750 template <class ElementType> | 711 template <class ElementType> |
| 751 class CFX_SegmentedArray : public CFX_BaseSegmentedArray | 712 class CFX_SegmentedArray : public CFX_BaseSegmentedArray |
| 752 { | 713 { |
| 753 public: | 714 public: |
| 754 | 715 CFX_SegmentedArray(int segment_units, int index_size = 8) |
| 755 CFX_SegmentedArray(int segment_units, int index_size = 8, IFX_Allocator* pAl
locator = NULL) | 716 : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size) |
| 756 : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size,
pAllocator) | |
| 757 {} | 717 {} |
| 758 | 718 |
| 759 void Add(ElementType data) | 719 void Add(ElementType data) |
| 760 { | 720 { |
| 761 *(ElementType*)CFX_BaseSegmentedArray::Add() = data; | 721 *(ElementType*)CFX_BaseSegmentedArray::Add() = data; |
| 762 } | 722 } |
| 763 | 723 |
| 764 ElementType& operator [] (int index) | 724 ElementType& operator [] (int index) |
| 765 { | 725 { |
| 766 return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index); | 726 return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index); |
| 767 } | 727 } |
| 768 }; | 728 }; |
| 769 template <class DataType, int FixedSize> | 729 template <class DataType, int FixedSize> |
| 770 class CFX_FixedBufGrow : public CFX_Object | 730 class CFX_FixedBufGrow : public CFX_Object |
| 771 { | 731 { |
| 772 public: | 732 public: |
| 773 CFX_FixedBufGrow(IFX_Allocator* pAllocator = NULL) | 733 CFX_FixedBufGrow() : m_pData(NULL) |
| 774 : m_pAllocator(pAllocator) | |
| 775 , m_pData(NULL) | |
| 776 {} | 734 {} |
| 777 CFX_FixedBufGrow(int data_size, IFX_Allocator* pAllocator = NULL) | 735 CFX_FixedBufGrow(int data_size) : m_pData(NULL) |
| 778 : m_pAllocator(pAllocator) | |
| 779 , m_pData(NULL) | |
| 780 { | 736 { |
| 781 if (data_size > FixedSize) { | 737 if (data_size > FixedSize) { |
| 782 m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size); | 738 m_pData = FX_Alloc(DataType, data_size); |
| 783 } else { | 739 } else { |
| 784 if (FixedSize > SIZE_MAX/sizeof(DataType)) | |
| 785 return; | |
| 786 | |
| 787 FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize); | 740 FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize); |
| 788 } | 741 } |
| 789 } | 742 } |
| 790 void SetDataSize(int data_size) | 743 void SetDataSize(int data_size) |
| 791 { | 744 { |
| 792 if (m_pData) { | 745 if (m_pData) { |
| 793 FX_Allocator_Free(m_pAllocator, m_pData); | 746 FX_Free(m_pData); |
| 794 } | 747 } |
| 795 m_pData = NULL; | 748 m_pData = NULL; |
| 796 if (data_size > FixedSize) { | 749 if (data_size > FixedSize) { |
| 797 m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size); | 750 m_pData = FX_Alloc(DataType, data_size); |
| 798 } else { | 751 } else { |
| 799 | |
| 800 if (FixedSize > SIZE_MAX/sizeof(DataType)) | |
| 801 return; | |
| 802 | |
| 803 FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize); | 752 FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize); |
| 804 } | 753 } |
| 805 } | 754 } |
| 806 ~CFX_FixedBufGrow() | 755 ~CFX_FixedBufGrow() |
| 807 { | 756 { |
| 808 if (m_pData) { | 757 if (m_pData) { |
| 809 FX_Allocator_Free(m_pAllocator, m_pData); | 758 FX_Free(m_pData); |
| 810 } | 759 } |
| 811 } | 760 } |
| 812 operator DataType*() | 761 operator DataType*() |
| 813 { | 762 { |
| 814 return m_pData ? m_pData : m_Data; | 763 return m_pData ? m_pData : m_Data; |
| 815 } | 764 } |
| 816 private: | 765 private: |
| 817 IFX_Allocator* m_pAllocator; | |
| 818 DataType m_Data[FixedSize]; | 766 DataType m_Data[FixedSize]; |
| 819 DataType* m_pData; | 767 DataType* m_pData; |
| 820 }; | 768 }; |
| 821 template <class DataType> | 769 template <class DataType> |
| 822 class CFX_TempBuf | 770 class CFX_TempBuf |
| 823 { | 771 { |
| 824 public: | 772 public: |
| 825 CFX_TempBuf(int size, IFX_Allocator* pAllocator = NULL) : m_pAllocator(pAllo
cator) | 773 CFX_TempBuf(int size) |
| 826 { | 774 { |
| 827 m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, size); | 775 m_pData = FX_Alloc(DataType, size); |
| 828 } | 776 } |
| 829 ~CFX_TempBuf() | 777 ~CFX_TempBuf() |
| 830 { | 778 { |
| 831 if (m_pData) { | 779 if (m_pData) { |
| 832 FX_Allocator_Free(m_pAllocator, m_pData); | 780 FX_Free(m_pData); |
| 833 } | 781 } |
| 834 } | 782 } |
| 835 DataType& operator[](int i) | 783 DataType& operator[](int i) |
| 836 { | 784 { |
| 837 FXSYS_assert(m_pData != NULL); | 785 FXSYS_assert(m_pData != NULL); |
| 838 return m_pData[i]; | 786 return m_pData[i]; |
| 839 } | 787 } |
| 840 operator DataType*() | 788 operator DataType*() |
| 841 { | 789 { |
| 842 return m_pData; | 790 return m_pData; |
| 843 } | 791 } |
| 844 private: | 792 private: |
| 845 IFX_Allocator* m_pAllocator; | |
| 846 DataType* m_pData; | 793 DataType* m_pData; |
| 847 }; | 794 }; |
| 848 class CFX_MapPtrToPtr : public CFX_Object | 795 class CFX_MapPtrToPtr : public CFX_Object |
| 849 { | 796 { |
| 850 protected: | 797 protected: |
| 851 | 798 |
| 852 struct CAssoc { | 799 struct CAssoc { |
| 853 | 800 |
| 854 CAssoc* pNext; | 801 CAssoc* pNext; |
| 855 | 802 |
| 856 void* key; | 803 void* key; |
| 857 | 804 |
| 858 void* value; | 805 void* value; |
| 859 }; | 806 }; |
| 860 public: | 807 public: |
| 861 | 808 CFX_MapPtrToPtr(int nBlockSize = 10); |
| 862 CFX_MapPtrToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL); | |
| 863 | 809 |
| 864 ~CFX_MapPtrToPtr(); | 810 ~CFX_MapPtrToPtr(); |
| 865 | 811 |
| 866 int GetCount() const | 812 int GetCount() const |
| 867 { | 813 { |
| 868 return m_nCount; | 814 return m_nCount; |
| 869 } | 815 } |
| 870 | 816 |
| 871 FX_BOOL IsEmpty() const | 817 FX_BOOL IsEmpty() const |
| 872 { | 818 { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 896 void GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) co
nst; | 842 void GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) co
nst; |
| 897 | 843 |
| 898 FX_DWORD GetHashTableSize() const | 844 FX_DWORD GetHashTableSize() const |
| 899 { | 845 { |
| 900 return m_nHashTableSize; | 846 return m_nHashTableSize; |
| 901 } | 847 } |
| 902 | 848 |
| 903 void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE); | 849 void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE); |
| 904 protected: | 850 protected: |
| 905 | 851 |
| 906 IFX_Allocator* m_pAllocator; | |
| 907 | |
| 908 CAssoc** m_pHashTable; | 852 CAssoc** m_pHashTable; |
| 909 | 853 |
| 910 FX_DWORD m_nHashTableSize; | 854 FX_DWORD m_nHashTableSize; |
| 911 | 855 |
| 912 int m_nCount; | 856 int m_nCount; |
| 913 | 857 |
| 914 CAssoc* m_pFreeList; | 858 CAssoc* m_pFreeList; |
| 915 | 859 |
| 916 struct CFX_Plex* m_pBlocks; | 860 struct CFX_Plex* m_pBlocks; |
| 917 | 861 |
| 918 int m_nBlockSize; | 862 int m_nBlockSize; |
| 919 | 863 |
| 920 FX_DWORD HashKey(void* key) const; | 864 FX_DWORD HashKey(void* key) const; |
| 921 | 865 |
| 922 CAssoc* NewAssoc(); | 866 CAssoc* NewAssoc(); |
| 923 | 867 |
| 924 void FreeAssoc(CAssoc* pAssoc); | 868 void FreeAssoc(CAssoc* pAssoc); |
| 925 | 869 |
| 926 CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const; | 870 CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const; |
| 927 }; | 871 }; |
| 928 template <class KeyType, class ValueType> | 872 template <class KeyType, class ValueType> |
| 929 class CFX_MapPtrTemplate : public CFX_MapPtrToPtr | 873 class CFX_MapPtrTemplate : public CFX_MapPtrToPtr |
| 930 { | 874 { |
| 931 public: | 875 public: |
| 932 | 876 CFX_MapPtrTemplate() : CFX_MapPtrToPtr(10) {} |
| 933 CFX_MapPtrTemplate(IFX_Allocator* pAllocator = NULL) : CFX_MapPtrToPtr(10, p
Allocator) {} | |
| 934 | 877 |
| 935 FX_BOOL Lookup(KeyType key, ValueType& rValue) const | 878 FX_BOOL Lookup(KeyType key, ValueType& rValue) const |
| 936 { | 879 { |
| 937 FX_LPVOID pValue = NULL; | 880 FX_LPVOID pValue = NULL; |
| 938 if (!CFX_MapPtrToPtr::Lookup((void*)(FX_UINTPTR)key, pValue)) { | 881 if (!CFX_MapPtrToPtr::Lookup((void*)(FX_UINTPTR)key, pValue)) { |
| 939 return FALSE; | 882 return FALSE; |
| 940 } | 883 } |
| 941 rValue = (ValueType)(FX_UINTPTR)pValue; | 884 rValue = (ValueType)(FX_UINTPTR)pValue; |
| 942 return TRUE; | 885 return TRUE; |
| 943 } | 886 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 963 void* pValue = NULL; | 906 void* pValue = NULL; |
| 964 CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue); | 907 CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue); |
| 965 rKey = (KeyType)(FX_UINTPTR)pKey; | 908 rKey = (KeyType)(FX_UINTPTR)pKey; |
| 966 rValue = (ValueType)(FX_UINTPTR)pValue; | 909 rValue = (ValueType)(FX_UINTPTR)pValue; |
| 967 } | 910 } |
| 968 }; | 911 }; |
| 969 class CFX_CMapDWordToDWord : public CFX_Object | 912 class CFX_CMapDWordToDWord : public CFX_Object |
| 970 { | 913 { |
| 971 public: | 914 public: |
| 972 | 915 |
| 973 CFX_CMapDWordToDWord(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator
) {} | |
| 974 | |
| 975 FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const; | 916 FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const; |
| 976 | 917 |
| 977 void SetAt(FX_DWORD key, FX_DWORD value); | 918 void SetAt(FX_DWORD key, FX_DWORD value); |
| 978 | 919 |
| 979 void EstimateSize(FX_DWORD size, FX_DWORD grow_by); | 920 void EstimateSize(FX_DWORD size, FX_DWORD grow_by); |
| 980 | 921 |
| 981 FX_POSITION GetStartPosition() const; | 922 FX_POSITION GetStartPosition() const; |
| 982 | 923 |
| 983 void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX
_DWORD& value) const; | 924 void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX
_DWORD& value) const; |
| 984 protected: | 925 protected: |
| 985 | 926 |
| 986 CFX_BinaryBuf m_Buffer; | 927 CFX_BinaryBuf m_Buffer; |
| 987 }; | 928 }; |
| 988 class CFX_MapByteStringToPtr : public CFX_Object | 929 class CFX_MapByteStringToPtr : public CFX_Object |
| 989 { | 930 { |
| 990 protected: | 931 protected: |
| 991 | 932 |
| 992 struct CAssoc { | 933 struct CAssoc { |
| 993 | 934 |
| 994 CAssoc* pNext; | 935 CAssoc* pNext; |
| 995 | 936 |
| 996 FX_DWORD nHashValue; | 937 FX_DWORD nHashValue; |
| 997 | 938 |
| 998 CFX_ByteString key; | 939 CFX_ByteString key; |
| 999 | 940 |
| 1000 void* value; | 941 void* value; |
| 1001 }; | 942 }; |
| 1002 public: | 943 public: |
| 1003 | 944 CFX_MapByteStringToPtr(int nBlockSize = 10); |
| 1004 CFX_MapByteStringToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL
); | |
| 1005 | 945 |
| 1006 int GetCount() const | 946 int GetCount() const |
| 1007 { | 947 { |
| 1008 return m_nCount; | 948 return m_nCount; |
| 1009 } | 949 } |
| 1010 | 950 |
| 1011 FX_BOOL IsEmpty() const | 951 FX_BOOL IsEmpty() const |
| 1012 { | 952 { |
| 1013 return m_nCount == 0; | 953 return m_nCount == 0; |
| 1014 } | 954 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1038 FX_DWORD GetHashTableSize() const | 978 FX_DWORD GetHashTableSize() const |
| 1039 { | 979 { |
| 1040 return m_nHashTableSize; | 980 return m_nHashTableSize; |
| 1041 } | 981 } |
| 1042 | 982 |
| 1043 void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE); | 983 void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE); |
| 1044 | 984 |
| 1045 FX_DWORD HashKey(FX_BSTR key) const; | 985 FX_DWORD HashKey(FX_BSTR key) const; |
| 1046 protected: | 986 protected: |
| 1047 | 987 |
| 1048 IFX_Allocator* m_pAllocator; | |
| 1049 | |
| 1050 CAssoc** m_pHashTable; | 988 CAssoc** m_pHashTable; |
| 1051 | 989 |
| 1052 FX_DWORD m_nHashTableSize; | 990 FX_DWORD m_nHashTableSize; |
| 1053 | 991 |
| 1054 int m_nCount; | 992 int m_nCount; |
| 1055 | 993 |
| 1056 CAssoc* m_pFreeList; | 994 CAssoc* m_pFreeList; |
| 1057 | 995 |
| 1058 struct CFX_Plex* m_pBlocks; | 996 struct CFX_Plex* m_pBlocks; |
| 1059 | 997 |
| 1060 int m_nBlockSize; | 998 int m_nBlockSize; |
| 1061 | 999 |
| 1062 CAssoc* NewAssoc(); | 1000 CAssoc* NewAssoc(); |
| 1063 | 1001 |
| 1064 void FreeAssoc(CAssoc* pAssoc); | 1002 void FreeAssoc(CAssoc* pAssoc); |
| 1065 | 1003 |
| 1066 CAssoc* GetAssocAt(FX_BSTR key, FX_DWORD& hash) const; | 1004 CAssoc* GetAssocAt(FX_BSTR key, FX_DWORD& hash) const; |
| 1067 public: | 1005 public: |
| 1068 | 1006 |
| 1069 ~CFX_MapByteStringToPtr(); | 1007 ~CFX_MapByteStringToPtr(); |
| 1070 }; | 1008 }; |
| 1071 class CFX_CMapByteStringToPtr : public CFX_Object | 1009 class CFX_CMapByteStringToPtr : public CFX_Object |
| 1072 { | 1010 { |
| 1073 public: | 1011 public: |
| 1074 | 1012 CFX_CMapByteStringToPtr(); |
| 1075 CFX_CMapByteStringToPtr(IFX_Allocator* pAllocator = NULL); | |
| 1076 | 1013 |
| 1077 ~CFX_CMapByteStringToPtr(); | 1014 ~CFX_CMapByteStringToPtr(); |
| 1078 | 1015 |
| 1079 void RemoveAll(); | 1016 void RemoveAll(); |
| 1080 | 1017 |
| 1081 FX_POSITION GetStartPosition() const; | 1018 FX_POSITION GetStartPosition() const; |
| 1082 | 1019 |
| 1083 void GetNextAssoc(FX_POSITION& rNextPosition, CFX_Byt
eString& rKey, void*& rValue) const; | 1020 void GetNextAssoc(FX_POSITION& rNextPosition, CFX_Byt
eString& rKey, void*& rValue) const; |
| 1084 | 1021 |
| 1085 FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const; | 1022 FX_LPVOID GetNextValue(FX_POSITION& rNextPosition) const; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1103 | 1040 |
| 1104 struct CNode { | 1041 struct CNode { |
| 1105 | 1042 |
| 1106 CNode* pNext; | 1043 CNode* pNext; |
| 1107 | 1044 |
| 1108 CNode* pPrev; | 1045 CNode* pPrev; |
| 1109 | 1046 |
| 1110 void* data; | 1047 void* data; |
| 1111 }; | 1048 }; |
| 1112 public: | 1049 public: |
| 1113 | 1050 CFX_PtrList(int nBlockSize = 10); |
| 1114 CFX_PtrList(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL); | |
| 1115 | 1051 |
| 1116 FX_POSITION GetHeadPosition() const | 1052 FX_POSITION GetHeadPosition() const |
| 1117 { | 1053 { |
| 1118 return (FX_POSITION)m_pNodeHead; | 1054 return (FX_POSITION)m_pNodeHead; |
| 1119 } | 1055 } |
| 1120 | 1056 |
| 1121 FX_POSITION GetTailPosition() const | 1057 FX_POSITION GetTailPosition() const |
| 1122 { | 1058 { |
| 1123 return (FX_POSITION)m_pNodeTail; | 1059 return (FX_POSITION)m_pNodeTail; |
| 1124 } | 1060 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 | 1108 |
| 1173 FX_POSITION Find(void* searchValue, FX_POSITION startAfter = NULL ) const; | 1109 FX_POSITION Find(void* searchValue, FX_POSITION startAfter = NULL ) const; |
| 1174 | 1110 |
| 1175 FX_POSITION FindIndex(int index) const; | 1111 FX_POSITION FindIndex(int index) const; |
| 1176 | 1112 |
| 1177 void RemoveAt(FX_POSITION pos); | 1113 void RemoveAt(FX_POSITION pos); |
| 1178 | 1114 |
| 1179 void RemoveAll(); | 1115 void RemoveAll(); |
| 1180 protected: | 1116 protected: |
| 1181 | 1117 |
| 1182 IFX_Allocator* m_pAllocator; | |
| 1183 | |
| 1184 CNode* m_pNodeHead; | 1118 CNode* m_pNodeHead; |
| 1185 | 1119 |
| 1186 CNode* m_pNodeTail; | 1120 CNode* m_pNodeTail; |
| 1187 | 1121 |
| 1188 int m_nCount; | 1122 int m_nCount; |
| 1189 | 1123 |
| 1190 CNode* m_pNodeFree; | 1124 CNode* m_pNodeFree; |
| 1191 | 1125 |
| 1192 struct CFX_Plex* m_pBlocks; | 1126 struct CFX_Plex* m_pBlocks; |
| 1193 | 1127 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1210 FX_LPVOID m_pData; | 1144 FX_LPVOID m_pData; |
| 1211 | 1145 |
| 1212 PD_CALLBACK_FREEDATA m_pCallback; | 1146 PD_CALLBACK_FREEDATA m_pCallback; |
| 1213 | 1147 |
| 1214 FX_BOOL m_bSelfDestruct; | 1148 FX_BOOL m_bSelfDestruct; |
| 1215 }; | 1149 }; |
| 1216 class CFX_PrivateData | 1150 class CFX_PrivateData |
| 1217 { | 1151 { |
| 1218 public: | 1152 public: |
| 1219 | 1153 |
| 1220 CFX_PrivateData(IFX_Allocator* pAllocator = NULL) : m_DataList(pAllocator) {
} | |
| 1221 | |
| 1222 ~CFX_PrivateData(); | 1154 ~CFX_PrivateData(); |
| 1223 | 1155 |
| 1224 void ClearAll(); | 1156 void ClearAll(); |
| 1225 | 1157 |
| 1226 void SetPrivateData(FX_LPVOID module_
id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback); | 1158 void SetPrivateData(FX_LPVOID module_
id, FX_LPVOID pData, PD_CALLBACK_FREEDATA callback); |
| 1227 | 1159 |
| 1228 void SetPrivateObj(FX_LPVOID module_i
d, CFX_DestructObject* pObj); | 1160 void SetPrivateObj(FX_LPVOID module_i
d, CFX_DestructObject* pObj); |
| 1229 | 1161 |
| 1230 FX_LPVOID GetPrivateData(FX_LPVOID module_id); | 1162 FX_LPVOID GetPrivateData(FX_LPVOID module_id); |
| 1231 | 1163 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 | 1432 |
| 1501 struct DataList { | 1433 struct DataList { |
| 1502 | 1434 |
| 1503 FX_INT32 start; | 1435 FX_INT32 start; |
| 1504 | 1436 |
| 1505 FX_INT32 count; | 1437 FX_INT32 count; |
| 1506 FX_LPBYTE data; | 1438 FX_LPBYTE data; |
| 1507 }; | 1439 }; |
| 1508 public: | 1440 public: |
| 1509 | 1441 |
| 1510 CFX_SortListArray(IFX_Allocator* pAllocator = NULL) : m_CurList(0), m_DataLi
sts(pAllocator) {} | 1442 CFX_SortListArray() : m_CurList(0) {} |
| 1511 | 1443 |
| 1512 ~CFX_SortListArray() | 1444 ~CFX_SortListArray() |
| 1513 { | 1445 { |
| 1514 Clear(); | 1446 Clear(); |
| 1515 } | 1447 } |
| 1516 | 1448 |
| 1517 | 1449 |
| 1518 void Clear() | 1450 void Clear() |
| 1519 { | 1451 { |
| 1520 IFX_Allocator* pAllocator = m_DataLists.m_pAllocator; | |
| 1521 for (FX_INT32 i = m_DataLists.GetUpperBound(); i >= 0; i--) { | 1452 for (FX_INT32 i = m_DataLists.GetUpperBound(); i >= 0; i--) { |
| 1522 DataList list = m_DataLists.ElementAt(i); | 1453 DataList list = m_DataLists.ElementAt(i); |
| 1523 if (list.data) { | 1454 if (list.data) { |
| 1524 FX_Allocator_Free(pAllocator, list.data); | 1455 FX_Free(list.data); |
| 1525 } | 1456 } |
| 1526 } | 1457 } |
| 1527 m_DataLists.RemoveAll(); | 1458 m_DataLists.RemoveAll(); |
| 1528 m_CurList = 0; | 1459 m_CurList = 0; |
| 1529 } | 1460 } |
| 1530 | 1461 |
| 1531 void Append(FX_INT32 nStart, FX_INT32 nCount) | 1462 void Append(FX_INT32 nStart, FX_INT32 nCount) |
| 1532 { | 1463 { |
| 1533 if (nStart < 0) { | 1464 if (nStart < 0) { |
| 1534 return; | 1465 return; |
| 1535 } | 1466 } |
| 1536 IFX_Allocator* pAllocator = m_DataLists.m_pAllocator; | |
| 1537 while (nCount > 0) { | 1467 while (nCount > 0) { |
| 1538 FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH); | 1468 FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH); |
| 1539 DataList list; | 1469 DataList list; |
| 1540 list.data = FX_Allocator_Alloc(pAllocator, FX_BYTE, temp_count * uni
t); | 1470 list.data = FX_Alloc(FX_BYTE, temp_count * unit); |
| 1541 if (!list.data) { | 1471 if (!list.data) { |
| 1542 break; | 1472 break; |
| 1543 } | 1473 } |
| 1544 FXSYS_memset32(list.data, 0, temp_count * unit); | |
| 1545 list.start = nStart; | 1474 list.start = nStart; |
| 1546 list.count = temp_count; | 1475 list.count = temp_count; |
| 1547 Append(list); | 1476 Append(list); |
| 1548 nCount -= temp_count; | 1477 nCount -= temp_count; |
| 1549 nStart += temp_count; | 1478 nStart += temp_count; |
| 1550 } | 1479 } |
| 1551 } | 1480 } |
| 1552 | 1481 |
| 1553 FX_LPBYTE GetAt(FX_INT32 nIndex) | 1482 FX_LPBYTE GetAt(FX_INT32 nIndex) |
| 1554 { | 1483 { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 Ready, | 1574 Ready, |
| 1646 ToBeContinued, | 1575 ToBeContinued, |
| 1647 Found, | 1576 Found, |
| 1648 NotFound, | 1577 NotFound, |
| 1649 Failed, | 1578 Failed, |
| 1650 Done | 1579 Done |
| 1651 } FX_ProgressiveStatus; | 1580 } FX_ProgressiveStatus; |
| 1652 #define ProgressiveStatus FX_ProgressiveStatus | 1581 #define ProgressiveStatus FX_ProgressiveStatus |
| 1653 #define FX_NAMESPACE_DECLARE(namespace, type) namespace::type | 1582 #define FX_NAMESPACE_DECLARE(namespace, type) namespace::type |
| 1654 #endif | 1583 #endif |
| OLD | NEW |