Tag: cws_src680_sqlite
User: aklitzing
Date: 2006/08/19 11:23:32

Modified:
   dba/connectivity/source/drivers/sqlite3/sqConnection.cxx
   dba/connectivity/source/drivers/sqlite3/sqDatabaseMetaData.cxx
   dba/connectivity/source/drivers/sqlite3/sqDB.cpp
   dba/connectivity/source/drivers/sqlite3/sqDB.h
   dba/connectivity/source/drivers/sqlite3/sqPreparedStatement.cxx
   dba/connectivity/source/drivers/sqlite3/sqQueryPrepared.cpp
   dba/connectivity/source/drivers/sqlite3/sqQueryPrepared.h
   dba/connectivity/source/drivers/sqlite3/sqResultSet.cxx
   dba/connectivity/source/drivers/sqlite3/sqResultSetMetaData.cxx
   dba/connectivity/source/drivers/sqlite3/sqStatement.cxx

Log:
 * UTF16 improved
 * API of sqlite3_bind implemented
 * PreparedStatements added
 * Some fixes

File Changes:

Directory: /dba/connectivity/source/drivers/sqlite3/
====================================================

File [changed]: sqConnection.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqConnection.cxx?r1=1.1.2.2&r2=1.1.2.3
Delta lines:  +4 -3
-------------------
--- sqConnection.cxx    18 Aug 2006 18:57:29 -0000      1.1.2.2
+++ sqConnection.cxx    19 Aug 2006 18:23:28 -0000      1.1.2.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqConnection.cxx,v $
  *
- *  $Revision: 1.1.2.2 $
+ *  $Revision: 1.1.2.3 $
  *
- *  last change: $Author: aklitzing $ $Date: 2006/08/18 18:57:29 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:28 $
  *
  *  Original contributor: André Klitzing
  *
@@ -102,11 +102,12 @@
        nLen = url.indexOf(':',nLen+1);
        OUString filename = url.copy(nLen+1);
 
+       //! \todo UTF16 is needed here later
        if(m_dataBase->openDatabase(::rtl::OUStringToOString(filename, 
RTL_TEXTENCODING_UTF8).getStr()) != SQLITE_OK)
        {
                osl_decrementInterlockedCount( &m_refCount );
        throw SQLException(OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to open 
database")), *this,
-               OUString::createFromAscii(m_dataBase->getLastErrorMsg()), 
m_dataBase->getLastErrorNo(), Any());
+                               m_dataBase->getLastErrorMsgUTF16(), 
m_dataBase->getLastErrorNo(), Any());
        }
 
        osl_decrementInterlockedCount( &m_refCount );

File [changed]: sqDatabaseMetaData.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqDatabaseMetaData.cxx?r1=1.1.2.5&r2=1.1.2.6
Delta lines:  +11 -12
---------------------
--- sqDatabaseMetaData.cxx      19 Aug 2006 01:42:45 -0000      1.1.2.5
+++ sqDatabaseMetaData.cxx      19 Aug 2006 18:23:28 -0000      1.1.2.6
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqDatabaseMetaData.cxx,v $
  *
- *  $Revision: 1.1.2.5 $
+ *  $Revision: 1.1.2.6 $
  *
- *  last change: $Author: aklitzing $ $Date: 2006/08/19 01:42:45 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:28 $
  *
  *  Original contributor: André Klitzing
  *
@@ -912,10 +912,10 @@
 // But it isn't possible to use SQLite-Types at this point
 // because we don't have any data in this result. Only Table-Structur!
 // SQLite has types on CELLS - not on Columns!
