Move to standard integer types #1147

This commit is contained in:
Alex Fabijanic
2017-10-05 14:02:36 -05:00
parent f68e0174b6
commit a6fa326c26
18 changed files with 117 additions and 130 deletions

View File

@@ -31,7 +31,11 @@ static void getProp(const TypeInfo& dataTypes, SQLSMALLINT sqlType, size_t& val)
Poco::DynamicAny r;
if (dataTypes.tryGetInfo(sqlType, NM, r))
{
#ifndef POCO_LONG_IS_64_BIT
long sz = r.convert<long>();
#else
Poco::Int64 sz = r.convert<Poco::Int64>();
#endif
// Postgres driver returns SQL_NO_TOTAL(-4) in some cases
if (sz >= 0)
val = static_cast<size_t>(sz);

View File

@@ -110,8 +110,6 @@ ODBCDB2Test::~ODBCDB2Test()
void ODBCDB2Test::testBareboneODBC()
{
if (! &session()) fail ("Test not available.");
std::string tableCreateString = "CREATE TABLE " + ExecUtil::test_tbl() +
"(First VARCHAR(30),"
"Second VARCHAR(30),"
@@ -140,8 +138,6 @@ void ODBCDB2Test::testBareboneODBC()
void ODBCDB2Test::testBLOB()
{
if (! &session()) fail ("Test not available.");
const std::size_t maxFldSize = 1000000;
session().setProperty("maxFieldSize", Poco::Any(maxFldSize-1));
recreatePersonBLOBTable();
@@ -177,8 +173,6 @@ void ODBCDB2Test::testBLOB()
void ODBCDB2Test::testFilter()
{
if (! &session()) fail ("Test not available.");
for (int i = 0; i < 8;)
{
recreateVectorsTable();
@@ -192,8 +186,6 @@ void ODBCDB2Test::testFilter()
void ODBCDB2Test::testStoredProcedure()
{
if (! &session()) fail ("Test not available.");
const std::string nm = ExecUtil::stored_proc();
dropObject("PROCEDURE", nm + "(INTEGER)");
@@ -266,8 +258,6 @@ void ODBCDB2Test::testStoredProcedure()
void ODBCDB2Test::testStoredProcedureAny()
{
if (! &session()) fail ("Test not available.");
const std::string nm = ExecUtil::stored_proc();
dropObject("PROCEDURE", nm + "(INTEGER)");
@@ -306,8 +296,6 @@ void ODBCDB2Test::testStoredProcedureAny()
void ODBCDB2Test::testStoredProcedureDynamicAny()
{
if (! &session()) fail ("Test not available.");
const std::string nm = ExecUtil::stored_proc();
dropObject("PROCEDURE", nm + "(INTEGER)");
@@ -346,7 +334,6 @@ void ODBCDB2Test::testStoredProcedureDynamicAny()
void ODBCDB2Test::testStoredFunction()
{
const std::string nm = ExecUtil::stored_func();
if (! &session()) fail ("Test not available.");
dropObject("PROCEDURE", nm + "()");
dropObject("PROCEDURE", nm + "(INTEGER)");

View File

@@ -115,7 +115,6 @@ ODBCTest(name, _pSession, _pExecutor, _dsn, _uid, _pwd, _connectString)
void SybaseODBC::testBareboneODBC()
{
if (!&session()) fail("Test not available.");
}
@@ -553,8 +552,6 @@ void SybaseODBC::testStoredProcedureAny()
void SybaseODBC::testTransaction()
{
if (!&session())fail("Test not available.");
for (int i = 0; i < 8;)
{
doPersonTable(" UNIQUE ");

View File

@@ -1129,7 +1129,6 @@ void ODBCTest::testMultipleResults()
void ODBCTest::testMultipleResultsNoProj()
{
if (! &session()) fail("Test not available.");
session().setFeature("autoBind", true); // DB2 fails without that
for (int autoE = 0; autoE < 2; ++autoE)
{

View File

@@ -1393,6 +1393,30 @@ inline AbstractBinding::Ptr use(T& t, const std::string& name = "")
}
template <>
inline AbstractBinding::Ptr use(long& t, const std::string& name)
/// Convenience function for a more compact Binding creation.
{
#ifndef POCO_LONG_IS_64_BIT
return new Binding<long>(t, name, AbstractBinding::PD_IN);
#else
return new Binding<Poco::Int64>(reinterpret_cast<Poco::Int64&>(t), name, AbstractBinding::PD_IN);
#endif
}
template <>
inline AbstractBinding::Ptr use(unsigned long& t, const std::string& name)
/// Convenience function for a more compact Binding creation.
{
#ifndef POCO_LONG_IS_64_BIT
return new Binding<unsigned long>(t, name, AbstractBinding::PD_IN);
#else
return new Binding<Poco::UInt64>(reinterpret_cast<Poco::UInt64&>(t), name, AbstractBinding::PD_IN);
#endif
}
inline AbstractBinding::Ptr use(const NullData& t, const std::string& name = "")
/// NullData overload.
{

View File

@@ -19,6 +19,7 @@
#include "Poco/Data/Data.h"
#include "Poco/Types.h"
#include "Poco/Data/AbstractExtraction.h"
#include "Poco/Data/Preparation.h"
#include "Poco/Data/TypeHandler.h"
@@ -865,6 +866,30 @@ inline AbstractExtraction::Ptr into(T& t)
}
template <>
inline AbstractExtraction::Ptr into(long& t)
/// Convenience function to allow for a more compact creation of an extraction object.
{
#ifndef POCO_LONG_IS_64_BIT
return new Extraction<long>(t);
#else
return new Extraction<Poco::Int64>(reinterpret_cast<Poco::Int64&>(t));
#endif
}
template <>
inline AbstractExtraction::Ptr into(unsigned long& t)
/// Convenience function to allow for a more compact creation of an extraction object.
{
#ifndef POCO_LONG_IS_64_BIT
return new Extraction<unsigned long>(t);
#else
return new Extraction<Poco::UInt64>(reinterpret_cast<Poco::UInt64&>(t));
#endif
}
template <typename T>
inline AbstractExtraction::Ptr into(T& t, const Position& pos)
/// Convenience function to allow for a more compact creation of an extraction object