diff options
23 files changed, 169 insertions, 266 deletions
diff --git a/connectivity/source/drivers/postgresql/pq_array.cxx b/connectivity/source/drivers/postgresql/pq_array.cxx index d11fc49233fa..92cd03398a23 100644 --- a/connectivity/source/drivers/postgresql/pq_array.cxx +++ b/connectivity/source/drivers/postgresql/pq_array.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/sdbc/XArray.hpp> #include <com/sun/star/sdbc/DataType.hpp> +#include <comphelper/sequence.hxx> #include "pq_array.hxx" @@ -69,7 +70,7 @@ sal_Int32 Array::getBaseType( ) const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& /* typeMap */ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) { - return m_data; + return comphelper::containerToSequence(m_data); } ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > Array::getArrayAtIndex( @@ -86,7 +87,7 @@ sal_Int32 Array::getBaseType( ) const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) { - return getResultSetAtIndex( 0 , m_data.getLength() , typeMap ); + return getResultSetAtIndex( 0 , m_data.size() , typeMap ); } ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > Array::getResultSetAtIndex( @@ -96,11 +97,11 @@ sal_Int32 Array::getBaseType( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) { checkRange( index, count ); - Sequence< Sequence< Any > > ret( count ); + std::vector< std::vector< Any > > ret( count ); for( int i = 0 ; i < count ; i ++ ) { - Sequence< Any > row( 2 ); + std::vector< Any > row( 2 ); row[0] <<= (sal_Int32) ( i + index ); row[1] = m_data[i+index-1]; ret[i] = row; @@ -113,11 +114,11 @@ sal_Int32 Array::getBaseType( ) void Array::checkRange( sal_Int32 index, sal_Int32 count ) { - if( index >= 1 && index -1 + count <= m_data.getLength() ) + if( index >= 1 && index -1 + count <= (sal_Int32)m_data.size() ) return; OUStringBuffer buf; buf.append( "Array::getArrayAtIndex(): allowed range for index + count " ); - buf.append( m_data.getLength() ); + buf.append( (sal_Int32)m_data.size() ); buf.append( ", got " ); buf.append( index ); buf.append( " + " ); diff --git a/connectivity/source/drivers/postgresql/pq_array.hxx b/connectivity/source/drivers/postgresql/pq_array.hxx index 6177eb0e98ff..ce1dc934faad 100644 --- a/connectivity/source/drivers/postgresql/pq_array.hxx +++ b/connectivity/source/drivers/postgresql/pq_array.hxx @@ -40,13 +40,14 @@ #include <com/sun/star/sdbc/XArray.hpp> #include "pq_connection.hxx" +#include <vector> namespace pq_sdbc_driver { class Array : public cppu::WeakImplHelper< com::sun::star::sdbc::XArray > { - com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_data; + std::vector< com::sun::star::uno::Any > m_data; com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_owner; com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > m_tc; rtl::Reference< RefCountedMutex > m_refMutex; @@ -54,7 +55,7 @@ class Array : public cppu::WeakImplHelper< com::sun::star::sdbc::XArray > public: Array( const rtl::Reference< RefCountedMutex > & mutex, - const com::sun::star::uno::Sequence< com::sun::star::uno::Any > & data, + const std::vector< com::sun::star::uno::Any > & data, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > & owner, const com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > &tc) : m_data( data ), diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx index e298262c1141..0c00c9a32692 100644 --- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx +++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx @@ -1106,7 +1106,7 @@ sal_Bool DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw (SQLExc // LEM TODO: at least fake the columns, even if no row. MutexGuard guard( m_refMutex->mutex ); return new SequenceResultSet( - m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc ); + m_refMutex, *this, std::vector< OUString >(), std::vector< std::vector< Any > > (), m_pSettings->tc ); } ::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getProcedureColumns( @@ -1120,7 +1120,7 @@ sal_Bool DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw (SQLExc // LEM TODO: implement // LEM TODO: at least fake the columns, even if no row. return new SequenceResultSet( - m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc ); + m_refMutex, *this, std::vector< OUString >(), std::vector< std::vector< Any > >(), m_pSettings->tc ); } ::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getTables( @@ -1167,11 +1167,11 @@ sal_Bool DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw (SQLExc Reference< XResultSet > rs = statement->executeQuery(); Reference< XRow > xRow( rs, UNO_QUERY_THROW ); - SequenceAnyVector vec; + std::vector< std::vector<Any> > vec; while( rs->next() ) { - Sequence< Any > row( 5 ); + std::vector< Any > row( 5 ); row[0] <<= m_pSettings->catalog; row[1] <<= xRow->getString( 1 ); @@ -1206,12 +1206,12 @@ sal_Bool DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw (SQLExc closeable->close(); return new SequenceResultSet( - m_refMutex, *this, statics.tablesRowNames, sequence_of_vector(vec), m_pSettings->tc ); + m_refMutex, *this, statics.tablesRowNames, vec, m_pSettings->tc ); } struct SortInternalSchemasLastAndPublicFirst { - bool operator () ( const Sequence< Any > & a, const Sequence< Any > & b ) + bool operator () ( const std::vector< Any > & a, const std::vector< Any > & b ) { OUString valueA; OUString valueB; @@ -1264,10 +1264,10 @@ struct SortInternalSchemasLastAndPublicFirst // in particular, excluding temporary schemas, but maybe better through pg_is_other_temp_schema(oid) OR == pg_my_temp_schema() Reference< XRow > xRow( rs, UNO_QUERY_THROW ); - SequenceAnyVector vec; + std::vector< std::vector<Any> > vec; while( rs->next() ) { - Sequence<Any> row(1); + std::vector<Any> row(1); row[0] <<= xRow->getString(1); vec.push_back( row ); } @@ -1279,7 +1279,7 @@ struct SortInternalSchemasLastAndPublicFirst if( closeable.is() ) closeable->close(); return new SequenceResultSet( - m_refMutex, *this, getStatics().schemaNames, sequence_of_vector(vec), m_pSettings->tc ); + m_refMutex, *this, getStatics().schemaNames, vec, m_pSettings->tc ); } ::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getCatalogs( ) @@ -1289,7 +1289,7 @@ struct SortInternalSchemasLastAndPublicFirst // at least fake the columns, even if no content MutexGuard guard( m_refMutex->mutex ); return new SequenceResultSet( - m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc ); + m_refMutex, *this, std::vector< OUString >(), std::vector< std::vector< Any > >(), m_pSettings->tc ); } ::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getTableTypes( ) @@ -1558,7 +1558,7 @@ static void columnMetaData2DatabaseTypeDescription( Reference< XResultSet > rs = statement->executeQuery(); Reference< XRow > xRow( rs, UNO_QUERY_THROW ); - SequenceAnyVector vec; + std::vector< std::vector<Any> > vec; Oid2DatabaseTypeDescriptionMap domainMap; Reference< XStatement > domainTypeStmt = m_origin->createStatement(); @@ -1583,7 +1583,7 @@ static void columnMetaData2DatabaseTypeDescription( else ++colNum; sal_Int32 precision, scale, type; - Sequence< Any > row( 18 ); + std::vector< Any > row( 18 ); row[0] <<= m_pSettings->catalog; row[1] <<= sNewSchema; row[2] <<= sNewTable; @@ -1630,7 +1630,7 @@ static void columnMetaData2DatabaseTypeDescription( closeable->close(); return new SequenceResultSet( - m_refMutex, *this, statics.columnRowNames, sequence_of_vector(vec), m_pSettings->tc ); + m_refMutex, *this, statics.columnRowNames, vec, m_pSettings->tc ); } ::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getColumnPrivileges( @@ -1701,7 +1701,7 @@ static void columnMetaData2DatabaseTypeDescription( //LEM TODO: implement! See JDBC driver MutexGuard guard( m_refMutex->mutex ); return new SequenceResultSet( - m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc ); + m_refMutex, *this, std::vector< OUString >(), std::vector< std::vector< Any > >(), m_pSettings->tc ); } ::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getVersionColumns( @@ -1712,7 +1712,7 @@ static void columnMetaData2DatabaseTypeDescription( //LEM TODO: implement! See JDBC driver MutexGuard guard( m_refMutex->mutex ); return new SequenceResultSet( - m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc ); + m_refMutex, *this, std::vector< OUString >(), std::vector< std::vector< Any > >(), m_pSettings->tc ); } ::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getPrimaryKeys( @@ -1756,11 +1756,11 @@ static void columnMetaData2DatabaseTypeDescription( Reference< XResultSet > rs = statement->executeQuery(); Reference< XRow > xRow( rs, UNO_QUERY_THROW ); - SequenceAnyVector vec; + std::vector< std::vector<Any> > vec; while( rs->next() ) { - Sequence< Any > row( 6 ); + std::vector< Any > row( 6 ); row[0] <<= m_pSettings->catalog; row[1] <<= xRow->getString(1); row[2] <<= xRow->getString(2); @@ -1795,15 +1795,15 @@ static void columnMetaData2DatabaseTypeDescription( } - SequenceAnyVector::iterator ii = vec.begin(); + std::vector< std::vector<Any> >::iterator ii = vec.begin(); OUString lastTableOid; sal_Int32 index = 0; - Sequence< Sequence< Any > > ret( vec.size() ); + std::vector< std::vector< Any > > ret( vec.size() ); int elements = 0; for( ; ii != vec.end() ; ++ ii ) { - Sequence< Any > row = *ii; + std::vector< Any > row = *ii; OUString tableOid; OUString attnum; @@ -1839,7 +1839,7 @@ static void columnMetaData2DatabaseTypeDescription( elements ++; } return new SequenceResultSet( - m_refMutex, *this, getStatics().primaryKeyNames, ret , m_pSettings->tc ); + m_refMutex, *this, getStatics().primaryKeyNames, ret, m_pSettings->tc ); } // Copied / adapted / simplified from JDBC driver @@ -2130,7 +2130,7 @@ void DatabaseMetaData::init_getPrivs_stmt () struct TypeInfoByDataTypeSorter { - bool operator () ( const Sequence< Any > & a, const Sequence< Any > & b ) + bool operator () ( const std::vector< Any > & a, const std::vector< Any > & b ) { OUString valueA; OUString valueB; @@ -2193,7 +2193,7 @@ static sal_Int32 getMaxScale( sal_Int32 dataType ) static void pgTypeInfo2ResultSet( - SequenceAnyVector &vec, + std::vector< std::vector<Any> > &vec, const Reference< XResultSet > &rs ) { static const sal_Int32 TYPE_NAME = 0; // string Type name @@ -2233,7 +2233,7 @@ static void pgTypeInfo2ResultSet( Reference< XRow > xRow( rs, UNO_QUERY_THROW ); while( rs->next() ) { - Sequence< Any > row(18); + std::vector< Any > row(18); sal_Int32 dataType =typeNameToDataType(xRow->getString(5),xRow->getString(2)); sal_Int32 precision = xRow->getString(3).toInt32(); @@ -2303,7 +2303,7 @@ static void pgTypeInfo2ResultSet( "OR pg_type.typtype = 'p'" ); - SequenceAnyVector vec; + std::vector< std::vector<Any> > vec; pgTypeInfo2ResultSet( vec, rs ); // check for domain types @@ -2323,26 +2323,12 @@ static void pgTypeInfo2ResultSet( m_refMutex, *this, getStatics().typeinfoColumnNames, - sequence_of_vector(vec), + vec, m_pSettings->tc, &( getStatics().typeInfoMetaData )); } -static sal_Int32 seqContains( const Sequence< sal_Int32 > &seq, sal_Int32 value ) -{ - sal_Int32 ret = -1; - for( int i = 0; i < seq.getLength(); i ++ ) - { - if( seq[i] == value ) - { - ret = i; - break; - } - } - return ret; -} - ::com::sun::star::uno::Reference< XResultSet > DatabaseMetaData::getIndexInfo( const ::com::sun::star::uno::Any& , const OUString& schema, @@ -2418,10 +2404,10 @@ static sal_Int32 seqContains( const Sequence< sal_Int32 > &seq, sal_Int32 value Reference< XResultSet > rs = stmt->executeQuery(); Reference< XRow > xRow ( rs, UNO_QUERY_THROW ); - SequenceAnyVector vec; + std::vector< std::vector<Any> > vec; while( rs->next() ) { - Sequence< sal_Int32 > columns = parseIntArray( xRow->getString(C_COLUMNS) ); + std::vector< sal_Int32 > columns = parseIntArray( xRow->getString(C_COLUMNS) ); Reference< XPreparedStatement > columnsStmt = m_origin->prepareStatement( "SELECT attnum, attname " "FROM pg_attribute " @@ -2446,10 +2432,10 @@ static sal_Int32 seqContains( const Sequence< sal_Int32 > &seq, sal_Int32 value Reference< XRow > rowColumn( rsColumn, UNO_QUERY_THROW ); while( rsColumn->next() ) { - sal_Int32 pos = seqContains( columns, rowColumn->getInt( 1 ) ); - if( pos >= 0 && ( ! isNonUnique || ! unique ) ) + auto findIt = std::find( columns.begin(), columns.end(), rowColumn->getInt( 1 ) ); + if( findIt != columns.end() && ( ! isNonUnique || ! unique ) ) { - Sequence< Any > result( 13 ); + std::vector< Any > result( 13 ); result[R_TABLE_SCHEM] = makeAny(currentSchema); result[R_TABLE_NAME] = makeAny(currentTable); result[R_INDEX_NAME] = makeAny(currentIndexName); @@ -2457,7 +2443,7 @@ static sal_Int32 seqContains( const Sequence< sal_Int32 > &seq, sal_Int32 value Any( &isNonUnique, cppu::UnoType<bool>::get() ); result[R_TYPE] = makeAny( indexType ); result[R_COLUMN_NAME] = makeAny( rowColumn->getString(2) ); - sal_Int32 nPos = ((sal_Int32)pos+1); // MSVC++ nonsense + sal_Int32 nPos = (sal_Int32)(findIt - columns.begin() +1); // MSVC++ nonsense result[R_ORDINAL_POSITION] = makeAny( nPos ); vec.push_back( result ); } @@ -2465,7 +2451,7 @@ static sal_Int32 seqContains( const Sequence< sal_Int32 > &seq, sal_Int32 value } return new SequenceResultSet( m_refMutex, *this, getStatics().indexinfoColumnNames, - sequence_of_vector(vec), + vec, m_pSettings->tc ); } @@ -2542,7 +2528,7 @@ css::uno::Reference< XResultSet > DatabaseMetaData::getUDTs( const ::com::sun::s //LEM TODO: implement! See JDBC driver MutexGuard guard( m_refMutex->mutex ); return new SequenceResultSet( - m_refMutex, *this, Sequence< OUString >(), Sequence< Sequence< Any > > (), m_pSettings->tc ); + m_refMutex, *this, std::vector< OUString >(), std::vector< std::vector< Any > >(), m_pSettings->tc ); } ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > DatabaseMetaData::getConnection() diff --git a/connectivity/source/drivers/postgresql/pq_sequenceresultset.cxx b/connectivity/source/drivers/postgresql/pq_sequenceresultset.cxx index 4175b5e2e305..9deb552f2f89 100644 --- a/connectivity/source/drivers/postgresql/pq_sequenceresultset.cxx +++ b/connectivity/source/drivers/postgresql/pq_sequenceresultset.cxx @@ -42,7 +42,6 @@ using com::sun::star::sdbc::XResultSetMetaData; -using com::sun::star::uno::Sequence; using com::sun::star::uno::Reference; using com::sun::star::uno::Any; @@ -66,17 +65,17 @@ Any SequenceResultSet::getValue( sal_Int32 columnIndex ) SequenceResultSet::SequenceResultSet( const ::rtl::Reference< RefCountedMutex > & mutex, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner, - const Sequence< OUString > &colNames, - const Sequence< Sequence< Any > > &data, + const std::vector< OUString > &colNames, + const std::vector< std::vector< Any > > &data, const Reference< com::sun::star::script::XTypeConverter > & tc, const ColumnMetaDataVector *pVec) : - BaseResultSet( mutex, owner, data.getLength(), colNames.getLength(),tc ), + BaseResultSet( mutex, owner, data.size(), colNames.size(), tc ), m_data(data ), m_columnNames( colNames ) { if( pVec ) { - m_meta = new SequenceResultSetMetaData( *pVec, m_columnNames.getLength() ); + m_meta = new SequenceResultSetMetaData( *pVec, m_columnNames.size() ); } } diff --git a/connectivity/source/drivers/postgresql/pq_sequenceresultset.hxx b/connectivity/source/drivers/postgresql/pq_sequenceresultset.hxx index 564471baf78b..5be338f0d386 100644 --- a/connectivity/source/drivers/postgresql/pq_sequenceresultset.hxx +++ b/connectivity/source/drivers/postgresql/pq_sequenceresultset.hxx @@ -54,9 +54,9 @@ namespace pq_sdbc_driver class SequenceResultSet : public BaseResultSet { protected: - ::com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > > m_data; + std::vector< std::vector< ::com::sun::star::uno::Any > > m_data; - ::com::sun::star::uno::Sequence< OUString > m_columnNames; + std::vector< OUString > m_columnNames; ::com::sun::star::uno::Reference< com::sun::star::sdbc::XResultSetMetaData > m_meta; protected: @@ -73,8 +73,8 @@ public: SequenceResultSet( const ::rtl::Reference< RefCountedMutex > & mutex, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner, - const com::sun::star::uno::Sequence< OUString > &colNames, - const com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > > &data, + const std::vector< OUString > &colNames, + const std::vector< std::vector< com::sun::star::uno::Any > > &data, const com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > &tc, const ColumnMetaDataVector *pVec = nullptr); virtual ~SequenceResultSet(); diff --git a/connectivity/source/drivers/postgresql/pq_statement.cxx b/connectivity/source/drivers/postgresql/pq_statement.cxx index 68ff3a14670b..bff2a1967340 100644 --- a/connectivity/source/drivers/postgresql/pq_statement.cxx +++ b/connectivity/source/drivers/postgresql/pq_statement.cxx @@ -317,14 +317,14 @@ static void raiseSQLException( // returns the elements of the primary key of the given table // static Sequence< Reference< com::sun::star::beans::XPropertySet > > lookupKeys( -static Sequence< OUString > lookupKeys( +static std::vector< OUString > lookupKeys( const Reference< com::sun::star::container::XNameAccess > &tables, const OUString & table, OUString *pSchema, OUString *pTable, ConnectionSettings *pSettings) { - Sequence< OUString > ret; + std::vector< OUString > ret; Reference< XKeysSupplier > keySupplier; Statics & st = getStatics(); @@ -406,7 +406,7 @@ static Sequence< OUString > lookupKeys( Reference< XIndexAccess > ( columns->getColumns(), UNO_QUERY ); int length = indexAccess->getCount(); - ret.realloc( length ); + ret.resize( length ); // printf( "primary key for Table %s is ", // OUStringToOString( table, RTL_TEXTENCODING_ASCII_US ).getStr() ); for( int i = 0 ; i < length ; i ++ ) @@ -420,7 +420,7 @@ static Sequence< OUString > lookupKeys( // printf( "\n" ); } } - if( ! ret.getLength() ) + if( ! ret.size() ) { if( isLog( pSettings, LogLevel::INFO ) ) { @@ -496,7 +496,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) // belonging to the primary key are in the result set, allow updateable result sets // otherwise, don't OUString table, schema; - Sequence< OUString > sourceTableKeys; + std::vector< OUString > sourceTableKeys; OStringVector vec; tokenizeSQL( cmd, vec ); OUString sourceTable = @@ -519,7 +519,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) // check, whether the columns are in the result set (required !) int i; - for( i = 0 ; i < sourceTableKeys.getLength() ; i ++ ) + for( i = 0 ; i < (int)sourceTableKeys.size() ; i ++ ) { if( -1 == PQfnumber( result, @@ -530,7 +530,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) } } - if( sourceTableKeys.getLength() && i == sourceTableKeys.getLength() ) + if( sourceTableKeys.size() && i == (int)sourceTableKeys.size() ) { *(data->pLastResultset) = UpdateableResultSet::createFromPGResultSet( @@ -546,7 +546,7 @@ bool executePostgresCommand( const OString & cmd, struct CommandData *data ) buf.append( "." ); aReason = buf.makeStringAndClear(); } - else if( sourceTableKeys.getLength() ) + else if( sourceTableKeys.size() ) { OStringBuffer buf( 128 ); buf.append( "can't support updateable resultset for table " ); diff --git a/connectivity/source/drivers/postgresql/pq_statics.cxx b/connectivity/source/drivers/postgresql/pq_statics.cxx index edbe7ae3b008..bc72da4a6767 100644 --- a/connectivity/source/drivers/postgresql/pq_statics.cxx +++ b/connectivity/source/drivers/postgresql/pq_statics.cxx @@ -68,20 +68,6 @@ struct DefColumnMetaData struct BaseTypeDef { const char * typeName; sal_Int32 value; }; -static Sequence< OUString > createStringSequence( const char * names[] ) -{ - int length = 0; - while (names[length]) - ++length; - - Sequence< OUString > seq( length ); - for( int i = 0; i < length; i ++ ) - { - seq[i] = OUString( names[i] , strlen( names[i] ), RTL_TEXTENCODING_ASCII_US ); - } - return seq; -} - struct PropertyDef { PropertyDef( const OUString &str, const Type &t ) @@ -489,14 +475,14 @@ Statics & getStatics() resultSet, sizeof(resultSet)/sizeof(PropertyDef), 0 ); // databasemetadata - statics.tablesRowNames = Sequence< OUString > ( 5 ); + statics.tablesRowNames = std::vector< OUString > ( 5 ); statics.tablesRowNames[TABLE_INDEX_CATALOG] = "TABLE_CAT"; statics.tablesRowNames[TABLE_INDEX_SCHEMA] = "TABLE_SCHEM"; statics.tablesRowNames[TABLE_INDEX_NAME] = "TABLE_NAME"; statics.tablesRowNames[TABLE_INDEX_TYPE] = "TABLE_TYPE"; statics.tablesRowNames[TABLE_INDEX_REMARKS] = "REMARKS"; - statics.primaryKeyNames = Sequence< OUString > ( 6 ); + statics.primaryKeyNames = std::vector< OUString > ( 6 ); statics.primaryKeyNames[0] = "TABLE_CAT"; statics.primaryKeyNames[1] = "TABLE_SCHEM"; statics.primaryKeyNames[2] = "TABLE_NAME"; @@ -518,86 +504,51 @@ Statics & getStatics() statics.INDEX = "Index"; statics.INDEX_COLUMN = "IndexColumn"; - statics.schemaNames = Sequence< OUString > ( 1 ); + statics.schemaNames = std::vector< OUString > ( 1 ); statics.schemaNames[0] = "TABLE_SCHEM"; - statics.tableTypeData = Sequence< Sequence< Any > >( 2 ); + statics.tableTypeData = std::vector< std::vector< Any > >( 2 ); - statics.tableTypeData[0] = Sequence< Any > ( 1 ); + statics.tableTypeData[0] = std::vector< Any > ( 1 ); statics.tableTypeData[0][0] <<= statics.TABLE; // statics.tableTypeData[2] = Sequence< Any > ( 1 ); // statics.tableTypeData[2][0] <<= statics.VIEW; - statics.tableTypeData[1] = Sequence< Any > ( 1 ); + statics.tableTypeData[1] = std::vector< Any > ( 1 ); statics.tableTypeData[1][0] <<= statics.SYSTEM_TABLE; - statics.tableTypeNames = Sequence< OUString > ( 1 ); + statics.tableTypeNames = std::vector< OUString > ( 1 ); statics.tableTypeNames[0] = "TABLE_TYPE"; - static const char *tablePrivilegesNames[] = - { - "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "GRANTOR", "GRANTEE", "PRIVILEGE", - "IS_GRANTABLE" , nullptr - }; - statics.tablePrivilegesNames = - createStringSequence( tablePrivilegesNames ); - - static const char * columnNames[] = + statics.columnRowNames = { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "COLUMN_NAME", "DATA_TYPE", "TYPE_NAME", "COLUMN_SIZE", "BUFFER_LENGTH", "DECIMAL_DIGITS", "NUM_PREC_RADIX", "NULLABLE", "REMARKS", "COLUMN_DEF", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", "CHAR_OCTET_LENGTH", - "ORDINAL_POSITION", "IS_NULLABLE", nullptr + "ORDINAL_POSITION", "IS_NULLABLE" }; - statics.columnRowNames = - createStringSequence( columnNames ); - static const char * typeinfoColumnNames[] = + statics.typeinfoColumnNames = { "TYPE_NAME", "DATA_TYPE", "PRECISION", "LITERAL_PREFIX", "LITERAL_SUFFIX", "CREATE_PARAMS", "NULLABLE", "CASE_SENSITIVE", "SEARCHABLE", "UNSIGNED_ATTRIBUTE", "FIXED_PREC_SCALE", "AUTO_INCREMENT", "LOCAL_TYPE_NAME", "MINIMUM_SCALE", "MAXIMUM_SCALE", "SQL_DATA_TYPE", "SQL_DATETIME_SUB", - "NUM_PREC_RADIX", nullptr + "NUM_PREC_RADIX" }; - statics.typeinfoColumnNames = createStringSequence( typeinfoColumnNames ); - static const char * indexinfoColumnNames[] = + statics.indexinfoColumnNames = { "TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "NON_UNIQUE", "INDEX_QUALIFIER", "INDEX_NAME", "TYPE", "ORDINAL_POSITION", "COLUMN_NAME", - "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION",nullptr - }; - statics.indexinfoColumnNames = createStringSequence( indexinfoColumnNames ); - - static const char * importedKeysColumnNames[] = - { - "PKTABLE_CAT" , - "PKTABLE_SCHEM", - "PKTABLE_NAME" , - "PKCOLUMN_NAME", - "FKTABLE_CAT" , - "FKTABLE_SCHEM", - "FKTABLE_NAME" , - "FKCOLUMN_NAME", - "KEY_SEQ" , - "UPDATE_RULE", - "DELETE_RULE", - "FK_NAME" , - "PK_NAME" , - "DEFERRABILITY" , - nullptr + "ASC_OR_DESC", "CARDINALITY", "PAGES", "FILTER_CONDITION" }; - statics.importedKeysColumnNames = - createStringSequence( importedKeysColumnNames ); - static const char * resultSetArrayColumnNames[] = { "INDEX" , "VALUE", nullptr }; - statics.resultSetArrayColumnNames = - createStringSequence( resultSetArrayColumnNames ); + statics.resultSetArrayColumnNames = { "INDEX" , "VALUE" }; // LEM TODO see if a refresh is needed; obtain automatically from pg_catalog.pg_type? BaseTypeDef baseTypeDefs[] = diff --git a/connectivity/source/drivers/postgresql/pq_statics.hxx b/connectivity/source/drivers/postgresql/pq_statics.hxx index 2b4a75bc393e..3592502e257d 100644 --- a/connectivity/source/drivers/postgresql/pq_statics.hxx +++ b/connectivity/source/drivers/postgresql/pq_statics.hxx @@ -221,17 +221,15 @@ struct Statics OUString IS_ASCENDING; ReflectionImplementations refl; - com::sun::star::uno::Sequence< OUString > tablesRowNames; - com::sun::star::uno::Sequence< OUString > columnRowNames; - com::sun::star::uno::Sequence< OUString > primaryKeyNames; - com::sun::star::uno::Sequence< OUString > tablePrivilegesNames; - com::sun::star::uno::Sequence< OUString > schemaNames; - com::sun::star::uno::Sequence< OUString > tableTypeNames; - com::sun::star::uno::Sequence< OUString > typeinfoColumnNames; - com::sun::star::uno::Sequence< OUString > indexinfoColumnNames; - com::sun::star::uno::Sequence< OUString > importedKeysColumnNames; - com::sun::star::uno::Sequence< OUString > resultSetArrayColumnNames; - com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > > tableTypeData; + std::vector< OUString > tablesRowNames; + std::vector< OUString > columnRowNames; + std::vector< OUString > primaryKeyNames; + std::vector< OUString > schemaNames; + std::vector< OUString > tableTypeNames; + std::vector< OUString > typeinfoColumnNames; + std::vector< OUString > indexinfoColumnNames; + std::vector< OUString > resultSetArrayColumnNames; + std::vector< std::vector< com::sun::star::uno::Any > > tableTypeData; ColumnMetaDataVector typeInfoMetaData; BaseTypeMap baseTypeMap; diff --git a/connectivity/source/drivers/postgresql/pq_tools.cxx b/connectivity/source/drivers/postgresql/pq_tools.cxx index a5d7d3ac85df..672ef5d1f3d0 100644 --- a/connectivity/source/drivers/postgresql/pq_tools.cxx +++ b/connectivity/source/drivers/postgresql/pq_tools.cxx @@ -566,9 +566,6 @@ void splitConcatenatedIdentifier( const OUString & source, OUString *first, OUSt } } -typedef std::vector< sal_Int32 > IntVector; - - OUString array2String( const com::sun::star::uno::Sequence< Any > &seq ) { OUStringBuffer buf(128); @@ -598,13 +595,8 @@ OUString array2String( const com::sun::star::uno::Sequence< Any > &seq ) return buf.makeStringAndClear(); } -typedef -std::vector -< - com::sun::star::uno::Any -> AnyVector; -com::sun::star::uno::Sequence< Any > parseArray( const OUString & str ) throw( SQLException ) +std::vector< Any > parseArray( const OUString & str ) throw( SQLException ) { int len = str.getLength(); bool doubleQuote = false; @@ -612,7 +604,7 @@ com::sun::star::uno::Sequence< Any > parseArray( const OUString & str ) throw( S int i = 0; OUStringBuffer current; - AnyVector elements; + std::vector<Any> elements; bool doubleQuotedValue = false; while( i < len ) { @@ -699,13 +691,13 @@ com::sun::star::uno::Sequence< Any > parseArray( const OUString & str ) throw( S } i++; } - return sequence_of_vector(elements); + return elements; } -com::sun::star::uno::Sequence< sal_Int32 > parseIntArray( const OUString & str ) +std::vector< sal_Int32 > parseIntArray( const OUString & str ) { sal_Int32 start = 0; - IntVector vec; + std::vector<sal_Int32> vec; // printf( ">%s<\n" , OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() ); for( sal_Int32 i = str.indexOf( ' ' ) ; i != -1 ; i = str.indexOf( ' ', start) ) { @@ -715,7 +707,7 @@ com::sun::star::uno::Sequence< sal_Int32 > parseIntArray( const OUString & str ) } vec.push_back( (sal_Int32)rtl_ustr_toInt32( &str.pData->buffer[start], 10 ) ); // printf( "found %d\n" , rtl_ustr_toInt32( &str.pData->buffer[start], 10 )); - return sequence_of_vector(vec); + return vec; } void fillAttnum2attnameMap( diff --git a/connectivity/source/drivers/postgresql/pq_tools.hxx b/connectivity/source/drivers/postgresql/pq_tools.hxx index f68612a171cd..670e92e5f409 100644 --- a/connectivity/source/drivers/postgresql/pq_tools.hxx +++ b/connectivity/source/drivers/postgresql/pq_tools.hxx @@ -47,6 +47,8 @@ #include <rtl/string.hxx> #include "pq_connection.hxx" +#include <vector> + namespace pq_sdbc_driver { bool isWhitespace( sal_Unicode c ); @@ -100,8 +102,8 @@ OString extractSingleTableFromSelect( const OStringVector &vec ); void tokenizeSQL( const OString & sql, OStringVector &vec ); void splitSQL( const OString & sql, OStringVector &vec ); -com::sun::star::uno::Sequence< sal_Int32 > parseIntArray( const OUString & str ); -com::sun::star::uno::Sequence< com::sun::star::uno::Any > parseArray( const OUString & str ) +std::vector< sal_Int32 > parseIntArray( const OUString & str ); +std::vector< com::sun::star::uno::Any > parseArray( const OUString & str ) throw( com::sun::star::sdbc::SQLException ); OUString array2String( const com::sun::star::uno::Sequence< com::sun::star::uno::Any > &seq ); @@ -164,14 +166,6 @@ public: void executeUpdate( const OUString & sql ); }; -template < typename T > com::sun::star::uno::Sequence<T> sequence_of_vector ( const std::vector<T> &vec ) -{ - if ( vec.empty() ) - return com::sun::star::uno::Sequence<T>(); - else - return com::sun::star::uno::Sequence<T>( &vec[0], vec.size()); -} - } #endif diff --git a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx index 33a192469bae..ab2b83b5064f 100644 --- a/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx +++ b/connectivity/source/drivers/postgresql/pq_updateableresultset.cxx @@ -90,24 +90,24 @@ com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > UpdateableRes PGresult *result, const OUString &schema, const OUString &table, - const com::sun::star::uno::Sequence< OUString > &primaryKey ) + const std::vector< OUString > &primaryKey ) { ConnectionSettings *pSettings = *ppSettings; sal_Int32 columnCount = PQnfields( result ); sal_Int32 rowCount = PQntuples( result ); - Sequence< OUString > columnNames( columnCount ); + std::vector< OUString > columnNames( columnCount ); for( int i = 0 ; i < columnCount ; i ++ ) { char * name = PQfname( result, i ); columnNames[i] = OUString( name, strlen(name), pSettings->encoding ); } - Sequence< Sequence< Any > > data( rowCount ); + std::vector< std::vector< Any > > data( rowCount ); // copy all the data into unicode strings (also binaries, as we yet // don't know, what a binary is and what not!) for( int row = 0 ; row < rowCount ; row ++ ) { - Sequence< Any > aRow( columnCount ); + std::vector< Any > aRow( columnCount ); for( int col = 0 ; col < columnCount ; col ++ ) { if( ! PQgetisnull( result, row, col ) ) @@ -122,7 +122,7 @@ com::sun::star::uno::Reference< com::sun::star::sdbc::XCloseable > UpdateableRes } UpdateableResultSet *pRS = new UpdateableResultSet( - mutex, owner, columnNames, data, ppSettings, schema, table , primaryKey ); + mutex, owner, columnNames, data, ppSettings, schema, table, primaryKey ); Reference <XCloseable > ret = pRS; // give it an refcount @@ -176,11 +176,11 @@ com::sun::star::uno::Sequence< sal_Int8> UpdateableResultSet::getImplementationI OUString UpdateableResultSet::buildWhereClause() { OUString ret; - if( m_primaryKey.getLength() ) + if( m_primaryKey.size() ) { OUStringBuffer buf( 128 ); buf.append( " WHERE " ); - for( int i = 0 ; i < m_primaryKey.getLength() ; i ++ ) + for( size_t i = 0 ; i < m_primaryKey.size() ; i ++ ) { if( i > 0 ) buf.append( " AND " ); @@ -251,8 +251,8 @@ void UpdateableResultSet::insertRow( ) throw (SQLException, RuntimeException, s // reflect the changes ! m_rowCount ++; - m_data.realloc( m_rowCount ); - m_data[m_rowCount-1] = Sequence< Any > ( m_fieldCount ); + m_data.resize( m_rowCount ); + m_data[m_rowCount-1] = std::vector< Any > ( m_fieldCount ); Reference< XGeneratedResultSet > result( stmt, UNO_QUERY ); if( result.is() ) { @@ -375,7 +375,7 @@ void UpdateableResultSet::deleteRow( ) throw (SQLException, RuntimeException, s m_data[i-1] = m_data[i]; } m_rowCount --; - m_data.realloc( m_rowCount ); + m_data.resize( m_rowCount ); } void UpdateableResultSet::cancelRowUpdates( ) throw (SQLException, RuntimeException, std::exception) diff --git a/connectivity/source/drivers/postgresql/pq_updateableresultset.hxx b/connectivity/source/drivers/postgresql/pq_updateableresultset.hxx index 325b3b4b4383..338952beace0 100644 --- a/connectivity/source/drivers/postgresql/pq_updateableresultset.hxx +++ b/connectivity/source/drivers/postgresql/pq_updateableresultset.hxx @@ -68,7 +68,7 @@ class UpdateableResultSet : ConnectionSettings **m_ppSettings; OUString m_schema; OUString m_table; - com::sun::star::uno::Sequence< OUString > m_primaryKey; + std::vector< OUString > m_primaryKey; UpdateableFieldVector m_updateableField; bool m_insertRow; @@ -76,12 +76,12 @@ protected: UpdateableResultSet( const ::rtl::Reference< RefCountedMutex > & mutex, const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner, - const com::sun::star::uno::Sequence< OUString > &colNames, - const com::sun::star::uno::Sequence< com::sun::star::uno::Sequence< com::sun::star::uno::Any > > &data, + const std::vector< OUString > &colNames, + const std::vector< std::vector< com::sun::star::uno::Any > > &data, ConnectionSettings **ppSettings, const OUString &schema, const OUString &table, - const com::sun::star::uno::Sequence< OUString > &primaryKey) + const std::vector< OUString > &primaryKey) : SequenceResultSet( mutex, owner, colNames, data, (*ppSettings)->tc ), m_ppSettings( ppSettings ), m_schema( schema ), @@ -121,7 +121,7 @@ public: PGresult *result, const OUString &schema, const OUString &table, - const com::sun::star::uno::Sequence< OUString > &primaryKey ); + const std::vector< OUString > &primaryKey ); public: // XInterface virtual void SAL_CALL acquire() throw() override { SequenceResultSet::acquire(); } diff --git a/connectivity/source/drivers/postgresql/pq_xbase.hxx b/connectivity/source/drivers/postgresql/pq_xbase.hxx index cd6f10452476..c30503ba0503 100644 --- a/connectivity/source/drivers/postgresql/pq_xbase.hxx +++ b/connectivity/source/drivers/postgresql/pq_xbase.hxx @@ -64,7 +64,7 @@ protected: ::com::sun::star::uno::Reference< com::sun::star::sdbc::XConnection > m_conn; ConnectionSettings *m_pSettings; cppu::IPropertyArrayHelper & m_propsDesc; - com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_values; + std::vector< com::sun::star::uno::Any > m_values; public: ReflectionBase( const OUString &implName, diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx index d5d61cae2e98..8d5f271be8f0 100644 --- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx @@ -62,7 +62,6 @@ using com::sun::star::uno::UNO_QUERY; using com::sun::star::uno::Type; using com::sun::star::uno::XInterface; using com::sun::star::uno::Reference; -using com::sun::star::uno::Sequence; using com::sun::star::uno::RuntimeException; using com::sun::star::container::NoSuchElementException; @@ -311,7 +310,7 @@ void Columns::refresh() String2IntMap map; - m_values = Sequence< com::sun::star::uno::Any > (); + m_values.clear(); int columnIndex = 0; while( rs->next() ) { @@ -331,11 +330,9 @@ void Columns::refresh() // name ) ); { - const int currentColumnIndex = columnIndex++; - assert(currentColumnIndex == m_values.getLength()); - m_values.realloc( columnIndex ); - m_values[currentColumnIndex] = makeAny( prop ); - map[ name ] = currentColumnIndex; + m_values.push_back( makeAny( prop ) ); + map[ name ] = columnIndex; + ++columnIndex; } } m_name2index.swap( map ); @@ -514,11 +511,11 @@ void Columns::dropByIndex( sal_Int32 index ) ::com::sun::star::uno::RuntimeException, std::exception) { osl::MutexGuard guard( m_refMutex->mutex ); - if( index < 0 || index >= m_values.getLength() ) + if( index < 0 || index >= (sal_Int32)m_values.size() ) { OUStringBuffer buf( 128 ); buf.append( "COLUMNS: Index out of range (allowed 0 to " ); - buf.append((sal_Int32)(m_values.getLength() -1) ); + buf.append((sal_Int32)(m_values.size() -1) ); buf.append( ", got " ); buf.append( index ); buf.append( ")" ); diff --git a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx index deaac7757182..5ec408919c96 100644 --- a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx @@ -172,14 +172,14 @@ Any Container::getByName( const OUString& aName ) buf.append( "-Container" ); throw NoSuchElementException( buf.makeStringAndClear() , *this ); } - OSL_ASSERT( ii->second >= 0 && ii->second < m_values.getLength() ); + OSL_ASSERT( ii->second >= 0 && ii->second < (int)m_values.size() ); return m_values[ ii->second ]; } Sequence< OUString > Container::getElementNames( ) throw (::com::sun::star::uno::RuntimeException, std::exception) { - Sequence< OUString > ret( m_values.getLength() ); + Sequence< OUString > ret( m_values.size() ); for( String2IntMap::const_iterator ii = m_name2index.begin(); ii != m_name2index.end() ; ++ ii ) @@ -214,7 +214,7 @@ Any Container::getByIndex( sal_Int32 Index ) ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) { - if( Index < 0 || Index >= m_values.getLength() ) + if( Index < 0 || Index >= (sal_Int32)m_values.size() ) { OUStringBuffer buf(128); buf.append( "Index " ); @@ -222,7 +222,7 @@ Any Container::getByIndex( sal_Int32 Index ) buf.append(" out of range for " ); buf.append( m_type ); buf.append("-Container, expected 0 <= x <= " ); - buf.append( (sal_Int32 ) (m_values.getLength() -1)); + buf.append( (sal_Int32 ) (m_values.size() -1)); throw IndexOutOfBoundsException( buf.makeStringAndClear(), *this ); } return m_values[Index]; @@ -231,16 +231,16 @@ Any Container::getByIndex( sal_Int32 Index ) sal_Int32 Container::getCount() throw (::com::sun::star::uno::RuntimeException, std::exception) { - return m_values.getLength(); + return m_values.size(); } class ContainerEnumeration : public ::cppu::WeakImplHelper< XEnumeration > { - com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_vec; + std::vector< com::sun::star::uno::Any > m_vec; sal_Int32 m_index; public: - explicit ContainerEnumeration( const com::sun::star::uno::Sequence< com::sun::star::uno::Any > &vec ) + explicit ContainerEnumeration( const std::vector< com::sun::star::uno::Any > &vec ) : m_vec( vec ), m_index( -1 ) {} @@ -259,7 +259,7 @@ public: sal_Bool ContainerEnumeration::hasMoreElements() throw (::com::sun::star::uno::RuntimeException, std::exception) { - return m_vec.getLength() > m_index +1; + return (int)m_vec.size() > m_index +1; } com::sun::star::uno::Any ContainerEnumeration::nextElement() @@ -350,11 +350,11 @@ void Container::dropByIndex( sal_Int32 index ) ::com::sun::star::uno::RuntimeException, std::exception) { osl::MutexGuard guard( m_refMutex->mutex ); - if( index < 0 || index >= m_values.getLength() ) + if( index < 0 || index >=(sal_Int32)m_values.size() ) { OUStringBuffer buf( 128 ); buf.append( "Index out of range (allowed 0 to " ); - buf.append((sal_Int32)(m_values.getLength() -1) ); + buf.append((sal_Int32)(m_values.size() -1) ); buf.append( ", got " ); buf.append( index ); buf.append( ") in " ); @@ -376,7 +376,7 @@ void Container::dropByIndex( sal_Int32 index ) } } - for( int i = index +1 ; i < m_values.getLength() ; i ++ ) + for( int i = index +1 ; i < (int)m_values.size() ; i ++ ) { m_values[i-1] = m_values[i]; @@ -392,7 +392,7 @@ void Container::dropByIndex( sal_Int32 index ) } } } - m_values.realloc( m_values.getLength() - 1 ); + m_values.resize( m_values.size() - 1 ); fire( RemovedBroadcaster( *this, name ) ); } @@ -417,9 +417,8 @@ void Container::append( buf.makeStringAndClear() , *this ); } - int index = m_values.getLength(); - m_values.realloc( m_values.getLength() + 1 ); - m_values[index] = makeAny( descriptor ); + int index = m_values.size(); + m_values.push_back( makeAny( descriptor ) ); m_name2index[name] = index; fire( InsertedBroadcaster( *this, name, makeAny( descriptor ) ) ); diff --git a/connectivity/source/drivers/postgresql/pq_xcontainer.hxx b/connectivity/source/drivers/postgresql/pq_xcontainer.hxx index 6155290d3300..852b206018fb 100644 --- a/connectivity/source/drivers/postgresql/pq_xcontainer.hxx +++ b/connectivity/source/drivers/postgresql/pq_xcontainer.hxx @@ -50,7 +50,6 @@ #include <cppuhelper/compbase.hxx> #include <unordered_map> -#include <vector> #include "pq_connection.hxx" #include "pq_statics.hxx" @@ -113,7 +112,7 @@ protected: ConnectionSettings *m_pSettings; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_origin; String2IntMap m_name2index; // maps the element name to an index - ::com::sun::star::uno::Sequence< com::sun::star::uno::Any > m_values; // contains the real values + std::vector< com::sun::star::uno::Any > m_values; // contains the real values OUString m_type; public: diff --git a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx index 8e8bdc56ce66..8e73c643f7d1 100644 --- a/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xindexcolumns.cxx @@ -131,7 +131,8 @@ void IndexColumns::refresh() DisposeGuard disposeIt( rs ); Reference< XRow > xRow( rs , UNO_QUERY ); - m_values = Sequence< Any >( m_columns.getLength() ); + m_values.clear(); + m_values.resize( m_columns.getLength() ); while( rs->next() ) { diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx index d22312e4fd2c..d35f079234b2 100644 --- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx +++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx @@ -137,7 +137,7 @@ void Indexes::refresh() Reference< XRow > row( rs, UNO_QUERY ); String2IntMap map; - m_values = Sequence< com::sun::star::uno::Any > (); + m_values.clear(); sal_Int32 index = 0; while( rs->next() ) { @@ -167,9 +167,9 @@ void Indexes::refresh() pIndex->setPropertyValue_NoBroadcast_public( st.NAME, makeAny( currentIndexName ) ); - Sequence< sal_Int32 > seq = parseIntArray( row->getString( C_COLUMNS ) ); - Sequence< OUString > columnNames(seq.getLength()); - for( int columns = 0 ; columns < seq.getLength() ; columns ++ ) + std::vector< sal_Int32 > seq = parseIntArray( row->getString( C_COLUMNS ) ); + Sequence< OUString > columnNames(seq.size()); + for( size_t columns = 0 ; columns < seq.size() ; columns ++ ) { columnNames[columns] = column2NameMap[ seq[columns] ]; } @@ -178,11 +178,9 @@ void Indexes::refresh() st.PRIVATE_COLUMN_INDEXES, makeAny( columnNames )); { - const int currentIndex = index++; - assert(currentIndex == m_values.getLength()); - m_values.realloc( index ); - m_values[currentIndex] = makeAny( prop ); - map[ currentIndexName ] = currentIndex; + m_values.push_back( makeAny( prop ) ); + map[ currentIndexName ] = index; + ++index; } } m_name2index.swap( map ); @@ -256,11 +254,11 @@ void Indexes::dropByIndex( sal_Int32 index ) osl::MutexGuard guard( m_refMutex->mutex ); - if( index < 0 || index >= m_values.getLength() ) + if( index < 0 || index >= (sal_Int32)m_values.size() ) { OUStringBuffer buf( 128 ); buf.append( "Indexes: Index out of range (allowed 0 to " ); - buf.append( (sal_Int32) (m_values.getLength() -1) ); + buf.append( (sal_Int32) (m_values.size() -1) ); buf.append( ", got " ); buf.append( index ); buf.append( ")" ); diff --git a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx index f22cc3e87cb2..2a5d2d963fd9 100644 --- a/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xkeycolumns.cxx @@ -124,7 +124,7 @@ void KeyColumns::refresh() String2IntMap map; - m_values = Sequence< com::sun::star::uno::Any > (); + m_values.clear(); sal_Int32 columnIndex = 0; while( rs->next() ) { @@ -151,11 +151,9 @@ void KeyColumns::refresh() } { - const int currentColumnIndex = columnIndex++; - assert(currentColumnIndex == m_values.getLength()); - m_values.realloc( columnIndex ); - m_values[currentColumnIndex] = makeAny( prop ); - map[ name ] = currentColumnIndex; + m_values.push_back( makeAny( prop ) ); + map[ name ] = columnIndex; + ++columnIndex; } } m_name2index.swap( map ); diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx index 7eff2aa8ab0a..9c84ae2f7aa0 100644 --- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx +++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx @@ -58,7 +58,6 @@ using com::sun::star::uno::UNO_QUERY; using com::sun::star::uno::Type; using com::sun::star::uno::XInterface; using com::sun::star::uno::Reference; -using com::sun::star::uno::Sequence; using com::sun::star::uno::RuntimeException; using com::sun::star::container::NoSuchElementException; @@ -155,7 +154,7 @@ void Keys::refresh() Reference< XRow > xRow( rs , UNO_QUERY ); String2IntMap map; - m_values = Sequence< com::sun::star::uno::Any > (); + m_values.clear(); int keyIndex = 0; while( rs->next() ) { @@ -197,11 +196,9 @@ void Keys::refresh() { - const int currentKeyIndex = keyIndex++; - map[ xRow->getString( 1 ) ] = currentKeyIndex; - assert(currentKeyIndex == m_values.getLength()); - m_values.realloc( keyIndex ); - m_values[currentKeyIndex] = makeAny( prop ); + map[ xRow->getString( 1 ) ] = keyIndex; + m_values.push_back( makeAny( prop ) ); + ++keyIndex; } } m_name2index.swap( map ); @@ -241,10 +238,10 @@ void Keys::dropByIndex( sal_Int32 index ) ::com::sun::star::uno::RuntimeException, std::exception) { osl::MutexGuard guard( m_refMutex->mutex ); - if( index < 0 || index >= m_values.getLength() ) + if( index < 0 || index >= (sal_Int32)m_values.size() ) { OUStringBuffer buf( 128 ); - buf.append( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.getLength() -1) + + buf.append( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) + ", got " + OUString::number( index ) + ")" ); throw com::sun::star::lang::IndexOutOfBoundsException( buf.makeStringAndClear(), *this ); diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx index fc75b13c707a..2fd8a98682aa 100644 --- a/connectivity/source/drivers/postgresql/pq_xtables.cxx +++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx @@ -107,7 +107,7 @@ void Tables::refresh() String2IntMap map; - m_values = Sequence< com::sun::star::uno::Any > (); + m_values.clear(); sal_Int32 tableIndex = 0; while( rs->next() ) { @@ -141,13 +141,11 @@ void Tables::refresh() com::sun::star::sdbcx::Privilege::DROP ) ) ); { - const int currentTableIndex = tableIndex++; - assert(currentTableIndex == m_values.getLength()); - m_values.realloc( tableIndex ); - m_values[currentTableIndex] = makeAny( prop ); + m_values.push_back( makeAny( prop ) ); OUStringBuffer buf( name.getLength() + schema.getLength() + 1); buf.append( schema + "." + name ); - map[ buf.makeStringAndClear() ] = currentTableIndex; + map[ buf.makeStringAndClear() ] = tableIndex; + ++tableIndex; } } m_name2index.swap( map ); @@ -329,10 +327,10 @@ void Tables::dropByIndex( sal_Int32 index ) ::com::sun::star::uno::RuntimeException, std::exception) { osl::MutexGuard guard( m_refMutex->mutex ); - if( index < 0 || index >= m_values.getLength() ) + if( index < 0 || index >= (sal_Int32)m_values.size() ) { OUStringBuffer buf( 128 ); - buf.append( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.getLength() -1) + + buf.append( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) + ", got " + OUString::number( index ) + ")" ); throw com::sun::star::lang::IndexOutOfBoundsException( buf.makeStringAndClear(), *this ); } diff --git a/connectivity/source/drivers/postgresql/pq_xusers.cxx b/connectivity/source/drivers/postgresql/pq_xusers.cxx index 6b8f2f517394..6169ce323be6 100644 --- a/connectivity/source/drivers/postgresql/pq_xusers.cxx +++ b/connectivity/source/drivers/postgresql/pq_xusers.cxx @@ -56,7 +56,6 @@ using com::sun::star::uno::UNO_QUERY; using com::sun::star::uno::Type; using com::sun::star::uno::XInterface; using com::sun::star::uno::Reference; -using com::sun::star::uno::Sequence; using com::sun::star::uno::RuntimeException; using com::sun::star::container::NoSuchElementException; @@ -98,7 +97,7 @@ void Users::refresh() String2IntMap map; - m_values = Sequence< com::sun::star::uno::Any > ( ); + m_values.clear(); sal_Int32 tableIndex = 0; while( rs->next() ) { @@ -111,11 +110,9 @@ void Users::refresh() st.NAME , makeAny(xRow->getString( TABLE_INDEX_CATALOG+1) ) ); { - const int currentTableIndex = tableIndex++; - assert(currentTableIndex == m_values.getLength()); - m_values.realloc( tableIndex ); - m_values[currentTableIndex] = makeAny( prop ); - map[ name ] = currentTableIndex; + m_values.push_back( makeAny( prop ) ); + map[ name ] = tableIndex; + ++tableIndex; } } m_name2index.swap( map ); @@ -173,11 +170,11 @@ void Users::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_refMutex->mutex ); - if( index < 0 || index >= m_values.getLength() ) + if( index < 0 || index >= (sal_Int32)m_values.size() ) { OUStringBuffer buf( 128 ); buf.append( "USERS: Index out of range (allowed 0 to " ); - buf.append( (sal_Int32) (m_values.getLength() -1) ); + buf.append( (sal_Int32) (m_values.size() -1) ); buf.append( ", got " ); buf.append( index ); buf.append( ")" ); diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx index db4cf6fbefaf..d656707b64af 100644 --- a/connectivity/source/drivers/postgresql/pq_xviews.cxx +++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx @@ -57,7 +57,6 @@ using com::sun::star::uno::UNO_QUERY; using com::sun::star::uno::Type; using com::sun::star::uno::XInterface; using com::sun::star::uno::Reference; -using com::sun::star::uno::Sequence; using com::sun::star::uno::RuntimeException; using com::sun::star::container::NoSuchElementException; @@ -107,7 +106,7 @@ void Views::refresh() Reference< XRow > xRow( rs , UNO_QUERY ); - m_values = Sequence< com::sun::star::uno::Any > (); + m_values.clear(); String2IntMap map; sal_Int32 viewIndex = 0; @@ -126,13 +125,11 @@ void Views::refresh() pView->setPropertyValue_NoBroadcast_public(st.COMMAND, makeAny(command) ); { - const int currentViewIndex = viewIndex++; - assert(currentViewIndex == m_values.getLength()); - m_values.realloc( viewIndex ); - m_values[currentViewIndex] = makeAny( prop ); + m_values.push_back( makeAny( prop ) ); OUStringBuffer buf( table.getLength() + schema.getLength() + 1); buf.append( schema + "." + table ); - map[ buf.makeStringAndClear() ] = currentViewIndex; + map[ buf.makeStringAndClear() ] = viewIndex; + ++viewIndex; } } m_name2index.swap( map ); @@ -199,10 +196,10 @@ void Views::dropByIndex( sal_Int32 index ) ::com::sun::star::uno::RuntimeException, std::exception) { osl::MutexGuard guard( m_refMutex->mutex ); - if( index < 0 || index >= m_values.getLength() ) + if( index < 0 || index >= (sal_Int32)m_values.size() ) { OUStringBuffer buf( 128 ); - buf.append( "VIEWS: Index out of range (allowed 0 to " + OUString::number(m_values.getLength() -1) + + buf.append( "VIEWS: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) + ", got " + OUString::number( index ) + ")"); throw com::sun::star::lang::IndexOutOfBoundsException( buf.makeStringAndClear(), *this ); |