-long getColumns_ColType(const wchar_t* typeAsString)
+long getColumns_ColType(const sal_Unicode* typeAsString)
 {
        using ::rtl::OUString;
-       OUString str = OUString((const sal_Unicode*) 
typeAsString).toAsciiLowerCase();
+       OUString str = OUString(typeAsString).toAsciiLowerCase();
 
        if(str.indexOf(OUString::createFromAscii("int"), 0) != -1 || 
str.indexOf(OUString::createFromAscii("numeric"), 0) != -1)
                return com::sun::star::sdbc::DataType::INTEGER;
@@ -955,12 +955,12 @@
                [5] = flag: is this column part of the table's PRIMARY KEY?
                */
                sqQueryPrepared* query = db->getQuery("pragma table_info(%q)", 
mTableName);
-               // TODO - attached databases (schema) needs "pragma 
schema.table_info(%q)" - will be added with sqlite3_BINDs
+               // TODO - attached databases (schema) needs "pragma 
schema.table_info(%q)"
                checkError(query, 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unable to get column 
information")));
 
                for(query->execute(); !query->isDone(); query->nextRow())
                {
-                       const sal_Unicode* tmp = (const sal_Unicode*) 
query->getTextUTF16(1); // to avoid stack-usage
+                       const sal_Unicode* tmp = query->getTextUTF16(1); // to 
avoid stack-usage
                        if(!columnNamePattern.equalsAscii("%") && (tmp == 0 || 
!columnNamePattern.equals(tmp)))
                                continue;
 
@@ -986,7 +986,7 @@
                        aRow.push_back(new 
ORowSetValueDecorator(::rtl::OUString::valueOf( 
getColumns_ColType(query->getTextUTF16(2)) )));
 
                        // TYPE_NAME
-                       tmp = (const sal_Unicode*) query->getTextUTF16(2);
+                       tmp = query->getTextUTF16(2);
                        if (tmp == 0)
                                
aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
                        else
@@ -1006,7 +1006,7 @@
                        aRow.push_back(new ORowSetValueDecorator());
 
                        // COLUMN_DEF
-                       tmp = (const sal_Unicode*) query->getTextUTF16(4);
+                       tmp = query->getTextUTF16(4);
                        if (query->isNull(4))
                                aRow.push_back(new ORowSetValueDecorator());
                        else
@@ -1069,7 +1069,7 @@
 
        for (query->execute(); !query->isDone(); query->nextRow())
        {
-           ::rtl::OUString tableName((const sal_Unicode*) 
query->getTextUTF16(0));
+           ::rtl::OUString tableName(query->getTextUTF16(0));
 
            ODatabaseMetaDataResultSet::ORow aRow(3);
            aRow.push_back(new ORowSetValueDecorator(tableName));
@@ -1157,7 +1157,7 @@
                        // TABLE_NAME
                        aRow.push_back(new ORowSetValueDecorator(table));
                        // COLUMN_NAME
-                       aRow.push_back(new 
ORowSetValueDecorator(::rtl::OUString((const sal_Unicode*) 
query->getTextUTF16(1))));
+                       aRow.push_back(new 
ORowSetValueDecorator(::rtl::OUString(query->getTextUTF16(1))));
                        // KEY_SEQ
                        aRow.push_back(new 
ORowSetValueDecorator(::rtl::OUString::valueOf(key_seq++)));
                        // PK_NAME
@@ -1227,8 +1227,7 @@
        if (query->getReturnNo() != SQLITE_OK)
        {
                sqDB* parent = query->getParentDB();
-           ::rtl::OUString msg((const sal_Unicode*) 
parent->getLastErrorMsgUTF16());
            parent->free(query);
-       throw SQLException(error, *this, msg, parent->getLastErrorNo(), Any());
+       throw SQLException(error, *this, parent->getLastErrorMsgUTF16(), 
parent->getLastErrorNo(), Any());
        }
 }

File [changed]: sqDB.cpp
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqDB.cpp?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +12 -4
--------------------
--- sqDB.cpp    19 Aug 2006 01:42:45 -0000      1.1.2.3
+++ sqDB.cpp    19 Aug 2006 18:23:28 -0000      1.1.2.4
@@ -4,9 +4,9 @@
  *

  *  $RCSfile: sqDB.cpp,v $

  *

- *  $Revision: 1.1.2.3 $

+ *  $Revision: 1.1.2.4 $

  *

- *  last change: $Author: aklitzing $ $Date: 2006/08/19 01:42:45 $

+ *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:28 $

  *

  *  Original contributor: André Klitzing

  *

@@ -74,6 +74,14 @@
        */

 }

 

+int sqDB::openDatabaseUTF16(const utf16* filename)

+{

+       // todo.. wie oben

+       return sqlite3_open16((const void*) filename, &m_db);

+}

+

+

+

 /*

 // TODO... Zusammenhang ist oben

 bool sqDB::isOpenDatabase() const

@@ -102,9 +110,9 @@
        return sqlite3_errmsg(m_db);

 }

 

-const wchar_t* sqDB::getLastErrorMsgUTF16() const

+const utf16* sqDB::getLastErrorMsgUTF16() const

 {

-       return (const wchar_t*) sqlite3_errmsg16(m_db); // sqlite returns 
(const void*)

+       return (const utf16*) sqlite3_errmsg16(m_db); // sqlite returns (const 
void*)

 }

 

 int sqDB::getLastErrorNo() const


File [changed]: sqDB.h
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqDB.h?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +16 -5
--------------------
--- sqDB.h      19 Aug 2006 01:42:45 -0000      1.1.2.3
+++ sqDB.h      19 Aug 2006 18:23:28 -0000      1.1.2.4
@@ -4,9 +4,9 @@
  *

  *  $RCSfile: sqDB.h,v $

  *

- *  $Revision: 1.1.2.3 $

+ *  $Revision: 1.1.2.4 $

  *

- *  last change: $Author: aklitzing $ $Date: 2006/08/19 01:42:45 $

+ *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:28 $

  *

  *  Original contributor: André Klitzing

  *

@@ -43,6 +43,8 @@
 #include "sqQueryTable.h"

 // #include "sqQueryPrepared.h" // you don't need it - sqQueryPreparedCursor 
has it

 

+typedef unsigned short utf16;

+

 //! An 'Interface object' to a sqlite3 database file

 /*!

        Required:

@@ -77,6 +79,7 @@
        SQLITE_MISUSE      21   // Library used incorrectly

        SQLITE_NOLFS       22   // Uses OS features not supported on host

        SQLITE_AUTH        23   // Authorization denied

+       SQLITE_RANGE       25   // 2nd parameter to sqlite3_bind_* out of range

        SQLITE_ROW         100  // sqlite_step() has another row ready

        SQLITE_DONE        101  // sqlite_step() has finished executing

 */

@@ -84,7 +87,9 @@
 {

 private:

                //! queryList keeps ALL querys of the current database 
connection

-               //! if an user forget to free() the result table - this will 
avoid memory leaks!

+               /*!

+                       If an user forget to free() the result table - this 
will avoid memory leaks and problems with non-finalized statements!

+               */

                class queryList

                {

                        private:

@@ -135,6 +140,12 @@
        //! \return result-code of sqlite - SQLITE_OK if the database is opened 
correctly

        int openDatabase(const char* filename);

 

+       //! \fn int openDatabaseUTF16(const utf16* filename)

+       //! \brief opens a new database-connection to the given filename

+       //! \param filename path+filename to the sqlite3 database file as a 
utf16 widechar

+       //! \return result-code of sqlite - SQLITE_OK if the database is opened 
correctly

+       int openDatabaseUTF16(const utf16* filename);

+

        //! \fn bool isOpenDatabase() const

        //! \brief check if a database file is opened

        //! \return true if open, otherwise false

@@ -160,10 +171,10 @@
        //! \return a read-only null-terminated char-array or "not an error" if 
the last API call was successful

        const char* getLastErrorMsg() const;

 

-       //! \fn const wchar_t* getLastErrorMsgUTF16() const

+       //! \fn const utf16* getLastErrorMsgUTF16() const

        //! \brief returns a human-readable message of the last error

        //! \return a read-only null-terminated widechar-array or "not an 
error" if the last API call was successful

-       const wchar_t* getLastErrorMsgUTF16() const;

+       const utf16* getLastErrorMsgUTF16() const;

 

        //! \fn int getLastErrorNo() const

        //! \brief returns the error-number of the last error


File [changed]: sqPreparedStatement.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqPreparedStatement.cxx?r1=1.1.2.2&r2=1.1.2.3
Delta lines:  +22 -10
---------------------
--- sqPreparedStatement.cxx     18 Aug 2006 19:00:00 -0000      1.1.2.2
+++ sqPreparedStatement.cxx     19 Aug 2006 18:23:29 -0000      1.1.2.3
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqPreparedStatement.cxx,v $
  *
- *  $Revision: 1.1.2.2 $
+ *  $Revision: 1.1.2.3 $
  *
- *  last change: $Author: aklitzing $ $Date: 2006/08/18 19:00:00 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:29 $
  *
  *  Original contributor: André Klitzing
  *
@@ -157,13 +157,6 @@
 }
 // -------------------------------------------------------------------------
 
-void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const 
::rtl::OUString& x ) throw(SQLException, RuntimeException)
-{
-       ::osl::MutexGuard aGuard( m_aMutex );
-       checkDisposed(OStatement_BASE::rBHelper.bDisposed);
-}
-// -------------------------------------------------------------------------
-
 Reference< XConnection > SAL_CALL OPreparedStatement::getConnection(  ) 
throw(SQLException, RuntimeException)
 {
        ::osl::MutexGuard aGuard( m_aMutex );
@@ -185,6 +178,15 @@
 }
 // -------------------------------------------------------------------------
 
+void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const 
::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+       ::osl::MutexGuard aGuard( m_aMutex );
+       checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+       m_pQuery->setTextUTF16(parameterIndex, x.getStr(), 
x.getLength()*sizeof(sal_Unicode)); // just a work-around
+}
+// -------------------------------------------------------------------------
+
 void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, 
sal_Bool x ) throw(SQLException, RuntimeException)
 {
        ::osl::MutexGuard aGuard( m_aMutex );
@@ -231,6 +233,7 @@
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(OStatement_BASE::rBHelper.bDisposed);
 
+       m_pQuery->setDouble(parameterIndex, x);
 }
 
 // -------------------------------------------------------------------------
