Skip to content
This repository

Compile time support for 64-bit integers in mapnik::value #1661

Merged
merged 15 commits into from over 1 year ago

2 participants

Artem Pavlenko Dane Springmeyer
Artem Pavlenko
Owner

#define BIGINT to support long long otherwise default to int for mapnik::value_integer

Dane Springmeyer

@artemp - can you explain the LL here?

Owner

@springmeyer - I changed it to be mapnik::value_integer(4) in e331566

Artem Pavlenko artemp merged commit da0c99b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 27 changed files with 260 additions and 183 deletions. Show diff stats Hide diff stats

  1. +1 1  bindings/python/mapnik_datasource.cpp
  2. +1 1  bindings/python/mapnik_datasource_cache.cpp
  3. +4 4 bindings/python/mapnik_feature.cpp
  4. +2 2 bindings/python/mapnik_parameters.cpp
  5. +1 1  bindings/python/mapnik_value_converter.hpp
  6. +2 2 include/mapnik/attribute.hpp
  7. +8 1 include/mapnik/expression_grammar.hpp
  8. +4 2 include/mapnik/json/feature_generator_grammar.hpp
  9. +6 2 include/mapnik/json/feature_grammar.hpp
  10. +1 1  include/mapnik/params.hpp
  11. +3 0  include/mapnik/util/conversions.hpp
  12. +147 105 include/mapnik/value.hpp
  13. +3 3 plugins/input/csv/csv_datasource.cpp
  14. +2 2 plugins/input/gdal/gdal_featureset.cpp
  15. +13 13 plugins/input/geojson/geojson_datasource.cpp
  16. +1 1  plugins/input/ogr/ogr_featureset.cpp
  17. +1 1  plugins/input/ogr/ogr_index_featureset.cpp
  18. +6 10 plugins/input/postgis/postgis_featureset.cpp
  19. +1 1  plugins/input/shape/dbfile.cpp
  20. +1 1  plugins/input/sqlite/sqlite_featureset.cpp
  21. +22 0 src/conversions.cpp
  22. +7 7 src/expression_grammar.cpp
  23. +2 2 src/json/feature_grammar.cpp
  24. +2 2 src/load_map.cpp
  25. +2 2 src/save_map.cpp
  26. +3 2 src/xml_tree.cpp
  27. +14 14 tests/cpp_tests/params_test.cpp
2  bindings/python/mapnik_datasource.cpp
@@ -57,7 +57,7 @@ boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
57 57 std::string key = extract<std::string>(keys[i]);
58 58 object obj = d[key];
59 59 extract<std::string> ex0(obj);
60   - extract<int> ex1(obj);
  60 + extract<mapnik::value_integer> ex1(obj);
