summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-07-22 16:20:16 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-07-22 23:00:53 +0200
commit2006d7455f529d3d6f44d09a83be9a80e73b1d34 (patch)
tree936875a4ac98b3d3fdca4d2c34ce1c2ecaf399db /tools
parentf8a312617838e8626e6e406791ad8d0aac368f23 (diff)
no need to create OString temporaries when calling XmlWriter methods
Change-Id: Ief1101c55a0635dac43a7c4d66dd4ed0d5be70bd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154764 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/xml/XmlWriter.cxx33
1 files changed, 23 insertions, 10 deletions
diff --git a/tools/source/xml/XmlWriter.cxx b/tools/source/xml/XmlWriter.cxx
index a13190ecf9d2..424b13c67b01 100644
--- a/tools/source/xml/XmlWriter.cxx
+++ b/tools/source/xml/XmlWriter.cxx
@@ -93,28 +93,41 @@ void XmlWriter::startElement(const OString& sPrefix, const OString& sName,
(void)xmlTextWriterStartElementNS(mpImpl->mpWriter, xmlPrefix, xmlName, xmlNamespaceUri);
}
-void XmlWriter::startElement(const OString& sName)
+void XmlWriter::startElement(const char* pName)
{
- xmlChar* xmlName = BAD_CAST(sName.getStr());
+ xmlChar* xmlName = BAD_CAST(pName);
+ (void)xmlTextWriterStartElement(mpImpl->mpWriter, xmlName);
+}
+
+void XmlWriter::startElement(const OString& rName)
+{
+ xmlChar* xmlName = BAD_CAST(rName.getStr());
(void)xmlTextWriterStartElement(mpImpl->mpWriter, xmlName);
}
void XmlWriter::endElement() { (void)xmlTextWriterEndElement(mpImpl->mpWriter); }
-void XmlWriter::attributeBase64(const OString& rsName, std::vector<sal_uInt8> const& rValueInBytes)
+void XmlWriter::attributeBase64(const char* pName, std::vector<sal_uInt8> const& rValueInBytes)
{
std::vector<char> aSignedBytes(rValueInBytes.begin(), rValueInBytes.end());
- attributeBase64(rsName, aSignedBytes);
+ attributeBase64(pName, aSignedBytes);
}
-void XmlWriter::attributeBase64(const OString& rsName, std::vector<char> const& rValueInBytes)
+void XmlWriter::attributeBase64(const char* pName, std::vector<char> const& rValueInBytes)
{
- xmlChar* xmlName = BAD_CAST(rsName.getStr());
+ xmlChar* xmlName = BAD_CAST(pName);
(void)xmlTextWriterStartAttribute(mpImpl->mpWriter, xmlName);
(void)xmlTextWriterWriteBase64(mpImpl->mpWriter, rValueInBytes.data(), 0, rValueInBytes.size());
(void)xmlTextWriterEndAttribute(mpImpl->mpWriter);
}
+void XmlWriter::attribute(const char* name, const OString& value)
+{
+ xmlChar* xmlName = BAD_CAST(name);
+ xmlChar* xmlValue = BAD_CAST(value.getStr());
+ (void)xmlTextWriterWriteAttribute(mpImpl->mpWriter, xmlName, xmlValue);
+}
+
void XmlWriter::attribute(const OString& name, const OString& value)
{
xmlChar* xmlName = BAD_CAST(name.getStr());
@@ -122,17 +135,17 @@ void XmlWriter::attribute(const OString& name, const OString& value)
(void)xmlTextWriterWriteAttribute(mpImpl->mpWriter, xmlName, xmlValue);
}
-void XmlWriter::attribute(const OString& name, std::u16string_view value)
+void XmlWriter::attribute(const char* name, std::u16string_view value)
{
attribute(name, OUStringToOString(value, RTL_TEXTENCODING_UTF8));
}
-void XmlWriter::attribute(const OString& name, const sal_Int32 aNumber)
+void XmlWriter::attribute(const char* name, const sal_Int32 aNumber)
{
attribute(name, OString::number(aNumber));
}
-void XmlWriter::attributeDouble(const OString& name, const double aNumber)
+void XmlWriter::attributeDouble(const char* name, const double aNumber)
{
attribute(name, OString::number(aNumber));
}
@@ -148,7 +161,7 @@ void XmlWriter::content(std::u16string_view sValue)
content(OUStringToOString(sValue, RTL_TEXTENCODING_UTF8));
}
-void XmlWriter::element(const OString& sName)
+void XmlWriter::element(const char* sName)
{
startElement(sName);
endElement();