diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-24 10:09:16 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-24 15:29:18 +0000 |
commit | 637cceeefba0b0e2e09ac734bb0327364e8ddd25 (patch) | |
tree | ba321c814d9806921cbc23c293706cc54c8b82df /connectivity/source/drivers | |
parent | 4d90e2696dd4358b3d02bbbae90160c92d36263f (diff) |
loplugin:stringadd in c*
after my patch to merge the bufferadd loplugin into stringadd
Change-Id: I66f4ce2fd87c1e12eefb14406e0e17212f68ceff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149497
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'connectivity/source/drivers')
15 files changed, 51 insertions, 74 deletions
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx index 179b8e19ceb4..62e54caa4468 100644 --- a/connectivity/source/drivers/firebird/Connection.cxx +++ b/connectivity/source/drivers/firebird/Connection.cxx @@ -628,22 +628,18 @@ void Connection::runBackupService(const short nAction) OString sFBKPath = OUStringToOString(m_sFBKPath, RTL_TEXTENCODING_UTF8); - OStringBuffer aRequest; // byte array - - - aRequest.append(static_cast<char>(nAction)); - - aRequest.append(char(isc_spb_dbname)); // .fdb sal_uInt16 nFDBLength = sFDBPath.getLength(); - aRequest.append(static_cast<char>(nFDBLength & 0xFF)); // least significant byte first - aRequest.append(static_cast<char>((nFDBLength >> 8) & 0xFF)); - aRequest.append(sFDBPath); - - aRequest.append(char(isc_spb_bkp_file)); // .fbk sal_uInt16 nFBKLength = sFBKPath.getLength(); - aRequest.append(static_cast<char>(nFBKLength & 0xFF)); - aRequest.append(static_cast<char>((nFBKLength >> 8) & 0xFF)); - aRequest.append(sFBKPath); + OStringBuffer aRequest( // byte array + OStringChar(static_cast<char>(nAction)) + + OStringChar(char(isc_spb_dbname)) // .fdb + + OStringChar(static_cast<char>(nFDBLength & 0xFF)) // least significant byte first + + OStringChar(static_cast<char>((nFDBLength >> 8) & 0xFF)) + + sFDBPath + + OStringChar(char(isc_spb_bkp_file)) // .fbk + + OStringChar(static_cast<char>(nFBKLength & 0xFF)) + + OStringChar(static_cast<char>((nFBKLength >> 8) & 0xFF)) + + sFBKPath); if (nAction == isc_action_svc_restore) { diff --git a/connectivity/source/drivers/firebird/Tables.cxx b/connectivity/source/drivers/firebird/Tables.cxx index 936e1465cb10..8b69044bef79 100644 --- a/connectivity/source/drivers/firebird/Tables.cxx +++ b/connectivity/source/drivers/firebird/Tables.cxx @@ -90,9 +90,8 @@ OUString Tables::createStandardColumnPart(const Reference< XPropertySet >& xColP if ( xPropInfo.is() && xPropInfo->hasPropertyByName(rPropMap.getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION)) ) xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION)) >>= sAutoIncrementValue; - aSql.append(" "); - - aSql.append(dbtools::createStandardTypePart(xColProp, _xConnection)); + aSql.append(" " + + dbtools::createStandardTypePart(xColProp, _xConnection)); // Add character set for (VAR)BINARY (fix) types: // (VAR) BINARY is distinguished from other CHAR types by its character set. // Octets is a special character set for binary data. @@ -104,15 +103,13 @@ OUString Tables::createStandardColumnPart(const Reference< XPropertySet >& xColP >>= aType; if(aType == DataType::BINARY || aType == DataType::VARBINARY) { - aSql.append(" "); - aSql.append("CHARACTER SET OCTETS"); + aSql.append(" CHARACTER SET OCTETS"); } } if ( bIsAutoIncrement && !sAutoIncrementValue.isEmpty()) { - aSql.append(" "); - aSql.append(sAutoIncrementValue); + aSql.append(" " + sAutoIncrementValue); } // AutoIncrement "IDENTITY" is implicitly "NOT NULL" else if(::comphelper::getINT32(xColProp->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_ISNULLABLE))) == ColumnValue::NO_NULLS) @@ -149,8 +146,8 @@ ObjectType Tables::appendObject(const OUString& rName, if ( sComposedName.isEmpty() ) ::dbtools::throwFunctionSequenceException(xConnection); - aSqlBuffer.append(sComposedName); - aSqlBuffer.append(" ("); + aSqlBuffer.append(sComposedName + + " ("); // columns Reference<XColumnsSupplier> xColumnSup(rDescriptor,UNO_QUERY); @@ -166,8 +163,8 @@ ObjectType Tables::appendObject(const OUString& rName, { if ( (xColumns->getByIndex(i) >>= xColProp) && xColProp.is() ) { - aSqlBuffer.append(createStandardColumnPart(xColProp,xConnection)); - aSqlBuffer.append(","); + aSqlBuffer.append(createStandardColumnPart(xColProp,xConnection) + + ","); } } OUString sSql = aSqlBuffer.makeStringAndClear(); diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx index 1fd1bd03e7a2..3cee5dab6e0b 100644 --- a/connectivity/source/drivers/firebird/Util.cxx +++ b/connectivity/source/drivers/firebird/Util.cxx @@ -44,8 +44,8 @@ OUString firebird::StatusVectorToString(const ISC_STATUS_ARRAY& rStatusVector, while(fb_interpret(msg, sizeof(msg), &pStatus)) { // TODO: verify encoding - buf.append("\n*"); - buf.append(OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8)); + buf.append("\n*" + + OUString(msg, strlen(msg), RTL_TEXTENCODING_UTF8)); } } catch (...) diff --git a/connectivity/source/drivers/hsqldb/HConnection.cxx b/connectivity/source/drivers/hsqldb/HConnection.cxx index bed9f6cdab2a..28feb95fce9b 100644 --- a/connectivity/source/drivers/hsqldb/HConnection.cxx +++ b/connectivity/source/drivers/hsqldb/HConnection.cxx @@ -281,8 +281,7 @@ namespace connectivity::hsqldb ::dbtools::qualifiedNameComponents( xMetaData, _rTableName, sCatalog, sSchema, sName, ::dbtools::EComposeRule::Complete ); // get the table information - OUStringBuffer sSQL; - sSQL.append( "SELECT HSQLDB_TYPE FROM INFORMATION_SCHEMA.SYSTEM_TABLES" ); + OUStringBuffer sSQL( "SELECT HSQLDB_TYPE FROM INFORMATION_SCHEMA.SYSTEM_TABLES" ); HTools::appendTableFilterCrit( sSQL, sCatalog, sSchema, sName, true ); sSQL.append( " AND TABLE_TYPE = 'TABLE'" ); diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 1d3f13e5718b..200d9f4bd3fe 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -864,8 +864,7 @@ namespace connectivity OSL_ENSURE( xStatement.is(), "ODriverDelegator::onConnectedNewDatabase: could not create a statement!" ); if ( xStatement.is() ) { - OUStringBuffer aStatement; - aStatement.append( "SET DATABASE COLLATION \"" ); + OUStringBuffer aStatement( "SET DATABASE COLLATION \"" ); aStatement.appendAscii( lcl_getCollationForLocale( lcl_getSystemLocale( m_xContext ) ) ); aStatement.append( "\"" ); diff --git a/connectivity/source/drivers/hsqldb/HView.cxx b/connectivity/source/drivers/hsqldb/HView.cxx index 60381ea6b0ad..83946ee86f86 100644 --- a/connectivity/source/drivers/hsqldb/HView.cxx +++ b/connectivity/source/drivers/hsqldb/HView.cxx @@ -146,8 +146,8 @@ namespace connectivity::hsqldb OUString HView::impl_getCommand() const { - OUStringBuffer aCommand; - aCommand.append( "SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.SYSTEM_VIEWS " ); + OUStringBuffer aCommand( + "SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.SYSTEM_VIEWS " ); HTools::appendTableFilterCrit( aCommand, m_CatalogName, m_SchemaName, m_Name, false ); ::utl::SharedUNOComponent< XStatement > xStatement; xStatement.set( m_xConnection->createStatement(), UNO_QUERY_THROW ); Reference< XResultSet > xResult( xStatement->executeQuery( aCommand.makeStringAndClear() ), css::uno::UNO_SET_THROW ); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx index 109ae2c1c8e2..43d277fe0097 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx @@ -812,20 +812,14 @@ Reference<XResultSet> SAL_CALL ODatabaseMetaData::getTables(const Any& /*catalog if (types.getLength() == 1) { - buffer.append("AND TABLE_TYPE LIKE '"); - buffer.append(types[0]); - buffer.append("'"); + buffer.append("AND TABLE_TYPE LIKE '" + types[0] + "'"); } else if (types.getLength() > 1) { - buffer.append("AND (TABLE_TYPE LIKE '"); - buffer.append(types[0]); - buffer.append("'"); + buffer.append("AND (TABLE_TYPE LIKE '" + types[0] + "'"); for (sal_Int32 i = 1; i < types.getLength(); ++i) { - buffer.append(" OR TABLE_TYPE LIKE '"); - buffer.append(types[i]); - buffer.append("'"); + buffer.append(" OR TABLE_TYPE LIKE '" + types[i] + "'"); } buffer.append(")"); } diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx index da50e01f1a2b..3840e914d14b 100644 --- a/connectivity/source/drivers/odbc/OStatement.cxx +++ b/connectivity/source/drivers/odbc/OStatement.cxx @@ -477,8 +477,8 @@ Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) for (auto const& elem : m_aBatchVector) { - aBatchSql.append(OUStringToOString(elem,getOwnConnection()->getTextEncoding())); - aBatchSql.append(";"); + aBatchSql.append(OUStringToOString(elem,getOwnConnection()->getTextEncoding()) + + ";"); } OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!"); diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx index 99f82a1c3957..1fbcb1aa69f5 100644 --- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx @@ -1406,8 +1406,7 @@ static void columnMetaData2DatabaseTypeDescription( oidMap[row->getInt(12)] = DatabaseTypeDescription(); if( domains ) queryBuf.append( " OR " ); - queryBuf.append( "oid = " ); - queryBuf.append( row->getInt(12 ) ); + queryBuf.append( "oid = " + OUString::number( row->getInt(12 ) ) ); domains ++; } } diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx index dd30a39317ec..4f3faaec419c 100644 --- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx +++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx @@ -263,10 +263,9 @@ void PreparedStatement::close( ) void PreparedStatement::raiseSQLException( const char * errorMsg ) { OUStringBuffer buf(128); - buf.append( "pq_driver: "); - buf.append( - OUString( errorMsg, strlen(errorMsg) , ConnectionSettings::encoding ) ); - buf.append( " (caused by statement '" ); + buf.append( "pq_driver: " + + OUString( errorMsg, strlen(errorMsg) , ConnectionSettings::encoding ) + + " (caused by statement '" ); buf.appendAscii( m_executedStatement.getStr() ); buf.append( "')" ); OUString error = buf.makeStringAndClear(); diff --git a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx index 0b12f3a73d77..26b11de27985 100644 --- a/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_resultsetmetadata.cxx @@ -167,8 +167,7 @@ void ResultSetMetaData::checkForTypes() if( i > 0 ) buf.append( " OR " ); int oid = m_colDesc[i].typeOid; - buf.append( "oid=" ); - buf.append( static_cast<sal_Int32>(oid) ); + buf.append( "oid=" + OUString::number(static_cast<sal_Int32>(oid)) ); } Reference< XResultSet > rs = stmt->executeQuery( buf.makeStringAndClear() ); Reference< XRow > xRow( rs, UNO_QUERY ); diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx index 9622bfee6b7a..648faa69811b 100644 --- a/connectivity/source/drivers/postgresql/pq_statement.cxx +++ b/connectivity/source/drivers/postgresql/pq_statement.cxx @@ -253,10 +253,10 @@ static void raiseSQLException( buf.append( "]" ); } buf.append( - OUString( errorMsg, strlen(errorMsg) , ConnectionSettings::encoding ) ); - buf.append( " (caused by statement '" ); - buf.append( OStringToOUString( sql, ConnectionSettings::encoding ) ); - buf.append( "')" ); + OUString( errorMsg, strlen(errorMsg) , ConnectionSettings::encoding ) + + " (caused by statement '" + + OStringToOUString( sql, ConnectionSettings::encoding ) + + "')" ); OUString error = buf.makeStringAndClear(); SAL_WARN("connectivity.postgresql", error); throw SQLException( error, owner, OUString(), 1, Any() ); @@ -607,8 +607,7 @@ Reference< XResultSet > getGeneratedValuesFromLastInsert( bufferQuoteQualifiedIdentifier(buf, schemaName, tableName, pConnectionSettings ); else bufferQuoteIdentifier( buf, lastTableInserted, pConnectionSettings ); - buf.append( " WHERE oid = " ); - buf.append( nLastOid ); + buf.append( " WHERE oid = " + OUString::number(nLastOid) ); query = buf.makeStringAndClear(); } else if ( lastTableInserted.size() && lastQuery.getLength() ) @@ -700,8 +699,7 @@ Reference< XResultSet > getGeneratedValuesFromLastInsert( if( bAdditionalCondition ) buf.append( " AND " ); bufferQuoteIdentifier( buf, columnNameUnicode, pConnectionSettings ); - buf.append( " = " ); - buf.append( value ); + buf.append( " = " + value ); bAdditionalCondition = true; } query = buf.makeStringAndClear(); diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx index b9ff495a5105..222f57f528d2 100644 --- a/connectivity/source/drivers/postgresql/pq_tools.cxx +++ b/connectivity/source/drivers/postgresql/pq_tools.cxx @@ -943,19 +943,17 @@ OUString sqltype2string( const Reference< XPropertySet > & desc ) case css::sdbc::DataType::VARCHAR: case css::sdbc::DataType::CHAR: { - typeName.append( "(" ); - typeName.append( precision ); - typeName.append( ")" ); + typeName.append( "(" + OUString::number(precision) + ")" ); break; } case css::sdbc::DataType::DECIMAL: case css::sdbc::DataType::NUMERIC: { - typeName.append( "(" ); - typeName.append( precision ); - typeName.append( "," ); - typeName.append( extractIntProperty( desc, getStatics().SCALE ) ); - typeName.append( ")" ); + typeName.append( "(" + + OUString::number(precision) + + "," + + OUString::number(extractIntProperty( desc, getStatics().SCALE )) + + ")" ); break; } default: diff --git a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx index 5c1b23e82175..49eb65cd9fbf 100644 --- a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx +++ b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx @@ -296,8 +296,8 @@ void UpdateableResultSet::updateRow( ) buf.append( ", " ); columns ++; - buf.append( m_columnNames[i] ); - buf.append( " = " ); + buf.append( m_columnNames[i] + + " = " ); bufferQuoteAnyConstant( buf, m_updateableField[i].value, *m_ppSettings ); // OUString val; // m_updateableField[i].value >>= val; @@ -342,8 +342,8 @@ void UpdateableResultSet::deleteRow( ) OUStringBuffer buf( 128 ); buf.append( "DELETE FROM " ); bufferQuoteQualifiedIdentifier( buf, m_schema, m_table, *m_ppSettings ); - buf.append( " " ); - buf.append( buildWhereClause() ); + buf.append( " " + + buildWhereClause() ); stmt->executeUpdate( buf.makeStringAndClear() ); diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx index 0c0a80c44809..b72d569d2256 100644 --- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx @@ -406,11 +406,10 @@ void alterColumnByDescriptor( bufferQuoteQualifiedIdentifier( buf, schemaName, tableName, settings ); buf.append( "ALTER COLUMN" ); bufferQuoteIdentifier( buf, futureColumnName, settings ); - buf.append( "SET DEFAULT " ); // LEM TODO: check out // default value is not quoted, caller needs to quote himself (otherwise // how to pass e.g. nextval('something' ) ???? - buf.append( futureDefaultValue ); + buf.append( "SET DEFAULT " + futureDefaultValue ); // bufferQuoteConstant( buf, defaultValue, encoding ); transaction.executeUpdate( buf.makeStringAndClear() ); } |