61 61 extract<double> ex2(obj);
62 62 if (ex0.check())
63 63 {
2  bindings/python/mapnik_datasource_cache.cpp
@@ -38,7 +38,7 @@ boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
38 38 std::string key = extract<std::string>(keys[i]);
39 39 object obj = d[key];
40 40 extract<std::string> ex0(obj);
41   - extract<int> ex1(obj);
  41 + extract<mapnik::value_integer> ex1(obj);
42 42 extract<double> ex2(obj);
43 43
44 44 if (ex0.check())
8 bindings/python/mapnik_feature.cpp
@@ -196,11 +196,11 @@ void export_feature()
196 196 // Python to mapnik::value converters
197 197 // NOTE: order matters here. For example value_null must be listed before
198 198 // bool otherwise Py_None will be interpreted as bool (false)
199   - implicitly_convertible<UnicodeString,mapnik::value>();
  199 + implicitly_convertible<mapnik::value_unicode_string,mapnik::value>();
200 200 implicitly_convertible<mapnik::value_null,mapnik::value>();
201   - implicitly_convertible<int,mapnik::value>();
202   - implicitly_convertible<bool,mapnik::value>();
203   - implicitly_convertible<double,mapnik::value>();
  201 + implicitly_convertible<mapnik::value_integer,mapnik::value>();
  202 + implicitly_convertible<mapnik::value_double,mapnik::value>();
  203 + implicitly_convertible<mapnik::value_bool,mapnik::value>();
204 204
205 205 // http://misspent.wordpress.com/2009/09/27/how-to-write-boost-python-converters/
206 206 UnicodeString_from_python_str();
4 bindings/python/mapnik_parameters.cpp
@@ -78,7 +78,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
78 78 std::string key = extract<std::string>(keys[i]);
79 79 object obj = d[key];
80 80 extract<std::string> ex0(obj);
81   - extract<int> ex1(obj);
  81 + extract<mapnik::value_integer> ex1(obj);
82 82 extract<double> ex2(obj);
83 83 extract<UnicodeString> ex3(obj);
84 84
@@ -185,7 +185,7 @@ boost::shared_ptr<mapnik::parameter> create_parameter_from_string(std::string co
185 185 return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
186 186 }
187 187
188   -boost::shared_ptr<mapnik::parameter> create_parameter_from_int(std::string const& key, int value)
  188 +boost::shared_ptr<mapnik::parameter> create_parameter_from_int(std::string const& key, mapnik::value_integer value)
189 189 {
190 190 return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
191 191 }
2  bindings/python/mapnik_value_converter.hpp
@@ -30,7 +30,7 @@ namespace boost { namespace python {
30 30
31 31 struct value_converter : public boost::static_visitor<PyObject*>
32 32 {
33   - PyObject * operator() (int val) const
  33 + PyObject * operator() (mapnik::value_integer val) const
34 34 {
35 35 #if PY_VERSION_HEX >= 0x03000000
36 36 return ::PyLong_FromLong(val);
4 include/mapnik/attribute.hpp
@@ -52,14 +52,14 @@ struct geometry_type_attribute
52 52 template <typename V, typename F>
53 53 V value(F const& f) const
54 54 {
55   - int type = 0;
  55 + mapnik::value_integer type = 0;
56 56 geometry_container::const_iterator itr = f.paths().begin();
57 57 geometry_container::const_iterator end = f.paths().end();
58 58 for ( ; itr != end; ++itr)
59 59 {
60 60 if (type != 0 && itr->type() != type)
61 61 {
62   - return 4; // Collection
  62 + return value_integer(4); // Collection
63 63 }
64 64 type = itr->type();
65 65 }
9 include/mapnik/expression_grammar.hpp
@@ -108,7 +108,7 @@ struct regex_replace_impl
108 108 mapnik::transcoder const& tr_;
109 109 };
110 110
111   -struct geometry_types : qi::symbols<char,int>
  111 +struct geometry_types : qi::symbols<char,mapnik::value_integer>
112 112 {
113 113 geometry_types()
114 114 {
@@ -121,6 +121,12 @@ struct geometry_types : qi::symbols<char,int>
121 121 }
122 122 };
123 123
  124 +template <typename T>
  125 +struct integer_parser
  126 +{
  127 + typedef qi::int_parser<T,10,1,-1> type;
  128 +};
  129 +
124 130 template <typename Iterator>
125 131 struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
126 132 {
@@ -129,6 +135,7 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
129 135 explicit expression_grammar(mapnik::transcoder const& tr);
130 136
131 137 qi::real_parser<double, qi::strict_real_policies<double> > strict_double;
  138 + typename integer_parser<mapnik::value_integer>::type int__;
132 139 boost::phoenix::function<unicode_impl> unicode_;
133 140 boost::phoenix::function<regex_match_impl> regex_match_;
134 141 boost::phoenix::function<regex_replace_impl> regex_replace_;
6 include/mapnik/json/feature_generator_grammar.hpp
@@ -186,7 +186,8 @@ struct feature_generator_grammar:
186 186 using boost::spirit::karma::lit;
187 187 using boost::spirit::karma::uint_;
188 188 using boost::spirit::karma::bool_;
189   - using boost::spirit::karma::int_;
  189 + //using boost::spirit::karma::int_;
  190 + //using boost::spirit::karma::long_long;
190 191 using boost::spirit::karma::double_;
191 192 using boost::spirit::karma::_val;
192 193 using boost::spirit::karma::_1;
@@ -212,7 +213,7 @@ struct feature_generator_grammar:
212 213 << value(phoenix::at_c<1>(_val))
213 214 ;
214 215
215   - value = (value_null_| bool_ | int_| double_ | ustring)[_1 = value_base_(_r1)]
  216 + value = (value_null_| bool_ | int__ | double_ | ustring)[_1 = value_base_(_r1)]
216 217 ;
217 218
218 219 value_null_ = string[_1 = "null"]
@@ -231,6 +232,7 @@ struct feature_generator_grammar:
231 232 karma::rule<OutputIterator, void(mapnik::value const&)> value;
232 233 karma::rule<OutputIterator, mapnik::value_null()> value_null_;
233 234 karma::rule<OutputIterator, UnicodeString()> ustring;
  235 + typename karma::int_generator<mapnik::value_integer,10, false> int__;
234 236 // phoenix functions
235 237 phoenix::function<get_id> id_;
236 238 phoenix::function<value_base> value_base_;
8 include/mapnik/json/feature_grammar.hpp
@@ -29,6 +29,7 @@
29 29
30 30 // spirit::qi
31 31 #include <boost/config/warning_disable.hpp>
  32 +#include <boost/cstdint.hpp>
32 33 #include <boost/spirit/include/qi.hpp>
33 34 #include <boost/spirit/include/phoenix.hpp>
34 35 #include <boost/variant/apply_visitor.hpp>
@@ -59,6 +60,7 @@ class attribute_value_visitor
59 60 {
60 61 return mapnik::value(val);
61 62 }
  63 +
62 64 mapnik::transcoder const& tr_;
63 65 };
64 66
@@ -109,9 +111,11 @@ struct feature_grammar :
109 111 qi::rule<Iterator,space_type> value;
110 112 qi::symbols<char const, char const> unesc_char;
111 113 qi::uint_parser< unsigned, 16, 4, 4 > hex4 ;
  114 + qi::int_parser<mapnik::value_integer,10,1,-1> int__;
112 115 qi::rule<Iterator,std::string(), space_type> string_;
113 116 qi::rule<Iterator,space_type> key_value;
114   - qi::rule<Iterator,boost::variant<value_null,bool,int,double>(),space_type> number;
  117 + qi::rule<Iterator,boost::variant<value_null,bool,
  118 + value_integer,value_double>(),space_type> number;
115 119 qi::rule<Iterator,space_type> object;
116 120 qi::rule<Iterator,space_type> array;
117 121 qi::rule<Iterator,space_type> pairs;
@@ -123,7 +127,7 @@ struct feature_grammar :
123 127
124 128 qi::rule<Iterator,void(FeatureType &),space_type> properties;
125 129 qi::rule<Iterator,qi::locals<std::string>, void(FeatureType &),space_type> attributes;
126   - qi::rule<Iterator,boost::variant<value_null,bool,int,double,std::string>(), space_type> attribute_value;
  130 + qi::rule<Iterator,boost::variant<value_null,bool,value_integer,value_double,std::string>(), space_type> attribute_value;
127 131
128 132 phoenix::function<put_property> put_property_;
129 133 phoenix::function<extract_geometry> extract_geometry_;
2  include/mapnik/params.hpp
@@ -38,7 +38,7 @@
38 38
39 39 namespace mapnik
40 40 {
41   -typedef boost::variant<value_null,int,double,std::string> value_holder;
  41 +typedef boost::variant<value_null,value_integer,value_double,std::string> value_holder;
42 42 typedef std::pair<std::string, value_holder> parameter;
43 43 typedef std::map<std::string, value_holder> param_map;
44 44
3  include/mapnik/util/conversions.hpp
@@ -50,6 +50,9 @@ namespace mapnik { namespace util {
50 50 MAPNIK_DECL bool string2int(const char * value, int & result);
51 51 MAPNIK_DECL bool string2int(std::string const& value, int & result);
52 52
  53 +MAPNIK_DECL bool string2longlong(const char * value, boost::long_long_type & result);
  54 +MAPNIK_DECL bool string2longlong(std::string const& value, boost::long_long_type & result);
  55 +
53 56 MAPNIK_DECL bool string2double(std::string const& value, double & result);
54 57 MAPNIK_DECL bool string2double(const char * value, double & result);
55 58
252 include/mapnik/value.hpp
@@ -107,7 +107,19 @@ struct value_null
107 107 }
108 108 };
109 109
110   -typedef boost::variant<value_null,bool,int,double,UnicodeString> value_base;
  110 +#define BIGINT
  111 +
  112 +#ifdef BIGINT
  113 +typedef long long value_integer;
  114 +#else
  115 +typedef int value_integer;
  116 +#endif
  117 +
  118 +typedef double value_double;
  119 +typedef UnicodeString value_unicode_string;
  120 +typedef bool value_bool;
  121 +
  122 +typedef boost::variant<value_null,value_bool,value_integer,value_double,value_unicode_string> value_base;
111 123
112 124 namespace impl {
113 125
@@ -126,18 +138,18 @@ struct equals
126 138 return lhs == rhs;
127 139 }
128 140
129   - bool operator() (int lhs, double rhs) const
  141 + bool operator() (value_integer lhs, value_double rhs) const
130 142 {
131 143 return lhs == rhs;
132 144 }
133 145
134   - bool operator() (double lhs, int rhs) const
  146 + bool operator() (value_double lhs, value_integer rhs) const
135 147 {
136 148 return (lhs == rhs)? true : false ;
137 149 }
138 150
139   - bool operator() (UnicodeString const& lhs,
140   - UnicodeString const& rhs) const
  151 + bool operator() (value_unicode_string const& lhs,
  152 + value_unicode_string const& rhs) const
141 153 {
142 154 return (lhs == rhs) ? true: false;
143 155 }
@@ -164,18 +176,18 @@ struct not_equals
164 176 return lhs != rhs;
165 177 }
166 178
167   - bool operator() (int lhs, double rhs) const
  179 + bool operator() (value_integer lhs, value_double rhs) const
168 180 {
169 181 return lhs != rhs;
170 182 }
171 183
172   - bool operator() (double lhs, int rhs) const
  184 + bool operator() (value_double lhs, value_integer rhs) const
173 185 {
174 186 return lhs != rhs;
175 187 }
176 188
177   - bool operator() (UnicodeString const& lhs,
178   - UnicodeString const& rhs) const
  189 + bool operator() (value_unicode_string const& lhs,
  190 + value_unicode_string const& rhs) const
179 191 {
180 192 return (lhs != rhs)? true : false;
181 193 }
@@ -215,17 +227,17 @@ struct greater_than
215 227 return lhs > rhs;
216 228 }
217 229
218   - bool operator() (int lhs, double rhs) const
  230 + bool operator() (value_integer lhs, value_double rhs) const
219 231 {
220 232 return lhs > rhs;
221 233 }
222 234
223   - bool operator() (double lhs, int rhs) const
  235 + bool operator() (value_double lhs, value_integer rhs) const
224 236 {
225 237 return lhs > rhs;
226 238 }
227 239
228   - bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const
  240 + bool operator() (value_unicode_string const& lhs, value_unicode_string const& rhs) const
229 241 {
230 242 return (lhs > rhs) ? true : false ;
231 243 }
@@ -251,17 +263,17 @@ struct greater_or_equal
251 263 return lhs >= rhs;
252 264 }
253 265
254   - bool operator() (int lhs, double rhs) const
  266 + bool operator() (value_integer lhs, value_double rhs) const
255 267 {
256 268 return lhs >= rhs;
257 269 }
258 270
259   - bool operator() (double lhs, int rhs) const
  271 + bool operator() (value_double lhs, value_integer rhs) const
260 272 {
261 273 return lhs >= rhs;
262 274 }
263 275
264   - bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const
  276 + bool operator() (value_unicode_string const& lhs, value_unicode_string const& rhs) const
265 277 {
266 278 return ( lhs >= rhs ) ? true : false ;
267 279 }
@@ -287,18 +299,18 @@ struct less_than
287 299 return lhs < rhs;
288 300 }
289 301
290   - bool operator() (int lhs, double rhs) const
  302 + bool operator() (value_integer lhs, value_double rhs) const
291 303 {
292 304 return lhs < rhs;
293 305 }
294 306
295   - bool operator() (double lhs, int rhs) const
  307 + bool operator() (value_double lhs, value_integer rhs) const
296 308 {
297 309 return lhs < rhs;
298 310 }
299 311
300   - bool operator()(UnicodeString const& lhs,
301   - UnicodeString const& rhs ) const
  312 + bool operator()(value_unicode_string const& lhs,
  313 + value_unicode_string const& rhs ) const
302 314 {
303 315 return (lhs < rhs) ? true : false ;
304 316 }
@@ -324,18 +336,18 @@ struct less_or_equal
324 336 return lhs <= rhs;
325 337 }
326 338
327   - bool operator() (int lhs, double rhs) const
  339 + bool operator() (value_integer lhs, value_double rhs) const
328 340 {
329 341 return lhs <= rhs;
330 342 }
331 343
332   - bool operator() (double lhs, int rhs) const
  344 + bool operator() (value_double lhs, value_integer rhs) const
333 345 {
334 346 return lhs <= rhs;
335 347 }
336 348
337   - bool operator()(UnicodeString const& lhs,
338   - UnicodeString const& rhs ) const
  349 + bool operator()(value_unicode_string const& lhs,
  350 + value_unicode_string const& rhs ) const
339 351 {
340 352 return (lhs <= rhs) ? true : false ;
341 353 }
@@ -350,64 +362,68 @@ template <typename V>
350 362 struct add : public boost::static_visitor<V>
351 363 {
352 364 typedef V value_type;
353   -
354   - template <typename T>
355   - value_type operator() (T lhs, T rhs) const
356   - {
357   - return lhs + rhs ;
358   - }
359   -
360   - value_type operator() (UnicodeString const& lhs ,
361   - UnicodeString const& rhs ) const
  365 + value_type operator() (value_unicode_string const& lhs ,
  366 + value_unicode_string const& rhs ) const
362 367 {
363 368 return lhs + rhs;
364 369 }
365 370
366   - value_type operator() (double lhs, int rhs) const
  371 + value_type operator() (value_double lhs, value_integer rhs) const
367 372 {
368 373 return lhs + rhs;
369 374 }
370 375
371   - value_type operator() (int lhs, double rhs) const
  376 + value_type operator() (value_integer lhs, value_double rhs) const
372 377 {
373 378 return lhs + rhs;
374 379 }
375 380
376   - value_type operator() (UnicodeString const& lhs, value_null rhs) const
  381 + value_type operator() (value_unicode_string const& lhs, value_null rhs) const
377 382 {
378 383 boost::ignore_unused_variable_warning(rhs);
379 384 return lhs;
380 385 }
381 386
382   - value_type operator() (value_null lhs, UnicodeString const& rhs) const
  387 + value_type operator() (value_null lhs, value_unicode_string const& rhs) const
383 388 {
384 389 boost::ignore_unused_variable_warning(lhs);
385 390 return rhs;
386 391 }
387 392
388 393 template <typename R>
389   - value_type operator() (UnicodeString const& lhs, R const& rhs) const
  394 + value_type operator() (value_unicode_string const& lhs, R const& rhs) const
390 395 {
391 396 std::string val;
392 397 if (util::to_string(val,rhs))
393   - return lhs + UnicodeString(val.c_str());
  398 + return lhs + value_unicode_string(val.c_str());
394 399 return lhs;
395 400 }
396 401
397 402 template <typename L>
398   - value_type operator() (L const& lhs , UnicodeString const& rhs) const
  403 + value_type operator() (L const& lhs , value_unicode_string const& rhs) const
399 404 {
400 405 std::string val;
401 406 if (util::to_string(val,lhs))
402   - return UnicodeString(val.c_str()) + rhs;
  407 + return value_unicode_string(val.c_str()) + rhs;
403 408 return rhs;
404 409 }
405 410
  411 + template <typename T>
  412 + value_type operator() (T lhs, T rhs) const
  413 + {
  414 + return lhs + rhs ;
  415 + }
  416 +
406 417 template <typename T1, typename T2>
407 418 value_type operator() (T1 const& lhs, T2 const&) const
408 419 {
409 420 return lhs;
410 421 }
  422 +
  423 + value_type operator() (value_bool lhs, value_bool rhs) const
  424 + {
  425 + return value_integer(lhs + rhs);
  426 + }
411 427 };
412 428
413 429 template <typename V>
@@ -421,26 +437,31 @@ struct sub : public boost::static_visitor<V>
421 437 }
422 438
423 439 template <typename T>
424   - value_type operator() (T lhs, T rhs) const
  440 + value_type operator() (T lhs, T rhs) const
