summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-09-26 15:50:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-27 07:59:08 +0200
commit1026527a517fbdf35392d97f89b470a02d2e40e0 (patch)
tree180be00c512537a162d5493917747d08f2e67ea2 /dbaccess
parent23a7bdecee5278673a7c79286fb3faea553a85b2 (diff)
use more string_view in dbaccess
Change-Id: Id0b41d57015e8e2542b47d3a09ca8f13d090dbca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140621 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/core/api/SingleSelectQueryComposer.cxx8
-rw-r--r--dbaccess/source/core/misc/dsntypes.cxx4
-rw-r--r--dbaccess/source/core/recovery/dbdocrecovery.cxx23
-rw-r--r--dbaccess/source/filter/hsqldb/rowinputbinary.cxx4
-rw-r--r--dbaccess/source/filter/hsqldb/utils.cxx4
-rw-r--r--dbaccess/source/filter/hsqldb/utils.hxx2
-rw-r--r--dbaccess/source/inc/dsntypes.hxx2
-rw-r--r--dbaccess/source/ui/control/SqlNameEdit.cxx8
-rw-r--r--dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx2
-rw-r--r--dbaccess/source/ui/dlg/DbAdminImpl.hxx4
-rw-r--r--dbaccess/source/ui/dlg/TextConnectionHelper.cxx14
-rw-r--r--dbaccess/source/ui/dlg/dbwizsetup.cxx8
-rw-r--r--dbaccess/source/ui/inc/SqlNameEdit.hxx2
13 files changed, 46 insertions, 39 deletions
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index f69742d4422a..45d9a8ce6595 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -1524,9 +1524,9 @@ OUString OSingleSelectQueryComposer::getStatementPart( TGetParseNode const & _aG
namespace
{
- OUString lcl_getDecomposedColumnName(const OUString& rComposedName, const OUString& rQuoteString)
+ OUString lcl_getDecomposedColumnName(const OUString& rComposedName, std::u16string_view rQuoteString)
{
- const sal_Int32 nQuoteLength = rQuoteString.getLength();
+ const size_t nQuoteLength = rQuoteString.size();
OUString sName = rComposedName.trim();
OUString sColumnName;
sal_Int32 nPos, nRPos = 0;
@@ -1539,7 +1539,7 @@ namespace
nRPos = sName.indexOf( rQuoteString, nPos + nQuoteLength );
if ( nRPos > nPos )
{
- if ( nRPos + nQuoteLength < sName.getLength() )
+ if ( static_cast<sal_Int32>(nRPos + nQuoteLength) < sName.getLength() )
{
nRPos += nQuoteLength; // -1 + 1 skip dot
}
@@ -1561,7 +1561,7 @@ namespace
OUString lcl_getCondition(const Sequence< Sequence< PropertyValue > >& filter,
const OPredicateInputController& i_aPredicateInputController,
const Reference< XNameAccess >& i_xSelectColumns,
- const OUString& rQuoteString)
+ std::u16string_view rQuoteString)
{
OUStringBuffer sRet;
const Sequence< PropertyValue >* pOrIter = filter.getConstArray();
diff --git a/dbaccess/source/core/misc/dsntypes.cxx b/dbaccess/source/core/misc/dsntypes.cxx
index 91b93f353946..0038e0968c77 100644
--- a/dbaccess/source/core/misc/dsntypes.cxx
+++ b/dbaccess/source/core/misc/dsntypes.cxx
@@ -106,7 +106,7 @@ OUString ODsnTypeCollection::cutPrefix(std::u16string_view _sURL) const
return sRet;
}
-OUString ODsnTypeCollection::getPrefix(const OUString& _sURL) const
+OUString ODsnTypeCollection::getPrefix(std::u16string_view _sURL) const
{
OUString sRet;
OUString sOldPattern;
@@ -119,7 +119,7 @@ OUString ODsnTypeCollection::getPrefix(const OUString& _sURL) const
// foo*
// that is, the very concept of "prefix" applies.
sRet = comphelper::string::stripEnd(dsnPrefix, '*');
- OSL_ENSURE(sRet.getLength() <= _sURL.getLength(), "How can A match B when A shorter than B?");
+ OSL_ENSURE(sRet.getLength() <= static_cast<sal_Int32>(_sURL.size()), "How can A match B when A shorter than B?");
sOldPattern = dsnPrefix;
}
}
diff --git a/dbaccess/source/core/recovery/dbdocrecovery.cxx b/dbaccess/source/core/recovery/dbdocrecovery.cxx
index e027cc834e37..1c8763c02b4c 100644
--- a/dbaccess/source/core/recovery/dbdocrecovery.cxx
+++ b/dbaccess/source/core/recovery/dbdocrecovery.cxx
@@ -28,6 +28,7 @@
#include <com/sun/star/io/TextInputStream.hpp>
#include <com/sun/star/util/XModifiable.hpp>
+#include <o3tl/string_view.hxx>
#include <rtl/ustrbuf.hxx>
#include <sal/log.hxx>
#include <comphelper/diagnose_ex.hxx>
@@ -65,23 +66,23 @@ namespace dbaccess
o_rBuffer.append( sal_Unicode( i_rComponentDesc.second.bForEditing ? '1' : '0' ) );
}
- bool lcl_extractCompDesc( const OUString& i_rIniLine, OUString& o_rStorName, SubComponentDescriptor& o_rCompDesc )
+ bool lcl_extractCompDesc( std::u16string_view i_rIniLine, OUString& o_rStorName, SubComponentDescriptor& o_rCompDesc )
{
- const sal_Int32 nEqualSignPos = i_rIniLine.indexOf( '=' );
- if ( nEqualSignPos < 1 )
+ const size_t nEqualSignPos = i_rIniLine.find( '=' );
+ if ( nEqualSignPos == 0 || nEqualSignPos == std::u16string_view::npos )
{
OSL_FAIL( "lcl_extractCompDesc: invalid map file entry - unexpected pos of '='" );
return false;
}
- o_rStorName = i_rIniLine.copy( 0, nEqualSignPos );
+ o_rStorName = i_rIniLine.substr( 0, nEqualSignPos );
- const sal_Int32 nCommaPos = i_rIniLine.lastIndexOf( ',' );
- if ( nCommaPos != i_rIniLine.getLength() - 2 )
+ const size_t nCommaPos = i_rIniLine.rfind( ',' );
+ if ( nCommaPos != i_rIniLine.size() - 2 )
{
OSL_FAIL( "lcl_extractCompDesc: invalid map file entry - unexpected pos of ','" );
return false;
}
- o_rCompDesc.sName = i_rIniLine.copy( nEqualSignPos + 1, nCommaPos - nEqualSignPos - 1 );
+ o_rCompDesc.sName = i_rIniLine.substr( nEqualSignPos + 1, nCommaPos - nEqualSignPos - 1 );
o_rCompDesc.bForEditing = ( i_rIniLine[ nCommaPos + 1 ] == '1' );
return true;
}
@@ -112,12 +113,12 @@ namespace dbaccess
aTextOutput.writeLine();
}
- bool lcl_isSectionStart( const OUString& i_rIniLine, OUString& o_rSectionName )
+ bool lcl_isSectionStart( std::u16string_view i_rIniLine, OUString& o_rSectionName )
{
- const sal_Int32 nLen = i_rIniLine.getLength();
- if ( i_rIniLine.startsWith("[") && i_rIniLine.endsWith("]") )
+ const size_t nLen = i_rIniLine.size();
+ if ( o3tl::starts_with(i_rIniLine, u"[") && o3tl::ends_with(i_rIniLine, u"]") )
{
- o_rSectionName = i_rIniLine.copy( 1, nLen -2 );
+ o_rSectionName = i_rIniLine.substr( 1, nLen -2 );
return true;
}
return false;
diff --git a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
index 95ce05f69b56..b72ccfd8d760 100644
--- a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
+++ b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
@@ -115,11 +115,11 @@ OUString lcl_makeStringFromBigint(std::vector<sal_uInt8>&& aBytes)
return sRet.makeStringAndClear();
}
-OUString lcl_putDot(const OUString& sNum, sal_Int32 nScale)
+OUString lcl_putDot(std::u16string_view sNum, sal_Int32 nScale)
{
// e.g. sNum = "0", nScale = 2 -> "0.00"
OUStringBuffer sBuf{ sNum };
- sal_Int32 nNullsToAppend = nScale - sNum.getLength() + 1;
+ sal_Int32 nNullsToAppend = nScale - sNum.size() + 1;
for (sal_Int32 i = 0; i < nNullsToAppend; ++i)
sBuf.insert(0, "0");
diff --git a/dbaccess/source/filter/hsqldb/utils.cxx b/dbaccess/source/filter/hsqldb/utils.cxx
index 8387a34e0bf4..d8addd33623e 100644
--- a/dbaccess/source/filter/hsqldb/utils.cxx
+++ b/dbaccess/source/filter/hsqldb/utils.cxx
@@ -131,9 +131,9 @@ OUString utils::getTableNameFromStmt(std::u16string_view sSql)
return *wordIter;
}
-void utils::ensureFirebirdTableLength(const OUString& sName)
+void utils::ensureFirebirdTableLength(std::u16string_view sName)
{
- if (sName.getLength() > 30) // Firebird limitation
+ if (sName.size() > 30) // Firebird limitation
{
static constexpr OUStringLiteral NAME_TOO_LONG
= u"Firebird 3 doesn't support object (table, field) names "
diff --git a/dbaccess/source/filter/hsqldb/utils.hxx b/dbaccess/source/filter/hsqldb/utils.hxx
index cc3e2f0df16f..ed5fb8a1e380 100644
--- a/dbaccess/source/filter/hsqldb/utils.hxx
+++ b/dbaccess/source/filter/hsqldb/utils.hxx
@@ -21,7 +21,7 @@ OUString convertToUTF8(std::string_view original);
OUString getTableNameFromStmt(std::u16string_view sSql);
-void ensureFirebirdTableLength(const OUString& sName);
+void ensureFirebirdTableLength(std::u16string_view sName);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/inc/dsntypes.hxx b/dbaccess/source/inc/dsntypes.hxx
index 875d781d1fd1..7bc664f10d85 100644
--- a/dbaccess/source/inc/dsntypes.hxx
+++ b/dbaccess/source/inc/dsntypes.hxx
@@ -123,7 +123,7 @@ public:
OUString cutPrefix(std::u16string_view _sURL) const;
/// on a given string, return the type prefix
- OUString getPrefix(const OUString& _sURL) const;
+ OUString getPrefix(std::u16string_view _sURL) const;
/// determines whether there is a driver for the given URL prefix/pattern
bool hasDriver( const char* _pAsciiPattern ) const;
diff --git a/dbaccess/source/ui/control/SqlNameEdit.cxx b/dbaccess/source/ui/control/SqlNameEdit.cxx
index 9d968a0fdb68..9ac58cfda851 100644
--- a/dbaccess/source/ui/control/SqlNameEdit.cxx
+++ b/dbaccess/source/ui/control/SqlNameEdit.cxx
@@ -31,23 +31,23 @@ namespace dbaui
(_cChar >= 'a' && _cChar <= 'z')
);
}
- bool OSQLNameChecker::checkString(const OUString& _sToCheck,
+ bool OSQLNameChecker::checkString(std::u16string_view _sToCheck,
OUString& _rsCorrected)
{
bool bCorrected = false;
if ( m_bCheck )
{
sal_Int32 nMatch = 0;
- for (sal_Int32 i = nMatch; i < _sToCheck.getLength(); ++i)
+ for (size_t i = nMatch; i < _sToCheck.size(); ++i)
{
if ( !isCharOk( _sToCheck[i], i == 0, m_sAllowedChars ) )
{
- _rsCorrected += _sToCheck.subView(nMatch, i - nMatch);
+ _rsCorrected += _sToCheck.substr(nMatch, i - nMatch);
bCorrected = true;
nMatch = i + 1;
}
}
- _rsCorrected += _sToCheck.subView( nMatch );
+ _rsCorrected += _sToCheck.substr( nMatch );
}
return bCorrected;
}
diff --git a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
index ffbde972ff08..299dfa6b34cb 100644
--- a/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
+++ b/dbaccess/source/ui/dlg/DBSetupConnectionPages.cxx
@@ -153,7 +153,7 @@ using namespace ::com::sun::star;
OSL_ENSURE(pCollection, "OLDAPConnectionPageSetup::FillItemSet : really need a DSN type collection !");
if (pCollection)
{
- OUString sUrl = pCollection->getPrefix( "sdbc:address:ldap:") + m_xETHostServer->get_text();
+ OUString sUrl = pCollection->getPrefix( u"sdbc:address:ldap:") + m_xETHostServer->get_text();
_rSet->Put(SfxStringItem(DSID_CONNECTURL, sUrl));
bChangedSomething = true;
}
diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.hxx b/dbaccess/source/ui/dlg/DbAdminImpl.hxx
index 22a61eceec80..dd4adcdc525b 100644
--- a/dbaccess/source/ui/dlg/DbAdminImpl.hxx
+++ b/dbaccess/source/ui/dlg/DbAdminImpl.hxx
@@ -40,8 +40,8 @@ namespace dbaui
{
void convert(const css::uno::Reference< css::uno::XComponentContext> & xContext,
const ::dbaccess::ODsnTypeCollection* _pCollection,
- const OUString& _sOldURLPrefix,
- const OUString& _sNewURLPrefix,
+ std::u16string_view _sOldURLPrefix,
+ std::u16string_view _sNewURLPrefix,
const css::uno::Reference< css::beans::XPropertySet >& _xDatasource);
};
class IItemSetHelper;
diff --git a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
index 0d93dc373b5c..3148aad27924 100644
--- a/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
+++ b/dbaccess/source/ui/dlg/TextConnectionHelper.cxx
@@ -33,14 +33,20 @@
namespace
{
-OUString lcl_getListEntry(const OUString& rStr, sal_Int32& rIdx)
+OUString lcl_getListEntry(std::u16string_view rStr, sal_Int32& rIdx)
{
- const OUString sTkn {rStr.getToken( 0, '\t', rIdx )};
+ const OUString sTkn {o3tl::getToken(rStr, 0, '\t', rIdx )};
if (rIdx>=0)
{
- rIdx = rStr.indexOf('\t', rIdx);
- if (rIdx>=0 && ++rIdx>=rStr.getLength())
+ size_t nFnd = rStr.find('\t', rIdx);
+ if (nFnd == std::u16string_view::npos)
rIdx = -1;
+ else
+ {
+ rIdx = nFnd + 1;
+ if (rIdx >= static_cast<sal_Int32>(rStr.size()))
+ rIdx = -1;
+ }
}
return sTkn;
}
diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx
index 59d928c958b9..4543affd0f0f 100644
--- a/dbaccess/source/ui/dlg/dbwizsetup.cxx
+++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx
@@ -266,7 +266,7 @@ static void lcl_removeUnused(const ::comphelper::NamedValueCollection& _aOld,con
}
}
-void DataSourceInfoConverter::convert(const Reference<XComponentContext> & xContext, const ::dbaccess::ODsnTypeCollection* _pCollection,const OUString& _sOldURLPrefix,const OUString& _sNewURLPrefix,const css::uno::Reference< css::beans::XPropertySet >& _xDatasource)
+void DataSourceInfoConverter::convert(const Reference<XComponentContext> & xContext, const ::dbaccess::ODsnTypeCollection* _pCollection, std::u16string_view _sOldURLPrefix, std::u16string_view _sNewURLPrefix,const css::uno::Reference< css::beans::XPropertySet >& _xDatasource)
{
if ( _pCollection->getPrefix(_sOldURLPrefix) == _pCollection->getPrefix(_sNewURLPrefix) )
return ;
@@ -486,16 +486,16 @@ std::unique_ptr<BuilderPage> ODbTypeWizDialogSetup::createPage(WizardState _nSta
break;
case PAGE_DBSETUPWIZARD_MYSQL_ODBC:
- m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix("sdbc:mysql:odbc:")));
+ m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(u"sdbc:mysql:odbc:")));
xPage = OConnectionTabPageSetup::CreateODBCTabPage(pPageContainer, this, *m_pOutSet);
break;
case PAGE_DBSETUPWIZARD_MYSQL_JDBC:
- m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix("sdbc:mysql:jdbc:")));
+ m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(u"sdbc:mysql:jdbc:")));
xPage = OGeneralSpecialJDBCConnectionPageSetup::CreateMySQLJDBCTabPage(pPageContainer, this, *m_pOutSet);
break;
case PAGE_DBSETUPWIZARD_MYSQL_NATIVE:
- m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix("sdbc:mysql:mysqlc:")));
+ m_pOutSet->Put(SfxStringItem(DSID_CONNECTURL, m_pCollection->getPrefix(u"sdbc:mysql:mysqlc:")));
xPage = MySQLNativeSetupPage::Create(pPageContainer, this, *m_pOutSet);
break;
diff --git a/dbaccess/source/ui/inc/SqlNameEdit.hxx b/dbaccess/source/ui/inc/SqlNameEdit.hxx
index 5b613608830a..14d845b4b17c 100644
--- a/dbaccess/source/ui/inc/SqlNameEdit.hxx
+++ b/dbaccess/source/ui/inc/SqlNameEdit.hxx
@@ -43,7 +43,7 @@ namespace dbaui
{
m_bCheck = _bCheck;
}
- bool checkString(const OUString& _sToCheck,OUString& _rsCorrected);
+ bool checkString(std::u16string_view _sToCheck,OUString& _rsCorrected);
};
class OSQLNameEditControl : public svt::EditControl