@@ -240,6 +243,7 @@
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(OStatement_BASE::rBHelper.bDisposed);
 
+       m_pQuery->setDouble(parameterIndex, x);
 }
 // -------------------------------------------------------------------------
 
@@ -248,14 +252,16 @@
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(OStatement_BASE::rBHelper.bDisposed);
 
+       m_pQuery->setInteger(parameterIndex, x);
 }
 // -------------------------------------------------------------------------
 
-void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 
aVal ) throw(SQLException, RuntimeException)
+void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 
x ) throw(SQLException, RuntimeException)
 {
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(OStatement_BASE::rBHelper.bDisposed);
 
+       m_pQuery->setInteger64(parameterIndex, x);
 }
 // -------------------------------------------------------------------------
 
@@ -264,6 +270,7 @@
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(OStatement_BASE::rBHelper.bDisposed);
 
+       m_pQuery->setNull(parameterIndex);
 }
 // -------------------------------------------------------------------------
 
@@ -328,6 +335,7 @@
        ::osl::MutexGuard aGuard( m_aMutex );
        checkDisposed(OStatement_BASE::rBHelper.bDisposed);
 
+       m_pQuery->setInteger(parameterIndex, x);
 }
 // -------------------------------------------------------------------------
 
@@ -358,6 +366,10 @@
 
 void SAL_CALL OPreparedStatement::clearParameters(  ) throw(SQLException, 
RuntimeException)
 {
+       m_pQuery->reset();
+       int params = m_pQuery->getParamCount();
+       for(int i=1; i < params; ++i) // SQLite starts with 1, not 0
+               m_pQuery->setNull(i); // unbound parameters are interpreted as 
NULL in SQLite
 }
 // -------------------------------------------------------------------------
 void SAL_CALL OPreparedStatement::clearBatch(  ) throw(SQLException, 
RuntimeException)