425 441 {
426 442 return lhs - rhs ;
427 443 }
428 444
429   - value_type operator() (UnicodeString const& lhs,
430   - UnicodeString const& ) const
  445 + value_type operator() (value_unicode_string const& lhs,
  446 + value_unicode_string const& ) const
431 447 {
432 448 return lhs;
433 449 }
434 450
435   - value_type operator() (double lhs, int rhs) const
  451 + value_type operator() (value_double lhs, value_integer rhs) const
436 452 {
437 453 return lhs - rhs;
438 454 }
439 455
440   - value_type operator() (int lhs, double rhs) const
  456 + value_type operator() (value_integer lhs, value_double rhs) const
441 457 {
442 458 return lhs - rhs;
443 459 }
  460 +
  461 + value_type operator() (value_bool lhs, value_bool rhs) const
  462 + {
  463 + return value_integer(lhs - rhs);
  464 + }
444 465 };
445 466
446 467 template <typename V>
@@ -458,21 +479,26 @@ struct mult : public boost::static_visitor<V>
458 479 return lhs * rhs;
459 480 }
460 481
461   - value_type operator() (UnicodeString const& lhs,
462   - UnicodeString const& ) const
  482 + value_type operator() (value_unicode_string const& lhs,
  483 + value_unicode_string const& ) const
