From 956aafbd0b3b521c27bff1a85f5847f6e637e1db Mon Sep 17 00:00:00 2001 From: Aleksandar Fabijanic Date: Fri, 25 May 2007 01:57:15 +0000 Subject: [PATCH] std::list, std::deque bindings --- Data/ODBC/testsuite/src/ODBCDB2Test.cpp | 129 ++++++++++ Data/ODBC/testsuite/src/ODBCDB2Test.h | 11 + Data/ODBC/testsuite/src/ODBCMySQLTest.cpp | 129 ++++++++++ Data/ODBC/testsuite/src/ODBCMySQLTest.h | 11 + Data/ODBC/testsuite/src/ODBCOracleTest.cpp | 136 ++++++++++ Data/ODBC/testsuite/src/ODBCOracleTest.h | 12 + .../ODBC/testsuite/src/ODBCPostgreSQLTest.cpp | 129 ++++++++++ Data/ODBC/testsuite/src/ODBCPostgreSQLTest.h | 11 + Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp | 129 ++++++++++ Data/ODBC/testsuite/src/ODBCSQLServerTest.h | 11 + Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp | 129 ++++++++++ Data/ODBC/testsuite/src/ODBCSQLiteTest.h | 11 + Data/ODBC/testsuite/src/SQLExecutor.cpp | 232 ++++++++++++++++++ Data/ODBC/testsuite/src/SQLExecutor.h | 11 + Data/include/Poco/Data/Binding.h | 110 ++++++++- Data/include/Poco/Data/Extraction.h | 61 +++++ Data/include/Poco/Data/Prepare.h | 59 ++++- 17 files changed, 1317 insertions(+), 4 deletions(-) diff --git a/Data/ODBC/testsuite/src/ODBCDB2Test.cpp b/Data/ODBC/testsuite/src/ODBCDB2Test.cpp index 202403436..f3128a605 100644 --- a/Data/ODBC/testsuite/src/ODBCDB2Test.cpp +++ b/Data/ODBC/testsuite/src/ODBCDB2Test.cpp @@ -194,6 +194,126 @@ void ODBCDB2Test::testInsertEmptyVector() } +void ODBCDB2Test::testSimpleAccessList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessList(); + i += 2; + } +} + + +void ODBCDB2Test::testComplexTypeList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeList(); + i += 2; + } +} + + +void ODBCDB2Test::testInsertList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertList(); + i += 2; + } +} + + +void ODBCDB2Test::testInsertEmptyList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyList(); + i += 2; + } +} + + +void ODBCDB2Test::testSimpleAccessDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessDeque(); + i += 2; + } +} + + +void ODBCDB2Test::testComplexTypeDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeDeque(); + i += 2; + } +} + + +void ODBCDB2Test::testInsertDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertDeque(); + i += 2; + } +} + + +void ODBCDB2Test::testInsertEmptyDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyDeque(); + i += 2; + } +} + + void ODBCDB2Test::testInsertSingleBulk() { if (!_pSession) fail ("Test not available."); @@ -854,6 +974,7 @@ void ODBCDB2Test::tearDown() { dropTable("Person"); dropTable("Strings"); + dropTable("Tuples"); } @@ -894,6 +1015,14 @@ CppUnit::Test* ODBCDB2Test::suite() CppUnit_addTest(pSuite, ODBCDB2Test, testComplexTypeVector); CppUnit_addTest(pSuite, ODBCDB2Test, testInsertVector); CppUnit_addTest(pSuite, ODBCDB2Test, testInsertEmptyVector); + CppUnit_addTest(pSuite, ODBCDB2Test, testSimpleAccessList); + CppUnit_addTest(pSuite, ODBCDB2Test, testComplexTypeList); + CppUnit_addTest(pSuite, ODBCDB2Test, testInsertList); + CppUnit_addTest(pSuite, ODBCDB2Test, testInsertEmptyList); + CppUnit_addTest(pSuite, ODBCDB2Test, testSimpleAccessDeque); + CppUnit_addTest(pSuite, ODBCDB2Test, testComplexTypeDeque); + CppUnit_addTest(pSuite, ODBCDB2Test, testInsertDeque); + CppUnit_addTest(pSuite, ODBCDB2Test, testInsertEmptyDeque); CppUnit_addTest(pSuite, ODBCDB2Test, testInsertSingleBulk); CppUnit_addTest(pSuite, ODBCDB2Test, testInsertSingleBulkVec); CppUnit_addTest(pSuite, ODBCDB2Test, testLimit); diff --git a/Data/ODBC/testsuite/src/ODBCDB2Test.h b/Data/ODBC/testsuite/src/ODBCDB2Test.h index 190f1233c..dc216ebc3 100644 --- a/Data/ODBC/testsuite/src/ODBCDB2Test.h +++ b/Data/ODBC/testsuite/src/ODBCDB2Test.h @@ -60,11 +60,22 @@ public: void testSimpleAccess(); void testComplexType(); + void testSimpleAccessVector(); void testComplexTypeVector(); void testInsertVector(); void testInsertEmptyVector(); + void testSimpleAccessList(); + void testComplexTypeList(); + void testInsertList(); + void testInsertEmptyList(); + + void testSimpleAccessDeque(); + void testComplexTypeDeque(); + void testInsertDeque(); + void testInsertEmptyDeque(); + void testInsertSingleBulk(); void testInsertSingleBulkVec(); diff --git a/Data/ODBC/testsuite/src/ODBCMySQLTest.cpp b/Data/ODBC/testsuite/src/ODBCMySQLTest.cpp index df97067e9..b5db870ce 100644 --- a/Data/ODBC/testsuite/src/ODBCMySQLTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCMySQLTest.cpp @@ -183,6 +183,126 @@ void ODBCMySQLTest::testInsertEmptyVector() } +void ODBCMySQLTest::testSimpleAccessList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessList(); + i += 2; + } +} + + +void ODBCMySQLTest::testComplexTypeList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeList(); + i += 2; + } +} + + +void ODBCMySQLTest::testInsertList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertList(); + i += 2; + } +} + + +void ODBCMySQLTest::testInsertEmptyList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyList(); + i += 2; + } +} + + +void ODBCMySQLTest::testSimpleAccessDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessDeque(); + i += 2; + } +} + + +void ODBCMySQLTest::testComplexTypeDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeDeque(); + i += 2; + } +} + + +void ODBCMySQLTest::testInsertDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertDeque(); + i += 2; + } +} + + +void ODBCMySQLTest::testInsertEmptyDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyDeque(); + i += 2; + } +} + + void ODBCMySQLTest::testInsertSingleBulk() { if (!_pSession) fail ("Test not available."); @@ -841,6 +961,7 @@ void ODBCMySQLTest::tearDown() { dropTable("Person"); dropTable("Strings"); + dropTable("Tuples"); } @@ -885,6 +1006,14 @@ CppUnit::Test* ODBCMySQLTest::suite() CppUnit_addTest(pSuite, ODBCMySQLTest, testComplexTypeVector); CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertVector); CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertEmptyVector); + CppUnit_addTest(pSuite, ODBCMySQLTest, testSimpleAccessList); + CppUnit_addTest(pSuite, ODBCMySQLTest, testComplexTypeList); + CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertList); + CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertEmptyList); + CppUnit_addTest(pSuite, ODBCMySQLTest, testSimpleAccessDeque); + CppUnit_addTest(pSuite, ODBCMySQLTest, testComplexTypeDeque); + CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertDeque); + CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertEmptyDeque); CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertSingleBulk); CppUnit_addTest(pSuite, ODBCMySQLTest, testInsertSingleBulkVec); CppUnit_addTest(pSuite, ODBCMySQLTest, testLimit); diff --git a/Data/ODBC/testsuite/src/ODBCMySQLTest.h b/Data/ODBC/testsuite/src/ODBCMySQLTest.h index 7e685fd79..4485aca05 100644 --- a/Data/ODBC/testsuite/src/ODBCMySQLTest.h +++ b/Data/ODBC/testsuite/src/ODBCMySQLTest.h @@ -63,11 +63,22 @@ public: void testSimpleAccess(); void testComplexType(); + void testSimpleAccessVector(); void testComplexTypeVector(); void testInsertVector(); void testInsertEmptyVector(); + void testSimpleAccessList(); + void testComplexTypeList(); + void testInsertList(); + void testInsertEmptyList(); + + void testSimpleAccessDeque(); + void testComplexTypeDeque(); + void testInsertDeque(); + void testInsertEmptyDeque(); + void testInsertSingleBulk(); void testInsertSingleBulkVec(); diff --git a/Data/ODBC/testsuite/src/ODBCOracleTest.cpp b/Data/ODBC/testsuite/src/ODBCOracleTest.cpp index 18e104dfb..5a5be5560 100644 --- a/Data/ODBC/testsuite/src/ODBCOracleTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCOracleTest.cpp @@ -191,6 +191,126 @@ void ODBCOracleTest::testInsertEmptyVector() } +void ODBCOracleTest::testSimpleAccessList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessList(); + i += 2; + } +} + + +void ODBCOracleTest::testComplexTypeList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeList(); + i += 2; + } +} + + +void ODBCOracleTest::testInsertList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertList(); + i += 2; + } +} + + +void ODBCOracleTest::testInsertEmptyList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyList(); + i += 2; + } +} + + +void ODBCOracleTest::testSimpleAccessDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessDeque(); + i += 2; + } +} + + +void ODBCOracleTest::testComplexTypeDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeDeque(); + i += 2; + } +} + + +void ODBCOracleTest::testInsertDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertDeque(); + i += 2; + } +} + + +void ODBCOracleTest::testInsertEmptyDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyDeque(); + i += 2; + } +} + + void ODBCOracleTest::testInsertSingleBulk() { if (!_pSession) fail ("Test not available."); @@ -705,6 +825,12 @@ void ODBCOracleTest::testInternalExtraction() } +void ODBCOracleTest::testStoredProcedure() +{ + //TODO +} + + void ODBCOracleTest::dropTable(const std::string& tableName) { try @@ -873,6 +999,7 @@ void ODBCOracleTest::tearDown() { dropTable("Person"); dropTable("Strings"); + dropTable("Tuples"); } @@ -913,6 +1040,14 @@ CppUnit::Test* ODBCOracleTest::suite() CppUnit_addTest(pSuite, ODBCOracleTest, testComplexTypeVector); CppUnit_addTest(pSuite, ODBCOracleTest, testInsertVector); CppUnit_addTest(pSuite, ODBCOracleTest, testInsertEmptyVector); + CppUnit_addTest(pSuite, ODBCOracleTest, testSimpleAccessList); + CppUnit_addTest(pSuite, ODBCOracleTest, testComplexTypeList); + CppUnit_addTest(pSuite, ODBCOracleTest, testInsertList); + CppUnit_addTest(pSuite, ODBCOracleTest, testInsertEmptyList); + CppUnit_addTest(pSuite, ODBCOracleTest, testSimpleAccessDeque); + CppUnit_addTest(pSuite, ODBCOracleTest, testComplexTypeDeque); + CppUnit_addTest(pSuite, ODBCOracleTest, testInsertDeque); + CppUnit_addTest(pSuite, ODBCOracleTest, testInsertEmptyDeque); CppUnit_addTest(pSuite, ODBCOracleTest, testInsertSingleBulk); CppUnit_addTest(pSuite, ODBCOracleTest, testInsertSingleBulkVec); CppUnit_addTest(pSuite, ODBCOracleTest, testLimit); @@ -945,6 +1080,7 @@ CppUnit::Test* ODBCOracleTest::suite() CppUnit_addTest(pSuite, ODBCOracleTest, testDouble); CppUnit_addTest(pSuite, ODBCOracleTest, testTuple); CppUnit_addTest(pSuite, ODBCOracleTest, testTupleVector); + CppUnit_addTest(pSuite, ODBCOracleTest, testStoredProcedure); CppUnit_addTest(pSuite, ODBCOracleTest, testInternalExtraction); return pSuite; diff --git a/Data/ODBC/testsuite/src/ODBCOracleTest.h b/Data/ODBC/testsuite/src/ODBCOracleTest.h index d377317cb..6291a37b7 100644 --- a/Data/ODBC/testsuite/src/ODBCOracleTest.h +++ b/Data/ODBC/testsuite/src/ODBCOracleTest.h @@ -61,11 +61,22 @@ public: void testSimpleAccess(); void testComplexType(); + void testSimpleAccessVector(); void testComplexTypeVector(); void testInsertVector(); void testInsertEmptyVector(); + void testSimpleAccessList(); + void testComplexTypeList(); + void testInsertList(); + void testInsertEmptyList(); + + void testSimpleAccessDeque(); + void testComplexTypeDeque(); + void testInsertDeque(); + void testInsertEmptyDeque(); + void testInsertSingleBulk(); void testInsertSingleBulkVec(); @@ -105,6 +116,7 @@ public: void testTupleVector(); void testInternalExtraction(); + void testStoredProcedure(); void setUp(); void tearDown(); diff --git a/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp b/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp index 25acee391..d02c2adab 100644 --- a/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp @@ -185,6 +185,126 @@ void ODBCPostgreSQLTest::testInsertEmptyVector() } +void ODBCPostgreSQLTest::testSimpleAccessList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessList(); + i += 2; + } +} + + +void ODBCPostgreSQLTest::testComplexTypeList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeList(); + i += 2; + } +} + + +void ODBCPostgreSQLTest::testInsertList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertList(); + i += 2; + } +} + + +void ODBCPostgreSQLTest::testInsertEmptyList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyList(); + i += 2; + } +} + + +void ODBCPostgreSQLTest::testSimpleAccessDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessDeque(); + i += 2; + } +} + + +void ODBCPostgreSQLTest::testComplexTypeDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeDeque(); + i += 2; + } +} + + +void ODBCPostgreSQLTest::testInsertDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertDeque(); + i += 2; + } +} + + +void ODBCPostgreSQLTest::testInsertEmptyDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyDeque(); + i += 2; + } +} + + void ODBCPostgreSQLTest::testInsertSingleBulk() { if (!_pSession) fail ("Test not available."); @@ -866,6 +986,7 @@ void ODBCPostgreSQLTest::tearDown() { dropTable("Person"); dropTable("Strings"); + dropTable("Tuples"); } @@ -906,6 +1027,14 @@ CppUnit::Test* ODBCPostgreSQLTest::suite() CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testComplexTypeVector); CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertVector); CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertEmptyVector); + CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSimpleAccessList); + CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testComplexTypeList); + CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertList); + CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertEmptyList); + CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testSimpleAccessDeque); + CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testComplexTypeDeque); + CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertDeque); + CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertEmptyDeque); CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertSingleBulk); CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testInsertSingleBulkVec); CppUnit_addTest(pSuite, ODBCPostgreSQLTest, testLimit); diff --git a/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.h b/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.h index 3a15d1732..ba6c22a37 100644 --- a/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.h +++ b/Data/ODBC/testsuite/src/ODBCPostgreSQLTest.h @@ -63,11 +63,22 @@ public: void testSimpleAccess(); void testComplexType(); + void testSimpleAccessVector(); void testComplexTypeVector(); void testInsertVector(); void testInsertEmptyVector(); + void testSimpleAccessList(); + void testComplexTypeList(); + void testInsertList(); + void testInsertEmptyList(); + + void testSimpleAccessDeque(); + void testComplexTypeDeque(); + void testInsertDeque(); + void testInsertEmptyDeque(); + void testInsertSingleBulk(); void testInsertSingleBulkVec(); diff --git a/Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp b/Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp index 39969d796..eeb9590b4 100644 --- a/Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp @@ -195,6 +195,126 @@ void ODBCSQLServerTest::testInsertEmptyVector() } +void ODBCSQLServerTest::testSimpleAccessList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessList(); + i += 2; + } +} + + +void ODBCSQLServerTest::testComplexTypeList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeList(); + i += 2; + } +} + + +void ODBCSQLServerTest::testInsertList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertList(); + i += 2; + } +} + + +void ODBCSQLServerTest::testInsertEmptyList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyList(); + i += 2; + } +} + + +void ODBCSQLServerTest::testSimpleAccessDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessDeque(); + i += 2; + } +} + + +void ODBCSQLServerTest::testComplexTypeDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeDeque(); + i += 2; + } +} + + +void ODBCSQLServerTest::testInsertDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertDeque(); + i += 2; + } +} + + +void ODBCSQLServerTest::testInsertEmptyDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyDeque(); + i += 2; + } +} + + void ODBCSQLServerTest::testInsertSingleBulk() { if (!_pSession) fail ("Test not available."); @@ -863,6 +983,7 @@ void ODBCSQLServerTest::tearDown() { dropTable("Person"); dropTable("Strings"); + dropTable("Tuples"); } @@ -907,6 +1028,14 @@ CppUnit::Test* ODBCSQLServerTest::suite() CppUnit_addTest(pSuite, ODBCSQLServerTest, testComplexTypeVector); CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertVector); CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertEmptyVector); + CppUnit_addTest(pSuite, ODBCSQLServerTest, testSimpleAccessList); + CppUnit_addTest(pSuite, ODBCSQLServerTest, testComplexTypeList); + CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertList); + CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertEmptyList); + CppUnit_addTest(pSuite, ODBCSQLServerTest, testSimpleAccessDeque); + CppUnit_addTest(pSuite, ODBCSQLServerTest, testComplexTypeDeque); + CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertDeque); + CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertEmptyDeque); CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertSingleBulk); CppUnit_addTest(pSuite, ODBCSQLServerTest, testInsertSingleBulkVec); CppUnit_addTest(pSuite, ODBCSQLServerTest, testLimit); diff --git a/Data/ODBC/testsuite/src/ODBCSQLServerTest.h b/Data/ODBC/testsuite/src/ODBCSQLServerTest.h index 4bfe67f07..4ebacc0e7 100644 --- a/Data/ODBC/testsuite/src/ODBCSQLServerTest.h +++ b/Data/ODBC/testsuite/src/ODBCSQLServerTest.h @@ -63,11 +63,22 @@ public: void testSimpleAccess(); void testComplexType(); + void testSimpleAccessVector(); void testComplexTypeVector(); void testInsertVector(); void testInsertEmptyVector(); + void testSimpleAccessList(); + void testComplexTypeList(); + void testInsertList(); + void testInsertEmptyList(); + + void testSimpleAccessDeque(); + void testComplexTypeDeque(); + void testInsertDeque(); + void testInsertEmptyDeque(); + void testInsertSingleBulk(); void testInsertSingleBulkVec(); diff --git a/Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp b/Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp index 59b8af26a..af05ca19c 100644 --- a/Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp +++ b/Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp @@ -195,6 +195,126 @@ void ODBCSQLiteTest::testInsertEmptyVector() } +void ODBCSQLiteTest::testSimpleAccessList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessList(); + i += 2; + } +} + + +void ODBCSQLiteTest::testComplexTypeList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeList(); + i += 2; + } +} + + +void ODBCSQLiteTest::testInsertList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertList(); + i += 2; + } +} + + +void ODBCSQLiteTest::testInsertEmptyList() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyList(); + i += 2; + } +} + + +void ODBCSQLiteTest::testSimpleAccessDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->simpleAccessDeque(); + i += 2; + } +} + + +void ODBCSQLiteTest::testComplexTypeDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreatePersonTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->complexTypeDeque(); + i += 2; + } +} + + +void ODBCSQLiteTest::testInsertDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertDeque(); + i += 2; + } +} + + +void ODBCSQLiteTest::testInsertEmptyDeque() +{ + if (!_pSession) fail ("Test not available."); + + for (int i = 0; i < 8;) + { + recreateStringsTable(); + _pSession->setFeature("autoBind", bindValues[i]); + _pSession->setFeature("autoExtract", bindValues[i+1]); + _pExecutor->insertEmptyDeque(); + i += 2; + } +} + + void ODBCSQLiteTest::testInsertSingleBulk() { if (!_pSession) fail ("Test not available."); @@ -827,6 +947,7 @@ void ODBCSQLiteTest::tearDown() { dropTable("Person"); dropTable("Strings"); + dropTable("Tuples"); } @@ -867,6 +988,14 @@ CppUnit::Test* ODBCSQLiteTest::suite() CppUnit_addTest(pSuite, ODBCSQLiteTest, testComplexTypeVector); CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertVector); CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertEmptyVector); + CppUnit_addTest(pSuite, ODBCSQLiteTest, testSimpleAccessList); + CppUnit_addTest(pSuite, ODBCSQLiteTest, testComplexTypeList); + CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertList); + CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertEmptyList); + CppUnit_addTest(pSuite, ODBCSQLiteTest, testSimpleAccessDeque); + CppUnit_addTest(pSuite, ODBCSQLiteTest, testComplexTypeDeque); + CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertDeque); + CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertEmptyDeque); CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertSingleBulk); CppUnit_addTest(pSuite, ODBCSQLiteTest, testInsertSingleBulkVec); CppUnit_addTest(pSuite, ODBCSQLiteTest, testLimit); diff --git a/Data/ODBC/testsuite/src/ODBCSQLiteTest.h b/Data/ODBC/testsuite/src/ODBCSQLiteTest.h index ed9c61aea..f022cd21d 100644 --- a/Data/ODBC/testsuite/src/ODBCSQLiteTest.h +++ b/Data/ODBC/testsuite/src/ODBCSQLiteTest.h @@ -60,11 +60,22 @@ public: void testSimpleAccess(); void testComplexType(); + void testSimpleAccessVector(); void testComplexTypeVector(); void testInsertVector(); void testInsertEmptyVector(); + void testSimpleAccessList(); + void testComplexTypeList(); + void testInsertList(); + void testInsertEmptyList(); + + void testSimpleAccessDeque(); + void testComplexTypeDeque(); + void testInsertDeque(); + void testInsertEmptyDeque(); + void testInsertSingleBulk(); void testInsertSingleBulkVec(); diff --git a/Data/ODBC/testsuite/src/SQLExecutor.cpp b/Data/ODBC/testsuite/src/SQLExecutor.cpp index ed68067dd..587a260ca 100644 --- a/Data/ODBC/testsuite/src/SQLExecutor.cpp +++ b/Data/ODBC/testsuite/src/SQLExecutor.cpp @@ -640,6 +640,238 @@ void SQLExecutor::insertEmptyVector() } +void SQLExecutor::simpleAccessList() +{ + std::string funct = "simpleAccessList()"; + std::list lastNames; + std::list firstNames; + std::list addresses; + std::list ages; + std::string tableName("Person"); + lastNames.push_back("LN1"); + lastNames.push_back("LN2"); + firstNames.push_back("FN1"); + firstNames.push_back("FN2"); + addresses.push_back("ADDR1"); + addresses.push_back("ADDR2"); + ages.push_back(1); + ages.push_back(2); + int count = 0; + std::string result; + + try { *_pSession << "INSERT INTO PERSON VALUES (?,?,?,?)", use(lastNames), use(firstNames), use(addresses), use(ages), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + + try { *_pSession << "SELECT COUNT(*) FROM PERSON", into(count), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (count == 2); + + std::list lastNamesR; + std::list firstNamesR; + std::list addressesR; + std::list agesR; + try { *_pSession << "SELECT * FROM PERSON", into(lastNamesR), into(firstNamesR), into(addressesR), into(agesR), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (ages == agesR); + assert (lastNames == lastNamesR); + assert (firstNames == firstNamesR); + assert (addresses == addressesR); +} + + +void SQLExecutor::complexTypeList() +{ + std::string funct = "complexTypeList()"; + std::list people; + people.push_back(Person("LN1", "FN1", "ADDR1", 1)); + people.push_back(Person("LN2", "FN2", "ADDR2", 2)); + + try { *_pSession << "INSERT INTO PERSON VALUES (?,?,?,?)", use(people), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + + int count = 0; + try { *_pSession << "SELECT COUNT(*) FROM PERSON", into(count), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (count == 2); + + std::list result; + try { *_pSession << "SELECT * FROM PERSON", into(result), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (result == people); +} + + +void SQLExecutor::insertList() +{ + std::string funct = "insertList()"; + std::list str; + str.push_back("s1"); + str.push_back("s2"); + str.push_back("s3"); + str.push_back("s3"); + int count = 100; + + { + Statement stmt((*_pSession << "INSERT INTO Strings VALUES (?)", use(str))); + try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (count == 0); + + try { stmt.execute(); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + + try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (count == 4); + } + count = 0; + try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (count == 4); +} + + +void SQLExecutor::insertEmptyList() +{ + std::string funct = "insertEmptyList()"; + std::list str; + + try + { + *_pSession << "INSERT INTO Strings VALUES (?)", use(str), now; + fail("empty collections should not work"); + } + catch (Poco::Exception&) + { + } +} + + +void SQLExecutor::simpleAccessDeque() +{ + std::string funct = "simpleAccessDeque()"; + std::deque lastNames; + std::deque firstNames; + std::deque addresses; + std::deque ages; + std::string tableName("Person"); + lastNames.push_back("LN1"); + lastNames.push_back("LN2"); + firstNames.push_back("FN1"); + firstNames.push_back("FN2"); + addresses.push_back("ADDR1"); + addresses.push_back("ADDR2"); + ages.push_back(1); + ages.push_back(2); + int count = 0; + std::string result; + + try { *_pSession << "INSERT INTO PERSON VALUES (?,?,?,?)", use(lastNames), use(firstNames), use(addresses), use(ages), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + + try { *_pSession << "SELECT COUNT(*) FROM PERSON", into(count), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (count == 2); + + std::deque lastNamesR; + std::deque firstNamesR; + std::deque addressesR; + std::deque agesR; + try { *_pSession << "SELECT * FROM PERSON", into(lastNamesR), into(firstNamesR), into(addressesR), into(agesR), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (ages == agesR); + assert (lastNames == lastNamesR); + assert (firstNames == firstNamesR); + assert (addresses == addressesR); +} + + +void SQLExecutor::complexTypeDeque() +{ + std::string funct = "complexTypeDeque()"; + std::deque people; + people.push_back(Person("LN1", "FN1", "ADDR1", 1)); + people.push_back(Person("LN2", "FN2", "ADDR2", 2)); + + try { *_pSession << "INSERT INTO PERSON VALUES (?,?,?,?)", use(people), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + + int count = 0; + try { *_pSession << "SELECT COUNT(*) FROM PERSON", into(count), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (count == 2); + + std::deque result; + try { *_pSession << "SELECT * FROM PERSON", into(result), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (result == people); +} + + +void SQLExecutor::insertDeque() +{ + std::string funct = "insertDeque()"; + std::deque str; + str.push_back("s1"); + str.push_back("s2"); + str.push_back("s3"); + str.push_back("s3"); + int count = 100; + + { + Statement stmt((*_pSession << "INSERT INTO Strings VALUES (?)", use(str))); + try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (count == 0); + + try { stmt.execute(); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + + try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (count == 4); + } + count = 0; + try { *_pSession << "SELECT COUNT(*) FROM Strings", into(count), now; } + catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); } + catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); } + assert (count == 4); +} + + +void SQLExecutor::insertEmptyDeque() +{ + std::string funct = "insertEmptyDeque()"; + std::deque str; + + try + { + *_pSession << "INSERT INTO Strings VALUES (?)", use(str), now; + fail("empty collections should not work"); + } + catch (Poco::Exception&) + { + } +} + + void SQLExecutor::insertSingleBulk() { std::string funct = "insertSingleBulk()"; diff --git a/Data/ODBC/testsuite/src/SQLExecutor.h b/Data/ODBC/testsuite/src/SQLExecutor.h index dc08f23d9..b1b21d89d 100644 --- a/Data/ODBC/testsuite/src/SQLExecutor.h +++ b/Data/ODBC/testsuite/src/SQLExecutor.h @@ -72,11 +72,22 @@ public: void simpleAccess(); void complexType(); + void simpleAccessVector(); void complexTypeVector(); void insertVector(); void insertEmptyVector(); + void simpleAccessList(); + void complexTypeList(); + void insertList(); + void insertEmptyList(); + + void simpleAccessDeque(); + void complexTypeDeque(); + void insertDeque(); + void insertEmptyDeque(); + void insertSingleBulk(); void insertSingleBulkVec(); diff --git a/Data/include/Poco/Data/Binding.h b/Data/include/Poco/Data/Binding.h index 7d1adcd42..c1e98c7ae 100644 --- a/Data/include/Poco/Data/Binding.h +++ b/Data/include/Poco/Data/Binding.h @@ -44,8 +44,10 @@ #include "Poco/Data/AbstractBinding.h" #include "Poco/Data/DataException.h" #include "Poco/Data/TypeHandler.h" -#include #include +#include +#include +#include #include #include @@ -155,6 +157,112 @@ private: }; +template +class Binding >: public AbstractBinding + /// Specialization for std::list. +{ +public: + explicit Binding(const std::list& val): _val(val), _begin(val.begin()), _end(val.end()) + /// Creates the Binding. + { + if (numOfRowsHandled() == 0) + throw BindingException("It is illegal to bind to an empty data collection"); + } + + ~Binding() + /// Destroys the Binding. + { + } + + std::size_t numOfColumnsHandled() const + { + return TypeHandler::size(); + } + + std::size_t numOfRowsHandled() const + { + return _val.size(); + } + + bool canBind() const + { + return _begin != _end; + } + + void bind(std::size_t pos) + { + poco_assert_dbg(getBinder() != 0); + poco_assert_dbg(canBind()); + TypeHandler::bind(pos, *_begin, getBinder()); + ++_begin; + } + + void reset() + { + _begin = _val.begin(); + _end = _val.end(); + } + +private: + const std::list& _val; + typename std::list::const_iterator _begin; + typename std::list::const_iterator _end; +}; + + +template +class Binding >: public AbstractBinding + /// Specialization for std::deque. +{ +public: + explicit Binding(const std::deque& val): _val(val), _begin(val.begin()), _end(val.end()) + /// Creates the Binding. + { + if (numOfRowsHandled() == 0) + throw BindingException("It is illegal to bind to an empty data collection"); + } + + ~Binding() + /// Destroys the Binding. + { + } + + std::size_t numOfColumnsHandled() const + { + return TypeHandler::size(); + } + + std::size_t numOfRowsHandled() const + { + return _val.size(); + } + + bool canBind() const + { + return _begin != _end; + } + + void bind(std::size_t pos) + { + poco_assert_dbg(getBinder() != 0); + poco_assert_dbg(canBind()); + TypeHandler::bind(pos, *_begin, getBinder()); + ++_begin; + } + + void reset() + { + _begin = _val.begin(); + _end = _val.end(); + } + +private: + const std::deque& _val; + typename std::deque::const_iterator _begin; + typename std::deque::const_iterator _end; +}; + + template class Binding >: public AbstractBinding /// Specialization for std::set. diff --git a/Data/include/Poco/Data/Extraction.h b/Data/include/Poco/Data/Extraction.h index 9512056cb..b3d855ae3 100644 --- a/Data/include/Poco/Data/Extraction.h +++ b/Data/include/Poco/Data/Extraction.h @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -236,6 +237,66 @@ private: }; +template +class Extraction >: public AbstractExtraction + /// Deque Data Type specialization for extraction of values from a query result set. +{ +public: + Extraction(std::deque& result): _rResult(result), _default() + { + } + + Extraction(std::deque& result, const T& def): _rResult(result), _default(def) + { + } + + virtual ~Extraction() + { + } + + std::size_t numOfColumnsHandled() const + { + return TypeHandler::size(); + } + + std::size_t numOfRowsHandled() const + { + return _rResult.size(); + } + + std::size_t numOfRowsAllowed() const + { + return getLimit(); + } + + void extract(std::size_t pos) + { + _rResult.push_back(_default); + TypeHandler::extract(pos, _rResult.back(), _default, getExtractor()); + } + + virtual void reset() + { + } + + AbstractPrepare* createPrepareObject(AbstractPreparation* pPrep, std::size_t pos) const + { + return new Prepare(pPrep, pos, _default); + } + +protected: + + const std::deque& result() const + { + return _rResult; + } + +private: + std::deque& _rResult; + T _default; // copy the default +}; + + template > class InternalExtraction: public Extraction /// Container Data Type specialization extension for extraction of values from a query result set. diff --git a/Data/include/Poco/Data/Prepare.h b/Data/include/Poco/Data/Prepare.h index e220db862..73817a779 100644 --- a/Data/include/Poco/Data/Prepare.h +++ b/Data/include/Poco/Data/Prepare.h @@ -47,15 +47,14 @@ #include #include #include +#include +#include namespace Poco { namespace Data { -class BLOB; - - template class Prepare: public AbstractPrepare /// Class for calling the appropriate AbstractPreparation method. @@ -110,6 +109,60 @@ private: }; +template +class Prepare >: public AbstractPrepare + /// Class for calling the appropriate AbstractPreparation method. +{ +public: + Prepare(AbstractPreparation* pPrepare, std::size_t pos, const T& val): AbstractPrepare(pPrepare), _pos(pos), _val(val) + /// Creates the Prepare. + { + } + + ~Prepare() + /// Destroys the Prepare. + { + } + + void prepare() + /// Prepares data. + { + TypeHandler::prepare(_pos, _val, preparation()); + } + +private: + std::size_t _pos; + const T& _val; +}; + + +template +class Prepare >: public AbstractPrepare + /// Class for calling the appropriate AbstractPreparation method. +{ +public: + Prepare(AbstractPreparation* pPrepare, std::size_t pos, const T& val): AbstractPrepare(pPrepare), _pos(pos), _val(val) + /// Creates the Prepare. + { + } + + ~Prepare() + /// Destroys the Prepare. + { + } + + void prepare() + /// Prepares data. + { + TypeHandler::prepare(_pos, _val, preparation()); + } + +private: + std::size_t _pos; + const T& _val; +}; + + template class Prepare >: public AbstractPrepare /// Class for calling the appropriate AbstractPreparation method.