From 242385f16d156ad2f5aa5c3d1cb4a0d451cdbe45 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Fri, 23 Mar 2012 11:01:18 +0000 Subject: [PATCH] use mapnik::util namespace for conversions --- include/mapnik/util/conversions.hpp | 11 +++++------ plugins/input/postgis/postgis_datasource.cpp | 12 ++++++------ plugins/input/postgis/postgis_featureset.cpp | 2 +- src/conversions.cpp | 2 +- src/image_util.cpp | 10 +++++----- src/xml_tree.cpp | 6 +++--- 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/include/mapnik/util/conversions.hpp b/include/mapnik/util/conversions.hpp index c4d4a321b..b57f55ff9 100644 --- a/include/mapnik/util/conversions.hpp +++ b/include/mapnik/util/conversions.hpp @@ -20,15 +20,15 @@ * *****************************************************************************/ -#ifndef MAPNIK_CONVERSIONS_UTIL_HPP -#define MAPNIK_CONVERSIONS_UTIL_HPP +#ifndef MAPNIK_UTIL_CONVERSIONS_HPP +#define MAPNIK_UTIL_CONVERSIONS_HPP // mapnik // stl #include -namespace mapnik { namespace conversions { +namespace mapnik { namespace util { bool string2int(const char * value, int & result); bool string2int(std::string const& value, int & result); @@ -39,7 +39,6 @@ namespace mapnik { namespace conversions { bool string2float(std::string const& value, float & result); bool string2float(const char * value, float & result); - } -} +}} -#endif // MAPNIK_CONVERSIONS_UTIL_HPP +#endif // MAPNIK_UTIL_CONVERSIONS_HPP diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index 05c397892..316ee02c1 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -175,7 +175,7 @@ void postgis_datasource::bind() const if (srid_c != NULL) { int result; - if (mapnik::conversions::string2int(srid_c,result)) + if (mapnik::util::string2int(srid_c,result)) srid_ = result; } } @@ -205,7 +205,7 @@ void postgis_datasource::bind() const if (srid_c != NULL) { int result; - if (mapnik::conversions::string2int(srid_c,result)) + if (mapnik::util::string2int(srid_c,result)) srid_ = result; } } @@ -685,10 +685,10 @@ box2d postgis_datasource::envelope() const double loy; double hix; double hiy; - if (mapnik::conversions::string2double(rs->getValue(0),lox) && - mapnik::conversions::string2double(rs->getValue(1),loy) && - mapnik::conversions::string2double(rs->getValue(2),hix) && - mapnik::conversions::string2double(rs->getValue(3),hiy)) + if (mapnik::util::string2double(rs->getValue(0),lox) && + mapnik::util::string2double(rs->getValue(1),loy) && + mapnik::util::string2double(rs->getValue(2),hix) && + mapnik::util::string2double(rs->getValue(3),hiy)) { extent_.init(lox,loy,hix,hiy); extent_initialized_ = true; diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index f4bbfe4b2..177413fee 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -162,7 +162,7 @@ feature_ptr postgis_featureset::next() { std::string str = mapnik::sql_utils::numeric2string(buf); double val; - if (mapnik::conversions::string2double(str,val)) + if (mapnik::util::string2double(str,val)) feature->put(name,val); } else diff --git a/src/conversions.cpp b/src/conversions.cpp index d19272162..76e9d0531 100644 --- a/src/conversions.cpp +++ b/src/conversions.cpp @@ -31,7 +31,7 @@ BOOST_AUTO(name, boost::proto::deep_copy(expr)); \ -namespace mapnik { namespace conversions { +namespace mapnik { namespace util { using namespace boost::spirit; diff --git a/src/image_util.cpp b/src/image_util.cpp index dfc1c54c6..cde2ba9e2 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -158,7 +158,7 @@ void handle_png_options(std::string const& type, if (*colors < 0) throw ImageWriterException("invalid color parameter: unavailable for true color images"); - if (!mapnik::conversions::string2int(t.substr(2),*colors) || *colors < 0 || *colors > 256) + if (!mapnik::util::string2int(t.substr(2),*colors) || *colors < 0 || *colors > 256) throw ImageWriterException("invalid color parameter: " + t.substr(2)); } else if (boost::algorithm::starts_with(t, "t=")) @@ -166,14 +166,14 @@ void handle_png_options(std::string const& type, if (*colors < 0) throw ImageWriterException("invalid trans_mode parameter: unavailable for true color images"); - if (!mapnik::conversions::string2int(t.substr(2),*trans_mode) || *trans_mode < 0 || *trans_mode > 2) + if (!mapnik::util::string2int(t.substr(2),*trans_mode) || *trans_mode < 0 || *trans_mode > 2) throw ImageWriterException("invalid trans_mode parameter: " + t.substr(2)); } else if (boost::algorithm::starts_with(t, "g=")) { if (*colors < 0) throw ImageWriterException("invalid gamma parameter: unavailable for true color images"); - if (!mapnik::conversions::string2double(t.substr(2),*gamma) || *gamma < 0) + if (!mapnik::util::string2double(t.substr(2),*gamma) || *gamma < 0) { throw ImageWriterException("invalid gamma parameter: " + t.substr(2)); } @@ -186,7 +186,7 @@ void handle_png_options(std::string const& type, #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) */ - if (!mapnik::conversions::string2int(t.substr(2),*compression) + if (!mapnik::util::string2int(t.substr(2),*compression) || *compression < Z_DEFAULT_COMPRESSION || *compression > Z_BEST_COMPRESSION) { @@ -317,7 +317,7 @@ void save_to_stream(T const& image, std::string const& val = t.substr(4); if (!val.empty()) { - if (!mapnik::conversions::string2int(val,quality) || quality < 0 || quality > 100) + if (!mapnik::util::string2int(val,quality) || quality < 0 || quality > 100) { throw ImageWriterException("invalid jpeg quality: '" + val + "'"); } diff --git a/src/xml_tree.cpp b/src/xml_tree.cpp index ef61e9258..36995166f 100644 --- a/src/xml_tree.cpp +++ b/src/xml_tree.cpp @@ -54,7 +54,7 @@ template <> inline boost::optional fast_cast(xml_tree const& tree, std::string const& value) { int result; - if (mapnik::conversions::string2int(value, result)) + if (mapnik::util::string2int(value, result)) return boost::optional(result); return boost::optional(); } @@ -63,7 +63,7 @@ template <> inline boost::optional fast_cast(xml_tree const& tree, std::string const& value) { double result; - if (mapnik::conversions::string2double(value, result)) + if (mapnik::util::string2double(value, result)) return boost::optional(result); return boost::optional(); } @@ -72,7 +72,7 @@ template <> inline boost::optional fast_cast(xml_tree const& tree, std::string const& value) { float result; - if (mapnik::conversions::string2float(value, result)) + if (mapnik::util::string2float(value, result)) return boost::optional(result); return boost::optional(); }