463 484 {
464 485 return lhs;
465 486 }
466 487
467   - value_type operator() (double lhs, int rhs) const
  488 + value_type operator() (value_double lhs, value_integer rhs) const
468 489 {
469 490 return lhs * rhs;
470 491 }
471 492
472   - value_type operator() (int lhs, double rhs) const
  493 + value_type operator() (value_integer lhs, value_double rhs) const
473 494 {
474 495 return lhs * rhs;
475 496 }
  497 +
  498 + value_type operator() (value_bool lhs, value_bool rhs) const
  499 + {
  500 + return value_integer(0);
  501 + }
476 502 };
477 503
478 504 template <typename V>
@@ -491,25 +517,25 @@ struct div: public boost::static_visitor<V>
491 517 return lhs / rhs;
492 518 }
493 519
494   - value_type operator() (bool lhs, bool rhs ) const
  520 + value_type operator() (value_bool lhs, value_bool rhs ) const
495 521 {
496 522 boost::ignore_unused_variable_warning(lhs);
497 523 boost::ignore_unused_variable_warning(rhs);
498 524 return false;
499 525 }
500 526
501   - value_type operator() (UnicodeString const& lhs,
502   - UnicodeString const&) const
  527 + value_type operator() (value_unicode_string const& lhs,
  528 + value_unicode_string const&) const