File [changed]: sqQueryPrepared.cpp
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqQueryPrepared.cpp?r1=1.1.2.4&r2=1.1.2.5
Delta lines:  +63 -14
---------------------
--- sqQueryPrepared.cpp 19 Aug 2006 01:42:45 -0000      1.1.2.4
+++ sqQueryPrepared.cpp 19 Aug 2006 18:23:29 -0000      1.1.2.5
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqQueryPrepared.cpp,v $
  *
- *  $Revision: 1.1.2.4 $
+ *  $Revision: 1.1.2.5 $
  *
- *  last change: $Author: aklitzing $ $Date: 2006/08/19 01:42:45 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:29 $
  *
  *  Original contributor: André Klitzing
  *
@@ -176,9 +176,9 @@
        return sqlite3_column_name(m_stmt, column);
 }
 
-const wchar_t* sqQueryPrepared::getNameUTF16(int column) const
+const utf16* sqQueryPrepared::getNameUTF16(int column) const
 {
-       return (const wchar_t*) sqlite3_column_name16(m_stmt, column); // 
sqlite3 returns (const void*)
+       return (const utf16*) sqlite3_column_name16(m_stmt, column); // sqlite3 
returns (const void*)
 }
 
 const char* sqQueryPrepared::getOriginName(int column) const
@@ -186,9 +186,9 @@
        return sqlite3_column_origin_name(m_stmt, column);
 }
 
-const wchar_t* sqQueryPrepared::getOriginNameUTF16(int column) const
+const utf16* sqQueryPrepared::getOriginNameUTF16(int column) const
 {
-       return (const wchar_t*) sqlite3_column_origin_name16(m_stmt, column); 
// sqlite3 returns (const void*)
+       return (const utf16*) sqlite3_column_origin_name16(m_stmt, column); // 
sqlite3 returns (const void*)
 }
 
 // needs >= sqlite 3.3.0
@@ -197,9 +197,9 @@
        return sqlite3_column_table_name(m_stmt, column);
 }
 
-const wchar_t* sqQueryPrepared::getTableNameUTF16(int column) const
+const utf16* sqQueryPrepared::getTableNameUTF16(int column) const
 {
-       return (const wchar_t*) sqlite3_column_table_name16(m_stmt, column); // 
sqlite3 returns (const void*)
+       return (const utf16*) sqlite3_column_table_name16(m_stmt, column); // 
sqlite3 returns (const void*)
 }
 
 const char* sqQueryPrepared::getDatabaseName(int column) const
