summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-04-01 17:42:34 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-04-02 13:31:19 +0200
commit1927b51993fb68907a75765676179b08ab195196 (patch)
tree1b7d09c1b5e7ea945fb6ea618a4c100e8630ebb4 /dbaccess
parent0dfa444f393a5766d36fe7d2480d0c8ec832e329 (diff)
loplugin:stringviewparam convert methods using indexOf
.. and lastIndexOf, which convert to find and rfind Change-Id: I6c4156cf904774c0d867f85a4c2785dba7593f62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132445 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/filter/hsqldb/createparser.cxx15
-rw-r--r--dbaccess/source/sdbtools/connection/objectnames.cxx16
-rw-r--r--dbaccess/source/ui/control/SqlNameEdit.cxx4
-rw-r--r--dbaccess/source/ui/inc/WColumnSelect.hxx4
-rw-r--r--dbaccess/source/ui/inc/WCopyTable.hxx2
-rw-r--r--dbaccess/source/ui/misc/WColumnSelect.cxx4
-rw-r--r--dbaccess/source/ui/misc/WCopyTable.cxx2
7 files changed, 27 insertions, 20 deletions
diff --git a/dbaccess/source/filter/hsqldb/createparser.cxx b/dbaccess/source/filter/hsqldb/createparser.cxx
index de1213945151..9dfe2b2c53d7 100644
--- a/dbaccess/source/filter/hsqldb/createparser.cxx
+++ b/dbaccess/source/filter/hsqldb/createparser.cxx
@@ -67,10 +67,11 @@ std::vector<OUString> lcl_splitColumnPart(const OUString& sColumnPart)
return sReturn;
}
-sal_Int32 lcl_getAutoIncrementDefault(const OUString& sColumnDef)
+sal_Int32 lcl_getAutoIncrementDefault(std::u16string_view sColumnDef)
{
// TODO what if there are more spaces?
- if (sColumnDef.indexOf("GENERATED BY DEFAULT AS IDENTITY") > 0)
+ size_t nPos = sColumnDef.find(u"GENERATED BY DEFAULT AS IDENTITY");
+ if (nPos != std::u16string_view::npos && nPos > 0)
{
// TODO parse starting sequence stated by "START WITH"
return 0;
@@ -93,9 +94,15 @@ OUString lcl_getDefaultValue(const OUString& sColumnDef)
return OUString{};
}
-bool lcl_isNullable(const OUString& sColumnDef) { return sColumnDef.indexOf("NOT NULL") < 0; }
+bool lcl_isNullable(std::u16string_view sColumnDef)
+{
+ return sColumnDef.find(u"NOT NULL") == std::u16string_view::npos;
+}
-bool lcl_isPrimaryKey(const OUString& sColumnDef) { return sColumnDef.indexOf("PRIMARY KEY") >= 0; }
+bool lcl_isPrimaryKey(std::u16string_view sColumnDef)
+{
+ return sColumnDef.find(u"PRIMARY KEY") != std::u16string_view::npos;
+}
sal_Int32 lcl_getDataTypeFromHsql(std::u16string_view sTypeName)
{
diff --git a/dbaccess/source/sdbtools/connection/objectnames.cxx b/dbaccess/source/sdbtools/connection/objectnames.cxx
index 5ec2c22e8ea4..66dd037870c5 100644
--- a/dbaccess/source/sdbtools/connection/objectnames.cxx
+++ b/dbaccess/source/sdbtools/connection/objectnames.cxx
@@ -159,18 +159,18 @@ namespace sdbtools
{
}
- static ::connectivity::ErrorCondition validateName_getErrorCondition( const OUString& _rName )
+ static ::connectivity::ErrorCondition validateName_getErrorCondition( std::u16string_view _rName )
{
- if ( ( _rName.indexOf( u'"' ) >= 0 )
- || ( _rName.indexOf( u'\'' ) >= 0 )
- || ( _rName.indexOf( u'`' ) >= 0 )
- || ( _rName.indexOf( u'\x0091' ) >= 0 )
- || ( _rName.indexOf( u'\x0092' ) >= 0 )
- || ( _rName.indexOf( u'\x00B4' ) >= 0 ) // removed unparsable chars
+ if ( ( _rName.find( u'"' ) != std::u16string_view::npos )
+ || ( _rName.find( u'\'' ) != std::u16string_view::npos )
+ || ( _rName.find( u'`' ) != std::u16string_view::npos )
+ || ( _rName.find( u'\x0091' ) != std::u16string_view::npos )
+ || ( _rName.find( u'\x0092' ) != std::u16string_view::npos )
+ || ( _rName.find( u'\x00B4' ) != std::u16string_view::npos ) // removed unparsable chars
)
return ErrorCondition::DB_QUERY_NAME_WITH_QUOTES;
- if ( _rName.indexOf( '/') >= 0 )
+ if ( _rName.find( '/') != std::u16string_view::npos )
return ErrorCondition::DB_OBJECT_NAME_WITH_SLASHES;
return 0;
diff --git a/dbaccess/source/ui/control/SqlNameEdit.cxx b/dbaccess/source/ui/control/SqlNameEdit.cxx
index 89c0afc0bda1..9d968a0fdb68 100644
--- a/dbaccess/source/ui/control/SqlNameEdit.cxx
+++ b/dbaccess/source/ui/control/SqlNameEdit.cxx
@@ -21,12 +21,12 @@
namespace dbaui
{
- static bool isCharOk(sal_Unicode _cChar,bool _bFirstChar, const OUString& _sAllowedChars)
+ static bool isCharOk(sal_Unicode _cChar,bool _bFirstChar, std::u16string_view _sAllowedChars)
{
return (
(_cChar >= 'A' && _cChar <= 'Z') ||
_cChar == '_' ||
- _sAllowedChars.indexOf(_cChar) != -1 ||
+ _sAllowedChars.find(_cChar) != std::u16string_view::npos ||
(!_bFirstChar && (_cChar >= '0' && _cChar <= '9')) ||
(_cChar >= 'a' && _cChar <= 'z')
);
diff --git a/dbaccess/source/ui/inc/WColumnSelect.hxx b/dbaccess/source/ui/inc/WColumnSelect.hxx
index 706ccfd0371c..38b1317fd507 100644
--- a/dbaccess/source/ui/inc/WColumnSelect.hxx
+++ b/dbaccess/source/ui/inc/WColumnSelect.hxx
@@ -49,7 +49,7 @@ namespace dbaui
OFieldDescription const * _pSrcField,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase);
@@ -57,7 +57,7 @@ namespace dbaui
weld::TreeView const * _pLeft,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase);
diff --git a/dbaccess/source/ui/inc/WCopyTable.hxx b/dbaccess/source/ui/inc/WCopyTable.hxx
index 936acfc80c96..6133112835af 100644
--- a/dbaccess/source/ui/inc/WCopyTable.hxx
+++ b/dbaccess/source/ui/inc/WCopyTable.hxx
@@ -395,7 +395,7 @@ namespace dbaui
OUString convertColumnName( const TColumnFindFunctor& _rCmpFunctor,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen);
TOTypeInfoSP convertType(const TOTypeInfoSP&_pType, bool& _bNotConvert);
diff --git a/dbaccess/source/ui/misc/WColumnSelect.cxx b/dbaccess/source/ui/misc/WColumnSelect.cxx
index a24c2e25468b..8937cfb2d78d 100644
--- a/dbaccess/source/ui/misc/WColumnSelect.cxx
+++ b/dbaccess/source/ui/misc/WColumnSelect.cxx
@@ -275,7 +275,7 @@ void OWizColumnSelect::createNewColumn( weld::TreeView* _pListbox,
OFieldDescription const * _pSrcField,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase)
{
@@ -301,7 +301,7 @@ void OWizColumnSelect::moveColumn( weld::TreeView* _pRight,
weld::TreeView const * _pLeft,
std::vector< OUString>& _rRightColumns,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen,
const ::comphelper::UStringMixEqual& _aCase)
{
diff --git a/dbaccess/source/ui/misc/WCopyTable.cxx b/dbaccess/source/ui/misc/WCopyTable.cxx
index a4f04f1aa037..e378ab35e2f0 100644
--- a/dbaccess/source/ui/misc/WCopyTable.cxx
+++ b/dbaccess/source/ui/misc/WCopyTable.cxx
@@ -1359,7 +1359,7 @@ void OCopyTableWizard::setOperation( const sal_Int16 _nOperation )
OUString OCopyTableWizard::convertColumnName(const TColumnFindFunctor& _rCmpFunctor,
const OUString& _sColumnName,
- const OUString& _sExtraChars,
+ std::u16string_view _sExtraChars,
sal_Int32 _nMaxNameLen)
{
OUString sAlias = _sColumnName;