503 529 {
504 530 return lhs;
505 531 }
506 532
507   - value_type operator() (double lhs, int rhs) const
  533 + value_type operator() (value_double lhs, value_integer rhs) const
508 534 {
509 535 return lhs / rhs;
510 536 }
511 537
512   - value_type operator() (int lhs, double rhs) const
  538 + value_type operator() (value_integer lhs, value_double rhs) const
513 539 {
514 540 return lhs / rhs;
515 541 }
@@ -531,31 +557,31 @@ struct mod: public boost::static_visitor<V>
531 557 return lhs % rhs;
532 558 }
533 559
534   - value_type operator() (UnicodeString const& lhs,
535   - UnicodeString const&) const
  560 + value_type operator() (value_unicode_string const& lhs,
  561 + value_unicode_string const&) const
536 562 {
537 563 return lhs;
538 564 }
539 565
540   - value_type operator() (bool lhs,
541   - bool rhs) const
  566 + value_type operator() (value_bool lhs,
  567 + value_bool rhs) const
542 568 {
543 569 boost::ignore_unused_variable_warning(lhs);
544 570 boost::ignore_unused_variable_warning(rhs);
545 571 return false;
546 572 }
547 573
548   - value_type operator() (double lhs, int rhs) const
  574 + value_type operator() (value_double lhs, value_integer rhs) const
549 575 {
550 576 return std::fmod(lhs, rhs);
551 577 }
552 578
553   - value_type operator() (int lhs, double rhs) const
  579 + value_type operator() (value_integer lhs, value_double rhs) const
