Skip to content

Commit 142c248

Browse files
committed
use std::size_t in Data interfaces (may break some code on 64-bit platforms)
1 parent 5b320c2 commit 142c248

34 files changed

+190
-194
lines changed

Data/Data_VS90.vcproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@
451451
>
452452
</File>
453453
<File
454-
RelativePath=".\include\Poco\Data\Prepare.h"
454+
RelativePath=".\include\Poco\data\Preparation.h"
455455
>
456456
</File>
457457
<File

Data/MySQL/include/Poco/Data/MySQL/Binder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class MySQL_API Binder: public Poco::Data::AbstractBinder
238238

239239
virtual void bind(std::size_t pos, const std::list<std::string>& val, Direction dir = PD_IN);
240240

241-
size_t size() const;
241+
std::size_t size() const;
242242
/// Return count of binded parameters
243243

244244
MYSQL_BIND* getBindArray() const;

Data/MySQL/include/Poco/Data/MySQL/Extractor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ class MySQL_API Extractor: public Poco::Data::AbstractExtractor
336336

337337
private:
338338

339-
bool realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, size_t length = 0);
339+
bool realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, std::size_t length = 0);
340340

341341
// Prevent VC8 warning "operator= could not be generated"
342342
Extractor& operator=(const Extractor&);

Data/MySQL/include/Poco/Data/MySQL/MySQLStatementImpl.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ class MySQL_API MySQLStatementImpl: public Poco::Data::StatementImpl
6868

6969
protected:
7070

71-
virtual Poco::UInt32 columnsReturned() const;
71+
virtual std::size_t columnsReturned() const;
7272
/// Returns number of columns returned by query.
7373

74-
virtual Poco::UInt32 affectedRowCount() const;
74+
virtual std::size_t affectedRowCount() const;
7575
/// Returns the number of affected rows.
7676
/// Used to find out the number of rows affected by insert, delete or update.
7777

78-
virtual const MetaColumn& metaColumn(Poco::UInt32 pos) const;
78+
virtual const MetaColumn& metaColumn(std::size_t pos) const;
7979
/// Returns column meta data.
8080

8181
virtual bool hasNext();
8282
/// Returns true if a call to next() will return data.
8383

84-
virtual Poco::UInt32 next();
84+
virtual std::size_t next();
8585
/// Retrieves the next row from the resultset.
8686
/// Will throw, if the resultset is empty.
8787

Data/MySQL/include/Poco/Data/MySQL/SessionImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
#include "Poco/Data/MySQL/MySQL.h"
4444
#include "Poco/Data/AbstractSessionImpl.h"
4545
#include "Poco/Data/MySQL/SessionHandle.h"
46+
#include "Poco/Data/MySQL/StatementExecutor.h"
47+
#include "Poco/Data/MySQL/ResultMetadata.h"
4648
#include "Poco/Mutex.h"
4749

4850

Data/MySQL/include/Poco/Data/MySQL/StatementExecutor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class StatementExecutor
7171
void prepare(const std::string& query);
7272
/// Prepares the statement for execution.
7373

74-
void bindParams(MYSQL_BIND* params, size_t count);
74+
void bindParams(MYSQL_BIND* params, std::size_t count);
7575
/// Binds the params.
7676

7777
void bindResult(MYSQL_BIND* result);
@@ -83,7 +83,7 @@ class StatementExecutor
8383
bool fetch();
8484
/// Fetches the data.
8585

86-
bool fetchColumn(size_t n, MYSQL_BIND *bind);
86+
bool fetchColumn(std::size_t n, MYSQL_BIND *bind);
8787
/// Fetches the column.
8888

8989
operator MYSQL_STMT* ();

Data/MySQL/src/Binder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ void Binder::bind(std::size_t pos, const NullData&, Direction dir)
226226
}
227227

228228

229-
size_t Binder::size() const
229+
std::size_t Binder::size() const
230230
{
231-
return _bindArray.size();
231+
return static_cast<std::size_t>(_bindArray.size());
232232
}
233233

234234

@@ -245,7 +245,7 @@ MYSQL_BIND* Binder::getBindArray() const
245245

