| 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_FXCRT_INCLUDE_FX_BASIC_H_ | 7 #ifndef CORE_FXCRT_INCLUDE_FX_BASIC_H_ |
| 8 #define CORE_FXCRT_INCLUDE_FX_BASIC_H_ | 8 #define CORE_FXCRT_INCLUDE_FX_BASIC_H_ |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 484 |
| 485 void RemoveAll() { | 485 void RemoveAll() { |
| 486 for (int i = 0; i < m_nSize; i++) { | 486 for (int i = 0; i < m_nSize; i++) { |
| 487 ((ObjectClass*)GetDataPtr(i))->~ObjectClass(); | 487 ((ObjectClass*)GetDataPtr(i))->~ObjectClass(); |
| 488 } | 488 } |
| 489 CFX_BasicArray::SetSize(0); | 489 CFX_BasicArray::SetSize(0); |
| 490 } | 490 } |
| 491 }; | 491 }; |
| 492 typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray; | 492 typedef CFX_ObjectArray<CFX_ByteString> CFX_ByteStringArray; |
| 493 typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray; | 493 typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray; |
| 494 class CFX_BaseSegmentedArray { | |
| 495 public: | |
| 496 CFX_BaseSegmentedArray(int unit_size = 1, | |
| 497 int segment_units = 512, | |
| 498 int index_size = 8); | |
| 499 | |
| 500 ~CFX_BaseSegmentedArray(); | |
| 501 | |
| 502 void SetUnitSize(int unit_size, int segment_units, int index_size = 8); | |
| 503 | |
| 504 void* Add(); | |
| 505 | |
| 506 void* GetAt(int index) const; | |
| 507 | |
| 508 void RemoveAll(); | |
| 509 | |
| 510 void Delete(int index, int count = 1); | |
| 511 | |
| 512 int GetSize() const { return m_DataSize; } | |
| 513 | |
| 514 int GetSegmentSize() const { return m_SegmentSize; } | |
| 515 | |
| 516 int GetUnitSize() const { return m_UnitSize; } | |
| 517 | |
| 518 void* Iterate(FX_BOOL (*callback)(void* param, void* pData), | |
| 519 void* param) const; | |
| 520 | |
| 521 private: | |
| 522 int m_UnitSize; | |
| 523 | |
| 524 short m_SegmentSize; | |
| 525 | |
| 526 uint8_t m_IndexSize; | |
| 527 | |
| 528 uint8_t m_IndexDepth; | |
| 529 | |
| 530 int m_DataSize; | |
| 531 | |
| 532 void* m_pIndex; | |
| 533 void** GetIndex(int seg_index) const; | |
| 534 void* IterateIndex(int level, | |
| 535 int& start, | |
| 536 void** pIndex, | |
| 537 FX_BOOL (*callback)(void* param, void* pData), | |
| 538 void* param) const; | |
| 539 void* IterateSegment(const uint8_t* pSegment, | |
| 540 int count, | |
| 541 FX_BOOL (*callback)(void* param, void* pData), | |
| 542 void* param) const; | |
| 543 }; | |
| 544 template <class ElementType> | |
| 545 class CFX_SegmentedArray : public CFX_BaseSegmentedArray { | |
| 546 public: | |
| 547 CFX_SegmentedArray(int segment_units, int index_size = 8) | |
| 548 : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size) { | |
| 549 } | |
| 550 | |
| 551 void Add(ElementType data) { | |
| 552 *(ElementType*)CFX_BaseSegmentedArray::Add() = data; | |
| 553 } | |
| 554 | |
| 555 ElementType& operator[](int index) { | |
| 556 return *(ElementType*)CFX_BaseSegmentedArray::GetAt(index); | |
| 557 } | |
| 558 }; | |
| 559 #endif // PDF_ENABLE_XFA | 494 #endif // PDF_ENABLE_XFA |
| 560 | 495 |
| 561 template <class DataType, int FixedSize> | 496 template <class DataType, int FixedSize> |
| 562 class CFX_FixedBufGrow { | 497 class CFX_FixedBufGrow { |
| 563 public: | 498 public: |
| 564 explicit CFX_FixedBufGrow(int data_size) { | 499 explicit CFX_FixedBufGrow(int data_size) { |
| 565 if (data_size > FixedSize) { | 500 if (data_size > FixedSize) { |
| 566 m_pGrowData.reset(FX_Alloc(DataType, data_size)); | 501 m_pGrowData.reset(FX_Alloc(DataType, data_size)); |
| 567 return; | 502 return; |
| 568 } | 503 } |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 FX_FLOAT c; | 1058 FX_FLOAT c; |
| 1124 FX_FLOAT d; | 1059 FX_FLOAT d; |
| 1125 FX_FLOAT e; | 1060 FX_FLOAT e; |
| 1126 FX_FLOAT f; | 1061 FX_FLOAT f; |
| 1127 FX_FLOAT g; | 1062 FX_FLOAT g; |
| 1128 FX_FLOAT h; | 1063 FX_FLOAT h; |
| 1129 FX_FLOAT i; | 1064 FX_FLOAT i; |
| 1130 }; | 1065 }; |
| 1131 | 1066 |
| 1132 #endif // CORE_FXCRT_INCLUDE_FX_BASIC_H_ | 1067 #endif // CORE_FXCRT_INCLUDE_FX_BASIC_H_ |
| OLD | NEW |