554 580 {
555 581 return std::fmod(lhs, rhs);
556 582 }
557 583
558   - value_type operator() (double lhs, double rhs) const
  584 + value_type operator() (value_double lhs, value_double rhs) const
559 585 {
560 586 return std::fmod(lhs, rhs);
561 587 }
@@ -577,39 +603,39 @@ struct negate : public boost::static_visitor<V>
577 603 return val;
578 604 }
579 605
580   - value_type operator() (bool val) const
  606 + value_type operator() (value_bool val) const
581 607 {
582   - return val ? -1 : 0;
  608 + return val ? value_integer(-1) : value_integer(0);
583 609 }
584 610
585   - value_type operator() (UnicodeString const& ustr) const
  611 + value_type operator() (value_unicode_string const& ustr) const
586 612 {
587   - UnicodeString inplace(ustr);
  613 + value_unicode_string inplace(ustr);
588 614 return inplace.reverse();
589 615 }
590 616 };
591 617
592   -struct to_bool : public boost::static_visitor<bool>
  618 +struct to_bool : public boost::static_visitor<value_bool>
593 619 {
594   - bool operator() (bool val) const
  620 + value_bool operator() (value_bool val) const
595 621 {
596 622 return val;
597 623 }
598 624
599   - bool operator() (UnicodeString const& ustr) const
  625 + value_bool operator() (value_unicode_string const& ustr) const
600 626 {
601 627 boost::ignore_unused_variable_warning(ustr);
602 628 return true;
603 629 }
604 630
605   - bool operator() (value_null const& val) const
  631 + value_bool operator() (value_null const& val) const
606 632 {
607 633 boost::ignore_unused_variable_warning(val);
608 634 return false;
609 635 }
610 636
611 637 template <typename T>
612   - bool operator() (T val) const
  638 + value_bool operator() (T val) const
613 639 {
614 640 return val > 0 ? true : false;
615 641 }
@@ -626,14 +652,14 @@ struct to_string : public boost::static_visitor<std::string>
626 652 }
627 653
628 654 // specializations
629   - std::string operator() (UnicodeString const& val) const
  655 + std::string operator() (value_unicode_string const& val) const
630 656 {
631 657 std::string utf8;
632 658 to_utf8(val,utf8);
633 659 return utf8;
634 660 }
635 661
636   - std::string operator() (double val) const
  662 + std::string operator() (value_double val) const
637 663 {
638 664 std::string str;
639 665 util::to_string(str, val); // TODO set precision(16)
@@ -647,54 +673,54 @@ struct to_string : public boost::static_visitor<std::string>
647 673 }
648 674 };
649 675
650   -struct to_unicode : public boost::static_visitor<UnicodeString>
  676 +struct to_unicode : public boost::static_visitor<value_unicode_string>
651 677 {
652 678
653 679 template <typename T>
654   - UnicodeString operator() (T val) const
  680 + value_unicode_string operator() (T val) const
655 681 {
656 682 std::string str;
657 683 util::to_string(str,val);
658   - return UnicodeString(str.c_str());
  684 + return value_unicode_string(str.c_str());
659 685 }
660 686
661 687 // specializations
662   - UnicodeString const& operator() (UnicodeString const& val) const
  688 + value_unicode_string const& operator() (value_unicode_string const& val) const
663 689 {
664 690 return val;
665 691 }
666 692
667   - UnicodeString operator() (double val) const
  693 + value_unicode_string operator() (value_double val) const
668 694 {
669 695 std::string str;
670 696 util::to_string(str,val);
671   - return UnicodeString(str.c_str());
  697 + return value_unicode_string(str.c_str());
672 698 }
673 699
674   - UnicodeString operator() (value_null const& val) const
  700 + value_unicode_string operator() (value_null const& val) const
675 701 {
676 702 boost::ignore_unused_variable_warning(val);
677   - return UnicodeString("");
  703 + return value_unicode_string("");
678 704 }
679 705 };
680 706
681 707 struct to_expression_string : public boost::static_visitor<std::string>
682 708 {
683   - std::string operator() (UnicodeString const& val) const
  709 + std::string operator() (value_unicode_string const& val) const
684 710 {
685 711 std::string utf8;
686 712 to_utf8(val,utf8);
687 713 return "'" + utf8 + "'";
688 714 }
689 715
690   - std::string operator() (double val) const
  716 + std::string operator() (value_double val) const
691 717 {
692 718 std::string output;
693 719 util::to_string(output,val); // TODO precision(16)
694 720 return output;
695 721 }
696 722
697   - std::string operator() (bool val) const
  723 + std::string operator() (value_bool val) const
698 724 {
699 725 return val ? "true":"false";
700 726 }
@@ -714,69 +740,85 @@ struct to_expression_string : public boost::static_visitor<std::string>
714 740 }
715 741 };
716 742
717   -struct to_double : public boost::static_visitor<double>
  743 +struct to_double : public boost::static_visitor<value_double>
