summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-08-31 14:46:48 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-08-31 23:34:30 +0200
commit0ccee5537371ea38265c2893fe110ca4f2f1492b (patch)
treeabca3ca7b6c7ea3d84a77bad6694fd63fb0951cb /sax
parentbc9cb2e6bb7dce18303c2713ae6bd89a32fb46e3 (diff)
Simplify code with std::string_view
Change-Id: Ic296bf6abe621e702fa47378ac4c3cdf9f73ba27 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101732 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sax')
-rw-r--r--sax/qa/cppunit/xmlimport.cxx31
1 files changed, 16 insertions, 15 deletions
diff --git a/sax/qa/cppunit/xmlimport.cxx b/sax/qa/cppunit/xmlimport.cxx
index 97406d88310d..b6bd71728019 100644
--- a/sax/qa/cppunit/xmlimport.cxx
+++ b/sax/qa/cppunit/xmlimport.cxx
@@ -38,6 +38,7 @@
#include <unotools/streamwrap.hxx>
#include <sax/fastattribs.hxx>
#include <stack>
+#include <string_view>
#include <deque>
#include <rtl/ref.hxx>
@@ -254,9 +255,9 @@ void SAL_CALL NSDocumentHandler::startElement( const OUString& aName, const Refe
class DummyTokenHandler : public sax_fastparser::FastTokenHandlerBase
{
public:
- const static OStringLiteral tokens[];
+ const static std::string_view tokens[];
const static OUStringLiteral namespaceURIs[];
- const static OStringLiteral namespacePrefixes[];
+ const static std::string_view namespacePrefixes[];
// XFastTokenHandler
virtual Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 nToken ) override;
@@ -265,26 +266,26 @@ public:
virtual sal_Int32 getTokenDirect( const char *pToken, sal_Int32 nLength ) const override;
};
-const OStringLiteral DummyTokenHandler::tokens[] = {
- OStringLiteral("Signature"), OStringLiteral("CanonicalizationMethod"),
- OStringLiteral("Algorithm"), OStringLiteral("Type"),
- OStringLiteral("DigestMethod"), OStringLiteral("Reference"),
- OStringLiteral("document"), OStringLiteral("spacing"),
- OStringLiteral("Player"), OStringLiteral("Height") };
+const std::string_view DummyTokenHandler::tokens[] = {
+ "Signature", "CanonicalizationMethod",
+ "Algorithm", "Type",
+ "DigestMethod", "Reference",
+ "document", "spacing",
+ "Player", "Height" };
const OUStringLiteral DummyTokenHandler::namespaceURIs[] = {
u"http://www.w3.org/2000/09/xmldsig#",
u"http://schemas.openxmlformats.org/wordprocessingml/2006/main/",
u"xyzsports.com/players/football/" };
-const OStringLiteral DummyTokenHandler::namespacePrefixes[] = {
- OStringLiteral(""),
- OStringLiteral("w"),
- OStringLiteral("Player") };
+const std::string_view DummyTokenHandler::namespacePrefixes[] = {
+ "",
+ "w",
+ "Player" };
Sequence< sal_Int8 > DummyTokenHandler::getUTF8Identifier( sal_Int32 nToken )
{
- OString aUtf8Token;
+ std::string_view aUtf8Token;
if ( ( nToken & 0xffff0000 ) != 0 ) //namespace
{
sal_uInt32 nNamespaceToken = ( nToken >> 16 ) - 1;
@@ -298,7 +299,7 @@ Sequence< sal_Int8 > DummyTokenHandler::getUTF8Identifier( sal_Int32 nToken )
aUtf8Token = tokens[ nElementToken ];
}
Sequence< sal_Int8 > aSeq( reinterpret_cast< const sal_Int8* >(
- aUtf8Token.getStr() ), aUtf8Token.getLength() );
+ aUtf8Token.data() ), aUtf8Token.size() );
return aSeq;
}
@@ -310,7 +311,7 @@ sal_Int32 DummyTokenHandler::getTokenFromUTF8( const uno::Sequence< sal_Int8 >&
sal_Int32 DummyTokenHandler::getTokenDirect( const char* pToken, sal_Int32 nLength ) const
{
- OString sToken( pToken, nLength );
+ std::string_view sToken( pToken, nLength );
for( size_t i = 0; i < SAL_N_ELEMENTS(tokens); i++ )
{
if ( tokens[i] == sToken )