diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-21 08:24:59 +0100 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2013-08-21 11:29:43 +0100 |
commit | e0157dfec5d0aed888fc214abc878881789511fb (patch) | |
tree | 779848d7e7004951ca776a74cbccbbfdb53d7932 | |
parent | 36f23dd846d0cf03f9c816ae296ab2ce7aff3a00 (diff) |
Simplify/improve sanitizeIdentifier usage. (firebird-sdbc)
Change-Id: Ic0f66cc68b49a2e9d9f9b8b139a479a7179cc08b
-rw-r--r-- | connectivity/source/drivers/firebird/DatabaseMetaData.cxx | 37 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Util.cxx | 8 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/Util.hxx | 2 |
3 files changed, 11 insertions, 36 deletions
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx index 555e0ab45ecd..9e0411663192 100644 --- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx @@ -1091,17 +1091,9 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges( while( rs->next() ) { // 3. TABLE_NAME - { - OUString sTableName = xRow->getString(1); - sanitizeIdentifier(sTableName); - aCurrentRow[3] = new ORowSetValueDecorator(sTableName); - } + aCurrentRow[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow->getString(1))); // 4. COLUMN_NAME - { - OUString sColumnName = xRow->getString(6); - sanitizeIdentifier(sColumnName); - aCurrentRow[4] = new ORowSetValueDecorator(sColumnName); - } + aCurrentRow[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow->getString(6))); aCurrentRow[5] = new ORowSetValueDecorator(xRow->getString(2)); // 5. GRANTOR aCurrentRow[6] = new ORowSetValueDecorator(xRow->getString(3)); // 6. GRANTEE aCurrentRow[7] = new ORowSetValueDecorator(xRow->getString(4)); // 7. Privilege @@ -1195,18 +1187,9 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( while( rs->next() ) { // 3. TABLE_NAME - { - OUString sTableName = xRow->getString(1); - sanitizeIdentifier(sTableName); - aCurrentRow[3] = new ORowSetValueDecorator(sTableName); - } + aCurrentRow[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow->getString(1))); // 4. Column Name - { - OUString sColumnName = xRow->getString(2); - sanitizeIdentifier(sColumnName); - aCurrentRow[4] = new ORowSetValueDecorator(sColumnName); - } - + aCurrentRow[4] = new ORowSetValueDecorator(sanitizeIdentifier(xRow->getString(2))); // 5. Datatype short aType = getFBTypeFromBlrType(xRow->getShort(6)); aCurrentRow[5] = new ORowSetValueDecorator(getColumnTypeFromFBType(aType)); @@ -1402,11 +1385,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( while( rs->next() ) { // 3. TABLE_NAME - { - OUString sTableName = xRow->getString(1); - sanitizeIdentifier(sTableName); - aCurrentRow[3] = new ORowSetValueDecorator(sTableName); - } + aCurrentRow[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow->getString(1))); // 4. TABLE_TYPE { // TODO: check this as the docs are a bit unclear. @@ -1655,11 +1634,7 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( while( rs->next() ) { // 3. TABLE_NAME - { - OUString sTableName = xRow->getString(1); - sanitizeIdentifier(sTableName); - aRow[3] = new ORowSetValueDecorator(sTableName); - } + aRow[3] = new ORowSetValueDecorator(sanitizeIdentifier(xRow->getString(1))); aRow[4] = new ORowSetValueDecorator(xRow->getString(2)); // 4. GRANTOR aRow[5] = new ORowSetValueDecorator(xRow->getString(3)); // 5. GRANTEE aRow[6] = new ORowSetValueDecorator(xRow->getString(4)); // 6. Privilege diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx index bdf673e3b862..47661dbdb929 100644 --- a/connectivity/source/drivers/firebird/Util.cxx +++ b/connectivity/source/drivers/firebird/Util.cxx @@ -19,12 +19,12 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::uno; -OUString& firebird::sanitizeIdentifier(OUString& rIdentifier) +OUString firebird::sanitizeIdentifier(const OUString& rIdentifier) { - rIdentifier = rIdentifier.trim(); - assert(rIdentifier.getLength() <= 31); // Firebird identifiers cannot be longer than this. + OUString sRet = rIdentifier.trim(); + assert(sRet.getLength() <= 31); // Firebird identifiers cannot be longer than this. - return rIdentifier; + return sRet; } void firebird::evaluateStatusVector(ISC_STATUS_ARRAY& aStatusVector, diff --git a/connectivity/source/drivers/firebird/Util.hxx b/connectivity/source/drivers/firebird/Util.hxx index 589337fc737a..3a992a81d30a 100644 --- a/connectivity/source/drivers/firebird/Util.hxx +++ b/connectivity/source/drivers/firebird/Util.hxx @@ -31,7 +31,7 @@ namespace connectivity * for such shorter strings, however any trailing padding makes the gui * editing of such names harder, hence we remove all trailing whitespace. */ - ::rtl::OUString& sanitizeIdentifier(::rtl::OUString& rIdentifier); + ::rtl::OUString sanitizeIdentifier(const ::rtl::OUString& rIdentifier); /** * Evaluate a firebird status vector and throw exceptions as necessary. |