use std::size_t in Data interfaces (may break some code on 64-bit platforms)

This commit is contained in:
Aleksandar Fabijanic
2009-02-16 03:34:35 +00:00
parent 5b320c2894
commit 142c248754
34 changed files with 190 additions and 194 deletions

View File

@@ -238,7 +238,7 @@ public:
virtual void bind(std::size_t pos, const std::list<std::string>& val, Direction dir = PD_IN);
size_t size() const;
std::size_t size() const;
/// Return count of binded parameters
MYSQL_BIND* getBindArray() const;

View File

@@ -336,7 +336,7 @@ public:
private:
bool realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, size_t length = 0);
bool realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, std::size_t length = 0);
// Prevent VC8 warning "operator= could not be generated"
Extractor& operator=(const Extractor&);

View File

@@ -68,20 +68,20 @@ public:
protected:
virtual Poco::UInt32 columnsReturned() const;
virtual std::size_t columnsReturned() const;
/// Returns number of columns returned by query.
virtual Poco::UInt32 affectedRowCount() const;
virtual std::size_t affectedRowCount() const;
/// Returns the number of affected rows.
/// Used to find out the number of rows affected by insert, delete or update.
virtual const MetaColumn& metaColumn(Poco::UInt32 pos) const;
virtual const MetaColumn& metaColumn(std::size_t pos) const;
/// Returns column meta data.
virtual bool hasNext();
/// Returns true if a call to next() will return data.
virtual Poco::UInt32 next();
virtual std::size_t next();
/// Retrieves the next row from the resultset.
/// Will throw, if the resultset is empty.

View File

@@ -43,6 +43,8 @@
#include "Poco/Data/MySQL/MySQL.h"
#include "Poco/Data/AbstractSessionImpl.h"
#include "Poco/Data/MySQL/SessionHandle.h"
#include "Poco/Data/MySQL/StatementExecutor.h"
#include "Poco/Data/MySQL/ResultMetadata.h"
#include "Poco/Mutex.h"

View File

@@ -71,7 +71,7 @@ public:
void prepare(const std::string& query);
/// Prepares the statement for execution.
void bindParams(MYSQL_BIND* params, size_t count);
void bindParams(MYSQL_BIND* params, std::size_t count);
/// Binds the params.
void bindResult(MYSQL_BIND* result);
@@ -83,7 +83,7 @@ public:
bool fetch();
/// Fetches the data.
bool fetchColumn(size_t n, MYSQL_BIND *bind);
bool fetchColumn(std::size_t n, MYSQL_BIND *bind);
/// Fetches the column.
operator MYSQL_STMT* ();

View File

