From bdbfc08f96f89581bea277d5ddd9755e893067d7 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 16 Apr 2018 17:59:07 +0000 Subject: Convert CXFA_XMLLocale to CFX_XML This CL converts CXFA_XMLLocale to use CFX_XML instead of CXML. Change-Id: I1db617a658548ae5979f2f38d72c5b3000998663 Reviewed-on: https://pdfium-review.googlesource.com/30693 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- core/fxcrt/xml/cfx_xmlelement.cpp | 22 ++++++++++++++++++++++ core/fxcrt/xml/cfx_xmlelement.h | 4 ++++ 2 files changed, 26 insertions(+) (limited to 'core/fxcrt') diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp index 530752e1dd..27d136305b 100644 --- a/core/fxcrt/xml/cfx_xmlelement.cpp +++ b/core/fxcrt/xml/cfx_xmlelement.cpp @@ -119,3 +119,25 @@ void CFX_XMLElement::Save( } pXMLStream->WriteString(ws.AsStringView()); } + +CFX_XMLElement* CFX_XMLElement::GetFirstChildNamed( + const WideStringView& name) const { + return GetNthChildNamed(name, 0); +} + +CFX_XMLElement* CFX_XMLElement::GetNthChildNamed(const WideStringView& name, + size_t idx) const { + for (auto* child = GetFirstChild(); child; child = child->GetNextSibling()) { + if (child->GetType() != FX_XMLNODE_Element) + continue; + + CFX_XMLElement* elem = static_cast(child); + if (elem->GetName() != name) + continue; + if (idx == 0) + return elem; + + --idx; + } + return nullptr; +} diff --git a/core/fxcrt/xml/cfx_xmlelement.h b/core/fxcrt/xml/cfx_xmlelement.h index e665e24a98..f713114eb7 100644 --- a/core/fxcrt/xml/cfx_xmlelement.h +++ b/core/fxcrt/xml/cfx_xmlelement.h @@ -23,6 +23,10 @@ class CFX_XMLElement : public CFX_XMLAttributeNode { std::unique_ptr Clone() override; void Save(const RetainPtr& pXMLStream) override; + CFX_XMLElement* GetFirstChildNamed(const WideStringView& name) const; + CFX_XMLElement* GetNthChildNamed(const WideStringView& name, + size_t idx) const; + WideString GetLocalTagName() const; WideString GetNamespacePrefix() const; WideString GetNamespaceURI() const; -- cgit v1.2.3