From 3f1c71f5a6ea058e3eec611c9dcc759b374dcb80 Mon Sep 17 00:00:00 2001 From: Oliver Chang Date: Mon, 11 Jan 2016 08:45:31 -0800 Subject: Merge to XFA: Use std::map as CPDF_Dictionary's underlying store. Replaces CFX_CMapByteStringToPtr. XFA still uses CFX_CMapByteStringToPtr so it's not completely removed just yet. Adds begin()/end() to CPDF_Dictionary and removes the GetStartPos()/GetNextElement() functions to traverse the dictionary. Callers are changed accordingly. AddValue() is also removed. TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1541703003 . (cherry picked from commit 14f39950451bb9c2a11fbc7173fd47367410f80f) Review URL: https://codereview.chromium.org/1576033002 . --- core/include/fpdfapi/fpdf_objects.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'core/include/fpdfapi') diff --git a/core/include/fpdfapi/fpdf_objects.h b/core/include/fpdfapi/fpdf_objects.h index a9a27c74a1..5e17685e65 100644 --- a/core/include/fpdfapi/fpdf_objects.h +++ b/core/include/fpdfapi/fpdf_objects.h @@ -7,6 +7,7 @@ #ifndef CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ +#include #include #include "core/include/fxcrt/fx_coordinates.h" @@ -339,6 +340,9 @@ inline const CPDF_Array* ToArray(const CPDF_Object* obj) { class CPDF_Dictionary : public CPDF_Object { public: + using iterator = std::map::iterator; + using const_iterator = std::map::const_iterator; + CPDF_Dictionary() : CPDF_Object(PDFOBJ_DICTIONARY) {} CPDF_Object* GetElement(const CFX_ByteStringC& key) const; @@ -381,10 +385,6 @@ class CPDF_Dictionary : public CPDF_Object { FX_BOOL KeyExist(const CFX_ByteStringC& key) const; - FX_POSITION GetStartPos() const; - - CPDF_Object* GetNextElement(FX_POSITION& pos, CFX_ByteString& key) const; - void SetAt(const CFX_ByteStringC& key, CPDF_Object* pObj); void SetAtName(const CFX_ByteStringC& key, const CFX_ByteString& name); @@ -421,14 +421,20 @@ class CPDF_Dictionary : public CPDF_Object { FX_BOOL Identical(CPDF_Dictionary* pDict) const; - int GetCount() const { return m_Map.GetCount(); } + size_t GetCount() const { return m_Map.size(); } + + iterator begin() { return m_Map.begin(); } + + iterator end() { return m_Map.end(); } + + const_iterator begin() const { return m_Map.begin(); } - void AddValue(const CFX_ByteStringC& key, CPDF_Object* pObj); + const_iterator end() const { return m_Map.end(); } protected: ~CPDF_Dictionary(); - CFX_CMapByteStringToPtr m_Map; + std::map m_Map; friend class CPDF_Object; }; -- cgit v1.2.3