summaryrefslogtreecommitdiff
path: root/unoxml
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-12-11 17:44:34 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-12-11 21:25:10 +0100
commit35e471bb4d1388cf5afcdcee214cf5111edf44e3 (patch)
treebb78f4f13f131f0cb206a9707cc3cfc495a3876a /unoxml
parent0c06e77c122f10a1842bc908bd6e25b1110ddbd2 (diff)
Adapt the remaining OUString functions to std string_view
...for LIBO_INTERNAL_ONLY. These had been missed by 1b43cceaea2084a0489db68cd0113508f34b6643 "Make many OUString functions take std::u16string_view parameters" because they did not match the multi-overload pattern that was addressed there, but they nevertheless benefit from being changed just as well (witness e.g. the various resulting changes from copy() to subView()). This showed a conversion from OStringChar to std::string_view to be missing (while the corresponding conversion form OUStringChar to std::u16string_view was already present). The improvement to loplugin:stringadd became necessary to fix > [CPT] compilerplugins/clang/test/stringadd.cxx > error: 'error' diagnostics expected but not seen: > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 43 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:42): simplify by merging with the preceding assignment [loplugin:stringadd] > File ~/lo/core/compilerplugins/clang/test/stringadd.cxx Line 61 (directive at ~/lo/core/compilerplugins/clang/test/stringadd.cxx:60): simplify by merging with the preceding assignment [loplugin:stringadd] > 2 errors generated. Change-Id: Ie40de0616a66e60e289c1af0ca60aed6f9ecc279 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107602 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'unoxml')
-rw-r--r--unoxml/source/dom/document.cxx8
-rw-r--r--unoxml/source/dom/element.cxx4
-rw-r--r--unoxml/source/dom/elementlist.cxx7
-rw-r--r--unoxml/source/dom/elementlist.hxx6
-rw-r--r--unoxml/source/rdf/librdf_repository.cxx9
5 files changed, 18 insertions, 16 deletions
diff --git a/unoxml/source/dom/document.cxx b/unoxml/source/dom/document.cxx
index c753f37c6054..8d56510da81f 100644
--- a/unoxml/source/dom/document.cxx
+++ b/unoxml/source/dom/document.cxx
@@ -440,8 +440,8 @@ namespace DOM
OString oPrefix, oName, oUri;
if (i != -1)
{
- oPrefix = OUStringToOString(qname.copy(0, i), RTL_TEXTENCODING_UTF8);
- oName = OUStringToOString(qname.copy(i+1), RTL_TEXTENCODING_UTF8);
+ oPrefix = OUStringToOString(qname.subView(0, i), RTL_TEXTENCODING_UTF8);
+ oName = OUStringToOString(qname.subView(i+1), RTL_TEXTENCODING_UTF8);
}
else
{
@@ -530,9 +530,9 @@ namespace DOM
xmlChar const *pName;
OString o1, o2, o3;
if ( i != -1) {
- o1 = OUStringToOString(qname.copy(0, i), RTL_TEXTENCODING_UTF8);
+ o1 = OUStringToOString(qname.subView(0, i), RTL_TEXTENCODING_UTF8);
pPrefix = reinterpret_cast<xmlChar const *>(o1.getStr());
- o2 = OUStringToOString(qname.copy(i+1), RTL_TEXTENCODING_UTF8);
+ o2 = OUStringToOString(qname.subView(i+1), RTL_TEXTENCODING_UTF8);
pName = reinterpret_cast<xmlChar const *>(o2.getStr());
} else {
// default prefix
diff --git a/unoxml/source/dom/element.cxx b/unoxml/source/dom/element.cxx
index afef8b313b29..f5dd67304d6b 100644
--- a/unoxml/source/dom/element.cxx
+++ b/unoxml/source/dom/element.cxx
@@ -659,11 +659,11 @@ namespace DOM
if (idx != -1)
{
o2 = OUStringToOString(
- qualifiedName.copy(0,idx),
+ qualifiedName.subView(0,idx),
RTL_TEXTENCODING_UTF8);
pPrefix = reinterpret_cast<xmlChar const *>(o2.getStr());
o3 = OUStringToOString(
- qualifiedName.copy(idx+1),
+ qualifiedName.subView(idx+1),
RTL_TEXTENCODING_UTF8);
pLName = reinterpret_cast<xmlChar const *>(o3.getStr());
} else {
diff --git a/unoxml/source/dom/elementlist.cxx b/unoxml/source/dom/elementlist.cxx
index 7379ebe1104b..290438b2ca28 100644
--- a/unoxml/source/dom/elementlist.cxx
+++ b/unoxml/source/dom/elementlist.cxx
@@ -20,6 +20,7 @@
#include "elementlist.hxx"
#include <string.h>
+#include <string_view>
#include <cppuhelper/implbase.hxx>
#include <o3tl/safeint.hxx>
@@ -58,7 +59,7 @@ namespace
namespace DOM
{
- static xmlChar* lcl_initXmlString(OUString const& rString)
+ static xmlChar* lcl_initXmlString(std::u16string_view rString)
{
OString const os =
OUStringToOString(rString, RTL_TEXTENCODING_UTF8);
@@ -69,7 +70,7 @@ namespace DOM
CElementList::CElementList(::rtl::Reference<CElement> const& pElement,
::osl::Mutex & rMutex,
- OUString const& rName, OUString const*const pURI)
+ std::u16string_view rName, OUString const*const pURI)
: m_xImpl(new CElementListImpl(pElement, rMutex, rName, pURI))
{
if (pElement.is()) {
@@ -79,7 +80,7 @@ namespace DOM
CElementListImpl::CElementListImpl(::rtl::Reference<CElement> const& pElement,
::osl::Mutex & rMutex,
- OUString const& rName, OUString const*const pURI)
+ std::u16string_view rName, OUString const*const pURI)
: m_pElement(pElement)
, m_rMutex(rMutex)
, m_pName(lcl_initXmlString(rName))
diff --git a/unoxml/source/dom/elementlist.hxx b/unoxml/source/dom/elementlist.hxx
index b3157900c04b..16a3eff8c5d2 100644
--- a/unoxml/source/dom/elementlist.hxx
+++ b/unoxml/source/dom/elementlist.hxx
@@ -21,7 +21,7 @@
#define INCLUDED_UNOXML_SOURCE_DOM_ELEMENTLIST_HXX
#include <vector>
-
+#include <string_view>
#include <memory>
#include <libxml/tree.h>
@@ -63,7 +63,7 @@ namespace DOM
public:
CElementListImpl(::rtl::Reference<CElement> const& pElement,
::osl::Mutex & rMutex,
- OUString const& rName, OUString const*const pURI);
+ std::u16string_view rName, OUString const*const pURI);
void registerListener(CElement & rElement);
@@ -91,7 +91,7 @@ namespace DOM
public:
CElementList(::rtl::Reference<CElement> const& pElement,
::osl::Mutex & rMutex,
- OUString const& rName, OUString const*const pURI = nullptr);
+ std::u16string_view rName, OUString const*const pURI = nullptr);
/**
The number of nodes in the list.
diff --git a/unoxml/source/rdf/librdf_repository.cxx b/unoxml/source/rdf/librdf_repository.cxx
index 9ebd7217b24f..13a10b4edb41 100644
--- a/unoxml/source/rdf/librdf_repository.cxx
+++ b/unoxml/source/rdf/librdf_repository.cxx
@@ -22,6 +22,7 @@
#include <map>
#include <memory>
#include <set>
+#include <string_view>
#include <iterator>
#include <algorithm>
#include <atomic>
@@ -2346,7 +2347,7 @@ librdf_TypeConverter::convertToXURI(librdf_uri* i_pURI) const
"librdf_uri_as_string failed", m_rRep);
}
OUString uriU( OStringToOUString(
- OString(reinterpret_cast<const char*>(uri)),
+ std::string_view(reinterpret_cast<const char*>(uri)),
RTL_TEXTENCODING_UTF8) );
try {
return rdf::URI::create(m_xContext, uriU);
@@ -2388,7 +2389,7 @@ librdf_TypeConverter::convertToXResource(librdf_node* i_pNode) const
"blank node has no label", m_rRep);
}
OUString labelU( OStringToOUString(
- OString(reinterpret_cast<const char*>(label)),
+ std::string_view(reinterpret_cast<const char*>(label)),
RTL_TEXTENCODING_UTF8) );
try {
return rdf::BlankNode::create(m_xContext, labelU);
@@ -2421,11 +2422,11 @@ librdf_TypeConverter::convertToXNode(librdf_node* i_pNode) const
librdf_node_get_literal_value_datatype_uri(i_pNode) );
OSL_ENSURE(!lang || !pType, "convertToXNode: invalid literal");
const OUString valueU( OStringToOUString(
- OString(reinterpret_cast<const char*>(value)),
+ std::string_view(reinterpret_cast<const char*>(value)),
RTL_TEXTENCODING_UTF8) );
if (lang) {
const OUString langU( OStringToOUString(
- OString(reinterpret_cast<const char*>(lang)),
+ std::string_view(reinterpret_cast<const char*>(lang)),
RTL_TEXTENCODING_UTF8) );
return rdf::Literal::createWithLanguage(m_xContext, valueU, langU);
} else if (pType) {