Skip to content

Commit

Permalink
more stl to qt ports and size_t => int fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Dec 25, 2015
1 parent 5605eaf commit 71dc339
Show file tree
Hide file tree
Showing 51 changed files with 227 additions and 237 deletions.
2 changes: 1 addition & 1 deletion python/analysis/network/qgsgraph.sip
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class QgsGraphArc
QVariant property( int propertyIndex ) const;

/**
* get array of proertyes
* get array of properties
*/
QVector< QVariant > properties() const;

Expand Down
11 changes: 2 additions & 9 deletions python/core/geometry/qgsgeometry.sip
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ typedef QVector< QVector<QgsPoint> > QgsMultiPolyline;
/** A collection of QgsPolygons that share a common collection of attributes */
typedef QVector< QVector< QVector<QgsPoint> > > QgsMultiPolygon;

%If (WS_MACX)
typedef unsigned long size_t;
%End
%If (WS_X11 || WS_WIN)
typedef unsigned int size_t;
%End

/** \ingroup core
* A geometry is the spatial representation of a feature. Since QGIS 2.10, QgsGeometry acts as a generic container
* for geometry objects. QgsGeometry is implicitly shared, so making copies of geometries is inexpensive. The geometry
Expand Down Expand Up @@ -98,7 +91,7 @@ class QgsGeometry
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
This class will take ownership of the buffer.
*/
void fromWkb( unsigned char * wkb /Array/, size_t length /ArraySize/ );
void fromWkb( unsigned char * wkb /Array/, int length /ArraySize/ );
%MethodCode
// create copy of Python's string and pass it to fromWkb()
unsigned char * copy = new unsigned char[a1];
Expand All @@ -120,7 +113,7 @@ class QgsGeometry
* Returns the size of the WKB in asWkb().
* @see asWkb
*/
size_t wkbSize() const;
int wkbSize() const;

/** Returns a geos geometry. QgsGeometry retains ownership of the geometry, so the returned object should not be deleted.
@param precision The precision of the grid to which to snap the geometry vertices. If 0, no snapping is performed.
Expand Down
3 changes: 1 addition & 2 deletions python/core/qgsfeature.sip
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ class QgsFeature
* @see constGeometry
* @see geometryAndOwnership
* @see setGeometryAndOwnership
* @deprecated will be removed in QGIS 3.0
*/
// void setGeometry( QgsGeometry* geom /Transfer/ );

Expand All @@ -392,7 +391,7 @@ class QgsFeature
* @see geometryAndOwnership
* @deprecated will be removed in QGIS 3.0
*/
void setGeometryAndOwnership( unsigned char * geom /Transfer/, size_t length ) /Deprecated/;
void setGeometryAndOwnership( unsigned char * geom /Transfer/, int length ) /Deprecated/;

/** Assign a field map with the feature to allow attribute access by attribute name.
* @param fields The attribute fields which this feature holds
Expand Down
3 changes: 2 additions & 1 deletion src/analysis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ IF(NOT MSVC)
)
ELSE(NOT MSVC)
IF(PEDANTIC)
# 4127 expression is constant
# 4702 unreachable code
SET_SOURCE_FILES_PROPERTIES(
${CMAKE_BINARY_DIR}/src/analysis/qgsrastercalcparser.cpp
PROPERTIES COMPILE_FLAGS "-wd4702"
PROPERTIES COMPILE_FLAGS "-wd4127 -wd4702"
)
ENDIF(PEDANTIC)
ENDIF(NOT MSVC)
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/network/qgsgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ANALYSIS_EXPORT QgsGraphArc
QVariant property( int propertyIndex ) const;

/**
* get array of proertyes
* get array of properties
*/
QVector< QVariant > properties() const;

