Chromium Code Reviews| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 | 123 |
| 124 FX_WCHAR* GetBuffer() const { return (FX_WCHAR*)m_pBuffer; } | 124 FX_WCHAR* GetBuffer() const { return (FX_WCHAR*)m_pBuffer; } |
| 125 | 125 |
| 126 void Delete(int start_index, int count) { | 126 void Delete(int start_index, int count) { |
| 127 CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), | 127 CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), |
| 128 count * sizeof(FX_WCHAR)); | 128 count * sizeof(FX_WCHAR)); |
| 129 } | 129 } |
| 130 | 130 |
| 131 CFX_WideStringC GetWideString() const; | 131 CFX_WideStringC GetWideString() const; |
| 132 }; | 132 }; |
| 133 #ifdef PDF_ENABLE_XFA | |
| 134 class CFX_ArchiveSaver { | |
| 135 public: | |
| 136 CFX_ArchiveSaver() : m_pStream(NULL) {} | |
| 137 | |
| 138 CFX_ArchiveSaver& operator<<(uint8_t i); | |
| 139 | |
| 140 CFX_ArchiveSaver& operator<<(int i); | |
| 141 | |
| 142 CFX_ArchiveSaver& operator<<(FX_DWORD i); | |
| 143 | |
| 144 CFX_ArchiveSaver& operator<<(FX_FLOAT i); | |
| 145 | |
| 146 CFX_ArchiveSaver& operator<<(double i); | |
| 147 | |
| 148 CFX_ArchiveSaver& operator<<(const CFX_ByteStringC& bstr); | |
| 149 | |
| 150 CFX_ArchiveSaver& operator<<(const FX_WCHAR* bstr); | |
| 151 | |
| 152 CFX_ArchiveSaver& operator<<(const CFX_WideString& wstr); | |
| 153 | |
| 154 void Write(const void* pData, FX_STRSIZE dwSize); | |
| 155 | |
| 156 intptr_t GetLength() { return m_SavingBuf.GetSize(); } | |
| 157 | |
| 158 const uint8_t* GetBuffer() { return m_SavingBuf.GetBuffer(); } | |
| 159 | |
| 160 void SetStream(IFX_FileStream* pStream) { m_pStream = pStream; } | |
| 161 | |
| 162 protected: | |
| 163 CFX_BinaryBuf m_SavingBuf; | |
| 164 | |
| 165 IFX_FileStream* m_pStream; | |
| 166 }; | |
| 167 class CFX_ArchiveLoader { | |
| 168 public: | |
| 169 CFX_ArchiveLoader(const uint8_t* pData, FX_DWORD dwSize); | |
| 170 | |
| 171 CFX_ArchiveLoader& operator>>(uint8_t& i); | |
| 172 | |
| 173 CFX_ArchiveLoader& operator>>(int& i); | |
| 174 | |
| 175 CFX_ArchiveLoader& operator>>(FX_DWORD& i); | |
| 176 | |
| 177 CFX_ArchiveLoader& operator>>(FX_FLOAT& i); | |
| 178 | |
| 179 CFX_ArchiveLoader& operator>>(double& i); | |
| 180 | |
| 181 CFX_ArchiveLoader& operator>>(CFX_ByteString& bstr); | |
| 182 | |
| 183 CFX_ArchiveLoader& operator>>(CFX_WideString& wstr); | |
| 184 | |
| 185 FX_BOOL IsEOF(); | |
| 186 | |
| 187 FX_BOOL Read(void* pBuf, FX_DWORD dwSize); | |
| 188 | |
| 189 protected: | |
| 190 FX_DWORD m_LoadingPos; | |
| 191 | |
| 192 const uint8_t* m_pLoadingBuf; | |
| 193 | |
| 194 FX_DWORD m_LoadingSize; | |
| 195 }; | |
| 196 #endif | |
| 133 | 197 |
| 134 class IFX_BufferArchive { | 198 class IFX_BufferArchive { |
| 135 public: | 199 public: |
| 136 IFX_BufferArchive(FX_STRSIZE size); | 200 IFX_BufferArchive(FX_STRSIZE size); |
| 137 virtual ~IFX_BufferArchive() {} | 201 virtual ~IFX_BufferArchive() {} |
| 138 | 202 |
| 139 virtual void Clear(); | 203 virtual void Clear(); |
| 140 | 204 |
| 141 FX_BOOL Flush(); | 205 FX_BOOL Flush(); |
| 142 | 206 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 return iStart; | 431 return iStart; |
| 368 } | 432 } |
| 369 return -1; | 433 return -1; |
| 370 } | 434 } |
| 371 }; | 435 }; |
| 372 typedef CFX_ArrayTemplate<uint8_t> CFX_ByteArray; | 436 typedef CFX_ArrayTemplate<uint8_t> CFX_ByteArray; |
| 373 typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray; | 437 typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray; |
| 374 typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray; | 438 typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray; |
| 375 typedef CFX_ArrayTemplate<void*> CFX_PtrArray; | 439 typedef CFX_ArrayTemplate<void*> CFX_PtrArray; |
| 376 typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray; | 440 typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray; |
| 441 #ifdef PDF_ENABLE_XFA | |
| 442 typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray; | |
| 443 typedef CFX_ArrayTemplate<int32_t> CFX_Int32Array; | |
| 444 #endif | |
| 377 | 445 |
| 378 template <class ObjectClass> | 446 template <class ObjectClass> |
| 379 class CFX_ObjectArray : public CFX_BasicArray { | 447 class CFX_ObjectArray : public CFX_BasicArray { |
| 380 public: | 448 public: |
| 381 CFX_ObjectArray() : CFX_BasicArray(sizeof(ObjectClass)) {} | 449 CFX_ObjectArray() : CFX_BasicArray(sizeof(ObjectClass)) {} |
| 382 | 450 |
| 383 ~CFX_ObjectArray() { RemoveAll(); } | 451 ~CFX_ObjectArray() { RemoveAll(); } |
| 384 | 452 |
| 385 void Add(const ObjectClass& data) { | 453 void Add(const ObjectClass& data) { |
| 386 new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data); | 454 new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 627 int m_nBlockSize; | 695 int m_nBlockSize; |
| 628 | 696 |
| 629 FX_DWORD HashKey(void* key) const; | 697 FX_DWORD HashKey(void* key) const; |
| 630 | 698 |
| 631 CAssoc* NewAssoc(); | 699 CAssoc* NewAssoc(); |
| 632 | 700 |
| 633 void FreeAssoc(CAssoc* pAssoc); | 701 void FreeAssoc(CAssoc* pAssoc); |
| 634 | 702 |
| 635 CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const; | 703 CAssoc* GetAssocAt(void* key, FX_DWORD& hash) const; |
| 636 }; | 704 }; |
| 705 #ifdef PDF_ENABLE_XFA | |
| 706 template <class KeyType, class ValueType> | |
| 707 class CFX_MapPtrTemplate : public CFX_MapPtrToPtr { | |
| 708 public: | |
| 709 CFX_MapPtrTemplate() : CFX_MapPtrToPtr(10) {} | |
| 637 | 710 |
| 711 FX_BOOL Lookup(KeyType key, ValueType& rValue) const { | |
| 712 void* pValue = NULL; | |
| 713 if (!CFX_MapPtrToPtr::Lookup((void*)(uintptr_t)key, pValue)) { | |
| 714 return FALSE; | |
| 715 } | |
| 716 rValue = (ValueType)(uintptr_t)pValue; | |
| 717 return TRUE; | |
| 718 } | |
| 719 | |
| 720 ValueType& operator[](KeyType key) { | |
| 721 return (ValueType&)CFX_MapPtrToPtr::operator[]((void*)(uintptr_t)key); | |
| 722 } | |
| 723 | |
| 724 void SetAt(KeyType key, ValueType newValue) { | |
| 725 CFX_MapPtrToPtr::SetAt((void*)(uintptr_t)key, (void*)(uintptr_t)newValue); | |
| 726 } | |
| 727 | |
| 728 FX_BOOL RemoveKey(KeyType key) { | |
| 729 return CFX_MapPtrToPtr::RemoveKey((void*)(uintptr_t)key); | |
| 730 } | |
| 731 #endif | |
| 732 | |
| 733 #ifdef PDF_ENABLE_XFA | |
| 734 void GetNextAssoc(FX_POSITION& rNextPosition, | |
| 735 KeyType& rKey, | |
| 736 ValueType& rValue) const { | |
| 737 void* pKey = NULL; | |
| 738 void* pValue = NULL; | |
| 739 CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue); | |
| 740 rKey = (KeyType)(uintptr_t)pKey; | |
| 741 rValue = (ValueType)(uintptr_t)pValue; | |
| 742 } | |
| 743 }; | |
| 744 #endif | |
| 638 class CFX_CMapByteStringToPtr { | 745 class CFX_CMapByteStringToPtr { |
| 639 public: | 746 public: |
| 640 CFX_CMapByteStringToPtr(); | 747 CFX_CMapByteStringToPtr(); |
| 641 | 748 |
| 642 ~CFX_CMapByteStringToPtr(); | 749 ~CFX_CMapByteStringToPtr(); |
| 643 | 750 |
| 644 void RemoveAll(); | 751 void RemoveAll(); |
| 645 | 752 |
| 646 FX_POSITION GetStartPosition() const; | 753 FX_POSITION GetStartPosition() const; |
| 647 | 754 |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1081 typedef enum { | 1188 typedef enum { |
| 1082 Ready, | 1189 Ready, |
| 1083 ToBeContinued, | 1190 ToBeContinued, |
| 1084 Found, | 1191 Found, |
| 1085 NotFound, | 1192 NotFound, |
| 1086 Failed, | 1193 Failed, |
| 1087 Done | 1194 Done |
| 1088 } FX_ProgressiveStatus; | 1195 } FX_ProgressiveStatus; |
| 1089 #define ProgressiveStatus FX_ProgressiveStatus | 1196 #define ProgressiveStatus FX_ProgressiveStatus |
| 1090 #define FX_NAMESPACE_DECLARE(namespace, type) namespace ::type | 1197 #define FX_NAMESPACE_DECLARE(namespace, type) namespace ::type |
| 1198 #ifdef PDF_ENABLE_XFA | |
| 1199 class IFX_Unknown { | |
|
Lei Zhang
2015/10/30 06:15:30
I think we killed this on master.
| |
| 1200 public: | |
| 1201 virtual ~IFX_Unknown() {} | |
| 1202 virtual FX_DWORD Release() = 0; | |
| 1203 virtual FX_DWORD AddRef() = 0; | |
| 1204 }; | |
| 1205 #define FX_IsOdd(a) ((a)&1) | |
| 1206 #endif | |
| 1091 | 1207 |
| 1092 class CFX_Vector_3by1 { | 1208 class CFX_Vector_3by1 { |
| 1093 public: | 1209 public: |
| 1094 CFX_Vector_3by1() : a(0.0f), b(0.0f), c(0.0f) {} | 1210 CFX_Vector_3by1() : a(0.0f), b(0.0f), c(0.0f) {} |
| 1095 | 1211 |
| 1096 CFX_Vector_3by1(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1) | 1212 CFX_Vector_3by1(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1) |
| 1097 : a(a1), b(b1), c(c1) {} | 1213 : a(a1), b(b1), c(c1) {} |
| 1098 | 1214 |
| 1099 FX_FLOAT a; | 1215 FX_FLOAT a; |
| 1100 FX_FLOAT b; | 1216 FX_FLOAT b; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1135 FX_FLOAT c; | 1251 FX_FLOAT c; |
| 1136 FX_FLOAT d; | 1252 FX_FLOAT d; |
| 1137 FX_FLOAT e; | 1253 FX_FLOAT e; |
| 1138 FX_FLOAT f; | 1254 FX_FLOAT f; |
| 1139 FX_FLOAT g; | 1255 FX_FLOAT g; |
| 1140 FX_FLOAT h; | 1256 FX_FLOAT h; |
| 1141 FX_FLOAT i; | 1257 FX_FLOAT i; |
| 1142 }; | 1258 }; |
| 1143 | 1259 |
| 1144 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 1260 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
| OLD | NEW |