summaryrefslogtreecommitdiff
path: root/dbaccess
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 /dbaccess
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 'dbaccess')
-rw-r--r--dbaccess/qa/unit/dbtest_base.cxx4
-rw-r--r--dbaccess/source/core/misc/dsntypes.cxx24
-rw-r--r--dbaccess/source/filter/hsqldb/rowinputbinary.cxx7
-rw-r--r--dbaccess/source/filter/hsqldb/utils.cxx2
-rw-r--r--dbaccess/source/filter/hsqldb/utils.hxx6
-rw-r--r--dbaccess/source/inc/dsntypes.hxx25
-rw-r--r--dbaccess/source/ui/dlg/dbwizsetup.cxx2
-rw-r--r--dbaccess/source/ui/dlg/generalpage.cxx4
8 files changed, 43 insertions, 31 deletions
diff --git a/dbaccess/qa/unit/dbtest_base.cxx b/dbaccess/qa/unit/dbtest_base.cxx
index 72f4e9b685f1..f0b276cbb1ea 100644
--- a/dbaccess/qa/unit/dbtest_base.cxx
+++ b/dbaccess/qa/unit/dbtest_base.cxx
@@ -47,7 +47,9 @@ utl::TempFile DBTestBase::createTempCopy(OUString const & pathname) {
tmp.EnableKillingFile();
auto const e = osl::File::copy(url, tmp.GetURL());
CPPUNIT_ASSERT_EQUAL_MESSAGE(
- (OUStringToOString("<" + url + "> -> <" + tmp.GetURL() + ">", RTL_TEXTENCODING_UTF8)
+ (OString(
+ "<" + OUStringToOString(url, RTL_TEXTENCODING_UTF8) + "> -> <"
+ + OUStringToOString(tmp.GetURL(), RTL_TEXTENCODING_UTF8) + ">")
.getStr()),
osl::FileBase::E_None, e);
return tmp;
diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx
index b44b11fc16f0..494994c347da 100644
--- a/dbaccess/source/core/misc/dsntypes.cxx
+++ b/dbaccess/source/core/misc/dsntypes.cxx
@@ -72,7 +72,7 @@ ODsnTypeCollection::~ODsnTypeCollection()
#endif
}
-OUString ODsnTypeCollection::getTypeDisplayName(const OUString& _sURL) const
+OUString ODsnTypeCollection::getTypeDisplayName(std::u16string_view _sURL) const
{
return m_aDriverConfig.getDriverTypeDisplayName(_sURL);
}
@@ -130,7 +130,7 @@ bool ODsnTypeCollection::hasDriver( const char* _pAsciiPattern ) const
return !sPrefix.isEmpty();
}
-bool ODsnTypeCollection::isConnectionUrlRequired(const OUString& _sURL) const
+bool ODsnTypeCollection::isConnectionUrlRequired(std::u16string_view _sURL) const
{
OUString sRet;
OUString sOldPattern;
@@ -146,7 +146,7 @@ bool ODsnTypeCollection::isConnectionUrlRequired(const OUString& _sURL) const
return !sRet.isEmpty() && sRet[sRet.getLength()-1] == '*';
}
-OUString ODsnTypeCollection::getMediaType(const OUString& _sURL) const
+OUString ODsnTypeCollection::getMediaType(std::u16string_view _sURL) const
{
const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
return aFeatures.getOrDefault("MediaType",OUString());
@@ -236,43 +236,43 @@ void ODsnTypeCollection::extractHostNamePort(const OUString& _rDsn,OUString& _sD
}
}
-OUString ODsnTypeCollection::getJavaDriverClass(const OUString& _sURL) const
+OUString ODsnTypeCollection::getJavaDriverClass(std::u16string_view _sURL) const
{
const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getProperties(_sURL);
return aFeatures.getOrDefault("JavaDriverClass",OUString());
}
-bool ODsnTypeCollection::isFileSystemBased(const OUString& _sURL) const
+bool ODsnTypeCollection::isFileSystemBased(std::u16string_view _sURL) const
{
const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
return aFeatures.getOrDefault("FileSystemBased",false);
}
-bool ODsnTypeCollection::supportsTableCreation(const OUString& _sURL) const
+bool ODsnTypeCollection::supportsTableCreation(std::u16string_view _sURL) const
{
const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
return aFeatures.getOrDefault("SupportsTableCreation",false);
}
-bool ODsnTypeCollection::supportsColumnDescription(const OUString& _sURL) const
+bool ODsnTypeCollection::supportsColumnDescription(std::u16string_view _sURL) const
{
const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
return aFeatures.getOrDefault("SupportsColumnDescription",false);
}
-bool ODsnTypeCollection::supportsBrowsing(const OUString& _sURL) const
+bool ODsnTypeCollection::supportsBrowsing(std::u16string_view _sURL) const
{
const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
return aFeatures.getOrDefault("SupportsBrowsing",false);
}
-bool ODsnTypeCollection::supportsDBCreation(const OUString& _sURL) const
+bool ODsnTypeCollection::supportsDBCreation(std::u16string_view _sURL) const
{
const ::comphelper::NamedValueCollection& aFeatures = m_aDriverConfig.getMetaData(_sURL);
return aFeatures.getOrDefault("SupportsDBCreation",false);
}
-Sequence<PropertyValue> ODsnTypeCollection::getDefaultDBSettings( const OUString& _sURL ) const
+Sequence<PropertyValue> ODsnTypeCollection::getDefaultDBSettings( std::u16string_view _sURL ) const
{
const ::comphelper::NamedValueCollection& aProperties = m_aDriverConfig.getProperties(_sURL);
return aProperties.getPropertyValues();
@@ -467,7 +467,7 @@ void ODsnTypeCollection::fillPageIds(const OUString& _sURL,std::vector<sal_Int16
}
}
-OUString ODsnTypeCollection::getType(const OUString& _sURL) const
+OUString ODsnTypeCollection::getType(std::u16string_view _sURL) const
{
OUString sOldPattern;
for (auto const& dsnPrefix : m_aDsnPrefixes)
@@ -481,7 +481,7 @@ OUString ODsnTypeCollection::getType(const OUString& _sURL) const
return sOldPattern;
}
-sal_Int32 ODsnTypeCollection::getIndexOf(const OUString& _sURL) const
+sal_Int32 ODsnTypeCollection::getIndexOf(std::u16string_view _sURL) const
{
sal_Int32 nRet = -1;
OUString sOldPattern;
diff --git a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
index 89c748fcbb82..5ded17936c38 100644
--- a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
+++ b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <string_view>
+
#include "rowinputbinary.hxx"
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/io/WrongFormatException.hpp>
@@ -82,7 +86,8 @@ OUString lcl_double_dabble(const std::vector<sal_uInt8>& bytes)
digit += '0';
/* Resize and return the resulting string. */
- return OStringToOUString(OString(scratch.data(), scratch.size()), RTL_TEXTENCODING_UTF8);
+ return OStringToOUString(std::string_view(scratch.data(), scratch.size()),
+ RTL_TEXTENCODING_UTF8);
}
OUString lcl_makeStringFromBigint(const std::vector<sal_uInt8>& bytes)
diff --git a/dbaccess/source/filter/hsqldb/utils.cxx b/dbaccess/source/filter/hsqldb/utils.cxx
index 3dc8f2e55b16..f2b2b517b8fc 100644
--- a/dbaccess/source/filter/hsqldb/utils.cxx
+++ b/dbaccess/source/filter/hsqldb/utils.cxx
@@ -51,7 +51,7 @@ int getHexValue(sal_Unicode c)
} // unnamed namespace
//Convert ascii escaped unicode to utf-8
-OUString utils::convertToUTF8(const OString& original)
+OUString utils::convertToUTF8(std::string_view original)
{
OUString res = OStringToOUString(original, RTL_TEXTENCODING_UTF8);
for (sal_Int32 i = 0;;)
diff --git a/dbaccess/source/filter/hsqldb/utils.hxx b/dbaccess/source/filter/hsqldb/utils.hxx
index f0a0e35249a0..b8ed1a222c4c 100644
--- a/dbaccess/source/filter/hsqldb/utils.hxx
+++ b/dbaccess/source/filter/hsqldb/utils.hxx
@@ -9,11 +9,15 @@
#pragma once
+#include <sal/config.h>
+
+#include <string_view>
+
#include <rtl/ustring.hxx>
namespace dbahsql::utils
{
-OUString convertToUTF8(const OString& original);
+OUString convertToUTF8(std::string_view original);
OUString getTableNameFromStmt(const OUString& sSql);
diff --git a/dbaccess/source/inc/dsntypes.hxx b/dbaccess/source/inc/dsntypes.hxx
index 38f8ba9213a0..629759ccfd47 100644
--- a/dbaccess/source/inc/dsntypes.hxx
+++ b/dbaccess/source/inc/dsntypes.hxx
@@ -22,6 +22,7 @@
#include <sal/config.h>
+#include <string_view>
#include <vector>
#include <dbadllapi.hxx>
@@ -117,7 +118,7 @@ public:
~ODsnTypeCollection();
/// get the datasource type display name from a DSN string
- OUString getTypeDisplayName(const OUString& _sURL) const;
+ OUString getTypeDisplayName(std::u16string_view _sURL) const;
/// on a given string, cut the type prefix and return the result
OUString cutPrefix(const OUString& _sURL) const;
@@ -129,10 +130,10 @@ public:
bool hasDriver( const char* _pAsciiPattern ) const;
/// on a given string, return the Java Driver Class
- OUString getJavaDriverClass(const OUString& _sURL) const;
+ OUString getJavaDriverClass(std::u16string_view _sURL) const;
/// returns the media type of a file based database
- OUString getMediaType(const OUString& _sURL) const;
+ OUString getMediaType(std::u16string_view _sURL) const;
/// returns the dsn prefix for a given media type
OUString getDatasourcePrefixFromMediaType(std::u16string_view _sMediaType, std::u16string_view _sExtension );
@@ -140,21 +141,21 @@ public:
void extractHostNamePort(const OUString& _rDsn,OUString& _sDatabaseName,OUString& _rHostname,sal_Int32& _nPortNumber) const;
/// check if the given data source allows creation of tables
- bool supportsTableCreation(const OUString& _sURL) const;
+ bool supportsTableCreation(std::u16string_view _sURL) const;
/// check if the given data source allows to show column description.
- bool supportsColumnDescription(const OUString& _sURL) const;
+ bool supportsColumnDescription(std::u16string_view _sURL) const;
// check if a Browse button may be shown to insert connection url
- bool supportsBrowsing(const OUString& _sURL) const;
+ bool supportsBrowsing(std::u16string_view _sURL) const;
// check if a Create New Database button may be shown to insert connection url
- bool supportsDBCreation(const OUString& _sURL) const;
+ bool supportsDBCreation(std::u16string_view _sURL) const;
/// check if the given data source type is based on the file system - i.e. the URL is a prefix plus a file URL
- bool isFileSystemBased(const OUString& _sURL) const;
+ bool isFileSystemBased(std::u16string_view _sURL) const;
- bool isConnectionUrlRequired(const OUString& _sURL) const;
+ bool isConnectionUrlRequired(std::u16string_view _sURL) const;
/// checks if the given data source type embeds its data into the database document
static bool isEmbeddedDatabase( const OUString& _sURL );
@@ -167,7 +168,7 @@ public:
/** returns default settings for newly created databases of the given type.
*/
css::uno::Sequence< css::beans::PropertyValue>
- getDefaultDBSettings( const OUString& _sURL ) const;
+ getDefaultDBSettings( std::u16string_view _sURL ) const;
/// get access to the first element of the types collection
inline TypeIterator begin() const;
@@ -178,9 +179,9 @@ public:
DATASOURCE_TYPE determineType(const OUString& _rDsn) const;
- sal_Int32 getIndexOf(const OUString& _sURL) const;
+ sal_Int32 getIndexOf(std::u16string_view _sURL) const;
sal_Int32 size() const;
- OUString getType(const OUString& _sURL) const;
+ OUString getType(std::u16string_view _sURL) const;
};
//- ODsnTypeCollection::TypeIterator
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx
index 473c0d32ca34..88fd1151bfef 100644
--- a/dbaccess/source/ui/dlg/dbwizsetup.cxx
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -293,7 +293,7 @@ void ODbTypeWizDialogSetup::activateDatabasePath()
{
sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( m_pGeneralPage->GetSelectedType() );
if ( nCreateNewDBIndex == -1 )
- nCreateNewDBIndex = m_pCollection->getIndexOf( "sdbc:dbase:" );
+ nCreateNewDBIndex = m_pCollection->getIndexOf( u"sdbc:dbase:" );
OSL_ENSURE( nCreateNewDBIndex != -1, "ODbTypeWizDialogSetup::activateDatabasePath: the GeneralPage should have prevented this!" );
activatePath( static_cast< PathId >( nCreateNewDBIndex + 1 ), true );
diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx
index d61032fd4919..d02ac934fba7 100644
--- a/dbaccess/source/ui/dlg/generalpage.cxx
+++ b/dbaccess/source/ui/dlg/generalpage.cxx
@@ -461,7 +461,7 @@ namespace dbaui
// If no driver for embedded DBs is installed, and no dBase driver, then hide the "Create new database" option
sal_Int32 nCreateNewDBIndex = m_pCollection->getIndexOf( dbaccess::ODsnTypeCollection::getEmbeddedDatabase() );
if ( nCreateNewDBIndex == -1 )
- nCreateNewDBIndex = m_pCollection->getIndexOf( "sdbc:dbase:" );
+ nCreateNewDBIndex = m_pCollection->getIndexOf( u"sdbc:dbase:" );
bool bHideCreateNew = ( nCreateNewDBIndex == -1 );
// also, if our application policies tell us to hide the option, do it
@@ -551,7 +551,7 @@ namespace dbaui
// Sets the default selected database on startup.
if (m_xRB_CreateDatabase->get_active() )
{
- return m_pCollection->getTypeDisplayName( "sdbc:firebird:" );
+ return m_pCollection->getTypeDisplayName( u"sdbc:firebird:" );
}
return OGeneralPage::getDatasourceName( _rSet );