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 CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 7 #ifndef CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
8 #define CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 8 #define CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
9 | 9 |
10 #include "fx_memory.h" | 10 #include "fx_memory.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 CFX_ArchiveLoader& operator >> (FX_DWORD& i); | 211 CFX_ArchiveLoader& operator >> (FX_DWORD& i); |
212 | 212 |
213 CFX_ArchiveLoader& operator >> (FX_FLOAT& i); | 213 CFX_ArchiveLoader& operator >> (FX_FLOAT& i); |
214 | 214 |
215 CFX_ArchiveLoader& operator >> (double& i); | 215 CFX_ArchiveLoader& operator >> (double& i); |
216 | 216 |
217 CFX_ArchiveLoader& operator >> (CFX_ByteString& bstr); | 217 CFX_ArchiveLoader& operator >> (CFX_ByteString& bstr); |
218 | 218 |
219 CFX_ArchiveLoader& operator >> (CFX_WideString& wstr); | 219 CFX_ArchiveLoader& operator >> (CFX_WideString& wstr); |
220 | 220 |
221 FX_BOOL» » » » » IsEOF(); | 221 bool» » » » » IsEOF(); |
222 | 222 |
223 FX_BOOL» » » » » Read(void* pBuf, FX_DWORD dwSize
); | 223 bool» » » » » Read(void* pBuf, FX_DWORD dwSize
); |
224 protected: | 224 protected: |
225 | 225 |
226 FX_DWORD m_LoadingPos; | 226 FX_DWORD m_LoadingPos; |
227 | 227 |
228 const uint8_t* m_pLoadingBuf; | 228 const uint8_t* m_pLoadingBuf; |
229 | 229 |
230 FX_DWORD m_LoadingSize; | 230 FX_DWORD m_LoadingSize; |
231 | 231 |
232 }; | 232 }; |
233 | 233 |
234 class IFX_BufferArchive | 234 class IFX_BufferArchive |
235 { | 235 { |
236 public: | 236 public: |
237 IFX_BufferArchive(FX_STRSIZE size); | 237 IFX_BufferArchive(FX_STRSIZE size); |
238 virtual ~IFX_BufferArchive() {} | 238 virtual ~IFX_BufferArchive() {} |
239 | 239 |
240 virtual void Clear(); | 240 virtual void Clear(); |
241 | 241 |
242 FX_BOOL Flush(); | 242 bool Flush(); |
243 | 243 |
244 int32_t AppendBlock(const void* pBuf, size_t size); | 244 int32_t AppendBlock(const void* pBuf, size_t size); |
245 | 245 |
246 int32_t AppendByte(uint8_t byte); | 246 int32_t AppendByte(uint8_t byte); |
247 | 247 |
248 int32_t AppendDWord(FX_DWORD i); | 248 int32_t AppendDWord(FX_DWORD i); |
249 | 249 |
250 | 250 |
251 int32_t AppendString(const CFX_ByteStringC& lpsz); | 251 int32_t AppendString(const CFX_ByteStringC& lpsz); |
252 | 252 |
253 protected: | 253 protected: |
254 | 254 |
255 virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0; | 255 virtual bool DoWork(const void* pBuf, size_t size) = 0; |
256 | 256 |
257 FX_STRSIZE m_BufSize; | 257 FX_STRSIZE m_BufSize; |
258 | 258 |
259 uint8_t* m_pBuffer; | 259 uint8_t* m_pBuffer; |
260 | 260 |
261 FX_STRSIZE m_Length; | 261 FX_STRSIZE m_Length; |
262 }; | 262 }; |
263 | 263 |
264 class CFX_FileBufferArchive : public IFX_BufferArchive | 264 class CFX_FileBufferArchive : public IFX_BufferArchive |
265 { | 265 { |
266 public: | 266 public: |
267 CFX_FileBufferArchive(FX_STRSIZE size = 32768); | 267 CFX_FileBufferArchive(FX_STRSIZE size = 32768); |
268 ~CFX_FileBufferArchive() override; | 268 ~CFX_FileBufferArchive() override; |
269 | 269 |
270 void Clear() override; | 270 void Clear() override; |
271 | 271 |
272 FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover = FALSE); | 272 bool AttachFile(IFX_StreamWrite *pFile, bool bTakeover = false); |
273 | 273 |
274 FX_BOOL AttachFile(const FX_WCHAR* filename); | 274 bool AttachFile(const FX_WCHAR* filename); |
275 | 275 |
276 FX_BOOL AttachFile(const FX_CHAR* filename); | 276 bool AttachFile(const FX_CHAR* filename); |
277 | 277 |
278 private: | 278 private: |
279 FX_BOOL DoWork(const void* pBuf, size_t size) override; | 279 bool DoWork(const void* pBuf, size_t size) override; |
280 | 280 |
281 IFX_StreamWrite* m_pFile; | 281 IFX_StreamWrite* m_pFile; |
282 | 282 |
283 FX_BOOL m_bTakeover; | 283 bool m_bTakeover; |
284 }; | 284 }; |
285 | 285 |
286 struct CFX_CharMap { | 286 struct CFX_CharMap { |
287 | 287 |
288 static CFX_CharMap* GetDefaultMapper(int32_t codepage = 0); | 288 static CFX_CharMap* GetDefaultMapper(int32_t codepage = 0); |
289 | 289 |
290 | 290 |
291 CFX_WideString (*m_GetWideString)(CFX_CharMap* pMap, const CFX_ByteStri
ng& bstr); | 291 CFX_WideString (*m_GetWideString)(CFX_CharMap* pMap, const CFX_ByteStri
ng& bstr); |
292 | 292 |
293 CFX_ByteString (*m_GetByteString)(CFX_CharMap* pMap, const CFX_WideStri
ng& wstr); | 293 CFX_ByteString (*m_GetByteString)(CFX_CharMap* pMap, const CFX_WideStri
ng& wstr); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 CFX_WideString FX_UrlDecode(const CFX_ByteString& bsUrl); | 355 CFX_WideString FX_UrlDecode(const CFX_ByteString& bsUrl); |
356 CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI); | 356 CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI); |
357 CFX_WideString FX_DecodeURI(const CFX_ByteString& bsURI); | 357 CFX_WideString FX_DecodeURI(const CFX_ByteString& bsURI); |
358 class CFX_BasicArray | 358 class CFX_BasicArray |
359 { | 359 { |
360 protected: | 360 protected: |
361 CFX_BasicArray(int unit_size); | 361 CFX_BasicArray(int unit_size); |
362 | 362 |
363 ~CFX_BasicArray(); | 363 ~CFX_BasicArray(); |
364 | 364 |
365 FX_BOOL» » » SetSize(int nNewSize); | 365 bool» » » SetSize(int nNewSize); |
366 | 366 |
367 FX_BOOL» » » Append(const CFX_BasicArray& src); | 367 bool» » » Append(const CFX_BasicArray& src); |
368 | 368 |
369 FX_BOOL» » » Copy(const CFX_BasicArray& src); | 369 bool» » » Copy(const CFX_BasicArray& src); |
370 | 370 |
371 uint8_t* InsertSpaceAt(int nIndex, int nCount); | 371 uint8_t* InsertSpaceAt(int nIndex, int nCount); |
372 | 372 |
373 FX_BOOL» » » RemoveAt(int nIndex, int nCount); | 373 bool» » » RemoveAt(int nIndex, int nCount); |
374 | 374 |
375 FX_BOOL» » » InsertAt(int nStartIndex, const CFX_BasicArray*
pNewArray); | 375 bool» » » InsertAt(int nStartIndex, const CFX_BasicArray*
pNewArray); |
376 | 376 |
377 const void* GetDataPtr(int index) const; | 377 const void* GetDataPtr(int index) const; |
378 protected: | 378 protected: |
379 | 379 |
380 uint8_t* m_pData; | 380 uint8_t* m_pData; |
381 | 381 |
382 int m_nSize; | 382 int m_nSize; |
383 | 383 |
384 int m_nMaxSize; | 384 int m_nMaxSize; |
385 | 385 |
386 int m_nUnitSize; | 386 int m_nUnitSize; |
387 }; | 387 }; |
388 template<class TYPE> | 388 template<class TYPE> |
389 class CFX_ArrayTemplate : public CFX_BasicArray | 389 class CFX_ArrayTemplate : public CFX_BasicArray |
390 { | 390 { |
391 public: | 391 public: |
392 CFX_ArrayTemplate() : CFX_BasicArray(sizeof(TYPE)) {} | 392 CFX_ArrayTemplate() : CFX_BasicArray(sizeof(TYPE)) {} |
393 | 393 |
394 int GetSize() const | 394 int GetSize() const |
395 { | 395 { |
396 return m_nSize; | 396 return m_nSize; |
397 } | 397 } |
398 | 398 |
399 int GetUpperBound() const | 399 int GetUpperBound() const |
400 { | 400 { |
401 return m_nSize - 1; | 401 return m_nSize - 1; |
402 } | 402 } |
403 | 403 |
404 FX_BOOL» » SetSize(int nNewSize) | 404 bool» » SetSize(int nNewSize) |
405 { | 405 { |
406 return CFX_BasicArray::SetSize(nNewSize); | 406 return CFX_BasicArray::SetSize(nNewSize); |
407 } | 407 } |
408 | 408 |
409 void RemoveAll() | 409 void RemoveAll() |
410 { | 410 { |
411 SetSize(0); | 411 SetSize(0); |
412 } | 412 } |
413 | 413 |
414 const TYPE GetAt(int nIndex) const | 414 const TYPE GetAt(int nIndex) const |
415 { | 415 { |
416 if (nIndex < 0 || nIndex >= m_nSize) { | 416 if (nIndex < 0 || nIndex >= m_nSize) { |
417 return (const TYPE&)(*(volatile const TYPE*)NULL); | 417 return (const TYPE&)(*(volatile const TYPE*)NULL); |
418 } | 418 } |
419 return ((const TYPE*)m_pData)[nIndex]; | 419 return ((const TYPE*)m_pData)[nIndex]; |
420 } | 420 } |
421 | 421 |
422 FX_BOOL» » SetAt(int nIndex, TYPE newElement) | 422 bool» » SetAt(int nIndex, TYPE newElement) |
423 { | 423 { |
424 if (nIndex < 0 || nIndex >= m_nSize) { | 424 if (nIndex < 0 || nIndex >= m_nSize) { |
425 return FALSE; | 425 return false; |
426 } | 426 } |
427 ((TYPE*)m_pData)[nIndex] = newElement; | 427 ((TYPE*)m_pData)[nIndex] = newElement; |
428 return TRUE; | 428 return true; |
429 } | 429 } |
430 | 430 |
431 TYPE& ElementAt(int nIndex) | 431 TYPE& ElementAt(int nIndex) |
432 { | 432 { |
433 if (nIndex < 0 || nIndex >= m_nSize) { | 433 if (nIndex < 0 || nIndex >= m_nSize) { |
434 return *(TYPE*)NULL; | 434 return *(TYPE*)NULL; |
435 } | 435 } |
436 return ((TYPE*)m_pData)[nIndex]; | 436 return ((TYPE*)m_pData)[nIndex]; |
437 } | 437 } |
438 | 438 |
439 const TYPE* GetData() const | 439 const TYPE* GetData() const |
440 { | 440 { |
441 return (const TYPE*)m_pData; | 441 return (const TYPE*)m_pData; |
442 } | 442 } |
443 | 443 |
444 TYPE* GetData() | 444 TYPE* GetData() |
445 { | 445 { |
446 return (TYPE*)m_pData; | 446 return (TYPE*)m_pData; |
447 } | 447 } |
448 | 448 |
449 FX_BOOL» » SetAtGrow(int nIndex, TYPE newElement) | 449 bool» » SetAtGrow(int nIndex, TYPE newElement) |
450 { | 450 { |
451 if (nIndex < 0) { | 451 if (nIndex < 0) { |
452 return FALSE; | 452 return false; |
453 } | 453 } |
454 if (nIndex >= m_nSize) | 454 if (nIndex >= m_nSize) |
455 if (!SetSize(nIndex + 1)) { | 455 if (!SetSize(nIndex + 1)) { |
456 return FALSE; | 456 return false; |
457 } | 457 } |
458 ((TYPE*)m_pData)[nIndex] = newElement; | 458 ((TYPE*)m_pData)[nIndex] = newElement; |
459 return TRUE; | 459 return true; |
460 } | 460 } |
461 | 461 |
462 FX_BOOL» » Add(TYPE newElement) | 462 bool» » Add(TYPE newElement) |
463 { | 463 { |
464 if (m_nSize < m_nMaxSize) { | 464 if (m_nSize < m_nMaxSize) { |
465 m_nSize ++; | 465 m_nSize ++; |
466 } else if (!SetSize(m_nSize + 1)) { | 466 } else if (!SetSize(m_nSize + 1)) { |
467 return FALSE; | 467 return false; |
468 } | 468 } |
469 ((TYPE*)m_pData)[m_nSize - 1] = newElement; | 469 ((TYPE*)m_pData)[m_nSize - 1] = newElement; |
470 return TRUE; | 470 return true; |
471 } | 471 } |
472 | 472 |
473 FX_BOOL» » Append(const CFX_ArrayTemplate& src) | 473 bool» » Append(const CFX_ArrayTemplate& src) |
474 { | 474 { |
475 return CFX_BasicArray::Append(src); | 475 return CFX_BasicArray::Append(src); |
476 } | 476 } |
477 | 477 |
478 FX_BOOL» » Copy(const CFX_ArrayTemplate& src) | 478 bool» » Copy(const CFX_ArrayTemplate& src) |
479 { | 479 { |
480 return CFX_BasicArray::Copy(src); | 480 return CFX_BasicArray::Copy(src); |
481 } | 481 } |
482 | 482 |
483 TYPE* GetDataPtr(int index) | 483 TYPE* GetDataPtr(int index) |
484 { | 484 { |
485 return (TYPE*)CFX_BasicArray::GetDataPtr(index); | 485 return (TYPE*)CFX_BasicArray::GetDataPtr(index); |
486 } | 486 } |
487 | 487 |
488 TYPE* AddSpace() | 488 TYPE* AddSpace() |
(...skipping 15 matching lines...) Expand all Loading... |
504 } | 504 } |
505 | 505 |
506 TYPE& operator[](int nIndex) | 506 TYPE& operator[](int nIndex) |
507 { | 507 { |
508 if (nIndex < 0 || nIndex >= m_nSize) { | 508 if (nIndex < 0 || nIndex >= m_nSize) { |
509 *(volatile char*)0 = '\0'; | 509 *(volatile char*)0 = '\0'; |
510 } | 510 } |
511 return ((TYPE*)m_pData)[nIndex]; | 511 return ((TYPE*)m_pData)[nIndex]; |
512 } | 512 } |
513 | 513 |
514 FX_BOOL» » InsertAt(int nIndex, TYPE newElement, int nCount = 1) | 514 bool» » InsertAt(int nIndex, TYPE newElement, int nCount = 1) |
515 { | 515 { |
516 if (!InsertSpaceAt(nIndex, nCount)) { | 516 if (!InsertSpaceAt(nIndex, nCount)) { |
517 return FALSE; | 517 return false; |
518 } | 518 } |
519 while (nCount--) { | 519 while (nCount--) { |
520 ((TYPE*)m_pData)[nIndex++] = newElement; | 520 ((TYPE*)m_pData)[nIndex++] = newElement; |
521 } | 521 } |
522 return TRUE; | 522 return true; |
523 } | 523 } |
524 | 524 |
525 FX_BOOL» » RemoveAt(int nIndex, int nCount = 1) | 525 bool» » RemoveAt(int nIndex, int nCount = 1) |
526 { | 526 { |
527 return CFX_BasicArray::RemoveAt(nIndex, nCount); | 527 return CFX_BasicArray::RemoveAt(nIndex, nCount); |
528 } | 528 } |
529 | 529 |
530 FX_BOOL» » InsertAt(int nStartIndex, const CFX_BasicArray* pNewArra
y) | 530 bool» » InsertAt(int nStartIndex, const CFX_BasicArray* pNewArra
y) |
531 { | 531 { |
532 return CFX_BasicArray::InsertAt(nStartIndex, pNewArray); | 532 return CFX_BasicArray::InsertAt(nStartIndex, pNewArray); |
533 } | 533 } |
534 | 534 |
535 int Find(TYPE data, int iStart = 0) const | 535 int Find(TYPE data, int iStart = 0) const |
536 { | 536 { |
537 if (iStart < 0) { | 537 if (iStart < 0) { |
538 return -1; | 538 return -1; |
539 } | 539 } |
540 for (; iStart < (int)m_nSize; iStart ++) | 540 for (; iStart < (int)m_nSize; iStart ++) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 int GetSegmentSize() const | 693 int GetSegmentSize() const |
694 { | 694 { |
695 return m_SegmentSize; | 695 return m_SegmentSize; |
696 } | 696 } |
697 | 697 |
698 int GetUnitSize() const | 698 int GetUnitSize() const |
699 { | 699 { |
700 return m_UnitSize; | 700 return m_UnitSize; |
701 } | 701 } |
702 | 702 |
703 void*» Iterate(FX_BOOL (*callback)(void* param, void* pData), void* par
am) const; | 703 void*» Iterate(bool (*callback)(void* param, void* pData), void* param)
const; |
704 private: | 704 private: |
705 | 705 |
706 int m_UnitSize; | 706 int m_UnitSize; |
707 | 707 |
708 short m_SegmentSize; | 708 short m_SegmentSize; |
709 | 709 |
710 uint8_t m_IndexSize; | 710 uint8_t m_IndexSize; |
711 | 711 |
712 uint8_t m_IndexDepth; | 712 uint8_t m_IndexDepth; |
713 | 713 |
714 int m_DataSize; | 714 int m_DataSize; |
715 | 715 |
716 void* m_pIndex; | 716 void* m_pIndex; |
717 void** GetIndex(int seg_index) const; | 717 void** GetIndex(int seg_index) const; |
718 void*» IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*cal
lback)(void* param, void* pData), void* param) const; | 718 void*» IterateIndex(int level, int& start, void** pIndex, bool (*callba
ck)(void* param, void* pData), void* param) const; |
719 void*» IterateSegment(const uint8_t* pSegment, int count, FX_BOOL (*cal
lback)(void* param, void* pData), void* param) const; | 719 void*» IterateSegment(const uint8_t* pSegment, int count, bool (*callba
ck)(void* param, void* pData), void* param) const; |
720 }; | 720 }; |
721 template <class ElementType> | 721 template <class ElementType> |
722 class CFX_SegmentedArray : public CFX_BaseSegmentedArray | 722 class CFX_SegmentedArray : public CFX_BaseSegmentedArray |
723 { | 723 { |
724 public: | 724 public: |
725 CFX_SegmentedArray(int segment_units, int index_size = 8) | 725 CFX_SegmentedArray(int segment_units, int index_size = 8) |
726 : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size) | 726 : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size) |
727 {} | 727 {} |
728 | 728 |
729 void Add(ElementType data) | 729 void Add(ElementType data) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 public: | 791 public: |
792 CFX_MapPtrToPtr(int nBlockSize = 10); | 792 CFX_MapPtrToPtr(int nBlockSize = 10); |
793 | 793 |
794 ~CFX_MapPtrToPtr(); | 794 ~CFX_MapPtrToPtr(); |
795 | 795 |
796 int GetCount() const | 796 int GetCount() const |
797 { | 797 { |
798 return m_nCount; | 798 return m_nCount; |
799 } | 799 } |
800 | 800 |
801 FX_BOOL IsEmpty() const | 801 bool IsEmpty() const |
802 { | 802 { |
803 return m_nCount == 0; | 803 return m_nCount == 0; |
804 } | 804 } |
805 | 805 |
806 FX_BOOL Lookup(void* key, void*& rValue) const; | 806 bool Lookup(void* key, void*& rValue) const; |
807 | 807 |
808 void* GetValueAt(void* key) const; | 808 void* GetValueAt(void* key) const; |
809 | 809 |
810 void*& operator[](void* key); | 810 void*& operator[](void* key); |
811 | 811 |
812 void SetAt(void* key, void* newValue) | 812 void SetAt(void* key, void* newValue) |
813 { | 813 { |
814 (*this)[key] = newValue; | 814 (*this)[key] = newValue; |
815 } | 815 } |
816 | 816 |
817 FX_BOOL RemoveKey(void* key); | 817 bool RemoveKey(void* key); |
818 | 818 |
819 void RemoveAll(); | 819 void RemoveAll(); |
820 | 820 |
821 FX_POSITION GetStartPosition() const | 821 FX_POSITION GetStartPosition() const |
822 { | 822 { |
823 return (m_nCount == 0) ? NULL : (FX_POSITION) - 1; | 823 return (m_nCount == 0) ? NULL : (FX_POSITION) - 1; |
824 } | 824 } |
825 | 825 |
826 void GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) co
nst; | 826 void GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) co
nst; |
827 | 827 |
828 FX_DWORD GetHashTableSize() const | 828 FX_DWORD GetHashTableSize() const |
829 { | 829 { |
830 return m_nHashTableSize; | 830 return m_nHashTableSize; |
831 } | 831 } |
832 | 832 |
833 void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE); | 833 void InitHashTable(FX_DWORD hashSize, bool bAllocNow = true); |
834 protected: | 834 protected: |
835 | 835 |
836 CAssoc** m_pHashTable; | 836 CAssoc** m_pHashTable; |
837 | 837 |
838 FX_DWORD m_nHashTableSize; | 838 FX_DWORD m_nHashTableSize; |
839 | 839 |
840 int m_nCount; | 840 int m_nCount; |
841 | 841 |
842 CAssoc* m_pFreeList; | 842 CAssoc* m_pFreeList; |
843 | 843 |
844 struct CFX_Plex* m_pBlocks; | 844 struct CFX_Plex* m_pBlocks; |
845 | 845 |
846 int m_nBlockSize; | 846 int m_nBlockSize; |
847 | 847 |
848 FX_DWORD HashKey(void* key) const; | 848 FX_DWORD HashKey(void* key) const; |
849 | 849 |
850 CAssoc* NewAssoc(); | 850 CAssoc* NewAssoc(); |
851 | 851 |
852 void FreeAssoc(CAssoc* pAssoc); | 852 void FreeAssoc(CAssoc* pAssoc); |
853 | 853 |
854 CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const; | 854 CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const; |
855 }; | 855 }; |
856 | 856 |
857 class CFX_CMapDWordToDWord | 857 class CFX_CMapDWordToDWord |
858 { | 858 { |
859 public: | 859 public: |
860 | 860 |
861 FX_BOOL» » » Lookup(FX_DWORD key, FX_DWORD& value) const; | 861 bool» » » Lookup(FX_DWORD key, FX_DWORD& value) const; |
862 | 862 |
863 void SetAt(FX_DWORD key, FX_DWORD value); | 863 void SetAt(FX_DWORD key, FX_DWORD value); |
864 | 864 |
865 void EstimateSize(FX_DWORD size, FX_DWORD grow_by); | 865 void EstimateSize(FX_DWORD size, FX_DWORD grow_by); |
866 | 866 |
867 FX_POSITION GetStartPosition() const; | 867 FX_POSITION GetStartPosition() const; |
868 | 868 |
869 void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX
_DWORD& value) const; | 869 void GetNextAssoc(FX_POSITION& pos, FX_DWORD& key, FX
_DWORD& value) const; |
870 protected: | 870 protected: |
871 | 871 |
(...skipping 14 matching lines...) Expand all Loading... |
886 void* value; | 886 void* value; |
887 }; | 887 }; |
888 public: | 888 public: |
889 CFX_MapByteStringToPtr(int nBlockSize = 10); | 889 CFX_MapByteStringToPtr(int nBlockSize = 10); |
890 | 890 |
891 int GetCount() const | 891 int GetCount() const |
892 { | 892 { |
893 return m_nCount; | 893 return m_nCount; |
894 } | 894 } |
895 | 895 |
896 FX_BOOL IsEmpty() const | 896 bool IsEmpty() const |
897 { | 897 { |
898 return m_nCount == 0; | 898 return m_nCount == 0; |
899 } | 899 } |
900 | 900 |
901 FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const; | 901 bool Lookup(const CFX_ByteStringC& key, void*& rValue) const; |
902 | 902 |
903 void*& operator[](const CFX_ByteStringC& key); | 903 void*& operator[](const CFX_ByteStringC& key); |
904 | 904 |
905 void SetAt(const CFX_ByteStringC& key, void* newValue) | 905 void SetAt(const CFX_ByteStringC& key, void* newValue) |
906 { | 906 { |
907 (*this)[key] = newValue; | 907 (*this)[key] = newValue; |
908 } | 908 } |
909 | 909 |
910 FX_BOOL RemoveKey(const CFX_ByteStringC& key); | 910 bool RemoveKey(const CFX_ByteStringC& key); |
911 | 911 |
912 void RemoveAll(); | 912 void RemoveAll(); |
913 | 913 |
914 FX_POSITION GetStartPosition() const | 914 FX_POSITION GetStartPosition() const |
915 { | 915 { |
916 return (m_nCount == 0) ? NULL : (FX_POSITION) - 1; | 916 return (m_nCount == 0) ? NULL : (FX_POSITION) - 1; |
917 } | 917 } |
918 | 918 |
919 void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& r
Value) const; | 919 void GetNextAssoc(FX_POSITION& rNextPosition, CFX_ByteString& rKey, void*& r
Value) const; |
920 | 920 |
921 void* GetNextValue(FX_POSITION& rNextPosition) const; | 921 void* GetNextValue(FX_POSITION& rNextPosition) const; |
922 | 922 |
923 FX_DWORD GetHashTableSize() const | 923 FX_DWORD GetHashTableSize() const |
924 { | 924 { |
925 return m_nHashTableSize; | 925 return m_nHashTableSize; |
926 } | 926 } |
927 | 927 |
928 void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE); | 928 void InitHashTable(FX_DWORD hashSize, bool bAllocNow = true); |
929 | 929 |
930 FX_DWORD HashKey(const CFX_ByteStringC& key) const; | 930 FX_DWORD HashKey(const CFX_ByteStringC& key) const; |
931 protected: | 931 protected: |
932 | 932 |
933 CAssoc** m_pHashTable; | 933 CAssoc** m_pHashTable; |
934 | 934 |
935 FX_DWORD m_nHashTableSize; | 935 FX_DWORD m_nHashTableSize; |
936 | 936 |
937 int m_nCount; | 937 int m_nCount; |
938 | 938 |
(...skipping 20 matching lines...) Expand all Loading... |
959 ~CFX_CMapByteStringToPtr(); | 959 ~CFX_CMapByteStringToPtr(); |
960 | 960 |
961 void RemoveAll(); | 961 void RemoveAll(); |
962 | 962 |
963 FX_POSITION GetStartPosition() const; | 963 FX_POSITION GetStartPosition() const; |
964 | 964 |
965 void GetNextAssoc(FX_POSITION& rNextPosition, CFX_Byt
eString& rKey, void*& rValue) const; | 965 void GetNextAssoc(FX_POSITION& rNextPosition, CFX_Byt
eString& rKey, void*& rValue) const; |
966 | 966 |
967 void* GetNextValue(FX_POSITION& rNextPosition) const; | 967 void* GetNextValue(FX_POSITION& rNextPosition) const; |
968 | 968 |
969 FX_BOOL» » » Lookup(const CFX_ByteStringC& key, void*& rValue
) const; | 969 bool» » » Lookup(const CFX_ByteStringC& key, void*& rValue
) const; |
970 | 970 |
971 void SetAt(const CFX_ByteStringC& key, void* value); | 971 void SetAt(const CFX_ByteStringC& key, void* value); |
972 | 972 |
973 void RemoveKey(const CFX_ByteStringC& key); | 973 void RemoveKey(const CFX_ByteStringC& key); |
974 | 974 |
975 int GetCount() const; | 975 int GetCount() const; |
976 | 976 |
977 void AddValue(const CFX_ByteStringC& key, void* pValu
e); | 977 void AddValue(const CFX_ByteStringC& key, void* pValu
e); |
978 private: | 978 private: |
979 | 979 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 struct FX_PRIVATEDATA { | 1083 struct FX_PRIVATEDATA { |
1084 | 1084 |
1085 void FreeData(); | 1085 void FreeData(); |
1086 | 1086 |
1087 void* m_pModuleId; | 1087 void* m_pModuleId; |
1088 | 1088 |
1089 void* m_pData; | 1089 void* m_pData; |
1090 | 1090 |
1091 PD_CALLBACK_FREEDATA m_pCallback; | 1091 PD_CALLBACK_FREEDATA m_pCallback; |
1092 | 1092 |
1093 FX_BOOL» » » » » m_bSelfDestruct; | 1093 bool» » » » » m_bSelfDestruct; |
1094 }; | 1094 }; |
1095 class CFX_PrivateData | 1095 class CFX_PrivateData |
1096 { | 1096 { |
1097 public: | 1097 public: |
1098 | 1098 |
1099 ~CFX_PrivateData(); | 1099 ~CFX_PrivateData(); |
1100 | 1100 |
1101 void ClearAll(); | 1101 void ClearAll(); |
1102 | 1102 |
1103 void SetPrivateData(void* module_id,
void* pData, PD_CALLBACK_FREEDATA callback); | 1103 void SetPrivateData(void* module_id,
void* pData, PD_CALLBACK_FREEDATA callback); |
1104 | 1104 |
1105 void SetPrivateObj(void* module_id, C
FX_DestructObject* pObj); | 1105 void SetPrivateObj(void* module_id, C
FX_DestructObject* pObj); |
1106 | 1106 |
1107 void* GetPrivateData(void* module_id); | 1107 void* GetPrivateData(void* module_id); |
1108 | 1108 |
1109 FX_BOOL» » » » » LookupPrivateData(void* module_i
d, void* &pData) const | 1109 bool» » » » » LookupPrivateData(void* module_i
d, void* &pData) const |
1110 { | 1110 { |
1111 if (!module_id) { | 1111 if (!module_id) { |
1112 return FALSE; | 1112 return false; |
1113 } | 1113 } |
1114 FX_DWORD nCount = m_DataList.GetSize(); | 1114 FX_DWORD nCount = m_DataList.GetSize(); |
1115 for (FX_DWORD n = 0; n < nCount; n ++) { | 1115 for (FX_DWORD n = 0; n < nCount; n ++) { |
1116 if (m_DataList[n].m_pModuleId == module_id) { | 1116 if (m_DataList[n].m_pModuleId == module_id) { |
1117 pData = m_DataList[n].m_pData; | 1117 pData = m_DataList[n].m_pData; |
1118 return TRUE; | 1118 return true; |
1119 } | 1119 } |
1120 } | 1120 } |
1121 return FALSE; | 1121 return false; |
1122 } | 1122 } |
1123 | 1123 |
1124 FX_BOOL» » » » » RemovePrivateData(void* module_i
d); | 1124 bool» » » » » RemovePrivateData(void* module_i
d); |
1125 protected: | 1125 protected: |
1126 | 1126 |
1127 CFX_ArrayTemplate<FX_PRIVATEDATA> m_DataList; | 1127 CFX_ArrayTemplate<FX_PRIVATEDATA> m_DataList; |
1128 | 1128 |
1129 void» » » » » AddData(void* module_id, void* p
Data, PD_CALLBACK_FREEDATA callback, FX_BOOL bSelfDestruct); | 1129 void» » » » » AddData(void* module_id, void* p
Data, PD_CALLBACK_FREEDATA callback, bool bSelfDestruct); |
1130 }; | 1130 }; |
1131 class CFX_BitStream | 1131 class CFX_BitStream |
1132 { | 1132 { |
1133 public: | 1133 public: |
1134 | 1134 |
1135 void Init(const uint8_t* pData, FX_DWORD dwSi
ze); | 1135 void Init(const uint8_t* pData, FX_DWORD dwSi
ze); |
1136 | 1136 |
1137 | 1137 |
1138 FX_DWORD GetBits(FX_DWORD nBits); | 1138 FX_DWORD GetBits(FX_DWORD nBits); |
1139 | 1139 |
1140 void ByteAlign(); | 1140 void ByteAlign(); |
1141 | 1141 |
1142 FX_BOOL» » » » IsEOF() | 1142 bool» » » » IsEOF() |
1143 { | 1143 { |
1144 return m_BitPos >= m_BitSize; | 1144 return m_BitPos >= m_BitSize; |
1145 } | 1145 } |
1146 | 1146 |
1147 void SkipBits(FX_DWORD nBits) | 1147 void SkipBits(FX_DWORD nBits) |
1148 { | 1148 { |
1149 m_BitPos += nBits; | 1149 m_BitPos += nBits; |
1150 } | 1150 } |
1151 | 1151 |
1152 void Rewind() | 1152 void Rewind() |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 const ObjClass* GetObject() const | 1245 const ObjClass* GetObject() const |
1246 { | 1246 { |
1247 return m_pObject; | 1247 return m_pObject; |
1248 } | 1248 } |
1249 | 1249 |
1250 operator const ObjClass*() const | 1250 operator const ObjClass*() const |
1251 { | 1251 { |
1252 return m_pObject; | 1252 return m_pObject; |
1253 } | 1253 } |
1254 | 1254 |
1255 FX_BOOL» » » » IsNull() const | 1255 bool» » » » IsNull() const |
1256 { | 1256 { |
1257 return m_pObject == NULL; | 1257 return m_pObject == NULL; |
1258 } | 1258 } |
1259 | 1259 |
1260 FX_BOOL» » » » NotNull() const | 1260 bool» » » » NotNull() const |
1261 { | 1261 { |
1262 return m_pObject != NULL; | 1262 return m_pObject != NULL; |
1263 } | 1263 } |
1264 | 1264 |
1265 ObjClass* GetModify() | 1265 ObjClass* GetModify() |
1266 { | 1266 { |
1267 if (m_pObject == NULL) { | 1267 if (m_pObject == NULL) { |
1268 m_pObject = new CountedObj; | 1268 m_pObject = new CountedObj; |
1269 m_pObject->m_RefCount = 1; | 1269 m_pObject->m_RefCount = 1; |
1270 } else if (m_pObject->m_RefCount > 1) { | 1270 } else if (m_pObject->m_RefCount > 1) { |
(...skipping 10 matching lines...) Expand all Loading... |
1281 if (m_pObject == NULL) { | 1281 if (m_pObject == NULL) { |
1282 return; | 1282 return; |
1283 } | 1283 } |
1284 m_pObject->m_RefCount --; | 1284 m_pObject->m_RefCount --; |
1285 if (m_pObject->m_RefCount <= 0) { | 1285 if (m_pObject->m_RefCount <= 0) { |
1286 delete m_pObject; | 1286 delete m_pObject; |
1287 } | 1287 } |
1288 m_pObject = NULL; | 1288 m_pObject = NULL; |
1289 } | 1289 } |
1290 | 1290 |
1291 FX_BOOL» » » » operator == (const Ref& ref) const | 1291 bool» » » » operator == (const Ref& ref) const |
1292 { | 1292 { |
1293 return m_pObject == ref.m_pObject; | 1293 return m_pObject == ref.m_pObject; |
1294 } | 1294 } |
1295 protected: | 1295 protected: |
1296 | 1296 |
1297 CountedObj* m_pObject; | 1297 CountedObj* m_pObject; |
1298 }; | 1298 }; |
1299 class IFX_Pause | 1299 class IFX_Pause |
1300 { | 1300 { |
1301 public: | 1301 public: |
1302 virtual ~IFX_Pause() { } | 1302 virtual ~IFX_Pause() { } |
1303 virtual FX_BOOL» NeedToPauseNow() = 0; | 1303 virtual bool» NeedToPauseNow() = 0; |
1304 }; | 1304 }; |
1305 class CFX_DataFilter | 1305 class CFX_DataFilter |
1306 { | 1306 { |
1307 public: | 1307 public: |
1308 | 1308 |
1309 virtual ~CFX_DataFilter(); | 1309 virtual ~CFX_DataFilter(); |
1310 | 1310 |
1311 void SetDestFilter(CFX_DataFilter* pFilter); | 1311 void SetDestFilter(CFX_DataFilter* pFilter); |
1312 | 1312 |
1313 FX_BOOL» » » IsEOF() const | 1313 bool» » » IsEOF() const |
1314 { | 1314 { |
1315 return m_bEOF; | 1315 return m_bEOF; |
1316 } | 1316 } |
1317 | 1317 |
1318 FX_DWORD GetSrcPos() | 1318 FX_DWORD GetSrcPos() |
1319 { | 1319 { |
1320 return m_SrcPos; | 1320 return m_SrcPos; |
1321 } | 1321 } |
1322 | 1322 |
1323 void FilterIn(const uint8_t* src_buf, FX_DWORD src_si
ze, CFX_BinaryBuf& dest_buf); | 1323 void FilterIn(const uint8_t* src_buf, FX_DWORD src_si
ze, CFX_BinaryBuf& dest_buf); |
1324 | 1324 |
1325 void FilterFinish(CFX_BinaryBuf& dest_buf); | 1325 void FilterFinish(CFX_BinaryBuf& dest_buf); |
1326 protected: | 1326 protected: |
1327 | 1327 |
1328 CFX_DataFilter(); | 1328 CFX_DataFilter(); |
1329 virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CF
X_BinaryBuf& dest_buf) = 0; | 1329 virtual void v_FilterIn(const uint8_t* src_buf, FX_DWORD src_size, CF
X_BinaryBuf& dest_buf) = 0; |
1330 virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) = 0; | 1330 virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) = 0; |
1331 void ReportEOF(FX_DWORD left_input); | 1331 void ReportEOF(FX_DWORD left_input); |
1332 | 1332 |
1333 FX_BOOL» » » m_bEOF; | 1333 bool» » » m_bEOF; |
1334 | 1334 |
1335 FX_DWORD m_SrcPos; | 1335 FX_DWORD m_SrcPos; |
1336 | 1336 |
1337 CFX_DataFilter* m_pDestFilter; | 1337 CFX_DataFilter* m_pDestFilter; |
1338 }; | 1338 }; |
1339 | 1339 |
1340 template<typename T> | 1340 template<typename T> |
1341 class CFX_AutoRestorer { | 1341 class CFX_AutoRestorer { |
1342 public: | 1342 public: |
1343 explicit CFX_AutoRestorer(T* location) { | 1343 explicit CFX_AutoRestorer(T* location) { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 FX_FLOAT c; | 1568 FX_FLOAT c; |
1569 FX_FLOAT d; | 1569 FX_FLOAT d; |
1570 FX_FLOAT e; | 1570 FX_FLOAT e; |
1571 FX_FLOAT f; | 1571 FX_FLOAT f; |
1572 FX_FLOAT g; | 1572 FX_FLOAT g; |
1573 FX_FLOAT h; | 1573 FX_FLOAT h; |
1574 FX_FLOAT i; | 1574 FX_FLOAT i; |
1575 }; | 1575 }; |
1576 | 1576 |
1577 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 1577 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
OLD | NEW |