From bca00da68640bb052c1628270ce3924b7228d7b8 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 12 Dec 2014 17:51:11 +0100 Subject: connectivity: Use appropriate OUString functions on string constants Change-Id: I10b2ddf9dcc83219fea8eb55783507eed52702e8 --- connectivity/qa/connectivity/mork/DriverTest.cxx | 8 ++++---- connectivity/source/drivers/file/FConnection.cxx | 8 ++++---- connectivity/source/drivers/flat/EConnection.cxx | 12 ++++++------ connectivity/source/drivers/hsqldb/HConnection.cxx | 2 +- connectivity/source/drivers/hsqldb/HTable.cxx | 4 ++-- connectivity/source/drivers/mork/MDriver.cxx | 8 +------- connectivity/source/drivers/mork/MResultSet.cxx | 3 +-- connectivity/source/drivers/odbc/OConnection.cxx | 2 +- .../source/drivers/odbc/ODatabaseMetaDataResultSet.cxx | 4 ++-- .../source/drivers/postgresql/pq_databasemetadata.cxx | 12 ++++++------ include/connectivity/CommonTools.hxx | 4 ++-- include/connectivity/sqlnode.hxx | 2 +- 12 files changed, 31 insertions(+), 38 deletions(-) diff --git a/connectivity/qa/connectivity/mork/DriverTest.cxx b/connectivity/qa/connectivity/mork/DriverTest.cxx index b1c9d9ff923d..ca5ffdcca012 100644 --- a/connectivity/qa/connectivity/mork/DriverTest.cxx +++ b/connectivity/qa/connectivity/mork/DriverTest.cxx @@ -149,17 +149,17 @@ void MorkDriverTest::test_select_default_all() bool result = xResultSet->first(); CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result); OUString mail = xDelegatorRow->getString(1); - CPPUNIT_ASSERT_MESSAGE("first row is not john@doe.org!", mail.equalsAscii("john@doe.org")); + CPPUNIT_ASSERT_MESSAGE("first row is not john@doe.org!", mail == "john@doe.org"); result = xResultSet->next(); CPPUNIT_ASSERT_MESSAGE("fetch second row failed!", result); mail = xDelegatorRow->getString(1); - CPPUNIT_ASSERT_MESSAGE("second row is not john@doe10.org!", mail.equalsAscii("john@doe10.org")); + CPPUNIT_ASSERT_MESSAGE("second row is not john@doe10.org!", mail == "john@doe10.org"); result = xResultSet->last(); CPPUNIT_ASSERT_MESSAGE("fetch last row failed!", result); mail = xDelegatorRow->getString(1); - CPPUNIT_ASSERT_MESSAGE("last row is not john@doe9.org!", mail.equalsAscii("john@doe9.org")); + CPPUNIT_ASSERT_MESSAGE("last row is not john@doe9.org!", mail == "john@doe9.org"); css::uno::Reference( xStatement, css::uno::UNO_QUERY_THROW)->close(); @@ -189,7 +189,7 @@ void MorkDriverTest::test_select_list_table_joe_doe_5() bool result = xResultSet->first(); CPPUNIT_ASSERT_MESSAGE("fetch first row failed!", result); OUString mail = xDelegatorRow->getString(1); - CPPUNIT_ASSERT_MESSAGE("last row is not john@doe5.org!", mail.equalsAscii("john@doe5.org")); + CPPUNIT_ASSERT_MESSAGE("last row is not john@doe5.org!", mail == "john@doe5.org"); css::uno::Reference( xStatement, css::uno::UNO_QUERY_THROW)->close(); diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx index dbb3c675a516..4e1551674152 100644 --- a/connectivity/source/drivers/file/FConnection.cxx +++ b/connectivity/source/drivers/file/FConnection.cxx @@ -105,9 +105,9 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >& const PropertyValue *pEnd = pIter + info.getLength(); for(;pIter != pEnd;++pIter) { - if( pIter->Name.equalsAscii("Extension")) + if( pIter->Name == "Extension" ) OSL_VERIFY( pIter->Value >>= aExt ); - else if( pIter->Name.equalsAscii("CharSet")) + else if( pIter->Name == "CharSet" ) { OUString sIanaName; OSL_VERIFY( pIter->Value >>= sIanaName ); @@ -119,11 +119,11 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >& else m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW; } - else if( pIter->Name.equalsAscii("ShowDeleted")) + else if( pIter->Name == "ShowDeleted" ) { OSL_VERIFY( pIter->Value >>= m_bShowDeleted ); } - else if( pIter->Name.equalsAscii("EnableSQL92Check")) + else if( pIter->Name == "EnableSQL92Check" ) { pIter->Value >>= m_bCheckSQL92; } diff --git a/connectivity/source/drivers/flat/EConnection.cxx b/connectivity/source/drivers/flat/EConnection.cxx index 37d1d7877751..e3518e7dfe96 100644 --- a/connectivity/source/drivers/flat/EConnection.cxx +++ b/connectivity/source/drivers/flat/EConnection.cxx @@ -68,33 +68,33 @@ void OFlatConnection::construct(const OUString& url,const Sequence< PropertyValu const PropertyValue *pEnd = pBegin + info.getLength(); for(;pBegin != pEnd;++pBegin) { - if(pBegin->Name.equalsAscii("HeaderLine")) + if(pBegin->Name == "HeaderLine") OSL_VERIFY( pBegin->Value >>= m_bHeaderLine ); - else if(pBegin->Name.equalsAscii("FieldDelimiter")) + else if(pBegin->Name == "FieldDelimiter") { OUString aVal; OSL_VERIFY( pBegin->Value >>= aVal ); m_cFieldDelimiter = aVal.toChar(); } - else if(pBegin->Name.equalsAscii("StringDelimiter")) + else if(pBegin->Name == "StringDelimiter") { OUString aVal; OSL_VERIFY( pBegin->Value >>= aVal ); m_cStringDelimiter = aVal.toChar(); } - else if(pBegin->Name.equalsAscii("DecimalDelimiter")) + else if(pBegin->Name == "DecimalDelimiter") { OUString aVal; OSL_VERIFY( pBegin->Value >>= aVal ); m_cDecimalDelimiter = aVal.toChar(); } - else if(pBegin->Name.equalsAscii("ThousandDelimiter")) + else if(pBegin->Name == "ThousandDelimiter") { OUString aVal; OSL_VERIFY( pBegin->Value >>= aVal ); m_cThousandDelimiter = aVal.toChar(); } - else if ( pBegin->Name.equalsAscii("MaxRowScan") ) + else if ( pBegin->Name == "MaxRowScan" ) { pBegin->Value >>= m_nMaxRowsToScan; } diff --git a/connectivity/source/drivers/hsqldb/HConnection.cxx b/connectivity/source/drivers/hsqldb/HConnection.cxx index 70fc2529af3d..836a20d140ac 100644 --- a/connectivity/source/drivers/hsqldb/HConnection.cxx +++ b/connectivity/source/drivers/hsqldb/HConnection.cxx @@ -146,7 +146,7 @@ namespace connectivity { namespace hsqldb const PropertyValue* pEnd = pIter + aInfo.getLength(); for(;pIter != pEnd;++pIter) { - if ( pIter->Name.equalsAscii("readonly") ) + if ( pIter->Name == "readonly" ) m_bReadOnly = true; } } diff --git a/connectivity/source/drivers/hsqldb/HTable.cxx b/connectivity/source/drivers/hsqldb/HTable.cxx index 2ff063cba27a..31923db3579a 100644 --- a/connectivity/source/drivers/hsqldb/HTable.cxx +++ b/connectivity/source/drivers/hsqldb/HTable.cxx @@ -342,7 +342,7 @@ void OHSQLTable::executeStatement(const OUString& _rStatement ) Sequence< Type > SAL_CALL OHSQLTable::getTypes( ) throw(RuntimeException, std::exception) { - if ( m_Type.equalsAscii("VIEW") ) + if ( m_Type == "VIEW" ) { Sequence< Type > aTypes = OTableHelper::getTypes(); ::std::vector aOwnTypes; @@ -401,7 +401,7 @@ void SAL_CALL OHSQLTable::rename( const OUString& newName ) throw(SQLException, Any SAL_CALL OHSQLTable::queryInterface( const Type & rType ) throw(RuntimeException, std::exception) { - if( m_Type.equalsAscii("VIEW") && rType == cppu::UnoType::get()) + if( m_Type == "VIEW" && rType == cppu::UnoType::get()) return Any(); return OTableHelper::queryInterface(rType); diff --git a/connectivity/source/drivers/mork/MDriver.cxx b/connectivity/source/drivers/mork/MDriver.cxx index a9ee71078d16..48fd9a8754bb 100644 --- a/connectivity/source/drivers/mork/MDriver.cxx +++ b/connectivity/source/drivers/mork/MDriver.cxx @@ -118,13 +118,7 @@ sal_Bool MorkDriver::acceptsURL(OUString const & url) aAddrbookScheme = aAddrbookURI.copy(0, nLen); } - if (aAddrbookScheme.equalsAscii( "thunderbird" ) || - aAddrbookScheme.equalsAscii( "mozilla" ) ) - { - return true; - } - - return false; + return aAddrbookScheme == "thunderbird" || aAddrbookScheme == "mozilla"; } css::uno::Sequence< css::sdbc::DriverPropertyInfo > MorkDriver::getPropertyInfo( diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx index da81055fa87f..0021fe378292 100644 --- a/connectivity/source/drivers/mork/MResultSet.cxx +++ b/connectivity/source/drivers/mork/MResultSet.cxx @@ -880,8 +880,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT matchString = parseTree->getChild(2)->getTokenValue(); } - if ( columnName.equalsAscii("0") && op == MQueryOp::Is && - matchString.equalsAscii("1") ) { + if ( columnName == "0" && op == MQueryOp::Is && matchString == "1" ) { OSL_TRACE("Query always evaluates to FALSE"); m_bIsAlwaysFalseQuery = true; } diff --git a/connectivity/source/drivers/odbc/OConnection.cxx b/connectivity/source/drivers/odbc/OConnection.cxx index 3c524aece845..27d870b0e7e9 100644 --- a/connectivity/source/drivers/odbc/OConnection.cxx +++ b/connectivity/source/drivers/odbc/OConnection.cxx @@ -152,7 +152,7 @@ SQLRETURN OConnection::OpenConnection(const OUString& aConnectStr, sal_Int32 nTi { OUString aVal; OTools::GetInfo(this,m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,aVal,*this,getTextEncoding()); - m_bReadOnly = aVal.equalsAscii("Y"); + m_bReadOnly = aVal == "Y"; } catch(Exception&) { diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx index 6762ecde37fa..420aa3eb1ef3 100644 --- a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx @@ -1210,13 +1210,13 @@ void ODatabaseMetaDataResultSet::openImportedKeys(const Any& catalog, const OUSt const OUString& table) throw(SQLException, RuntimeException) { - openForeignKeys(Any(),NULL,NULL,catalog, schema.equalsAscii("%") ? &schema : NULL, &table); + openForeignKeys(Any(),NULL,NULL,catalog, schema == "%" ? &schema : NULL, &table); } void ODatabaseMetaDataResultSet::openExportedKeys(const Any& catalog, const OUString& schema, const OUString& table) throw(SQLException, RuntimeException) { - openForeignKeys(catalog, schema.equalsAscii("%") ? &schema : NULL, &table,Any(),NULL,NULL); + openForeignKeys(catalog, schema == "%" ? &schema : NULL, &table,Any(),NULL,NULL); } void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const OUString& schema, diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx index de0200fe9174..33c3209a4d4f 100644 --- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx @@ -1185,9 +1185,9 @@ sal_Bool DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw (SQLExc row[1] <<= xRow->getString( 1 ); row[2] <<= xRow->getString( 2 ); OUString type = xRow->getString(3); - if( type.equalsAscii( "r" ) ) + if( type == "r" ) { - if( xRow->getString(1).equalsAscii( "pg_catalog" ) ) + if( xRow->getString(1) == "pg_catalog" ) { row[3] <<= statics.SYSTEM_TABLE; } @@ -1196,7 +1196,7 @@ sal_Bool DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw (SQLExc row[3] <<= statics.TABLE; } } - else if( type.equalsAscii( "v" ) ) + else if( type == "v" ) { row[3] <<= statics.VIEW; } @@ -1323,7 +1323,7 @@ sal_Int32 typeNameToDataType( const OUString &typeName, const OUString &typtype // string representation. Additionally, the edit-table-type-selection-box // is not so unusable anymore. sal_Int32 ret = com::sun::star::sdbc::DataType::LONGVARCHAR; - if( typtype.equalsAscii( "b" ) ) + if( typtype == "b" ) { // as long as the OOo framework does not support arrays, // the user is better of with interpreting arrays as strings ! @@ -1341,11 +1341,11 @@ sal_Int32 typeNameToDataType( const OUString &typeName, const OUString &typtype ret = ii->second; } } - else if( typtype.equalsAscii( "c" ) ) + else if( typtype == "c" ) { ret = com::sun::star::sdbc::DataType::STRUCT; } - else if( typtype.equalsAscii( "d" ) ) + else if( typtype == "d" ) { ret = com::sun::star::sdbc::DataType::LONGVARCHAR; } diff --git a/include/connectivity/CommonTools.hxx b/include/connectivity/CommonTools.hxx index cda2f65df144..4680d99a63f7 100644 --- a/include/connectivity/CommonTools.hxx +++ b/include/connectivity/CommonTools.hxx @@ -162,12 +162,12 @@ namespace connectivity #define IMPLEMENT_SERVICE_INFO(classname, implasciiname, serviceasciiname) \ OUString SAL_CALL classname::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException, std::exception) \ { \ - return OUString::createFromAscii(implasciiname); \ + return OUString(implasciiname); \ } \ ::com::sun::star::uno::Sequence< OUString > SAL_CALL classname::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) \ { \ ::com::sun::star::uno::Sequence< OUString > aSupported(1); \ - aSupported[0] = OUString::createFromAscii(serviceasciiname); \ + aSupported[0] = serviceasciiname; \ return aSupported; \ } \ sal_Bool SAL_CALL classname::supportsService( const OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) \ diff --git a/include/connectivity/sqlnode.hxx b/include/connectivity/sqlnode.hxx index 389bd8865aca..bf7f476d27fb 100644 --- a/include/connectivity/sqlnode.hxx +++ b/include/connectivity/sqlnode.hxx @@ -464,7 +464,7 @@ namespace connectivity #define SQL_ISTOKEN(pParseNode, token) ((pParseNode)->isToken() && (pParseNode)->getTokenID() == SQL_TOKEN_##token) #define SQL_ISTOKENOR2(pParseNode, tok0, tok1) ((pParseNode)->isToken() && ( (pParseNode)->getTokenID() == SQL_TOKEN_##tok0 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok1 )) #define SQL_ISTOKENOR3(pParseNode, tok0, tok1, tok2) ((pParseNode)->isToken() && ( (pParseNode)->getTokenID() == SQL_TOKEN_##tok0 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok1 || (pParseNode)->getTokenID() == SQL_TOKEN_##tok2 )) - #define SQL_ISPUNCTUATION(pParseNode, aString) ((pParseNode)->getNodeType() == SQL_NODE_PUNCTUATION && (pParseNode)->getTokenValue().equalsAscii(aString)) + #define SQL_ISPUNCTUATION(pParseNode, aString) ((pParseNode)->getNodeType() == SQL_NODE_PUNCTUATION && (pParseNode)->getTokenValue() == (aString)) } #endif // INCLUDED_CONNECTIVITY_SQLNODE_HXX -- cgit