246246
/*void Binder::updateDates()
247247
{
248-
for (size_t i = 0; i < _dates.size(); i++)
248+
for (std::size_t i = 0; i < _dates.size(); i++)
249249
{
250250
switch (_dates[i].mt.time_type)
251251
{
@@ -282,7 +282,7 @@ void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer
282282
{
283283
if (pos >= _bindArray.size())
284284
{
285-
size_t s = _bindArray.size();
285+
std::size_t s = static_cast<std::size_t>(_bindArray.size());
286286
_bindArray.resize(pos + 1);
287287

288288
std::memset(&_bindArray[s], 0, sizeof(MYSQL_BIND) * (_bindArray.size() - s));

Data/MySQL/src/Extractor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ void Extractor::reset()
250250
}
251251

252252

253-
bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, size_t length)
253+
bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, std::size_t length)
254254
{
255255
MYSQL_BIND bind = {0};
256256
my_bool isNull = 0;

Data/MySQL/src/MySQLStatementImpl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ MySQLStatementImpl::~MySQLStatementImpl()
5555
}
5656

5757

58-
Poco::UInt32 MySQLStatementImpl::columnsReturned() const
58+
std::size_t MySQLStatementImpl::columnsReturned() const
5959
{
6060
return _metadata.columnsReturned();
6161
}
6262

6363

64-
Poco::UInt32 MySQLStatementImpl::affectedRowCount() const
64+
std::size_t MySQLStatementImpl::affectedRowCount() const
6565
{
6666
return 0;
6767
}
6868

6969

70-
const MetaColumn& MySQLStatementImpl::metaColumn(Poco::UInt32 pos) const
70+
const MetaColumn& MySQLStatementImpl::metaColumn(std::size_t pos) const
7171
{
7272
return _metadata.metaColumn(pos);
7373
}
@@ -100,7 +100,7 @@ bool MySQLStatementImpl::hasNext()
100100
}
101101

102102

103-
Poco::UInt32 MySQLStatementImpl::next()
103+
std::size_t MySQLStatementImpl::next()
104104
{
105105
if (!hasNext())
106106
throw StatementException("No data received");
@@ -151,7 +151,7 @@ void MySQLStatementImpl::compileImpl()
151151
void MySQLStatementImpl::bindImpl()
152152
{
153153
Poco::Data::AbstractBindingVec& binds = bindings();
154-
size_t pos = 0;
154+
std::size_t pos = 0;
155155
Poco::Data::AbstractBindingVec::iterator it = binds.begin();
156156
Poco::Data::AbstractBindingVec::iterator itEnd = binds.end();
157157
for (; it != itEnd && (*it)->canBind(); ++it)

Data/MySQL/src/ResultMetadata.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ namespace
6767
MYSQL_RES* h;
6868
};
6969

70-
size_t fieldSize(const MYSQL_FIELD& field)
70+
std::size_t fieldSize(const MYSQL_FIELD& field)
7171
/// Convert field MySQL-type and field MySQL-length to actual field length
7272
{
7373
switch (field.type)
@@ -171,13 +171,13 @@ void ResultMetadata::init(MYSQL_STMT* stmt)
171171
return;
172172
}
173173

174-
size_t count = mysql_num_fields(h);
174+
std::size_t count = mysql_num_fields(h);
175175
MYSQL_FIELD* fields = mysql_fetch_fields(h);
176176

177-
size_t commonSize = 0;
177+
std::size_t commonSize = 0;
178178
_columns.reserve(count);
179179

180-
{for (size_t i = 0; i < count; i++)
180+
{for (std::size_t i = 0; i < count; i++)
181181
{
182182
_columns.push_back(MetaColumn(
183183
i, // position
@@ -196,9 +196,9 @@ void ResultMetadata::init(MYSQL_STMT* stmt)
196196
_lengths.resize(count);
197197
_isNull.resize(count);
198198

199-
size_t offset = 0;
199+
std::size_t offset = 0;
200200

201-
{for (size_t i = 0; i < count; i++)
201+
{for (std::size_t i = 0; i < count; i++)
202202
{
203203
std::memset(&_row[i], 0, sizeof(MYSQL_BIND));
204204

@@ -227,17 +227,17 @@ MYSQL_BIND* ResultMetadata::row()
227227
return &_row[0];
228228
}
229229

230-
size_t ResultMetadata::length(size_t pos) const
230+
std::size_t ResultMetadata::length(std::size_t pos) const
231231
{
232232
return _lengths[pos];
233233
}
234234

235-
const unsigned char* ResultMetadata::rawData(size_t pos) const
235+
const unsigned char* ResultMetadata::rawData(std::size_t pos) const
236236
{
237237
return reinterpret_cast<const unsigned char*>(_row[pos].buffer);
238238
}
239239

240-
bool ResultMetadata::isNull(size_t pos) const
240+
bool ResultMetadata::isNull(std::size_t pos) const
241241
{
242242
return (_isNull[pos] != 0);
243243
}

0 commit comments

Comments
 (0)