@@ -207,9 +207,9 @@
        return sqlite3_column_database_name(m_stmt, column);
 }
 
-const wchar_t* sqQueryPrepared::getDatabaseNameUTF16(int column) const
+const utf16* sqQueryPrepared::getDatabaseNameUTF16(int column) const
 {
-       return (const wchar_t*) sqlite3_column_database_name16(m_stmt, column); 
// sqlite3 returns (const void*)
+       return (const utf16*) sqlite3_column_database_name16(m_stmt, column); 
// sqlite3 returns (const void*)
 }
 
 int sqQueryPrepared::getType(int column) const
@@ -222,9 +222,9 @@
        return sqlite3_column_decltype(m_stmt, column);
 }
 
-const wchar_t* sqQueryPrepared::getTypeTextUTF16(int column) const
+const utf16* sqQueryPrepared::getTypeTextUTF16(int column) const
 {
-       return (const wchar_t*) sqlite3_column_decltype16(m_stmt, column); // 
sqlite3 returns (const void*)
+       return (const utf16*) sqlite3_column_decltype16(m_stmt, column); // 
sqlite3 returns (const void*)
 }
 
 int sqQueryPrepared::getColumnMetadata(int column,
@@ -242,9 +242,9 @@
        return (const char*) sqlite3_column_text(m_stmt, column); // sqlite3 
returns (const unsigned char*)
 }
 
-const wchar_t* sqQueryPrepared::getTextUTF16(int column) const
+const utf16* sqQueryPrepared::getTextUTF16(int column) const
 {
-       return (const wchar_t*) sqlite3_column_text16(m_stmt, column); // 
sqlite3 returns (const void*)
+       return (const utf16*) sqlite3_column_text16(m_stmt, column); // sqlite3 
returns (const void*)
 }
 
 int sqQueryPrepared::getInteger(int column) const
@@ -265,4 +265,53 @@
 bool sqQueryPrepared::isNull(int column) const
 {
        return getType(column) == SQLITE_NULL ? true : false;
+}
+
+
+// ----------------------------------- BIND-Functions
+
+int sqQueryPrepared::getParamCount() const
+{
+       return sqlite3_bind_parameter_count(m_stmt);
+}
+
+const char* sqQueryPrepared::getParamName(int index) const
+{
+       return sqlite3_bind_parameter_name(m_stmt, index);
+}
+
+int sqQueryPrepared::getParamIndex(const char* name) const
+{
+       return sqlite3_bind_parameter_index(m_stmt, name);
+}
+
+
+int sqQueryPrepared::setText(int index, const char* value, int byteSize, 
void(*DTor)(void*))
+{
+       return sqlite3_bind_text(m_stmt, index, value, byteSize, DTor);
+}
+
+int sqQueryPrepared::setTextUTF16(int index, const utf16* value, int byteSize, 
void(*DTor)(void*))
+{
+       return sqlite3_bind_text16(m_stmt, index, (const void*) value, 
byteSize, DTor); // sqlite3 uses UTF16 as (const void*)
+}
+
+int sqQueryPrepared::setInteger(int index, int value)
+{
+       return sqlite3_bind_int(m_stmt, index, value);
+}
+
+int sqQueryPrepared::setInteger64(int index, long long int value)
+{
+       return sqlite3_bind_int64(m_stmt, index, value);
+}
+
+int sqQueryPrepared::setDouble(int index, double value)
+{
+       return sqlite3_bind_double(m_stmt, index, value);
+}
+
+int sqQueryPrepared::setNull(int index)
+{
+       return sqlite3_bind_null(m_stmt, index);
 }

File [changed]: sqQueryPrepared.h
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqQueryPrepared.h?r1=1.1.2.4&r2=1.1.2.5
Delta lines:  +83 -14
---------------------
--- sqQueryPrepared.h   19 Aug 2006 01:48:04 -0000      1.1.2.4
+++ sqQueryPrepared.h   19 Aug 2006 18:23:29 -0000      1.1.2.5
@@ -4,9 +4,9 @@
  *

  *  $RCSfile: sqQueryPrepared.h,v $

  *

- *  $Revision: 1.1.2.4 $

+ *  $Revision: 1.1.2.5 $

  *

- *  last change: $Author: aklitzing $ $Date: 2006/08/19 01:48:04 $

+ *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:29 $

  *

  *  Original contributor: André Klitzing

  *