718 744 {
719   - double operator() (int val) const
  745 + value_double operator() (value_double val) const
720 746 {
721   - return static_cast<double>(val);
  747 + return val;
722 748 }
723 749
724   - double operator() (double val) const
  750 + value_double operator() (value_integer val) const
725 751 {
726   - return val;
  752 + return static_cast<value_double>(val);
727 753 }
728 754
729   - double operator() (std::string const& val) const
  755 + value_double operator() (value_bool val) const
730 756 {
731   - double result;
  757 + return static_cast<value_double>(val);
  758 + }
  759 +
  760 + value_double operator() (std::string const& val) const
  761 + {
  762 + value_double result;
732 763 if (util::string2double(val,result))
733 764 return result;
734 765 return 0;
735 766 }
736   - double operator() (UnicodeString const& val) const
  767 +
  768 + value_double operator() (value_unicode_string const& val) const
737 769 {
738 770 std::string utf8;
739 771 to_utf8(val,utf8);
740 772 return operator()(utf8);
741 773 }
742 774
743   - double operator() (value_null const& val) const
  775 + value_double operator() (value_null const& val) const
744 776 {
745 777 boost::ignore_unused_variable_warning(val);
746 778 return 0.0;
747 779 }
748 780 };
749 781
750   -struct to_int : public boost::static_visitor<double>
  782 +struct to_int : public boost::static_visitor<value_integer>
751 783 {
752   - int operator() (int val) const
  784 + value_integer operator() (value_integer val) const
753 785 {
754 786 return val;
755 787 }
756 788
757   - int operator() (double val) const
  789 + value_integer operator() (value_double val) const
758 790 {
759 791 return rint(val);
760 792 }
761 793
762   - int operator() (std::string const& val) const
  794 + value_integer operator() (value_bool val) const
763 795 {
764   - int result;
  796 + return static_cast<int>(val);
  797 + }
  798 +
  799 + value_integer operator() (std::string const& val) const
  800 + {
  801 + value_integer result;
  802 +#ifdef BIGINT
  803 + if (util::string2longlong(val,result))
  804 +#else
765 805 if (util::string2int(val,result))
  806 +#endif
766 807 return result;
767   - return 0;
  808 + return value_integer(0);
768 809 }
769   - int operator() (UnicodeString const& val) const
  810 +
  811 + value_integer operator() (value_unicode_string const& val) const
770 812 {
771 813 std::string utf8;
772 814 to_utf8(val,utf8);
773 815 return operator()(utf8);
774 816 }
775 817
776   - int operator() (value_null const& val) const
  818 + value_integer operator() (value_null const& val) const
777 819 {
778 820 boost::ignore_unused_variable_warning(val);
779   - return 0;
  821 + return value_integer(0);
780 822 }
781 823 };
782 824
@@ -842,7 +884,7 @@ class value
842 884
843 885 bool is_null() const;
844 886
845   - bool to_bool() const
  887 + value_bool to_bool() const
846 888 {
847 889 return boost::apply_visitor(impl::to_bool(),base_);
848 890 }
@@ -857,17 +899,17 @@ class value
857 899 return boost::apply_visitor(impl::to_string(),base_);
858 900 }
859 901
860   - UnicodeString to_unicode() const
  902 + value_unicode_string to_unicode() const
861 903 {
862 904 return boost::apply_visitor(impl::to_unicode(),base_);
863 905 }
864 906
865   - double to_double() const
  907 + value_double to_double() const
866 908 {
867 909 return boost::apply_visitor(impl::to_double(),base_);
868 910 }
869 911
870   - double to_int() const
  912 + value_integer to_int() const
871 913 {
872 914 return boost::apply_visitor(impl::to_int(),base_);
873 915 }
6 plugins/input/csv/csv_datasource.cpp
@@ -453,7 +453,7 @@ void csv_datasource::parse_csv(T & stream,
453 453 {
454 454 csv_utils::fix_json_quoting(csv_line);
455 455 }
456   -
  456 +
457 457 Tokenizer tok(csv_line, grammer);
458 458 Tokenizer::iterator beg = tok.begin();
459 459
@@ -584,7 +584,7 @@ void csv_datasource::parse_csv(T & stream,
584 584 MAPNIK_LOG_ERROR(csv) << s.str();
585 585 }
586 586 }
587   - }
  587 + }
