From 5fa4e981ed6c431d86c51a74eba19ea4b816f541 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 5 Apr 2017 11:48:21 -0400 Subject: Move XML attribute handling to a base class. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL moves the attribute handling out of CFDE_XMLElement and CFDE_XMLInstruction into a common CFDE_XMLAttributeNode. The handling is also converted to a std::map from either a) a vector storing name,value,name,value or b) two vectors one for names and the other for values. The unused Get/Set methods for interger and float are removed and the iteration is converted to use iterators. Change-Id: Icda00ae898a595d58b06af0ced337f55f47c317c Reviewed-on: https://pdfium-review.googlesource.com/3753 Reviewed-by: Nicolás Peña Commit-Queue: dsinclair --- xfa/fde/xml/cfde_xmlinstruction.h | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'xfa/fde/xml/cfde_xmlinstruction.h') diff --git a/xfa/fde/xml/cfde_xmlinstruction.h b/xfa/fde/xml/cfde_xmlinstruction.h index 4e891e1fac..e9c4ad3dfe 100644 --- a/xfa/fde/xml/cfde_xmlinstruction.h +++ b/xfa/fde/xml/cfde_xmlinstruction.h @@ -11,9 +11,9 @@ #include #include "core/fxcrt/fx_string.h" -#include "xfa/fde/xml/cfde_xmlnode.h" +#include "xfa/fde/xml/cfde_xmlattributenode.h" -class CFDE_XMLInstruction : public CFDE_XMLNode { +class CFDE_XMLInstruction : public CFDE_XMLAttributeNode { public: explicit CFDE_XMLInstruction(const CFX_WideString& wsTarget); ~CFDE_XMLInstruction() override; @@ -22,29 +22,13 @@ class CFDE_XMLInstruction : public CFDE_XMLNode { FDE_XMLNODETYPE GetType() const override; std::unique_ptr Clone() override; - void GetTargetName(CFX_WideString& wsTarget) const { wsTarget = m_wsTarget; } - int32_t CountAttributes() const; - bool GetAttribute(int32_t index, - CFX_WideString& wsAttriName, - CFX_WideString& wsAttriValue) const; - bool HasAttribute(const wchar_t* pwsAttriName) const; - void GetString(const wchar_t* pwsAttriName, - CFX_WideString& wsAttriValue, - const wchar_t* pwsDefValue = nullptr) const; - void SetString(const CFX_WideString& wsAttriName, - const CFX_WideString& wsAttriValue); - int32_t GetInteger(const wchar_t* pwsAttriName, int32_t iDefValue = 0) const; - void SetInteger(const wchar_t* pwsAttriName, int32_t iAttriValue); - float GetFloat(const wchar_t* pwsAttriName, float fDefValue = 0) const; - void SetFloat(const wchar_t* pwsAttriName, float fAttriValue); - void RemoveAttribute(const wchar_t* pwsAttriName); - int32_t CountData() const; - bool GetData(int32_t index, CFX_WideString& wsData) const; + const std::vector& GetTargetData() const { + return m_TargetData; + } void AppendData(const CFX_WideString& wsData); void RemoveData(int32_t index); - CFX_WideString m_wsTarget; - std::vector m_Attributes; + private: std::vector m_TargetData; }; -- cgit v1.2.3