@@ -39,6 +39,9 @@
 #define __SQLITE3s_SQQUERYPREPARED_H

 

 #include "sqQuery.h"

+

+typedef unsigned short utf16;

+

 class sqDB; // do not include sqDB.h - your compiler won't like recursive 
includes even with include-flags ;-)

 

 //! A 'QueryPrepared object' - sqDB will return it with every getQuery()

@@ -171,11 +174,11 @@
        //! \param column index of the column; first is 0 and second is 1...

        const char* getName(int column) const;

 

-       //! \fn const wchar_t* getNameUTF16(int column) const

+       //! \fn const utf16* getNameUTF16(int column) const

        //! \brief returns the name of given column (the name from AS in 
SELECT-statement)

        //! \return a read-only null-terminated widechar-array, or NULL if 
there is no column with given index

        //! \param column index of the column; first is 0 and second is 1...

-       const wchar_t* getNameUTF16(int column) const;

+       const utf16* getNameUTF16(int column) const;

 

        //! \fn const char* getOriginName(int column) const

        //! \brief returns the original name of given column (not the AS-name 
from SELECT-statement)

@@ -183,11 +186,11 @@
        //! \param column index of the column; first is 0 and second is 1...

        const char* getOriginName(int column) const;

 

-       //! \fn const wchar_t* getOriginNameUTF16(int column) const

+       //! \fn const utf16* getOriginNameUTF16(int column) const

        //! \brief returns the original name of given column (not the AS-name 
from SELECT-statement)

        //! \return a read-only null-terminated widechar-array, or NULL if 
there is no column with given index

        //! \param column index of the column; first is 0 and second is 1...

-       const wchar_t* getOriginNameUTF16(int column) const;

+       const utf16* getOriginNameUTF16(int column) const;

 

        //! \fn const char* getTableName(int column) const

        //! \brief returns the name of the table of given column (more useful 
with JOINs)

@@ -195,11 +198,11 @@
        //! \param column index of the column; first is 0 and second is 1...

        const char* getTableName(int column) const;

 

-       //! \fn const wchar_t* getTableNameUTF16(int column) const

+       //! \fn const utf16* getTableNameUTF16(int column) const

        //! \brief returns the name of the table of given column (more useful 
with JOINs)

        //! \return a read-only null-terminated widechar-array, or NULL if 
there is no column with given index

        //! \param column index of the column; first is 0 and second is 1...

-       const wchar_t* getTableNameUTF16(int column) const;

+       const utf16* getTableNameUTF16(int column) const;

 

        //! \fn const char* getDatabaseName(int column) const

        //! \brief returns the database-name of given column (more useful with 
JOINs and attached database-files; default: 'main')

@@ -207,11 +210,11 @@
        //! \param column index of the column; first is 0 and second is 1...

        const char* getDatabaseName(int column) const;

 

-       //! \fn const wchar_t* getDatabaseNameUTF16(int column) const

+       //! \fn const utf16* getDatabaseNameUTF16(int column) const

        //! \brief returns the database-name of given column (more useful with 
JOINs and attached database-files; default: 'main')

        //! \return a read-only null-terminated widechar-array, or NULL if 
there is no column with given index

        //! \param column index of the column; first is 0 and second is 1...

-       const wchar_t* getDatabaseNameUTF16(int column) const;

+       const utf16* getDatabaseNameUTF16(int column) const;

 

        //! \fn int getType(int column) const

        //! \brief returns the type of the given column

@@ -233,11 +236,11 @@
        //! \return a read-only null-terminated char-array, or NULL if there is 
no column with given index

        const char* getTypeText(int column) const;

 

-       //! \fn const wchar_t* getTypeTextUTF16(int column) const

+       //! \fn const utf16* getTypeTextUTF16(int column) const

        //! \brief returns the type as a text. It will be taken CREATE TABLE 
statement. (e.g. varchar(255))

        //! \param column index of the column; first is 0 and second is 1...

        //! \return a read-only null-terminated widechar-array, or NULL if 
there is no column with given index

-       const wchar_t* getTypeTextUTF16(int column) const;

+       const utf16* getTypeTextUTF16(int column) const;

 

        //! \fn int getColumnMetadata(int column, char const** out_DataType, 
char const** out_CollSeq, int* out_isNotNull, int* out_isPK, int* 
out_isAutoInc) const

        //! \brief this is just a wrapper to sqDB::getColumnMetadata()

@@ -266,11 +269,11 @@
        //! \return a read-only null-terminated char-array, or NULL if there is 
no column with given index

        const char* getText(int column) const;

 

-       //! \fn const wchar_t* getTextUTF16(int column) const