@@ -226,9 +226,9 @@ void Binder::bind(std::size_t pos, const NullData&, Direction dir)
}
size_t Binder::size() const
std::size_t Binder::size() const
{
return _bindArray.size();
return static_cast<std::size_t>(_bindArray.size());
}
@@ -245,7 +245,7 @@ MYSQL_BIND* Binder::getBindArray() const
/*void Binder::updateDates()
{
for (size_t i = 0; i < _dates.size(); i++)
for (std::size_t i = 0; i < _dates.size(); i++)
{
switch (_dates[i].mt.time_type)
{
@@ -282,7 +282,7 @@ void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer
{
if (pos >= _bindArray.size())
{
size_t s = _bindArray.size();
std::size_t s = static_cast<std::size_t>(_bindArray.size());
_bindArray.resize(pos + 1);
std::memset(&_bindArray[s], 0, sizeof(MYSQL_BIND) * (_bindArray.size() - s));

View File

@@ -250,7 +250,7 @@ void Extractor::reset()
}
bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, size_t length)
bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, std::size_t length)
{
MYSQL_BIND bind = {0};
my_bool isNull = 0;

View File

@@ -55,19 +55,19 @@ MySQLStatementImpl::~MySQLStatementImpl()
}
Poco::UInt32 MySQLStatementImpl::columnsReturned() const
std::size_t MySQLStatementImpl::columnsReturned() const
{
return _metadata.columnsReturned();
}
Poco::UInt32 MySQLStatementImpl::affectedRowCount() const
std::size_t MySQLStatementImpl::affectedRowCount() const
{
return 0;
}
const MetaColumn& MySQLStatementImpl::metaColumn(Poco::UInt32 pos) const
const MetaColumn& MySQLStatementImpl::metaColumn(std::size_t pos) const
{
return _metadata.metaColumn(pos);
}
@@ -100,7 +100,7 @@ bool MySQLStatementImpl::hasNext()
}
Poco::UInt32 MySQLStatementImpl::next()
std::size_t MySQLStatementImpl::next()
{
if (!hasNext())
throw StatementException("No data received");
@@ -151,7 +151,7 @@ void MySQLStatementImpl::compileImpl()
void MySQLStatementImpl::bindImpl()
{
Poco::Data::AbstractBindingVec& binds = bindings();
size_t pos = 0;
std::size_t pos = 0;
Poco::Data::AbstractBindingVec::iterator it = binds.begin();
Poco::Data::AbstractBindingVec::iterator itEnd = binds.end();
for (; it != itEnd && (*it)->canBind(); ++it)

View File

@@ -67,7 +67,7 @@ namespace
MYSQL_RES* h;
};
size_t fieldSize(const MYSQL_FIELD& field)
std::size_t fieldSize(const MYSQL_FIELD& field)
/// Convert field MySQL-type and field MySQL-length to actual field length
{
switch (field.type)
@@ -171,13 +171,13 @@ void ResultMetadata::init(MYSQL_STMT* stmt)
return;
}
size_t count = mysql_num_fields(h);
std::size_t count = mysql_num_fields(h);
MYSQL_FIELD* fields = mysql_fetch_fields(h);
size_t commonSize = 0;
std::size_t commonSize = 0;
_columns.reserve(count);
{for (size_t i = 0; i < count; i++)
{for (std::size_t i = 0; i < count; i++)
{
_columns.push_back(MetaColumn(
i, // position
@@ -196,9 +196,9 @@ void ResultMetadata::init(MYSQL_STMT* stmt)
_lengths.resize(count);
_isNull.resize(count);
size_t offset = 0;
std::size_t offset = 0;
{for (size_t i = 0; i < count; i++)
{for (std::size_t i = 0; i < count; i++)
{
std::memset(&_row[i], 0, sizeof(MYSQL_BIND));
@@ -227,17 +227,17 @@ MYSQL_BIND* ResultMetadata::row()
return &_row[0];
}
size_t ResultMetadata::length(size_t pos) const
std::size_t ResultMetadata::length(std::size_t pos) const
{
return _lengths[pos];
}
const unsigned char* ResultMetadata::rawData(size_t pos) const
const unsigned char* ResultMetadata::rawData(std::size_t pos) const
{
return reinterpret_cast<const unsigned char*>(_row[pos].buffer);
}
bool ResultMetadata::isNull(size_t pos) const
bool ResultMetadata::isNull(std::size_t pos) const
{
return (_isNull[pos] != 0);
}

View File

@@ -36,7 +36,6 @@
#include "Poco/Data/MySQL/SessionImpl.h"
#include "Poco/Data/MySQL/MySQLStatementImpl.h"
#include "Poco/Data/MySQL/StatementExecutor.h"
#include "Poco/Data/Session.h"
#include "Poco/NumberParser.h"
#include "Poco/String.h"

View File

@@ -81,7 +81,7 @@ void StatementExecutor::prepare(const std::string& query)
}
void StatementExecutor::bindParams(MYSQL_BIND* params, size_t count)
void StatementExecutor::bindParams(MYSQL_BIND* params, std::size_t count)
{
if (_state < STMT_COMPILED)
throw StatementException("Satement is not compiled yet");
@@ -132,7 +132,7 @@ bool StatementExecutor::fetch()
}
bool StatementExecutor::fetchColumn(size_t n, MYSQL_BIND *bind)
bool StatementExecutor::fetchColumn(std::size_t n, MYSQL_BIND *bind)
{
if (_state < STMT_EXECUTED)
throw StatementException("Satement is not executed yet");

View File

@@ -493,7 +493,7 @@ void MySQLTest::testSessionTransaction()
{
if (!_pSession) fail ("Test not available.");
recreatePersonBLOBTable();
recreatePersonTable();
_pExecutor->sessionTransaction(_dbConnString);
}
@@ -502,7 +502,7 @@ void MySQLTest::testTransaction()
{
if (!_pSession) fail ("Test not available.");
recreatePersonBLOBTable();
recreatePersonTable();
_pExecutor->transaction(_dbConnString);
}

View File

@@ -1277,9 +1277,9 @@ void SQLExecutor::blob(int bigSize)
Poco::Data::CLOB big;
std::vector<char> v(bigSize, 'x');
big.assignRaw(&v[0], v.size());
big.assignRaw(&v[0], (std::size_t) v.size());
assert (big.size() == (size_t)bigSize);
assert (big.size() == (std::size_t) bigSize);
try { *_pSession << "DELETE FROM Person", now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
@@ -1359,7 +1359,7 @@ void SQLExecutor::tupleVector()
try { *_pSession << "SELECT COUNT(*) FROM Tuples", into(count), now; }
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; fail (funct); }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; fail (funct); }
assert (v.size() == (size_t)count);
assert (v.size() == (std::size_t) count);
std::vector<Tuple<int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int> > ret;
try { *_pSession << "SELECT * FROM Tuples", into(ret), now; }