588 588 }
589 589 else
590 590 {
@@ -695,7 +695,7 @@ void csv_datasource::parse_csv(T & stream,
695 695 }
696 696 else
697 697 {
698   - feature->put(fld_name,static_cast<int>(float_val));
  698 + feature->put(fld_name,static_cast<mapnik::value_integer>(float_val));
699 699 if (feature_count == 1)
700 700 {
701 701 desc_.add_descriptor(
4 plugins/input/gdal/gdal_featureset.cpp
@@ -445,10 +445,10 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
445 445 {
446 446 MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Loading colour table...";
447 447
448   - unsigned nodata_value = static_cast<unsigned>(nodata);
  448 + unsigned nodata_value = static_cast<unsigned>(nodata); // FIXME: is it realy unsigned ?
449 449 if (hasNoData)
450 450 {
451   - feature->put("NODATA",static_cast<int>(nodata_value));
  451 + feature->put("NODATA",static_cast<mapnik::value_integer>(nodata_value));
452 452 }
453 453 for (unsigned y = 0; y < image.height(); ++y)
454 454 {
26 plugins/input/geojson/geojson_datasource.cpp
@@ -51,7 +51,7 @@ DATASOURCE_PLUGIN(geojson_datasource)
51 51
52 52 struct attr_value_converter : public boost::static_visitor<mapnik::eAttributeType>
53 53 {
54   - mapnik::eAttributeType operator() (int /*val*/) const
  54 + mapnik::eAttributeType operator() (mapnik::value_integer /*val*/) const
55 55 {
56 56 return mapnik::Integer;
57 57 }
@@ -100,29 +100,29 @@ geojson_datasource::geojson_datasource(parameters const& params)
100 100 {
101 101 if (file_.empty()) throw mapnik::datasource_exception("GeoJSON Plugin: missing <file> parameter");
102 102
103   - typedef std::istreambuf_iterator<char> base_iterator_type;
104   -
  103 + typedef std::istreambuf_iterator<char> base_iterator_type;
  104 +
105 105 std::ifstream is(file_.c_str());
106   - boost::spirit::multi_pass<base_iterator_type> begin =
  106 + boost::spirit::multi_pass<base_iterator_type> begin =
107 107 boost::spirit::make_default_multi_pass(base_iterator_type(is));
108 108
109   - boost::spirit::multi_pass<base_iterator_type> end =
  109 + boost::spirit::multi_pass<base_iterator_type> end =
110 110 boost::spirit::make_default_multi_pass(base_iterator_type());
111   -
  111 +
112 112 mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
113 113 mapnik::json::feature_collection_parser<boost::spirit::multi_pass<base_iterator_type> > p(ctx,*tr_);
114 114 bool result = p.parse(begin,end, features_);
115   - if (!result)
  115 + if (!result)
116 116 {
117 117 throw mapnik::datasource_exception("geojson_datasource: Failed parse GeoJSON file '" + file_ + "'");
118 118 }
119   -
  119 +
120 120 bool first = true;
121 121 std::size_t count=0;
122 122 BOOST_FOREACH (mapnik::feature_ptr f, features_)
123 123 {
124 124 mapnik::box2d<double> const& box = f->envelope();
125   - if (first)
  125 + if (first)
126 126 {
127 127 extent_ = box;
128 128 first = false;
@@ -137,7 +137,7 @@ geojson_datasource::geojson_datasource(parameters const& params)
137 137 else
138 138 {
139 139 extent_.expand_to_include(box);
140   - }
  140 + }
141 141 tree_.insert(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())), count++);
142 142 }
143 143 }
@@ -149,7 +149,7 @@ const char * geojson_datasource::name()
149 149 return "geojson";
150 150 }
151 151
152   -boost::optional<mapnik::datasource::geometry_t> geojson_datasource::get_geometry_type() const
  152 +boost::optional<mapnik::datasource::geometry_t> geojson_datasource::get_geometry_type() const
153 153 {
154 154 boost::optional<mapnik::datasource::geometry_t> result;
155 155 int multi_type = 0;
@@ -171,7 +171,7 @@ boost::optional<mapnik::datasource::geometry_t> geojson_datasource::get_geometry
171 171 return result;
172 172 }
173 173
174   -mapnik::datasource::datasource_t geojson_datasource::type() const
  174 +mapnik::datasource::datasource_t geojson_datasource::type() const
175 175 {
176 176 return type_;
177 177 }
@@ -195,7 +195,7 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons
195 195 box_type box(point_type(b.minx(),b.miny()),point_type(b.maxx(),b.maxy()));
196 196 index_array_ = tree_.find(box);
197 197 return boost::make_shared<geojson_featureset>(features_, index_array_.begin(), index_array_.end());
198   - }
  198 + }
199 199 // otherwise return an empty featureset pointer
200 200 return mapnik::featureset_ptr();
201 201 }
2  plugins/input/ogr/ogr_featureset.cpp
@@ -117,7 +117,7 @@ feature_ptr ogr_featureset::next()
117 117 {
118 118 case OFTInteger:
119 119 {
120   - feature->put( fld_name, poFeature->GetFieldAsInteger(i));
  120 + feature->put<mapnik::value_integer>( fld_name, poFeature->GetFieldAsInteger(i));
121 121 break;
122 122 }
123 123
2  plugins/input/ogr/ogr_index_featureset.cpp
@@ -126,7 +126,7 @@ feature_ptr ogr_index_featureset<filterT>::next()
126 126 {
127 127 case OFTInteger:
128 128 {
129   - feature->put(fld_name,poFeature->GetFieldAsInteger (i));
  129 + feature->put<mapnik::value_integer>(fld_name,poFeature->GetFieldAsInteger (i));
130 130 break;
131 131 }
132 132
16 plugins/input/postgis/postgis_featureset.cpp
@@ -76,7 +76,8 @@ feature_ptr postgis_featureset::next()
76 76 std::string name = rs_->getFieldName(pos);
77 77
78 78 // validation happens of this type at initialization
79   - int val;
  79 + mapnik::value_integer val;