+       //! \fn const utf16* getTextUTF16(int column) const

        //! \brief returns the content of that cell as text (encoding UTF16)

        //! \param column index of the column; first is 0 and second is 1...

        //! \return a read-only null-terminated widechar-array, or NULL if 
there is no column with given index

-       const wchar_t* getTextUTF16(int column) const;

+       const utf16* getTextUTF16(int column) const;

 

        //! \fn int getInteger(int column) const

        //! \brief returns the content of that cell as integer - maybe 0 if 
sqlite can't cast it. Double values will be truncated

@@ -295,6 +298,72 @@
        //! \param column index of the column; first is 0 and second is 1...

        //! \return true if it is NULL, otherwise false

        bool isNull(int column) const;

+

+

+

+// BIND-Functions

+

+       //! \fn int getParamCount() const

+       //! \brief returns the number of paramters in the prepared query (?, 
:name; @name)

+       //! \return integer

+       int getParamCount() const;

+

+       //! \fn const char* getParamName(int index) const

+       //! \brief returns the name of the parameter of given index

+       //! \param index index of parameter; first is 1

+       //! \return a read-only null-terminated char-array, or NULL if there is 
no parameter with given index or the parameter is nameless -> ?

+       const char* getParamName(int index) const;

+

+       //! \fn int getParamIndex(const char* name) const

+       //! \brief returns the index of the given parameter name

+       //! \param name name the parameter

+       //! \return integer, first is 1. If there is no parameter with given 
name it will return 0

+       int getParamIndex(const char* name) const;

+

+       //! \fn int setText(int index, const char* value, int byteSize = -1, 
void(*DTor)(void*) = SQLITE_TRANSIENT)

+       //! \brief bind a char-text to the given parameter

+       //! \param index number of the parameter, first is 1

+       //! \param value the text that you want to bind

+       //! \param byteSize the size of your value in BYTES (not char-length), 
default is -1 so SQLite reads to the next NULL-termination

+       //! \param DTor you can SQLite a destructor that will be called if 
SQLite is finished, default is that the string will be copied

+       //! \return result-code of sqlite3

+       int setText(int index, const char* value, int byteSize = -1, 
void(*DTor)(void*) = SQLITE_TRANSIENT);

+

+       //! \fn int setTextUTF16(int index, const utf16* value, int byteSize = 
-1, void(*DTor)(void*) = SQLITE_TRANSIENT)

+       //! \brief bind a widechar-text to the given parameter

+       //! \param index number of the parameter, first is 1

+       //! \param value the utf16-text that you want to bind

+       //! \param byteSize the size of your value in BYTES (not char-length), 
default is -1 so SQLite reads to the next NULL-termination

+       //! \param DTor you can SQLite a destructor that will be called if 
SQLite is finished, default is that the string will be copied

+       //! \return result-code of sqlite3

+       int setTextUTF16(int index, const utf16* value, int byteSize = -1, 
void(*DTor)(void*) = SQLITE_TRANSIENT);

+

+       //! \fn int setInteger(int index, int value)

+       //! \brief bind an integer to the given parameter

+       //! \param index number of the parameter, first is 1

+       //! \param value the integer that you want to bind

+       //! \return result-code of sqlite3

+       int setInteger(int index, int value);

+

+       //! \fn int setInteger64(int index, long long int value)

+       //! \brief bind a 64bit integer to the given parameter

+       //! \param index number of the parameter, first is 1

+       //! \param value the 64bit integer that you want to bind

+       //! \return result-code of sqlite3

+       int setInteger64(int index, long long int value);

+

+       //! \fn int setDouble(int index, double value)

+       //! \brief bind a double to the given parameter

+       //! \param index number of the parameter, first is 1

+       //! \param value the double that you want to bind

+       //! \return result-code of sqlite3

+       int setDouble(int index, double value);

+

+       //! \fn int setNull(int index)

+       //! \brief set the given parameter to NULL. Unbound parameters are 
interpreted as NULL

+       //! \param index number of the parameter, first is 1

+       //! \return result-code of sqlite3

+       int setNull(int index);

 };

 

 #endif //__SQLITE3s_SQQUERYPREPARED_H


File [changed]: sqResultSet.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqResultSet.cxx?r1=1.1.2.4&r2=1.1.2.5
Delta lines:  +5 -5
-------------------
--- sqResultSet.cxx     19 Aug 2006 01:42:46 -0000      1.1.2.4
+++ sqResultSet.cxx     19 Aug 2006 18:23:29 -0000      1.1.2.5
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqResultSet.cxx,v $
  *
