diff options
Diffstat (limited to 'core/fxcrt/xml')
32 files changed, 266 insertions, 270 deletions
diff --git a/core/fxcrt/xml/cfx_saxcontext.h b/core/fxcrt/xml/cfx_saxcontext.h index f66c76c9cc..d4d74a385b 100644 --- a/core/fxcrt/xml/cfx_saxcontext.h +++ b/core/fxcrt/xml/cfx_saxcontext.h @@ -18,7 +18,7 @@ class CFX_SAXContext { ~CFX_SAXContext(); std::ostringstream m_TextBuf; - CFX_ByteString m_bsTagName; + ByteString m_bsTagName; CFX_SAXItem::Type m_eNode; }; diff --git a/core/fxcrt/xml/cfx_saxreader.cpp b/core/fxcrt/xml/cfx_saxreader.cpp index 641dc08688..e2c09d14cc 100644 --- a/core/fxcrt/xml/cfx_saxreader.cpp +++ b/core/fxcrt/xml/cfx_saxreader.cpp @@ -293,8 +293,8 @@ void CFX_SAXReader::ParseChar(uint8_t ch) { m_iEntityStart = -1; // NOTE: Relies on negative lengths being treated as empty strings. - CFX_ByteString csEntity(m_Data.data() + iSaveStart + 1, - CurrentDataIndex() - iSaveStart - 1); + ByteString csEntity(m_Data.data() + iSaveStart + 1, + CurrentDataIndex() - iSaveStart - 1); int32_t iLen = csEntity.GetLength(); if (iLen == 0) return; @@ -649,7 +649,7 @@ void CFX_SAXReader::NotifyData() { m_pHandler->OnTagData( pItem->m_pNode, m_bCharData ? CFX_SAXItem::Type::CharData : CFX_SAXItem::Type::Text, - CFX_ByteStringC(m_Data), m_File.m_dwCur + m_dwDataOffset); + ByteStringView(m_Data), m_File.m_dwCur + m_dwDataOffset); } void CFX_SAXReader::NotifyEnter() { @@ -662,7 +662,7 @@ void CFX_SAXReader::NotifyEnter() { if (pItem->m_eNode == CFX_SAXItem::Type::Tag || pItem->m_eNode == CFX_SAXItem::Type::Instruction) { - pItem->m_pNode = m_pHandler->OnTagEnter(CFX_ByteStringC(m_Data), + pItem->m_pNode = m_pHandler->OnTagEnter(ByteStringView(m_Data), pItem->m_eNode, m_dwNodePos); } } @@ -677,8 +677,8 @@ void CFX_SAXReader::NotifyAttribute() { if (pItem->m_eNode == CFX_SAXItem::Type::Tag || pItem->m_eNode == CFX_SAXItem::Type::Instruction) { - m_pHandler->OnTagAttribute(pItem->m_pNode, CFX_ByteStringC(m_Name), - CFX_ByteStringC(m_Data)); + m_pHandler->OnTagAttribute(pItem->m_pNode, ByteStringView(m_Name), + ByteStringView(m_Data)); } } @@ -717,7 +717,7 @@ void CFX_SAXReader::NotifyEnd() { return; if (pItem->m_eNode == CFX_SAXItem::Type::Tag) - m_pHandler->OnTagEnd(pItem->m_pNode, CFX_ByteStringC(m_Data), m_dwNodePos); + m_pHandler->OnTagEnd(pItem->m_pNode, ByteStringView(m_Data), m_dwNodePos); } void CFX_SAXReader::NotifyTargetData() { @@ -730,10 +730,10 @@ void CFX_SAXReader::NotifyTargetData() { if (pItem->m_eNode == CFX_SAXItem::Type::Instruction) { m_pHandler->OnTargetData(pItem->m_pNode, pItem->m_eNode, - CFX_ByteStringC(m_Name), m_dwNodePos); + ByteStringView(m_Name), m_dwNodePos); } else if (pItem->m_eNode == CFX_SAXItem::Type::Comment) { m_pHandler->OnTargetData(pItem->m_pNode, pItem->m_eNode, - CFX_ByteStringC(m_Data), m_dwNodePos); + ByteStringView(m_Data), m_dwNodePos); } } diff --git a/core/fxcrt/xml/cfx_saxreader.h b/core/fxcrt/xml/cfx_saxreader.h index 3db1c7c80c..51d9e43121 100644 --- a/core/fxcrt/xml/cfx_saxreader.h +++ b/core/fxcrt/xml/cfx_saxreader.h @@ -75,24 +75,24 @@ class CFX_SAXReader { class HandlerIface { public: virtual ~HandlerIface() {} - virtual CFX_SAXContext* OnTagEnter(const CFX_ByteStringC& bsTagName, + virtual CFX_SAXContext* OnTagEnter(const ByteStringView& bsTagName, CFX_SAXItem::Type eType, uint32_t dwStartPos) = 0; virtual void OnTagAttribute(CFX_SAXContext* pTag, - const CFX_ByteStringC& bsAttri, - const CFX_ByteStringC& bsValue) = 0; + const ByteStringView& bsAttri, + const ByteStringView& bsValue) = 0; virtual void OnTagBreak(CFX_SAXContext* pTag) = 0; virtual void OnTagData(CFX_SAXContext* pTag, CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, + const ByteStringView& bsData, uint32_t dwStartPos) = 0; virtual void OnTagClose(CFX_SAXContext* pTag, uint32_t dwEndPos) = 0; virtual void OnTagEnd(CFX_SAXContext* pTag, - const CFX_ByteStringC& bsTagName, + const ByteStringView& bsTagName, uint32_t dwEndPos) = 0; virtual void OnTargetData(CFX_SAXContext* pTag, CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, + const ByteStringView& bsData, uint32_t dwStartPos) = 0; }; diff --git a/core/fxcrt/xml/cfx_saxreader_unittest.cpp b/core/fxcrt/xml/cfx_saxreader_unittest.cpp index 62828500c9..13d06325a7 100644 --- a/core/fxcrt/xml/cfx_saxreader_unittest.cpp +++ b/core/fxcrt/xml/cfx_saxreader_unittest.cpp @@ -17,28 +17,28 @@ namespace { class MockHandler : public CFX_SAXReader::HandlerIface { public: MOCK_METHOD3(OnTagEnter, - CFX_SAXContext*(const CFX_ByteStringC& bsTagName, + CFX_SAXContext*(const ByteStringView& bsTagName, CFX_SAXItem::Type eType, uint32_t dwStartPos)); MOCK_METHOD3(OnTagAttribute, void(CFX_SAXContext* pTag, - const CFX_ByteStringC& bsAttri, - const CFX_ByteStringC& bsValue)); + const ByteStringView& bsAttri, + const ByteStringView& bsValue)); MOCK_METHOD1(OnTagBreak, void(CFX_SAXContext* pTag)); MOCK_METHOD4(OnTagData, void(CFX_SAXContext* pTag, CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, + const ByteStringView& bsData, uint32_t dwStartPos)); MOCK_METHOD2(OnTagClose, void(CFX_SAXContext* pTag, uint32_t dwEndPos)); MOCK_METHOD3(OnTagEnd, void(CFX_SAXContext* pTag, - const CFX_ByteStringC& bsTagName, + const ByteStringView& bsTagName, uint32_t dwEndPos)); MOCK_METHOD4(OnTargetData, void(CFX_SAXContext* pTag, CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, + const ByteStringView& bsData, uint32_t dwStartPos)); }; diff --git a/core/fxcrt/xml/cfx_saxreaderhandler.cpp b/core/fxcrt/xml/cfx_saxreaderhandler.cpp index b8399ff5cc..d255ce924d 100644 --- a/core/fxcrt/xml/cfx_saxreaderhandler.cpp +++ b/core/fxcrt/xml/cfx_saxreaderhandler.cpp @@ -18,7 +18,7 @@ CFX_SAXReaderHandler::CFX_SAXReaderHandler(CFX_ChecksumContext* pContext) CFX_SAXReaderHandler::~CFX_SAXReaderHandler() {} CFX_SAXContext* CFX_SAXReaderHandler::OnTagEnter( - const CFX_ByteStringC& bsTagName, + const ByteStringView& bsTagName, CFX_SAXItem::Type eType, uint32_t dwStartPos) { UpdateChecksum(true); @@ -38,8 +38,8 @@ CFX_SAXContext* CFX_SAXReaderHandler::OnTagEnter( } void CFX_SAXReaderHandler::OnTagAttribute(CFX_SAXContext* pTag, - const CFX_ByteStringC& bsAttri, - const CFX_ByteStringC& bsValue) { + const ByteStringView& bsAttri, + const ByteStringView& bsValue) { if (!pTag) return; pTag->m_TextBuf << " " << bsAttri << "=\"" << bsValue << "\""; @@ -55,7 +55,7 @@ void CFX_SAXReaderHandler::OnTagBreak(CFX_SAXContext* pTag) { void CFX_SAXReaderHandler::OnTagData(CFX_SAXContext* pTag, CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, + const ByteStringView& bsData, uint32_t dwStartPos) { if (!pTag) return; @@ -75,13 +75,13 @@ void CFX_SAXReaderHandler::OnTagClose(CFX_SAXContext* pTag, uint32_t dwEndPos) { if (pTag->m_eNode == CFX_SAXItem::Type::Instruction) pTag->m_TextBuf << "?>"; else if (pTag->m_eNode == CFX_SAXItem::Type::Tag) - pTag->m_TextBuf << "></" << pTag->m_bsTagName.AsStringC() << ">"; + pTag->m_TextBuf << "></" << pTag->m_bsTagName.AsStringView() << ">"; UpdateChecksum(false); } void CFX_SAXReaderHandler::OnTagEnd(CFX_SAXContext* pTag, - const CFX_ByteStringC& bsTagName, + const ByteStringView& bsTagName, uint32_t dwEndPos) { if (!pTag) return; @@ -92,7 +92,7 @@ void CFX_SAXReaderHandler::OnTagEnd(CFX_SAXContext* pTag, void CFX_SAXReaderHandler::OnTargetData(CFX_SAXContext* pTag, CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, + const ByteStringView& bsData, uint32_t dwStartPos) { if (!pTag && eType != CFX_SAXItem::Type::Comment) return; @@ -122,7 +122,7 @@ void CFX_SAXReaderHandler::UpdateChecksum(bool bCheckSpace) { } } if (bUpdata) - m_pContext->Update(CFX_ByteStringC(pBuffer, iLength)); + m_pContext->Update(ByteStringView(pBuffer, iLength)); m_SAXContext.m_TextBuf.str(""); } diff --git a/core/fxcrt/xml/cfx_saxreaderhandler.h b/core/fxcrt/xml/cfx_saxreaderhandler.h index c5e1dc28b6..263008f1ff 100644 --- a/core/fxcrt/xml/cfx_saxreaderhandler.h +++ b/core/fxcrt/xml/cfx_saxreaderhandler.h @@ -18,24 +18,24 @@ class CFX_SAXReaderHandler : public CFX_SAXReader::HandlerIface { explicit CFX_SAXReaderHandler(CFX_ChecksumContext* pContext); ~CFX_SAXReaderHandler() override; - CFX_SAXContext* OnTagEnter(const CFX_ByteStringC& bsTagName, + CFX_SAXContext* OnTagEnter(const ByteStringView& bsTagName, CFX_SAXItem::Type eType, uint32_t dwStartPos) override; void OnTagAttribute(CFX_SAXContext* pTag, - const CFX_ByteStringC& bsAttri, - const CFX_ByteStringC& bsValue) override; + const ByteStringView& bsAttri, + const ByteStringView& bsValue) override; void OnTagBreak(CFX_SAXContext* pTag) override; void OnTagData(CFX_SAXContext* pTag, CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, + const ByteStringView& bsData, uint32_t dwStartPos) override; void OnTagClose(CFX_SAXContext* pTag, uint32_t dwEndPos) override; void OnTagEnd(CFX_SAXContext* pTag, - const CFX_ByteStringC& bsTagName, + const ByteStringView& bsTagName, uint32_t dwEndPos) override; void OnTargetData(CFX_SAXContext* pTag, CFX_SAXItem::Type eType, - const CFX_ByteStringC& bsData, + const ByteStringView& bsData, uint32_t dwStartPos) override; private: diff --git a/core/fxcrt/xml/cfx_xmlattributenode.cpp b/core/fxcrt/xml/cfx_xmlattributenode.cpp index 9ea6756839..6104747793 100644 --- a/core/fxcrt/xml/cfx_xmlattributenode.cpp +++ b/core/fxcrt/xml/cfx_xmlattributenode.cpp @@ -8,28 +8,27 @@ #include "core/fxcrt/fx_extension.h" -CFX_XMLAttributeNode::CFX_XMLAttributeNode(const CFX_WideString& name) +CFX_XMLAttributeNode::CFX_XMLAttributeNode(const WideString& name) : CFX_XMLNode(), name_(name) { ASSERT(name_.GetLength() > 0); } CFX_XMLAttributeNode::~CFX_XMLAttributeNode() {} -bool CFX_XMLAttributeNode::HasAttribute(const CFX_WideString& name) const { +bool CFX_XMLAttributeNode::HasAttribute(const WideString& name) const { return attrs_.find(name) != attrs_.end(); } -CFX_WideString CFX_XMLAttributeNode::GetString( - const CFX_WideString& name) const { +WideString CFX_XMLAttributeNode::GetString(const WideString& name) const { auto it = attrs_.find(name); - return it != attrs_.end() ? it->second : CFX_WideString(); + return it != attrs_.end() ? it->second : WideString(); } -void CFX_XMLAttributeNode::SetString(const CFX_WideString& name, - const CFX_WideString& value) { +void CFX_XMLAttributeNode::SetString(const WideString& name, + const WideString& value) { attrs_[name] = value; } -void CFX_XMLAttributeNode::RemoveAttribute(const CFX_WideString& name) { +void CFX_XMLAttributeNode::RemoveAttribute(const WideString& name) { attrs_.erase(name); } diff --git a/core/fxcrt/xml/cfx_xmlattributenode.h b/core/fxcrt/xml/cfx_xmlattributenode.h index e8f358eb59..1ac9b84db2 100644 --- a/core/fxcrt/xml/cfx_xmlattributenode.h +++ b/core/fxcrt/xml/cfx_xmlattributenode.h @@ -15,30 +15,30 @@ class CFX_XMLAttributeNode : public CFX_XMLNode { public: - explicit CFX_XMLAttributeNode(const CFX_WideString& name); + explicit CFX_XMLAttributeNode(const WideString& name); ~CFX_XMLAttributeNode() override; // CFX_XMLNode FX_XMLNODETYPE GetType() const override = 0; std::unique_ptr<CFX_XMLNode> Clone() override = 0; - CFX_WideString GetName() const { return name_; } - const std::map<CFX_WideString, CFX_WideString>& GetAttributes() const { + WideString GetName() const { return name_; } + const std::map<WideString, WideString>& GetAttributes() const { return attrs_; } - void SetAttributes(const std::map<CFX_WideString, CFX_WideString>& attrs) { + void SetAttributes(const std::map<WideString, WideString>& attrs) { attrs_ = attrs; } - bool HasAttribute(const CFX_WideString& name) const; + bool HasAttribute(const WideString& name) const; - void SetString(const CFX_WideString& name, const CFX_WideString& value); - CFX_WideString GetString(const CFX_WideString& name) const; + void SetString(const WideString& name, const WideString& value); + WideString GetString(const WideString& name) const; - void RemoveAttribute(const CFX_WideString& name); + void RemoveAttribute(const WideString& name); private: - CFX_WideString name_; - std::map<CFX_WideString, CFX_WideString> attrs_; + WideString name_; + std::map<WideString, WideString> attrs_; }; #endif // CORE_FXCRT_XML_CFX_XMLATTRIBUTENODE_H_ diff --git a/core/fxcrt/xml/cfx_xmlchardata.cpp b/core/fxcrt/xml/cfx_xmlchardata.cpp index 185bd064df..902d139c99 100644 --- a/core/fxcrt/xml/cfx_xmlchardata.cpp +++ b/core/fxcrt/xml/cfx_xmlchardata.cpp @@ -8,7 +8,7 @@ #include "third_party/base/ptr_util.h" -CFX_XMLCharData::CFX_XMLCharData(const CFX_WideString& wsCData) +CFX_XMLCharData::CFX_XMLCharData(const WideString& wsCData) : CFX_XMLText(wsCData) {} CFX_XMLCharData::~CFX_XMLCharData() {} diff --git a/core/fxcrt/xml/cfx_xmlchardata.h b/core/fxcrt/xml/cfx_xmlchardata.h index c5c007be90..9a4710fa51 100644 --- a/core/fxcrt/xml/cfx_xmlchardata.h +++ b/core/fxcrt/xml/cfx_xmlchardata.h @@ -14,7 +14,7 @@ class CFX_XMLCharData : public CFX_XMLText { public: - explicit CFX_XMLCharData(const CFX_WideString& wsCData); + explicit CFX_XMLCharData(const WideString& wsCData); ~CFX_XMLCharData() override; FX_XMLNODETYPE GetType() const override; diff --git a/core/fxcrt/xml/cfx_xmldoc.cpp b/core/fxcrt/xml/cfx_xmldoc.cpp index 6fce38cea6..e9a09b761b 100644 --- a/core/fxcrt/xml/cfx_xmldoc.cpp +++ b/core/fxcrt/xml/cfx_xmldoc.cpp @@ -53,7 +53,7 @@ void CFX_XMLDoc::SaveXMLNode( CFX_XMLNode* pNode = (CFX_XMLNode*)pINode; switch (pNode->GetType()) { case FX_XMLNODE_Instruction: { - CFX_WideString ws; + WideString ws; CFX_XMLInstruction* pInstruction = (CFX_XMLInstruction*)pNode; if (pInstruction->GetName().CompareNoCase(L"xml") == 0) { ws = L"<?xml version=\"1.0\" encoding=\""; @@ -66,13 +66,13 @@ void CFX_XMLDoc::SaveXMLNode( ws += L"UTF-8"; } ws += L"\"?>"; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); } else { ws.Format(L"<?%s", pInstruction->GetName().c_str()); - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); for (auto it : pInstruction->GetAttributes()) { - CFX_WideString wsValue = it.second; + WideString wsValue = it.second; wsValue.Replace(L"&", L"&"); wsValue.Replace(L"<", L"<"); wsValue.Replace(L">", L">"); @@ -84,28 +84,28 @@ void CFX_XMLDoc::SaveXMLNode( ws += L"=\""; ws += wsValue; ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); } for (auto target : pInstruction->GetTargetData()) { ws = L" \""; ws += target; ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); } ws = L"?>"; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); } break; } case FX_XMLNODE_Element: { - CFX_WideString ws; + WideString ws; ws = L"<"; ws += static_cast<CFX_XMLElement*>(pNode)->GetName(); - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); for (auto it : static_cast<CFX_XMLElement*>(pNode)->GetAttributes()) { - CFX_WideString wsValue = it.second; + WideString wsValue = it.second; wsValue.Replace(L"&", L"&"); wsValue.Replace(L"<", L"<"); wsValue.Replace(L">", L">"); @@ -117,11 +117,11 @@ void CFX_XMLDoc::SaveXMLNode( ws += L"=\""; ws += wsValue; ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); } if (pNode->m_pChild) { ws = L"\n>"; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); CFX_XMLNode* pChild = pNode->m_pChild; while (pChild) { SaveXMLNode(pXMLStream, static_cast<CFX_XMLNode*>(pChild)); @@ -133,24 +133,24 @@ void CFX_XMLDoc::SaveXMLNode( } else { ws = L"\n/>"; } - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); break; } case FX_XMLNODE_Text: { - CFX_WideString ws = static_cast<CFX_XMLText*>(pNode)->GetText(); + WideString ws = static_cast<CFX_XMLText*>(pNode)->GetText(); ws.Replace(L"&", L"&"); ws.Replace(L"<", L"<"); ws.Replace(L">", L">"); ws.Replace(L"\'", L"'"); ws.Replace(L"\"", L"""); - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); break; } case FX_XMLNODE_CharData: { - CFX_WideString ws = L"<![CDATA["; + WideString ws = L"<![CDATA["; ws += static_cast<CFX_XMLCharData*>(pNode)->GetText(); ws += L"]]>"; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); break; } case FX_XMLNODE_Unknown: diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp index 5b5fe45561..1317e9a72b 100644 --- a/core/fxcrt/xml/cfx_xmlelement.cpp +++ b/core/fxcrt/xml/cfx_xmlelement.cpp @@ -15,7 +15,7 @@ #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -CFX_XMLElement::CFX_XMLElement(const CFX_WideString& wsTag) +CFX_XMLElement::CFX_XMLElement(const WideString& wsTag) : CFX_XMLAttributeNode(wsTag) {} CFX_XMLElement::~CFX_XMLElement() {} @@ -28,7 +28,7 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLElement::Clone() { auto pClone = pdfium::MakeUnique<CFX_XMLElement>(GetName()); pClone->SetAttributes(GetAttributes()); - CFX_WideString wsText; + WideString wsText; CFX_XMLNode* pChild = m_pChild; while (pChild) { switch (pChild->GetType()) { @@ -44,21 +44,21 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLElement::Clone() { return std::move(pClone); } -CFX_WideString CFX_XMLElement::GetLocalTagName() const { +WideString CFX_XMLElement::GetLocalTagName() const { auto pos = GetName().Find(L':'); return pos.has_value() ? GetName().Right(GetName().GetLength() - pos.value() - 1) : GetName(); } -CFX_WideString CFX_XMLElement::GetNamespacePrefix() const { +WideString CFX_XMLElement::GetNamespacePrefix() const { auto pos = GetName().Find(L':'); - return pos.has_value() ? GetName().Left(pos.value()) : CFX_WideString(); + return pos.has_value() ? GetName().Left(pos.value()) : WideString(); } -CFX_WideString CFX_XMLElement::GetNamespaceURI() const { - CFX_WideString wsAttri(L"xmlns"); - CFX_WideString wsPrefix = GetNamespacePrefix(); +WideString CFX_XMLElement::GetNamespaceURI() const { + WideString wsAttri(L"xmlns"); + WideString wsPrefix = GetNamespacePrefix(); if (wsPrefix.GetLength() > 0) { wsAttri += L":"; wsAttri += wsPrefix; @@ -76,10 +76,10 @@ CFX_WideString CFX_XMLElement::GetNamespaceURI() const { } return pElement->GetString(wsAttri); } - return CFX_WideString(); + return WideString(); } -CFX_WideString CFX_XMLElement::GetTextData() const { +WideString CFX_XMLElement::GetTextData() const { CFX_WideTextBuf buffer; CFX_XMLNode* pChild = m_pChild; while (pChild) { @@ -96,7 +96,7 @@ CFX_WideString CFX_XMLElement::GetTextData() const { return buffer.MakeString(); } -void CFX_XMLElement::SetTextData(const CFX_WideString& wsText) { +void CFX_XMLElement::SetTextData(const WideString& wsText) { if (wsText.GetLength() < 1) return; InsertChildNode(new CFX_XMLText(wsText)); diff --git a/core/fxcrt/xml/cfx_xmlelement.h b/core/fxcrt/xml/cfx_xmlelement.h index 20780342af..59e3af6a44 100644 --- a/core/fxcrt/xml/cfx_xmlelement.h +++ b/core/fxcrt/xml/cfx_xmlelement.h @@ -15,19 +15,19 @@ class CFX_XMLElement : public CFX_XMLAttributeNode { public: - explicit CFX_XMLElement(const CFX_WideString& wsTag); + explicit CFX_XMLElement(const WideString& wsTag); ~CFX_XMLElement() override; // CFX_XMLNode FX_XMLNODETYPE GetType() const override; std::unique_ptr<CFX_XMLNode> Clone() override; - CFX_WideString GetLocalTagName() const; - CFX_WideString GetNamespacePrefix() const; - CFX_WideString GetNamespaceURI() const; + WideString GetLocalTagName() const; + WideString GetNamespacePrefix() const; + WideString GetNamespaceURI() const; - CFX_WideString GetTextData() const; - void SetTextData(const CFX_WideString& wsText); + WideString GetTextData() const; + void SetTextData(const WideString& wsText); }; #endif // CORE_FXCRT_XML_CFX_XMLELEMENT_H_ diff --git a/core/fxcrt/xml/cfx_xmlinstruction.cpp b/core/fxcrt/xml/cfx_xmlinstruction.cpp index 3c7deda92a..75a4a2eec6 100644 --- a/core/fxcrt/xml/cfx_xmlinstruction.cpp +++ b/core/fxcrt/xml/cfx_xmlinstruction.cpp @@ -12,7 +12,7 @@ #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -CFX_XMLInstruction::CFX_XMLInstruction(const CFX_WideString& wsTarget) +CFX_XMLInstruction::CFX_XMLInstruction(const WideString& wsTarget) : CFX_XMLAttributeNode(wsTarget) {} CFX_XMLInstruction::~CFX_XMLInstruction() {} @@ -28,7 +28,7 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLInstruction::Clone() { return std::move(pClone); } -void CFX_XMLInstruction::AppendData(const CFX_WideString& wsData) { +void CFX_XMLInstruction::AppendData(const WideString& wsData) { m_TargetData.push_back(wsData); } diff --git a/core/fxcrt/xml/cfx_xmlinstruction.h b/core/fxcrt/xml/cfx_xmlinstruction.h index 99554fc239..ff27dae3a4 100644 --- a/core/fxcrt/xml/cfx_xmlinstruction.h +++ b/core/fxcrt/xml/cfx_xmlinstruction.h @@ -15,21 +15,19 @@ class CFX_XMLInstruction : public CFX_XMLAttributeNode { public: - explicit CFX_XMLInstruction(const CFX_WideString& wsTarget); + explicit CFX_XMLInstruction(const WideString& wsTarget); ~CFX_XMLInstruction() override; // CFX_XMLNode FX_XMLNODETYPE GetType() const override; std::unique_ptr<CFX_XMLNode> Clone() override; - const std::vector<CFX_WideString>& GetTargetData() const { - return m_TargetData; - } - void AppendData(const CFX_WideString& wsData); + const std::vector<WideString>& GetTargetData() const { return m_TargetData; } + void AppendData(const WideString& wsData); void RemoveData(int32_t index); private: - std::vector<CFX_WideString> m_TargetData; + std::vector<WideString> m_TargetData; }; #endif // CORE_FXCRT_XML_CFX_XMLINSTRUCTION_H_ diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp index 47b3105f10..7a893af4a0 100644 --- a/core/fxcrt/xml/cfx_xmlnode.cpp +++ b/core/fxcrt/xml/cfx_xmlnode.cpp @@ -84,7 +84,7 @@ CFX_XMLNode* CFX_XMLNode::GetPath(const wchar_t* pPath, if (iLength == 0) { return nullptr; } - CFX_WideString csPath; + WideString csPath; const wchar_t* pStart = pPath; const wchar_t* pEnd = pPath + iLength; wchar_t ch; @@ -105,7 +105,7 @@ CFX_XMLNode* CFX_XMLNode::GetPath(const wchar_t* pPath, } else if (csPath.Compare(L".") == 0) { pFind = (CFX_XMLNode*)this; } else { - CFX_WideString wsTag; + WideString wsTag; CFX_XMLNode* pNode = m_pChild; while (pNode) { if (pNode->GetType() == FX_XMLNODE_Element) { @@ -334,7 +334,7 @@ void CFX_XMLNode::SaveXMLNode( CFX_XMLNode* pNode = (CFX_XMLNode*)this; switch (pNode->GetType()) { case FX_XMLNODE_Instruction: { - CFX_WideString ws; + WideString ws; CFX_XMLInstruction* pInstruction = (CFX_XMLInstruction*)pNode; if (pInstruction->GetName().CompareNoCase(L"xml") == 0) { ws = L"<?xml version=\"1.0\" encoding=\""; @@ -347,13 +347,13 @@ void CFX_XMLNode::SaveXMLNode( ws += L"UTF-8"; } ws += L"\"?>"; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); } else { ws.Format(L"<?%s", pInstruction->GetName().c_str()); - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); for (auto it : pInstruction->GetAttributes()) { - CFX_WideString wsValue = it.second; + WideString wsValue = it.second; wsValue.Replace(L"&", L"&"); wsValue.Replace(L"<", L"<"); wsValue.Replace(L">", L">"); @@ -365,28 +365,28 @@ void CFX_XMLNode::SaveXMLNode( ws += L"=\""; ws += wsValue; ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); } for (auto target : pInstruction->GetTargetData()) { ws = L" \""; ws += target; ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); } ws = L"?>"; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); } break; } case FX_XMLNODE_Element: { - CFX_WideString ws; + WideString ws; ws = L"<"; ws += static_cast<CFX_XMLElement*>(pNode)->GetName(); - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); for (auto it : static_cast<CFX_XMLElement*>(pNode)->GetAttributes()) { - CFX_WideString wsValue = it.second; + WideString wsValue = it.second; wsValue.Replace(L"&", L"&"); wsValue.Replace(L"<", L"<"); wsValue.Replace(L">", L">"); @@ -398,11 +398,11 @@ void CFX_XMLNode::SaveXMLNode( ws += L"=\""; ws += wsValue; ws += L"\""; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); } if (pNode->m_pChild) { ws = L"\n>"; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); CFX_XMLNode* pChild = pNode->m_pChild; while (pChild) { pChild->SaveXMLNode(pXMLStream); @@ -414,24 +414,24 @@ void CFX_XMLNode::SaveXMLNode( } else { ws = L"\n/>"; } - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); break; } case FX_XMLNODE_Text: { - CFX_WideString ws = static_cast<CFX_XMLText*>(pNode)->GetText(); + WideString ws = static_cast<CFX_XMLText*>(pNode)->GetText(); ws.Replace(L"&", L"&"); ws.Replace(L"<", L"<"); ws.Replace(L">", L">"); ws.Replace(L"\'", L"'"); ws.Replace(L"\"", L"""); - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); break; } case FX_XMLNODE_CharData: { - CFX_WideString ws = L"<![CDATA["; + WideString ws = L"<![CDATA["; ws += static_cast<CFX_XMLCharData*>(pNode)->GetText(); ws += L"]]>"; - pXMLStream->WriteString(ws.AsStringC()); + pXMLStream->WriteString(ws.AsStringView()); break; } case FX_XMLNODE_Unknown: diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp index ce45481512..280c06d3f1 100644 --- a/core/fxcrt/xml/cfx_xmlparser.cpp +++ b/core/fxcrt/xml/cfx_xmlparser.cpp @@ -101,7 +101,7 @@ int32_t CFX_XMLParser::DoParser() { m_pParent = m_pChild; if (m_dwCheckStatus != 0x03 && m_NodeStack.size() == 3) { - CFX_WideString wsTag = + WideString wsTag = static_cast<CFX_XMLElement*>(m_pChild)->GetLocalTagName(); if (wsTag == L"template") { m_dwCheckStatus |= 0x01; diff --git a/core/fxcrt/xml/cfx_xmlparser.h b/core/fxcrt/xml/cfx_xmlparser.h index 9746d78ae8..f98b658d9a 100644 --- a/core/fxcrt/xml/cfx_xmlparser.h +++ b/core/fxcrt/xml/cfx_xmlparser.h @@ -38,8 +38,8 @@ class CFX_XMLParser { CFX_XMLNode* m_pParent; CFX_XMLNode* m_pChild; std::stack<CFX_XMLNode*> m_NodeStack; - CFX_WideString m_ws1; - CFX_WideString m_ws2; + WideString m_ws1; + WideString m_ws2; FX_XmlSyntaxResult m_syntaxParserResult; }; diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp index bbbc4f4399..d55985240d 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp @@ -623,7 +623,7 @@ void CFX_XMLSyntaxParser::ParseTextChar(wchar_t character) { m_pCurrentBlock[m_iIndexInBlock++] = character; m_BlockBuffer.IncrementDataLength(); if (m_iEntityStart > -1 && character == L';') { - CFX_WideString csEntity = m_BlockBuffer.GetTextData( + WideString csEntity = m_BlockBuffer.GetTextData( m_iEntityStart + 1, m_BlockBuffer.GetDataLength() - 1 - m_iEntityStart - 1); int32_t iLen = csEntity.GetLength(); diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.h b/core/fxcrt/xml/cfx_xmlsyntaxparser.h index c59cabae19..d3f4bf2edb 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.h +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.h @@ -50,27 +50,27 @@ class CFX_XMLSyntaxParser { int32_t GetCurrentNodeNumber() const { return m_iCurrentNodeNum; } int32_t GetLastNodeNumber() const { return m_iLastNodeNum; } - CFX_WideString GetTargetName() const { + WideString GetTargetName() const { return m_BlockBuffer.GetTextData(0, m_iTextDataLength); } - CFX_WideString GetTagName() const { + WideString GetTagName() const { return m_BlockBuffer.GetTextData(0, m_iTextDataLength); } - CFX_WideString GetAttributeName() const { + WideString GetAttributeName() const { return m_BlockBuffer.GetTextData(0, m_iTextDataLength); } - CFX_WideString GetAttributeValue() const { + WideString GetAttributeValue() const { return m_BlockBuffer.GetTextData(0, m_iTextDataLength); } - CFX_WideString GetTextData() const { + WideString GetTextData() const { return m_BlockBuffer.GetTextData(0, m_iTextDataLength); } - CFX_WideString GetTargetData() const { + WideString GetTargetData() const { return m_BlockBuffer.GetTextData(0, m_iTextDataLength); } diff --git a/core/fxcrt/xml/cfx_xmltext.cpp b/core/fxcrt/xml/cfx_xmltext.cpp index 4c41fcd9f8..83ad0434bf 100644 --- a/core/fxcrt/xml/cfx_xmltext.cpp +++ b/core/fxcrt/xml/cfx_xmltext.cpp @@ -8,7 +8,7 @@ #include "third_party/base/ptr_util.h" -CFX_XMLText::CFX_XMLText(const CFX_WideString& wsText) +CFX_XMLText::CFX_XMLText(const WideString& wsText) : CFX_XMLNode(), m_wsText(wsText) {} CFX_XMLText::~CFX_XMLText() {} diff --git a/core/fxcrt/xml/cfx_xmltext.h b/core/fxcrt/xml/cfx_xmltext.h index 20fb858302..e9f35855f5 100644 --- a/core/fxcrt/xml/cfx_xmltext.h +++ b/core/fxcrt/xml/cfx_xmltext.h @@ -14,18 +14,18 @@ class CFX_XMLText : public CFX_XMLNode { public: - explicit CFX_XMLText(const CFX_WideString& wsText); + explicit CFX_XMLText(const WideString& wsText); ~CFX_XMLText() override; // CFX_XMLNode FX_XMLNODETYPE GetType() const override; std::unique_ptr<CFX_XMLNode> Clone() override; - CFX_WideString GetText() const { return m_wsText; } - void SetText(const CFX_WideString& wsText) { m_wsText = wsText; } + WideString GetText() const { return m_wsText; } + void SetText(const WideString& wsText) { m_wsText = wsText; } private: - CFX_WideString m_wsText; + WideString m_wsText; }; #endif // CORE_FXCRT_XML_CFX_XMLTEXT_H_ diff --git a/core/fxcrt/xml/cxml_attritem.cpp b/core/fxcrt/xml/cxml_attritem.cpp index 8e55799a62..cbbf3f6041 100644 --- a/core/fxcrt/xml/cxml_attritem.cpp +++ b/core/fxcrt/xml/cxml_attritem.cpp @@ -6,7 +6,7 @@ #include "core/fxcrt/xml/cxml_attritem.h" -bool CXML_AttrItem::Matches(const CFX_ByteString& space, - const CFX_ByteString& name) const { +bool CXML_AttrItem::Matches(const ByteString& space, + const ByteString& name) const { return (space.IsEmpty() || m_QSpaceName == space) && m_AttrName == name; } diff --git a/core/fxcrt/xml/cxml_attritem.h b/core/fxcrt/xml/cxml_attritem.h index 63305e80c8..84d82950f9 100644 --- a/core/fxcrt/xml/cxml_attritem.h +++ b/core/fxcrt/xml/cxml_attritem.h @@ -11,11 +11,11 @@ class CXML_AttrItem { public: - bool Matches(const CFX_ByteString& space, const CFX_ByteString& name) const; + bool Matches(const ByteString& space, const ByteString& name) const; - CFX_ByteString m_QSpaceName; - CFX_ByteString m_AttrName; - CFX_WideString m_Value; + ByteString m_QSpaceName; + ByteString m_AttrName; + WideString m_Value; }; #endif // CORE_FXCRT_XML_CXML_ATTRITEM_H_ diff --git a/core/fxcrt/xml/cxml_attrmap.cpp b/core/fxcrt/xml/cxml_attrmap.cpp index 8d226fe5f0..733bbeaa71 100644 --- a/core/fxcrt/xml/cxml_attrmap.cpp +++ b/core/fxcrt/xml/cxml_attrmap.cpp @@ -13,8 +13,8 @@ CXML_AttrMap::CXML_AttrMap() {} CXML_AttrMap::~CXML_AttrMap() {} -const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteString& space, - const CFX_ByteString& name) const { +const WideString* CXML_AttrMap::Lookup(const ByteString& space, + const ByteString& name) const { if (!m_pMap) return nullptr; @@ -25,9 +25,9 @@ const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteString& space, return nullptr; } -void CXML_AttrMap::SetAt(const CFX_ByteString& space, - const CFX_ByteString& name, - const CFX_WideString& value) { +void CXML_AttrMap::SetAt(const ByteString& space, + const ByteString& name, + const WideString& value) { if (!m_pMap) m_pMap = pdfium::MakeUnique<std::vector<CXML_AttrItem>>(); @@ -38,7 +38,7 @@ void CXML_AttrMap::SetAt(const CFX_ByteString& space, } } - m_pMap->push_back({space, name, CFX_WideString(value)}); + m_pMap->push_back({space, name, WideString(value)}); } int CXML_AttrMap::GetSize() const { diff --git a/core/fxcrt/xml/cxml_attrmap.h b/core/fxcrt/xml/cxml_attrmap.h index 0a026d31d7..a09522b53c 100644 --- a/core/fxcrt/xml/cxml_attrmap.h +++ b/core/fxcrt/xml/cxml_attrmap.h @@ -18,14 +18,14 @@ class CXML_AttrMap { CXML_AttrMap(); ~CXML_AttrMap(); - const CFX_WideString* Lookup(const CFX_ByteString& space, - const CFX_ByteString& name) const; + const WideString* Lookup(const ByteString& space, + const ByteString& name) const; int GetSize() const; CXML_AttrItem& GetAt(int index) const; - void SetAt(const CFX_ByteString& space, - const CFX_ByteString& name, - const CFX_WideString& value); + void SetAt(const ByteString& space, + const ByteString& name, + const WideString& value); std::unique_ptr<std::vector<CXML_AttrItem>> m_pMap; }; diff --git a/core/fxcrt/xml/cxml_content.cpp b/core/fxcrt/xml/cxml_content.cpp index fe0c185bb7..a235009424 100644 --- a/core/fxcrt/xml/cxml_content.cpp +++ b/core/fxcrt/xml/cxml_content.cpp @@ -6,7 +6,7 @@ #include "core/fxcrt/xml/cxml_content.h" -CXML_Content::CXML_Content(bool bCDATA, const CFX_WideStringC& content) +CXML_Content::CXML_Content(bool bCDATA, const WideStringView& content) : m_bCDATA(bCDATA), m_Content(content) {} CXML_Content::~CXML_Content() {} diff --git a/core/fxcrt/xml/cxml_content.h b/core/fxcrt/xml/cxml_content.h index 641efe6720..97c1abfe1c 100644 --- a/core/fxcrt/xml/cxml_content.h +++ b/core/fxcrt/xml/cxml_content.h @@ -12,7 +12,7 @@ class CXML_Content : public CXML_Object { public: - CXML_Content(bool bCDATA, const CFX_WideStringC& content); + CXML_Content(bool bCDATA, const WideStringView& content); ~CXML_Content() override; // CXML_Object: @@ -20,7 +20,7 @@ class CXML_Content : public CXML_Object { const CXML_Content* AsContent() const override; bool m_bCDATA; - CFX_WideString m_Content; + WideString m_Content; }; #endif // CORE_FXCRT_XML_CXML_CONTENT_H_ diff --git a/core/fxcrt/xml/cxml_element.cpp b/core/fxcrt/xml/cxml_element.cpp index ec0a73b00d..42cbdec311 100644 --- a/core/fxcrt/xml/cxml_element.cpp +++ b/core/fxcrt/xml/cxml_element.cpp @@ -19,8 +19,8 @@ std::unique_ptr<CXML_Element> CXML_Element::Parse(const void* pBuffer, } CXML_Element::CXML_Element(const CXML_Element* pParent, - const CFX_ByteStringC& qSpace, - const CFX_ByteStringC& tagname) + const ByteStringView& qSpace, + const ByteStringView& tagname) : m_pParent(pParent), m_QSpaceName(qSpace), m_TagName(tagname) {} CXML_Element::~CXML_Element() {} @@ -33,23 +33,22 @@ const CXML_Element* CXML_Element::AsElement() const { return this; } -CFX_ByteString CXML_Element::GetTagName(bool bQualified) const { +ByteString CXML_Element::GetTagName(bool bQualified) const { if (!bQualified || m_QSpaceName.IsEmpty()) { return m_TagName; } - CFX_ByteString bsTag = m_QSpaceName; + ByteString bsTag = m_QSpaceName; bsTag += ":"; bsTag += m_TagName; return bsTag; } -CFX_ByteString CXML_Element::GetNamespace(bool bQualified) const { +ByteString CXML_Element::GetNamespace(bool bQualified) const { return bQualified ? m_QSpaceName : GetNamespaceURI(m_QSpaceName); } -CFX_ByteString CXML_Element::GetNamespaceURI( - const CFX_ByteString& qName) const { - const CFX_WideString* pwsSpace; +ByteString CXML_Element::GetNamespaceURI(const ByteString& qName) const { + const WideString* pwsSpace; const CXML_Element* pElement = this; do { if (qName.IsEmpty()) @@ -61,13 +60,13 @@ CFX_ByteString CXML_Element::GetNamespaceURI( pElement = pElement->GetParent(); } while (pElement); - return pwsSpace ? pwsSpace->UTF8Encode() : CFX_ByteString(); + return pwsSpace ? pwsSpace->UTF8Encode() : ByteString(); } void CXML_Element::GetAttrByIndex(int index, - CFX_ByteString* space, - CFX_ByteString* name, - CFX_WideString* value) const { + ByteString* space, + ByteString* name, + WideString* value) const { if (index < 0 || index >= m_AttrMap.GetSize()) return; @@ -77,26 +76,26 @@ void CXML_Element::GetAttrByIndex(int index, *value = item.m_Value; } -bool CXML_Element::HasAttr(const CFX_ByteStringC& name) const { - CFX_ByteStringC bsSpace; - CFX_ByteStringC bsName; +bool CXML_Element::HasAttr(const ByteStringView& name) const { + ByteStringView bsSpace; + ByteStringView bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); - return !!m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName)); + return !!m_AttrMap.Lookup(ByteString(bsSpace), ByteString(bsName)); } -bool CXML_Element::GetAttrValue(const CFX_ByteStringC& name, - CFX_WideString& attribute) const { - CFX_ByteStringC bsSpace; - CFX_ByteStringC bsName; +bool CXML_Element::GetAttrValue(const ByteStringView& name, + WideString& attribute) const { + ByteStringView bsSpace; + ByteStringView bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); return GetAttrValue(bsSpace, bsName, attribute); } -bool CXML_Element::GetAttrValue(const CFX_ByteStringC& space, - const CFX_ByteStringC& name, - CFX_WideString& attribute) const { - const CFX_WideString* pValue = - m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); +bool CXML_Element::GetAttrValue(const ByteStringView& space, + const ByteStringView& name, + WideString& attribute) const { + const WideString* pValue = + m_AttrMap.Lookup(ByteString(space), ByteString(name)); if (!pValue) return false; @@ -104,13 +103,13 @@ bool CXML_Element::GetAttrValue(const CFX_ByteStringC& space, return true; } -bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& name, +bool CXML_Element::GetAttrInteger(const ByteStringView& name, int& attribute) const { - CFX_ByteStringC bsSpace; - CFX_ByteStringC bsName; + ByteStringView bsSpace; + ByteStringView bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); - const CFX_WideString* pwsValue = - m_AttrMap.Lookup(CFX_ByteString(bsSpace), CFX_ByteString(bsName)); + const WideString* pwsValue = + m_AttrMap.Lookup(ByteString(bsSpace), ByteString(bsName)); if (!pwsValue) return false; @@ -118,11 +117,11 @@ bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& name, return true; } -bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& space, - const CFX_ByteStringC& name, +bool CXML_Element::GetAttrInteger(const ByteStringView& space, + const ByteStringView& name, int& attribute) const { - const CFX_WideString* pwsValue = - m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); + const WideString* pwsValue = + m_AttrMap.Lookup(ByteString(space), ByteString(name)); if (!pwsValue) return false; @@ -130,19 +129,19 @@ bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& space, return true; } -bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& name, +bool CXML_Element::GetAttrFloat(const ByteStringView& name, float& attribute) const { - CFX_ByteStringC bsSpace; - CFX_ByteStringC bsName; + ByteStringView bsSpace; + ByteStringView bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); return GetAttrFloat(bsSpace, bsName, attribute); } -bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& space, - const CFX_ByteStringC& name, +bool CXML_Element::GetAttrFloat(const ByteStringView& space, + const ByteStringView& name, float& attribute) const { - const CFX_WideString* pValue = - m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); + const WideString* pValue = + m_AttrMap.Lookup(ByteString(space), ByteString(name)); if (!pValue) return false; @@ -150,8 +149,8 @@ bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& space, return true; } -uint32_t CXML_Element::CountElements(const CFX_ByteStringC& space, - const CFX_ByteStringC& tag) const { +uint32_t CXML_Element::CountElements(const ByteStringView& space, + const ByteStringView& tag) const { int count = 0; for (const auto& pChild : m_Children) { const CXML_Element* pKid = pChild->AsElement(); @@ -167,8 +166,8 @@ CXML_Object* CXML_Element::GetChild(uint32_t index) const { return index < m_Children.size() ? m_Children[index].get() : nullptr; } -CXML_Element* CXML_Element::GetElement(const CFX_ByteStringC& space, - const CFX_ByteStringC& tag, +CXML_Element* CXML_Element::GetElement(const ByteStringView& space, + const ByteStringView& tag, int nth) const { if (nth < 0) return nullptr; @@ -196,10 +195,10 @@ uint32_t CXML_Element::FindElement(CXML_Element* pElement) const { return 0xFFFFFFFF; } -void CXML_Element::SetTag(const CFX_ByteStringC& qTagName) { +void CXML_Element::SetTag(const ByteStringView& qTagName) { ASSERT(!qTagName.IsEmpty()); - CFX_ByteStringC bsSpace; - CFX_ByteStringC bsName; + ByteStringView bsSpace; + ByteStringView bsName; FX_XML_SplitQualifiedName(qTagName, bsSpace, bsName); m_QSpaceName = bsSpace; m_TagName = bsName; diff --git a/core/fxcrt/xml/cxml_element.h b/core/fxcrt/xml/cxml_element.h index a4b4b14129..91ac731021 100644 --- a/core/fxcrt/xml/cxml_element.h +++ b/core/fxcrt/xml/cxml_element.h @@ -18,85 +18,84 @@ class CXML_Element : public CXML_Object { static std::unique_ptr<CXML_Element> Parse(const void* pBuffer, size_t size); CXML_Element(const CXML_Element* pParent, - const CFX_ByteStringC& qSpace, - const CFX_ByteStringC& tagname); + const ByteStringView& qSpace, + const ByteStringView& tagname); ~CXML_Element() override; // CXML_Object: CXML_Element* AsElement() override; const CXML_Element* AsElement() const override; - CFX_ByteString GetTagName(bool bQualified = false) const; - CFX_ByteString GetNamespace(bool bQualified = false) const; - CFX_ByteString GetNamespaceURI(const CFX_ByteString& qName) const; + ByteString GetTagName(bool bQualified = false) const; + ByteString GetNamespace(bool bQualified = false) const; + ByteString GetNamespaceURI(const ByteString& qName) const; const CXML_Element* GetParent() const { return m_pParent.Get(); } uint32_t CountAttrs() const { return m_AttrMap.GetSize(); } void GetAttrByIndex(int index, - CFX_ByteString* space, - CFX_ByteString* name, - CFX_WideString* value) const; - bool HasAttr(const CFX_ByteStringC& qName) const; - bool GetAttrValue(const CFX_ByteStringC& name, - CFX_WideString& attribute) const; - CFX_WideString GetAttrValue(const CFX_ByteStringC& name) const { - CFX_WideString attr; + ByteString* space, + ByteString* name, + WideString* value) const; + bool HasAttr(const ByteStringView& qName) const; + bool GetAttrValue(const ByteStringView& name, WideString& attribute) const; + WideString GetAttrValue(const ByteStringView& name) const { + WideString attr; GetAttrValue(name, attr); return attr; } - bool GetAttrValue(const CFX_ByteStringC& space, - const CFX_ByteStringC& name, - CFX_WideString& attribute) const; - CFX_WideString GetAttrValue(const CFX_ByteStringC& space, - const CFX_ByteStringC& name) const { - CFX_WideString attr; + bool GetAttrValue(const ByteStringView& space, + const ByteStringView& name, + WideString& attribute) const; + WideString GetAttrValue(const ByteStringView& space, + const ByteStringView& name) const { + WideString attr; GetAttrValue(space, name, attr); return attr; } - bool GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const; - int GetAttrInteger(const CFX_ByteStringC& name) const { + bool GetAttrInteger(const ByteStringView& name, int& attribute) const; + int GetAttrInteger(const ByteStringView& name) const { int attr = 0; GetAttrInteger(name, attr); return attr; } - bool GetAttrInteger(const CFX_ByteStringC& space, - const CFX_ByteStringC& name, + bool GetAttrInteger(const ByteStringView& space, + const ByteStringView& name, int& attribute) const; - int GetAttrInteger(const CFX_ByteStringC& space, - const CFX_ByteStringC& name) const { + int GetAttrInteger(const ByteStringView& space, + const ByteStringView& name) const { int attr = 0; GetAttrInteger(space, name, attr); return attr; } - bool GetAttrFloat(const CFX_ByteStringC& name, float& attribute) const; - float GetAttrFloat(const CFX_ByteStringC& name) const { + bool GetAttrFloat(const ByteStringView& name, float& attribute) const; + float GetAttrFloat(const ByteStringView& name) const { float attr = 0; GetAttrFloat(name, attr); return attr; } - bool GetAttrFloat(const CFX_ByteStringC& space, - const CFX_ByteStringC& name, + bool GetAttrFloat(const ByteStringView& space, + const ByteStringView& name, float& attribute) const; - float GetAttrFloat(const CFX_ByteStringC& space, - const CFX_ByteStringC& name) const { + float GetAttrFloat(const ByteStringView& space, + const ByteStringView& name) const { float attr = 0; GetAttrFloat(space, name, attr); return attr; } uint32_t CountChildren() const { return m_Children.size(); } - uint32_t CountElements(const CFX_ByteStringC& space, - const CFX_ByteStringC& tag) const; + uint32_t CountElements(const ByteStringView& space, + const ByteStringView& tag) const; CXML_Object* GetChild(uint32_t index) const; - CXML_Element* GetElement(const CFX_ByteStringC& space, - const CFX_ByteStringC& tag, + CXML_Element* GetElement(const ByteStringView& space, + const ByteStringView& tag, int nth) const; uint32_t FindElement(CXML_Element* pElement) const; - void SetTag(const CFX_ByteStringC& qTagName); + void SetTag(const ByteStringView& qTagName); void RemoveChild(uint32_t index); private: @@ -104,8 +103,8 @@ class CXML_Element : public CXML_Object { friend class CXML_Composer; CFX_UnownedPtr<const CXML_Element> const m_pParent; - CFX_ByteString m_QSpaceName; - CFX_ByteString m_TagName; + ByteString m_QSpaceName; + ByteString m_TagName; CXML_AttrMap m_AttrMap; std::vector<std::unique_ptr<CXML_Object>> m_Children; }; diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp index 9679e2cd41..adf83c7148 100644 --- a/core/fxcrt/xml/cxml_parser.cpp +++ b/core/fxcrt/xml/cxml_parser.cpp @@ -78,9 +78,9 @@ bool g_FXCRT_XML_IsNameChar(uint8_t ch) { } // namespace -void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, - CFX_ByteStringC& bsSpace, - CFX_ByteStringC& bsName) { +void FX_XML_SplitQualifiedName(const ByteStringView& bsFullName, + ByteStringView& bsSpace, + ByteStringView& bsName) { if (bsFullName.IsEmpty()) return; @@ -139,7 +139,7 @@ void CXML_Parser::SkipWhiteSpaces() { } while (ReadNextBlock()); } -void CXML_Parser::GetName(CFX_ByteString* space, CFX_ByteString* name) { +void CXML_Parser::GetName(ByteString* space, ByteString* name) { m_nOffset = m_nBufferOffset + static_cast<FX_FILESIZE>(m_dwIndex); if (IsEOF()) return; @@ -149,7 +149,7 @@ void CXML_Parser::GetName(CFX_ByteString* space, CFX_ByteString* name) { while (m_dwIndex < m_dwBufferSize) { uint8_t ch = m_pBuffer[m_dwIndex]; if (ch == ':') { - *space = CFX_ByteString(buf); + *space = ByteString(buf); buf.str(""); } else if (g_FXCRT_XML_IsNameChar(ch)) { buf << static_cast<char>(ch); @@ -162,10 +162,10 @@ void CXML_Parser::GetName(CFX_ByteString* space, CFX_ByteString* name) { if (m_dwIndex < m_dwBufferSize || IsEOF()) break; } while (ReadNextBlock()); - *name = CFX_ByteString(buf); + *name = ByteString(buf); } -void CXML_Parser::SkipLiterals(const CFX_ByteStringC& str) { +void CXML_Parser::SkipLiterals(const ByteStringView& str) { m_nOffset = m_nBufferOffset + static_cast<FX_FILESIZE>(m_dwIndex); if (IsEOF()) { return; @@ -281,7 +281,7 @@ uint32_t CXML_Parser::GetCharRef() { return code; } -void CXML_Parser::GetAttrValue(CFX_WideString& value) { +void CXML_Parser::GetAttrValue(WideString& value) { m_nOffset = m_nBufferOffset + static_cast<FX_FILESIZE>(m_dwIndex); if (IsEOF()) return; @@ -323,8 +323,8 @@ void CXML_Parser::GetAttrValue(CFX_WideString& value) { void CXML_Parser::GetTagName(bool bStartTag, bool* bEndTag, - CFX_ByteString* space, - CFX_ByteString* name) { + ByteString* space, + ByteString* name) { m_nOffset = m_nBufferOffset + static_cast<FX_FILESIZE>(m_dwIndex); if (IsEOF()) return; @@ -389,18 +389,18 @@ std::unique_ptr<CXML_Element> CXML_Parser::ParseElementInternal( if (IsEOF()) return nullptr; - CFX_ByteString tag_name; - CFX_ByteString tag_space; + ByteString tag_name; + ByteString tag_space; bool bEndTag; GetTagName(bStartTag, &bEndTag, &tag_space, &tag_name); if (tag_name.IsEmpty() || bEndTag) return nullptr; auto pElement = pdfium::MakeUnique<CXML_Element>( - pParent, tag_space.AsStringC(), tag_name.AsStringC()); + pParent, tag_space.AsStringView(), tag_name.AsStringView()); do { - CFX_ByteString attr_space; - CFX_ByteString attr_name; + ByteString attr_space; + ByteString attr_name; while (m_dwIndex < m_dwBufferSize) { SkipWhiteSpaces(); if (IsEOF()) @@ -422,7 +422,7 @@ std::unique_ptr<CXML_Element> CXML_Parser::ParseElementInternal( if (IsEOF()) break; - CFX_WideString attr_value; + WideString attr_value; GetAttrValue(attr_value); pElement->m_AttrMap.SetAt(attr_space, attr_name, attr_value); } @@ -474,19 +474,20 @@ std::unique_ptr<CXML_Element> CXML_Parser::ParseElementInternal( SkipWhiteSpaces(); iState = 0; } else if (ch == '/') { - CFX_ByteString space; - CFX_ByteString name; + ByteString space; + ByteString name; GetName(&space, &name); SkipWhiteSpaces(); m_dwIndex++; iState = 10; } else { content << decoder.GetResult(); - CFX_WideString dataStr = content.MakeString(); + WideString dataStr = content.MakeString(); if (!bCDATA) dataStr.TrimRight(L" \t\r\n"); - InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement.get()); + InsertContentSegment(bCDATA, dataStr.AsStringView(), + pElement.get()); content.Clear(); decoder.Clear(); bCDATA = false; @@ -524,10 +525,10 @@ std::unique_ptr<CXML_Element> CXML_Parser::ParseElementInternal( break; } while (ReadNextBlock()); content << decoder.GetResult(); - CFX_WideString dataStr = content.MakeString(); + WideString dataStr = content.MakeString(); dataStr.TrimRight(L" \t\r\n"); - InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement.get()); + InsertContentSegment(bCDATA, dataStr.AsStringView(), pElement.get()); content.Clear(); decoder.Clear(); bCDATA = false; @@ -535,7 +536,7 @@ std::unique_ptr<CXML_Element> CXML_Parser::ParseElementInternal( } void CXML_Parser::InsertContentSegment(bool bCDATA, - const CFX_WideStringC& content, + const WideStringView& content, CXML_Element* pElement) { if (content.IsEmpty()) return; diff --git a/core/fxcrt/xml/cxml_parser.h b/core/fxcrt/xml/cxml_parser.h index 33bd711ee1..ee5a1b6e18 100644 --- a/core/fxcrt/xml/cxml_parser.h +++ b/core/fxcrt/xml/cxml_parser.h @@ -26,18 +26,18 @@ class CXML_Parser { bool IsEOF(); bool HaveAvailData(); void SkipWhiteSpaces(); - void GetName(CFX_ByteString* space, CFX_ByteString* name); - void GetAttrValue(CFX_WideString& value); + void GetName(ByteString* space, ByteString* name); + void GetAttrValue(WideString& value); uint32_t GetCharRef(); void GetTagName(bool bStartTag, bool* bEndTag, - CFX_ByteString* space, - CFX_ByteString* name); - void SkipLiterals(const CFX_ByteStringC& str); + ByteString* space, + ByteString* name); + void SkipLiterals(const ByteStringView& str); std::unique_ptr<CXML_Element> ParseElement(CXML_Element* pParent, bool bStartTag); void InsertContentSegment(bool bCDATA, - const CFX_WideStringC& content, + const WideStringView& content, CXML_Element* pElement); void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement); @@ -54,8 +54,8 @@ class CXML_Parser { size_t m_dwIndex; }; -void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, - CFX_ByteStringC& bsSpace, - CFX_ByteStringC& bsName); +void FX_XML_SplitQualifiedName(const ByteStringView& bsFullName, + ByteStringView& bsSpace, + ByteStringView& bsName); #endif // CORE_FXCRT_XML_CXML_PARSER_H_ |