c++11 : use int types from <cstdint>

This commit is contained in:
artemp 2014-05-06 18:06:47 +01:00
parent 7bf50e9b5b
commit 99bbb10290
15 changed files with 91 additions and 101 deletions

View file

@ -58,12 +58,12 @@ void grid2utf(T const& grid_type,
keys_type keys;
// start counting at utf8 codepoint 32, aka space character
boost::uint16_t codepoint = 32;
std::uint16_t codepoint = 32;
unsigned array_size = data.width();
for (unsigned y = 0; y < data.height(); ++y)
{
boost::uint16_t idx = 0;
std::uint16_t idx = 0;
const std::unique_ptr<Py_UNICODE[]> line(new Py_UNICODE[array_size]);
typename T::value_type const* row = data.getRow(y);
for (unsigned x = 0; x < data.width(); ++x)
@ -121,12 +121,12 @@ void grid2utf(T const& grid_type,
keys_type keys;
// start counting at utf8 codepoint 32, aka space character
boost::uint16_t codepoint = 32;
std::uint16_t codepoint = 32;
unsigned array_size = std::ceil(grid_type.width()/static_cast<float>(resolution));
for (unsigned y = 0; y < grid_type.height(); y=y+resolution)
{
boost::uint16_t idx = 0;
std::uint16_t idx = 0;
const std::unique_ptr<Py_UNICODE[]> line(new Py_UNICODE[array_size]);
mapnik::grid::value_type const* row = grid_type.getRow(y);
for (unsigned x = 0; x < grid_type.width(); x=x+resolution)

View file

@ -28,11 +28,11 @@
#include <mapnik/global.hpp>
//boost
#include <boost/cstdint.hpp>
#include <boost/operators.hpp>
// stl
#include <sstream>
#include <cstdint>
namespace mapnik {
@ -40,10 +40,10 @@ class MAPNIK_DECL color
: boost::equality_comparable<color>
{
private:
boost::uint8_t red_;
boost::uint8_t green_;
boost::uint8_t blue_;
boost::uint8_t alpha_;
std::uint8_t red_;
std::uint8_t green_;
std::uint8_t blue_;
std::uint8_t alpha_;
public:
color()
@ -53,7 +53,7 @@ public:
alpha_(0xff)
{}
color(boost::uint8_t red, boost::uint8_t green, boost::uint8_t blue, boost::uint8_t alpha = 0xff)
color(std::uint8_t red, std::uint8_t green, std::uint8_t blue, std::uint8_t alpha = 0xff)
: red_(red),
green_(green),
blue_(blue),
@ -88,38 +88,38 @@ public:
(alpha_ == rhs.alpha());
}
inline boost::uint8_t red() const
inline std::uint8_t red() const
{
return red_;
}
inline boost::uint8_t green() const
inline std::uint8_t green() const
{
return green_;
}
inline boost::uint8_t blue() const
inline std::uint8_t blue() const
{
return blue_;
}
inline boost::uint8_t alpha() const
inline std::uint8_t alpha() const
{
return alpha_;
}
inline void set_red(boost::uint8_t red)
inline void set_red(std::uint8_t red)
{
red_ = red;
}
inline void set_green(boost::uint8_t green)
inline void set_green(std::uint8_t green)
{
green_ = green;
}
inline void set_blue(boost::uint8_t blue)
inline void set_blue(std::uint8_t blue)
{
blue_ = blue;
}
inline void set_alpha(boost::uint8_t alpha)
inline void set_alpha(std::uint8_t alpha)
{
alpha_ = alpha;
}

View file

@ -24,10 +24,10 @@
#define MAPNIK_GLOBAL_HPP
// boost
#include <boost/cstdint.hpp>
#include <boost/detail/endian.hpp>
// stl
#include <cstdint>
#include <cstring>
#include <cmath>
@ -38,24 +38,24 @@ namespace mapnik
#define MAPNIK_BIG_ENDIAN
#endif
#define int2net(A) (int16_t) (((boost::uint16_t) ((boost::uint8_t) (A)[1])) | \
(((boost::uint16_t) ((boost::uint8_t) (A)[0])) << 8))
#define int2net(A) (int16_t) (((std::uint16_t) ((std::uint8_t) (A)[1])) | \
(((std::uint16_t) ((std::uint8_t) (A)[0])) << 8))
#define int4net(A) (int32_t) (((boost::uint32_t) ((boost::uint8_t) (A)[3])) | \
(((boost::uint32_t) ((boost::uint8_t) (A)[2])) << 8) | \
(((boost::uint32_t) ((boost::uint8_t) (A)[1])) << 16) | \
(((boost::uint32_t) ((boost::uint8_t) (A)[0])) << 24))
#define int4net(A) (int32_t) (((std::uint32_t) ((std::uint8_t) (A)[3])) | \
(((std::uint32_t) ((std::uint8_t) (A)[2])) << 8) | \
(((std::uint32_t) ((std::uint8_t) (A)[1])) << 16) | \
(((std::uint32_t) ((std::uint8_t) (A)[0])) << 24))
#define int8net(A) (int64_t) (((boost::uint64_t) ((boost::uint8_t) (A)[7])) | \
(((boost::uint64_t) ((boost::uint8_t) (A)[6])) << 8) | \
(((boost::uint64_t) ((boost::uint8_t) (A)[5])) << 16) | \
(((boost::uint64_t) ((boost::uint8_t) (A)[4])) << 24) | \
(((boost::uint64_t) ((boost::uint8_t) (A)[3])) << 32) | \
(((boost::uint64_t) ((boost::uint8_t) (A)[2])) << 40) | \
(((boost::uint64_t) ((boost::uint8_t) (A)[1])) << 48) | \
(((boost::uint64_t) ((boost::uint8_t) (A)[0])) << 56))
#define int8net(A) (int64_t) (((std::uint64_t) ((std::uint8_t) (A)[7])) | \
(((std::uint64_t) ((std::uint8_t) (A)[6])) << 8) | \
(((std::uint64_t) ((std::uint8_t) (A)[5])) << 16) | \
(((std::uint64_t) ((std::uint8_t) (A)[4])) << 24) | \
(((std::uint64_t) ((std::uint8_t) (A)[3])) << 32) | \
(((std::uint64_t) ((std::uint8_t) (A)[2])) << 40) | \
(((std::uint64_t) ((std::uint8_t) (A)[1])) << 48) | \
(((std::uint64_t) ((std::uint8_t) (A)[0])) << 56))
typedef boost::uint8_t byte;
typedef std::uint8_t byte;
#define float8net(V,M) do { double def_temp; \
((byte*) &def_temp)[0]=(M)[7]; \
((byte*) &def_temp)[1]=(M)[6]; \
@ -75,7 +75,7 @@ typedef boost::uint8_t byte;
// read int16_t NDR (little endian)
inline void read_int16_ndr(const char* data, boost::int16_t & val)
inline void read_int16_ndr(const char* data, std::int16_t & val)
{
#ifndef MAPNIK_BIG_ENDIAN
std::memcpy(&val,data,2);
@ -86,7 +86,7 @@ inline void read_int16_ndr(const char* data, boost::int16_t & val)
}
// read int32_t NDR (little endian)
inline void read_int32_ndr(const char* data, boost::int32_t & val)
inline void read_int32_ndr(const char* data, std::int32_t & val)
{
#ifndef MAPNIK_BIG_ENDIAN
std::memcpy(&val,data,4);
@ -104,30 +104,30 @@ inline void read_double_ndr(const char* data, double & val)
#ifndef MAPNIK_BIG_ENDIAN
std::memcpy(&val,&data[0],8);
#else
boost::int64_t bits = ((boost::int64_t)data[0] & 0xff) |
((boost::int64_t)data[1] & 0xff) << 8 |
((boost::int64_t)data[2] & 0xff) << 16 |
((boost::int64_t)data[3] & 0xff) << 24 |
((boost::int64_t)data[4] & 0xff) << 32 |
((boost::int64_t)data[5] & 0xff) << 40 |
((boost::int64_t)data[6] & 0xff) << 48 |
((boost::int64_t)data[7] & 0xff) << 56 ;
std::int64_t bits = ((std::int64_t)data[0] & 0xff) |
((std::int64_t)data[1] & 0xff) << 8 |
((std::int64_t)data[2] & 0xff) << 16 |
((std::int64_t)data[3] & 0xff) << 24 |
((std::int64_t)data[4] & 0xff) << 32 |
((std::int64_t)data[5] & 0xff) << 40 |
((std::int64_t)data[6] & 0xff) << 48 |
((std::int64_t)data[7] & 0xff) << 56 ;
std::memcpy(&val,&bits,8);
#endif
}
// read int16_t XDR (big endian)
inline void read_int16_xdr(const char* data, boost::int16_t & val)
inline void read_int16_xdr(const char* data, std::int16_t & val)
{
#ifndef MAPNIK_BIG_ENDIAN
val = static_cast<boost::int16_t>((data[3]&0xff) | ((data[2]&0xff)<<8));
val = static_cast<std::int16_t>((data[3]&0xff) | ((data[2]&0xff)<<8));
#else
std::memcpy(&val,data,2);
#endif
}
// read int32_t XDR (big endian)
inline void read_int32_xdr(const char* data, boost::int32_t & val)
inline void read_int32_xdr(const char* data, std::int32_t & val)
{
#ifndef MAPNIK_BIG_ENDIAN
val = (data[3]&0xff) | ((data[2]&0xff)<<8) | ((data[1]&0xff)<<16) | ((data[0]&0xff)<<24);
@ -140,14 +140,14 @@ inline void read_int32_xdr(const char* data, boost::int32_t & val)
inline void read_double_xdr(const char* data, double & val)
{
#ifndef MAPNIK_BIG_ENDIAN
boost::int64_t bits = ((boost::int64_t)data[7] & 0xff) |
((boost::int64_t)data[6] & 0xff) << 8 |
((boost::int64_t)data[5] & 0xff) << 16 |
((boost::int64_t)data[4] & 0xff) << 24 |
((boost::int64_t)data[3] & 0xff) << 32 |
((boost::int64_t)data[2] & 0xff) << 40 |
((boost::int64_t)data[1] & 0xff) << 48 |
((boost::int64_t)data[0] & 0xff) << 56 ;
std::int64_t bits = ((std::int64_t)data[7] & 0xff) |
((std::int64_t)data[6] & 0xff) << 8 |
((std::int64_t)data[5] & 0xff) << 16 |
((std::int64_t)data[4] & 0xff) << 24 |
((std::int64_t)data[3] & 0xff) << 32 |
((std::int64_t)data[2] & 0xff) << 40 |
((std::int64_t)data[1] & 0xff) << 48 |
((std::int64_t)data[0] & 0xff) << 56 ;
std::memcpy(&val,&bits,8);
#else
std::memcpy(&val,&data[0],8);

View file

@ -35,7 +35,7 @@
#include <mapnik/util/conversions.hpp>
// boost
#include <boost/cstdint.hpp>
#include <cstdint>
// stl
#include <map>

View file

@ -31,7 +31,7 @@
#include <mapnik/datasource.hpp> // for feature_ptr
// boost
#include <boost/cstdint.hpp>
#include <cstdint>
// stl
#include <map>

View file

@ -83,9 +83,9 @@ class octree : private mapnik::noncopyable
return count == 0;
}
node * children_[8];
boost::uint64_t reds;
boost::uint64_t greens;
boost::uint64_t blues;
std::uint64_t reds;
std::uint64_t greens;
std::uint64_t blues;
unsigned count;
double reduce_cost;
unsigned count_cum;

View file

@ -56,7 +56,6 @@
namespace mapnik {
typedef boost::uint8_t byte;
struct rgba;
struct rgb {
@ -142,4 +141,3 @@ private:
} // namespace mapnik
#endif // MAPNIK_PALETTE_HPP

View file

@ -20,10 +20,10 @@
*
*****************************************************************************/
#include <boost/cstdint.hpp>
#include <cstdint>
#include "agg_span_image_filter_rgba.h"
namespace mapnik {
namespace mapnik {
using namespace agg;
@ -71,7 +71,7 @@ public:
(diameter * base_type::m_rx + image_subpixel_mask) >>
image_subpixel_shift;
const boost::int16_t* weight_array = base_type::filter().weight_array();
const std::int16_t* weight_array = base_type::filter().weight_array();
do
{
@ -104,7 +104,7 @@ public:
int weight = (weight_y * weight_array[x_hr] +
image_filter_scale / 2) >>
downscale_shift;
fg[0] += *fg_ptr++ * weight;
fg[1] += *fg_ptr++ * weight;
fg[2] += *fg_ptr++ * weight;
@ -144,7 +144,7 @@ public:
if(fg[order_type::G] > base_mask) fg[order_type::G] = base_mask;
if(fg[order_type::B] > base_mask) fg[order_type::B] = base_mask;
if(fg[order_type::A] > base_mask) fg[order_type::A] = base_mask;
span->r = (value_type)fg[order_type::R];
span->g = (value_type)fg[order_type::G];
span->b = (value_type)fg[order_type::B];

View file

@ -31,10 +31,8 @@
#include <mapnik/value_types.hpp>
#include <unicode/ucnv.h>
// boost
#include <boost/cstdint.hpp>
// stl
#include <cstdint>
#include <string>
namespace mapnik {
@ -43,7 +41,7 @@ class MAPNIK_DECL transcoder : private mapnik::noncopyable
{
public:
explicit transcoder (std::string const& encoding);
mapnik::value_unicode_string transcode(const char* data, boost::int32_t length = -1) const;
mapnik::value_unicode_string transcode(const char* data, std::int32_t length = -1) const;
~transcoder();
private:
bool ok_;

View file

@ -35,9 +35,6 @@
#include <mapnik/util/trim.hpp>
#include <mapnik/global.hpp> // for int2net
// boost
#include <boost/cstdint.hpp> // for boost::int16_t
// stl
#include <sstream>
#include <string>
@ -232,12 +229,12 @@ postgis_featureset::~postgis_featureset()
std::string numeric2string(const char* buf)
{
boost::int16_t ndigits = int2net(buf);
boost::int16_t weight = int2net(buf+2);
boost::int16_t sign = int2net(buf+4);
boost::int16_t dscale = int2net(buf+6);
std::int16_t ndigits = int2net(buf);
std::int16_t weight = int2net(buf+2);
std::int16_t sign = int2net(buf+4);
std::int16_t dscale = int2net(buf+6);
const std::unique_ptr<boost::int16_t[]> digits(new boost::int16_t[ndigits]);
const std::unique_ptr<std::int16_t[]> digits(new std::int16_t[ndigits]);
for (int n=0; n < ndigits ;++n)
{
digits[n] = int2net(buf+8+n*2);
@ -247,7 +244,7 @@ std::string numeric2string(const char* buf)
if (sign == 0x4000) ss << "-";
int i = std::max(weight,boost::int16_t(0));
int i = std::max(weight,std::int16_t(0));
int d = 0;
// Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field.

View file

@ -30,13 +30,13 @@
// boost
#include <boost/spirit/include/qi.hpp>
#include <boost/cstdint.hpp> // for int16_t and int32_t
#ifdef SHAPE_MEMORY_MAPPED_FILE
#include <boost/interprocess/mapped_region.hpp>
#include <mapnik/mapped_memory_cache.hpp>
#endif
// stl
#include <cstdint>
#include <string>
#include <cstring>
#include <stdexcept>
@ -257,7 +257,7 @@ int dbf_file::read_short()
{
char b[2];
file_.read(b,2);
boost::int16_t val;
std::int16_t val;
mapnik::read_int16_ndr(b,val);
return val;
}
@ -267,7 +267,7 @@ int dbf_file::read_int()
{
char b[4];
file_.read(b,4);
boost::int32_t val;
std::int32_t val;
mapnik::read_int32_ndr(b,val);
return val;
}

View file

@ -27,7 +27,7 @@
#include <cstring>
#include <fstream>
#include <stdexcept>
#include <cstdint>
// mapnik
#include <mapnik/global.hpp>
@ -40,9 +40,6 @@
#endif
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/cstdint.hpp>
using mapnik::box2d;
using mapnik::read_int32_ndr;
using mapnik::read_int32_xdr;
@ -106,7 +103,7 @@ struct shape_record
int read_ndr_integer()
{
boost::int32_t val;
std::int32_t val;
read_int32_ndr(&data[pos], val);
pos += 4;
return val;
@ -114,7 +111,7 @@ struct shape_record
int read_xdr_integer()
{
boost::int32_t val;
std::int32_t val;
read_int32_xdr(&data[pos], val);
pos += 4;
return val;
@ -206,7 +203,7 @@ public:
{
char b[4];
file_.read(b, 4);
boost::int32_t val;
std::int32_t val;
read_int32_xdr(b, val);
return val;
}
@ -215,7 +212,7 @@ public:
{
char b[4];
file_.read(b, 4);
boost::int32_t val;
std::int32_t val;
read_int32_ndr(b, val);
return val;
}

View file

@ -40,7 +40,7 @@ transcoder::transcoder (std::string const& encoding)
// TODO ??
}
mapnik::value_unicode_string transcoder::transcode(const char* data, boost::int32_t length) const
mapnik::value_unicode_string transcoder::transcode(const char* data, std::int32_t length) const
{
UErrorCode err = U_ZERO_ERROR;

View file

@ -215,7 +215,7 @@ private:
int read_integer()
{
boost::int32_t n;
std::int32_t n;
if (needSwap_)
{
read_int32_xdr(wkb_ + pos_, n);

View file

@ -34,22 +34,22 @@
#include "cursorresultset.hpp"
// boost
#include <boost/cstdint.hpp>
#include <boost/algorithm/string.hpp>
//stl
//st
#include <cstdint>
#include <iostream>
#include <fstream>
#include <memory>
static std::string numeric2string(const char* buf)
{
boost::int16_t ndigits = int2net(buf);
boost::int16_t weight = int2net(buf+2);
boost::int16_t sign = int2net(buf+4);
boost::int16_t dscale = int2net(buf+6);
std::int16_t ndigits = int2net(buf);
std::int16_t weight = int2net(buf+2);
std::int16_t sign = int2net(buf+4);
std::int16_t dscale = int2net(buf+6);
const std::unique_ptr<boost::int16_t[]> digits(new boost::int16_t[ndigits]);
const std::unique_ptr<std::int16_t[]> digits(new std::int16_t[ndigits]);
for (int n=0; n < ndigits ;++n)
{
digits[n] = int2net(buf+8+n*2);
@ -59,7 +59,7 @@ static std::string numeric2string(const char* buf)
if (sign == 0x4000) ss << "-";
int i = std::max(weight,boost::int16_t(0));
int i = std::max(weight,std::int16_t(0));
int d = 0;
// Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field.