- *  $Revision: 1.1.2.4 $
+ *  $Revision: 1.1.2.5 $
  *
- *  last change: $Author: aklitzing $ $Date: 2006/08/19 01:42:46 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:29 $
  *
  *  Original contributor: André Klitzing
  *
@@ -346,7 +346,7 @@
        checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
 
        setWasNull(columnIndex);
-       return ::rtl::OUString((const sal_Unicode*) 
m_pQuery->getTextUTF16(columnIndex-1));
+       return m_pQuery->getTextUTF16(columnIndex-1);
 }
 // -------------------------------------------------------------------------
 
@@ -526,8 +526,8 @@
        else
        {
                sqDB* parent = m_pQuery->getParentDB();
-               ::rtl::OUString msg((const sal_Unicode*) 
parent->getLastErrorMsgUTF16());
-               throw 
SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("An unkown error 
occured")), *this, msg, parent->getLastErrorNo(), Any());
+               throw 
SQLException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("An unkown error 
occured")),
+                               *this, parent->getLastErrorMsgUTF16(), 
parent->getLastErrorNo(), Any());
        }
 }
 // -------------------------------------------------------------------------

File [changed]: sqResultSetMetaData.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqResultSetMetaData.cxx?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +7 -7
-------------------
--- sqResultSetMetaData.cxx     19 Aug 2006 01:42:46 -0000      1.1.2.3
+++ sqResultSetMetaData.cxx     19 Aug 2006 18:23:29 -0000      1.1.2.4
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqResultSetMetaData.cxx,v $
  *
- *  $Revision: 1.1.2.3 $
+ *  $Revision: 1.1.2.4 $
  *
- *  last change: $Author: aklitzing $ $Date: 2006/08/19 01:42:46 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:29 $
  *
  *  Original contributor: André Klitzing
  *
@@ -86,18 +86,18 @@
 
 ::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 column ) 
throw(SQLException, RuntimeException)
 {
-       return ::rtl::OUString((const sal_Unicode*) 
m_pQuery->getDatabaseNameUTF16(column-1));
+       return m_pQuery->getDatabaseNameUTF16(column-1);
 }
 // -------------------------------------------------------------------------
 
 ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) 
throw(SQLException, RuntimeException)
 {
-       return ::rtl::OUString((const sal_Unicode*) 
m_pQuery->getOriginNameUTF16(column-1));
+       return m_pQuery->getOriginNameUTF16(column-1);
 }
 // -------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) 
throw(SQLException, RuntimeException)
 {
-       return ::rtl::OUString((const sal_Unicode*) 
m_pQuery->getTableNameUTF16(column-1));
+       return m_pQuery->getTableNameUTF16(column-1);
 }
 // -------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 column 
) throw(SQLException, RuntimeException)
@@ -107,12 +107,12 @@
 // -------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 
column ) throw(SQLException, RuntimeException)
 {
-       return ::rtl::OUString((const sal_Unicode*) 
m_pQuery->getTypeTextUTF16(column-1));
+       return m_pQuery->getTypeTextUTF16(column-1);
 }
 // -------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column 
) throw(SQLException, RuntimeException)
 {
-       return ::rtl::OUString((const sal_Unicode*) 
m_pQuery->getNameUTF16(column-1));
+       return m_pQuery->getNameUTF16(column-1);
 }
 // -------------------------------------------------------------------------
 ::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 
column ) throw(SQLException, RuntimeException)

File [changed]: sqStatement.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/sqlite3/sqStatement.cxx?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +3 -4
-------------------
--- sqStatement.cxx     19 Aug 2006 01:42:46 -0000      1.1.2.3
+++ sqStatement.cxx     19 Aug 2006 18:23:29 -0000      1.1.2.4
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: sqStatement.cxx,v $
  *
- *  $Revision: 1.1.2.3 $
+ *  $Revision: 1.1.2.4 $
  *
- *  last change: $Author: aklitzing $ $Date: 2006/08/19 01:42:46 $
+ *  last change: $Author: aklitzing $ $Date: 2006/08/19 18:23:29 $
  *
  *  Original contributor: André Klitzing
  *
@@ -405,8 +405,7 @@
        if (query->getReturnNo() != SQLITE_OK)
        {
                sqDB* parent = query->getParentDB();
-           ::rtl::OUString msg((const sal_Unicode*) 
parent->getLastErrorMsgUTF16());
            parent->free(query);
-       throw SQLException(error, *this, msg, parent->getLastErrorNo(), Any());
+       throw SQLException(error, *this, parent->getLastErrorMsgUTF16(), 
parent->getLastErrorNo(), Any());
        }
 }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to