| 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_FPDFAPI_FPDF_OBJECTS_H_ | 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ |
| 8 #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ | 8 #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ |
| 9 | 9 |
| 10 #include <map> |
| 10 #include <set> | 11 #include <set> |
| 11 | 12 |
| 12 #include "core/include/fxcrt/fx_coordinates.h" | 13 #include "core/include/fxcrt/fx_coordinates.h" |
| 13 #include "core/include/fxcrt/fx_system.h" | 14 #include "core/include/fxcrt/fx_system.h" |
| 14 | 15 |
| 15 class CPDF_Array; | 16 class CPDF_Array; |
| 16 class CPDF_Boolean; | 17 class CPDF_Boolean; |
| 17 class CPDF_CryptoHandler; | 18 class CPDF_CryptoHandler; |
| 18 class CPDF_Dictionary; | 19 class CPDF_Dictionary; |
| 19 class CPDF_Document; | 20 class CPDF_Document; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 }; | 333 }; |
| 333 inline CPDF_Array* ToArray(CPDF_Object* obj) { | 334 inline CPDF_Array* ToArray(CPDF_Object* obj) { |
| 334 return obj ? obj->AsArray() : nullptr; | 335 return obj ? obj->AsArray() : nullptr; |
| 335 } | 336 } |
| 336 inline const CPDF_Array* ToArray(const CPDF_Object* obj) { | 337 inline const CPDF_Array* ToArray(const CPDF_Object* obj) { |
| 337 return obj ? obj->AsArray() : nullptr; | 338 return obj ? obj->AsArray() : nullptr; |
| 338 } | 339 } |
| 339 | 340 |
| 340 class CPDF_Dictionary : public CPDF_Object { | 341 class CPDF_Dictionary : public CPDF_Object { |
| 341 public: | 342 public: |
| 343 using iterator = std::map<CFX_ByteString, CPDF_Object*>::iterator; |
| 344 using const_iterator = std::map<CFX_ByteString, CPDF_Object*>::const_iterator; |
| 345 |
| 342 CPDF_Dictionary() : CPDF_Object(PDFOBJ_DICTIONARY) {} | 346 CPDF_Dictionary() : CPDF_Object(PDFOBJ_DICTIONARY) {} |
| 343 | 347 |
| 344 CPDF_Object* GetElement(const CFX_ByteStringC& key) const; | 348 CPDF_Object* GetElement(const CFX_ByteStringC& key) const; |
| 345 | 349 |
| 346 CPDF_Object* GetElementValue(const CFX_ByteStringC& key) const; | 350 CPDF_Object* GetElementValue(const CFX_ByteStringC& key) const; |
| 347 | 351 |
| 348 CFX_ByteString GetString(const CFX_ByteStringC& key) const; | 352 CFX_ByteString GetString(const CFX_ByteStringC& key) const; |
| 349 | 353 |
| 350 CFX_ByteStringC GetConstString(const CFX_ByteStringC& key) const; | 354 CFX_ByteStringC GetConstString(const CFX_ByteStringC& key) const; |
| 351 | 355 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 374 CPDF_Array* GetArray(const CFX_ByteStringC& key) const; | 378 CPDF_Array* GetArray(const CFX_ByteStringC& key) const; |
| 375 | 379 |
| 376 CFX_FloatRect GetRect(const CFX_ByteStringC& key) const; | 380 CFX_FloatRect GetRect(const CFX_ByteStringC& key) const; |
| 377 | 381 |
| 378 CFX_Matrix GetMatrix(const CFX_ByteStringC& key) const; | 382 CFX_Matrix GetMatrix(const CFX_ByteStringC& key) const; |
| 379 | 383 |
| 380 FX_FLOAT GetFloat(const CFX_ByteStringC& key) const { return GetNumber(key); } | 384 FX_FLOAT GetFloat(const CFX_ByteStringC& key) const { return GetNumber(key); } |
| 381 | 385 |
| 382 FX_BOOL KeyExist(const CFX_ByteStringC& key) const; | 386 FX_BOOL KeyExist(const CFX_ByteStringC& key) const; |
| 383 | 387 |
| 384 FX_POSITION GetStartPos() const; | |
| 385 | |
| 386 CPDF_Object* GetNextElement(FX_POSITION& pos, CFX_ByteString& key) const; | |
| 387 | |
| 388 void SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj); | 388 void SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj); |
| 389 | 389 |
| 390 void SetAtName(const CFX_ByteStringC& key, const CFX_ByteString& name); | 390 void SetAtName(const CFX_ByteStringC& key, const CFX_ByteString& name); |
| 391 | 391 |
| 392 void SetAtString(const CFX_ByteStringC& key, const CFX_ByteString& string); | 392 void SetAtString(const CFX_ByteStringC& key, const CFX_ByteString& string); |
| 393 | 393 |
| 394 void SetAtInteger(const CFX_ByteStringC& key, int i); | 394 void SetAtInteger(const CFX_ByteStringC& key, int i); |
| 395 | 395 |
| 396 void SetAtNumber(const CFX_ByteStringC& key, FX_FLOAT f); | 396 void SetAtNumber(const CFX_ByteStringC& key, FX_FLOAT f); |
| 397 | 397 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 414 void SetAtMatrix(const CFX_ByteStringC& key, const CFX_Matrix& matrix); | 414 void SetAtMatrix(const CFX_ByteStringC& key, const CFX_Matrix& matrix); |
| 415 | 415 |
| 416 void SetAtBoolean(const CFX_ByteStringC& key, FX_BOOL bValue); | 416 void SetAtBoolean(const CFX_ByteStringC& key, FX_BOOL bValue); |
| 417 | 417 |
| 418 void RemoveAt(const CFX_ByteStringC& key); | 418 void RemoveAt(const CFX_ByteStringC& key); |
| 419 | 419 |
| 420 void ReplaceKey(const CFX_ByteStringC& oldkey, const CFX_ByteStringC& newkey); | 420 void ReplaceKey(const CFX_ByteStringC& oldkey, const CFX_ByteStringC& newkey); |
| 421 | 421 |
| 422 FX_BOOL Identical(CPDF_Dictionary* pDict) const; | 422 FX_BOOL Identical(CPDF_Dictionary* pDict) const; |
| 423 | 423 |
| 424 int GetCount() const { return m_Map.GetCount(); } | 424 size_t GetCount() const { return m_Map.size(); } |
| 425 | 425 |
| 426 void AddValue(const CFX_ByteStringC& key, CPDF_Object* pObj); | 426 iterator begin() { return m_Map.begin(); } |
| 427 |
| 428 iterator end() { return m_Map.end(); } |
| 429 |
| 430 const_iterator begin() const { return m_Map.begin(); } |
| 431 |
| 432 const_iterator end() const { return m_Map.end(); } |
| 427 | 433 |
| 428 protected: | 434 protected: |
| 429 ~CPDF_Dictionary(); | 435 ~CPDF_Dictionary(); |
| 430 | 436 |
| 431 CFX_CMapByteStringToPtr m_Map; | 437 std::map<CFX_ByteString, CPDF_Object*> m_Map; |
| 432 | 438 |
| 433 friend class CPDF_Object; | 439 friend class CPDF_Object; |
| 434 }; | 440 }; |
| 435 inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) { | 441 inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) { |
| 436 return obj ? obj->AsDictionary() : nullptr; | 442 return obj ? obj->AsDictionary() : nullptr; |
| 437 } | 443 } |
| 438 inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) { | 444 inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) { |
| 439 return obj ? obj->AsDictionary() : nullptr; | 445 return obj ? obj->AsDictionary() : nullptr; |
| 440 } | 446 } |
| 441 | 447 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 | 604 |
| 599 protected: | 605 protected: |
| 600 CFX_MapPtrToPtr m_IndirectObjs; | 606 CFX_MapPtrToPtr m_IndirectObjs; |
| 601 | 607 |
| 602 CPDF_Parser* m_pParser; | 608 CPDF_Parser* m_pParser; |
| 603 | 609 |
| 604 FX_DWORD m_LastObjNum; | 610 FX_DWORD m_LastObjNum; |
| 605 }; | 611 }; |
| 606 | 612 |
| 607 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ | 613 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ |
| OLD | NEW |