Expand Down
2 changes: 1 addition & 1 deletion src/analysis/vector/qgsgeometryanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ void QgsGeometryAnalyzer::dissolveFeature( QgsFeature& f, int nProcessedFeatures

if ( nProcessedFeatures == 0 )
{
size_t geomSize = featureGeometry->wkbSize();
int geomSize = featureGeometry->wkbSize();
*dissolveGeometry = new QgsGeometry();
unsigned char* wkb = new unsigned char[geomSize];
memcpy( wkb, featureGeometry->asWkb(), geomSize );
Expand Down
2 changes: 1 addition & 1 deletion src/app/gps/qwtpolar-0.1/qwt_polar_curve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void QwtPolarCurve::drawSymbols( QPainter *painter, const QwtSymbol &symbol,
*/
int QwtPolarCurve::dataSize() const
{
return d_points->size();
return (int) d_points->size();
}

//! Update the widget that represents the curve on the legend
Expand Down
6 changes: 5 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,11 @@ IF(NOT MSVC)
SET_SOURCE_FILES_PROPERTIES(qgsexpressionparser.cpp PROPERTIES COMPILE_FLAGS -w)
ELSE(NOT MSVC)
# -wd4702 unreachable code
SET_SOURCE_FILES_PROPERTIES(geometry/qgsgeos.cpp PROPERTIES COMPILE_FLAGS -wd4702)
SET_SOURCE_FILES_PROPERTIES(
geometry/qgsgeos.cpp
pal/feature.cpp
pal/pointset.cpp
PROPERTIES COMPILE_FLAGS -wd4702)
ENDIF(NOT MSVC)

SET(QGIS_CORE_MOC_HDRS
Expand Down
2 changes: 1 addition & 1 deletion src/core/dxf/qgsdxfexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3801,7 +3801,7 @@ int QgsDxfExport::closestColorMatch( QRgb pixel )
{
int idx = 0;
int current_distance = INT_MAX;
for ( size_t i = 1; i < sizeof( mDxfColors ) / sizeof( *mDxfColors ); ++i )
for ( int i = 1; i < ( int )( sizeof( mDxfColors ) / sizeof( *mDxfColors ) ); ++i )
{
int dist = color_distance( pixel, i );
if ( dist < current_distance )
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ QgsGeometry* QgsGeometry::fromRect( const QgsRectangle& rect )
return fromPolygon( polygon );
}

void QgsGeometry::fromWkb( unsigned char *wkb, size_t length )
void QgsGeometry::fromWkb( unsigned char *wkb, int length )
{
Q_UNUSED( length );

Expand Down Expand Up @@ -262,7 +262,7 @@ const unsigned char *QgsGeometry::asWkb() const
return d->mWkb;
}

size_t QgsGeometry::wkbSize() const
int QgsGeometry::wkbSize() const
{
if ( !d->geometry )
{
Expand Down
4 changes: 2 additions & 2 deletions src/core/geometry/qgsgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class CORE_EXPORT QgsGeometry
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
This class will take ownership of the buffer.
*/
void fromWkb( unsigned char * wkb, size_t length );
void fromWkb( unsigned char * wkb, int length );

/**
Returns the buffer containing this geometry in WKB format.
Expand All @@ -155,7 +155,7 @@ class CORE_EXPORT QgsGeometry
* Returns the size of the WKB in asWkb().
* @see asWkb
*/
size_t wkbSize() const;
int wkbSize() const;

/** Returns a geos geometry. QgsGeometry retains ownership of the geometry, so the returned object should not be deleted.
@param precision The precision of the grid to which to snap the geometry vertices. If 0, no snapping is performed.
Expand Down
3 changes: 2 additions & 1 deletion src/core/geometry/qgspointv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,9 @@ bool QgsPointV2::convertTo( QgsWKBTypes::Type type )
mWkbType = type;
return true;
default:
return false;
break;
}

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace pal
: PointSet( other )
, mLF( other.mLF )
{
Q_FOREACH ( FeaturePart* hole, other.mHoles )
Q_FOREACH ( const FeaturePart* hole, other.mHoles )
{
mHoles << new FeaturePart( *hole );
mHoles.last()->holeOf = this;
Expand Down
6 changes: 3 additions & 3 deletions src/core/pal/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ namespace pal
// Walk along line
unsigned int cur = 0;
double lambda = 0;
std::vector<Point> part;
QVector<Point> part;
for ( ;; )
{
lambda += chopInterval;
Expand All @@ -477,7 +477,7 @@ namespace pal
p.y = points[cur - 1].y + c * ( points[cur].y - points[cur - 1].y );
part.push_back( p );
GEOSCoordSequence* cooSeq = GEOSCoordSeq_create_r( geosctxt, part.size(), 2 );
for ( std::size_t i = 0; i < part.size(); ++i )
for ( int i = 0; i < part.size(); ++i )
{
GEOSCoordSeq_setX_r( geosctxt, cooSeq, i, part[i].x );
GEOSCoordSeq_setY_r( geosctxt, cooSeq, i, part[i].y );
Expand All @@ -494,7 +494,7 @@ namespace pal
// Create final part
part.push_back( points[n - 1] );
GEOSCoordSequence* cooSeq = GEOSCoordSeq_create_r( geosctxt, part.size(), 2 );
for ( std::size_t i = 0; i < part.size(); ++i )
for ( int i = 0; i < part.size(); ++i )
{
GEOSCoordSeq_setX_r( geosctxt, cooSeq, i, part[i].x );
GEOSCoordSeq_setY_r( geosctxt, cooSeq, i, part[i].y );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsexpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ class CORE_EXPORT QgsExpression
virtual QVariant eval( QgsExpression* parent, const QgsExpressionContext* context ) override;
virtual QString dump() const override;

virtual QStringList referencedColumns() const override { QStringList lst( mNode->referencedColumns() ); Q_FOREACH ( Node* n, mList->list() ) lst.append( n->referencedColumns() ); return lst; }
virtual QStringList referencedColumns() const override { QStringList lst( mNode->referencedColumns() ); Q_FOREACH ( const Node* n, mList->list() ) lst.append( n->referencedColumns() ); return lst; }
virtual bool needsGeometry() const override { bool needs = false; Q_FOREACH ( Node* n, mList->list() ) needs |= n->needsGeometry(); return needs; }
virtual void accept( Visitor& v ) const override { v.visit( *this ); }
virtual Node* clone() const override;
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void QgsFeature::setGeometry( QgsGeometry* geom )

/** Set the pointer to the feature geometry
*/
void QgsFeature::setGeometryAndOwnership( unsigned char *geom, size_t length )
void QgsFeature::setGeometryAndOwnership( unsigned char *geom, int length )
{
QgsGeometry *g = new QgsGeometry();
g->fromWkb( geom, length );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class CORE_EXPORT QgsFeature
* @see geometryAndOwnership
* @deprecated will be removed in QGIS 3.0
*/
Q_DECL_DEPRECATED void setGeometryAndOwnership( unsigned char * geom, size_t length );
Q_DECL_DEPRECATED void setGeometryAndOwnership( unsigned char * geom, int length );

/** Assign a field map with the feature to allow attribute access by attribute name.
* @param fields The attribute fields which this feature holds
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsgeometrysimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ bool QgsTopologyPreservingSimplifier::simplifyGeometry( QgsGeometry* geometry )

if ( g )
{
size_t wkbSize = g->wkbSize();
int wkbSize = g->wkbSize();
unsigned char* wkb = reinterpret_cast< unsigned char* >( malloc( wkbSize ) );
memcpy( wkb, g->asWkb(), wkbSize );
geometry->fromWkb( wkb, wkbSize );
Expand Down
36 changes: 18 additions & 18 deletions src/core/qgsmaptopixelgeometrysimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ float QgsMapToPixelSimplifier::calculateLengthSquared2D( double x1, double y1, d
}

//! Returns the BBOX of the specified WKB-point stream
inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, const unsigned char* wkb, size_t numPoints )
inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, const unsigned char* wkb, int numPoints )
{
double x, y;
QgsRectangle r;
Expand All @@ -50,7 +50,7 @@ inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, const un
int sizeOfDoubleX = sizeof( double );
int sizeOfDoubleY = ( QGis::wkbDimensions( wkbType ) - 1 ) * sizeof( double );

for ( size_t i = 0; i < numPoints; ++i )
for ( int i = 0; i < numPoints; ++i )
{
memcpy( &x, wkb, sizeof( double ) );
wkb += sizeOfDoubleX;
Expand All @@ -65,9 +65,9 @@ inline static QgsRectangle calculateBoundingBox( QGis::WkbType wkbType, const un
//! Generalize the WKB-geometry using the BBOX of the original geometry
static bool generalizeWkbGeometryByBoundingBox(
QGis::WkbType wkbType,
const unsigned char* sourceWkb, size_t sourceWkbSize,
unsigned char* targetWkb, size_t& targetWkbSize,
const QgsRectangle& envelope, bool writeHeader )
const unsigned char *sourceWkb, int sourceWkbSize,
unsigned char *targetWkb, int &targetWkbSize,
const QgsRectangle &envelope, bool writeHeader )
{
Q_UNUSED( sourceWkb );
unsigned char* wkb2 = targetWkb;
Expand All @@ -77,7 +77,7 @@ static bool generalizeWkbGeometryByBoundingBox(
int sizeOfDoubleY = sizeof( double ) * ( QGis::wkbDimensions( wkbType ) - 1 );

// If the geometry is already minimal skip the generalization
size_t minimumSize = geometryType == QGis::WKBLineString ? 4 + 2 * ( sizeOfDoubleX + sizeOfDoubleY ) : 8 + 5 * ( sizeOfDoubleX + sizeOfDoubleY );
int minimumSize = geometryType == QGis::WKBLineString ? 4 + 2 * ( sizeOfDoubleX + sizeOfDoubleY ) : 8 + 5 * ( sizeOfDoubleX + sizeOfDoubleY );

if ( writeHeader )
minimumSize += 5;
Expand Down Expand Up @@ -167,9 +167,9 @@ static bool generalizeWkbGeometryByBoundingBox(
//! Simplify the WKB-geometry using the specified tolerance
bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
int simplifyFlags, QGis::WkbType wkbType,
const unsigned char* sourceWkb, size_t sourceWkbSize,
unsigned char* targetWkb, size_t& targetWkbSize,
const QgsRectangle& envelope, double map2pixelTol,
const unsigned char *sourceWkb, int sourceWkbSize,
unsigned char *targetWkb, int &targetWkbSize,
const QgsRectangle &envelope, double map2pixelTol,
bool writeHeader, bool isaLinearRing )
{
bool isGeneralizable = true;
Expand All @@ -178,7 +178,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
// Save initial WKB settings to use when the simplification creates invalid geometries
const unsigned char* sourcePrevWkb = sourceWkb;
unsigned char* targetPrevWkb = targetWkb;
size_t targetWkbPrevSize = targetWkbSize;
int targetWkbPrevSize = targetWkbSize;

// Can replace the geometry by its BBOX ?
if (( simplifyFlags & QgsMapToPixelSimplifier::SimplifyEnvelope ) &&
Expand Down Expand Up @@ -296,7 +296,7 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
// approximate the geometry's shape by its bounding box
// (rect for linear ring / one segment for line string)
unsigned char* targetTempWkb = targetWkb;
size_t targetWkbTempSize = targetWkbSize;
int targetWkbTempSize = targetWkbSize;

sourceWkb = sourcePrevWkb;
targetWkb = targetPrevWkb;
Expand Down Expand Up @@ -352,8 +352,8 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(
memcpy( &numPoints_i, sourceWkb, 4 );
QgsRectangle envelope_i = numRings == 1 ? envelope : calculateBoundingBox( wkbType, sourceWkb + 4, numPoints_i );

size_t sourceWkbSize_i = 4 + numPoints_i * QGis::wkbDimensions( wkbType ) * sizeof( double );
size_t targetWkbSize_i = 0;
int sourceWkbSize_i = 4 + numPoints_i * QGis::wkbDimensions( wkbType ) * sizeof( double );
int targetWkbSize_i = 0;

result |= simplifyWkbGeometry( simplifyFlags, wkbType, sourceWkb, sourceWkbSize_i, targetWkb, targetWkbSize_i, envelope_i, map2pixelTol, false, true );
sourceWkb += sourceWkbSize_i;
Expand All @@ -375,8 +375,8 @@ bool QgsMapToPixelSimplifier::simplifyWkbGeometry(

for ( int i = 0; i < numGeoms; ++i )
{
size_t sourceWkbSize_i = 0;
size_t targetWkbSize_i = 0;
int sourceWkbSize_i = 0;
int targetWkbSize_i = 0;

// ... calculate the wkb-size of the current child complex geometry
if ( flatType == QGis::WKBMultiLineString )
Expand Down Expand Up @@ -429,7 +429,7 @@ QgsGeometry* QgsMapToPixelSimplifier::simplify( QgsGeometry* geometry ) const
{
QgsGeometry* g = new QgsGeometry();

size_t wkbSize = geometry->wkbSize();
int wkbSize = geometry->wkbSize();
unsigned char* wkb = reinterpret_cast< unsigned char* >( malloc( wkbSize ) );
memcpy( wkb, geometry->asWkb(), wkbSize );
g->fromWkb( wkb, wkbSize );
Expand All @@ -441,7 +441,7 @@ QgsGeometry* QgsMapToPixelSimplifier::simplify( QgsGeometry* geometry ) const
//! Simplifies the geometry (Removing duplicated points) when is applied the specified map2pixel context
bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry* geometry, int simplifyFlags, double tolerance )
{
size_t finalWkbSize = 0;
int finalWkbSize = 0;

// Check whether the geometry can be simplified using the map2pixel context
QGis::GeometryType geometryType = geometry->type();
Expand All @@ -452,7 +452,7 @@ bool QgsMapToPixelSimplifier::simplifyGeometry( QgsGeometry* geometry, int simpl
QGis::WkbType wkbType = geometry->wkbType();

const unsigned char* wkb = geometry->asWkb();
size_t wkbSize = geometry->wkbSize();
int wkbSize = geometry->wkbSize();

unsigned char* targetWkb = new unsigned char[wkbSize];
memcpy( targetWkb, wkb, wkbSize );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmaptopixelgeometrysimplifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CORE_EXPORT QgsMapToPixelSimplifier : public QgsAbstractGeometrySimplifier

private:
//! Simplify the WKB-geometry using the specified tolerance
static bool simplifyWkbGeometry( int simplifyFlags, QGis::WkbType wkbType, const unsigned char* sourceWkb, size_t sourceWkbSize, unsigned char* targetWkb, size_t& targetWkbSize, const QgsRectangle& envelope, double map2pixelTol, bool writeHeader = true, bool isaLinearRing = false );
static bool simplifyWkbGeometry( int simplifyFlags, QGis::WkbType wkbType, const unsigned char* sourceWkb, int sourceWkbSize, unsigned char* targetWkb, int &targetWkbSize, const QgsRectangle& envelope, double map2pixelTol, bool writeHeader = true, bool isaLinearRing = false );

protected:
//! Current simplification flags
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/dxf2shp_converter/builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ void Builder::addArc( const DL_ArcData& data )

// Finalize

int dim = arcPoints.size();
int dim = ( int ) arcPoints.size();
QVector<double> xv( dim );
QVector<double> yv( dim );
QVector<double> zv( dim );
Expand Down Expand Up @@ -325,7 +325,7 @@ void Builder::addCircle( const DL_CircleData& data )
circlePoints.push_back( myPoint );
}

int dim = circlePoints.size();
int dim = ( int ) circlePoints.size();
QVector<double> xv( dim );
QVector<double> yv( dim );
QVector<double> zv( dim );
Expand Down
Loading

0 comments on commit 71dc339

Please sign in to comment.