use mapnik::util namespace for conversions

This commit is contained in:
Artem Pavlenko 2012-03-23 11:01:18 +00:00
parent e9940c6add
commit 242385f16d
6 changed files with 21 additions and 22 deletions

View file

@ -20,15 +20,15 @@
* *
*****************************************************************************/ *****************************************************************************/
#ifndef MAPNIK_CONVERSIONS_UTIL_HPP #ifndef MAPNIK_UTIL_CONVERSIONS_HPP
#define MAPNIK_CONVERSIONS_UTIL_HPP #define MAPNIK_UTIL_CONVERSIONS_HPP
// mapnik // mapnik
// stl // stl
#include <string> #include <string>
namespace mapnik { namespace conversions { namespace mapnik { namespace util {
bool string2int(const char * value, int & result); bool string2int(const char * value, int & result);
bool string2int(std::string const& 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(std::string const& value, float & result);
bool string2float(const char * value, float & result); bool string2float(const char * value, float & result);
} }}
}
#endif // MAPNIK_CONVERSIONS_UTIL_HPP #endif // MAPNIK_UTIL_CONVERSIONS_HPP

View file

@ -175,7 +175,7 @@ void postgis_datasource::bind() const
if (srid_c != NULL) if (srid_c != NULL)
{ {
int result; int result;
if (mapnik::conversions::string2int(srid_c,result)) if (mapnik::util::string2int(srid_c,result))
srid_ = result; srid_ = result;
} }
} }
@ -205,7 +205,7 @@ void postgis_datasource::bind() const
if (srid_c != NULL) if (srid_c != NULL)
{ {
int result; int result;
if (mapnik::conversions::string2int(srid_c,result)) if (mapnik::util::string2int(srid_c,result))
srid_ = result; srid_ = result;
} }
} }
@ -685,10 +685,10 @@ box2d<double> postgis_datasource::envelope() const
double loy; double loy;
double hix; double hix;
double hiy; double hiy;
if (mapnik::conversions::string2double(rs->getValue(0),lox) && if (mapnik::util::string2double(rs->getValue(0),lox) &&
mapnik::conversions::string2double(rs->getValue(1),loy) && mapnik::util::string2double(rs->getValue(1),loy) &&
mapnik::conversions::string2double(rs->getValue(2),hix) && mapnik::util::string2double(rs->getValue(2),hix) &&
mapnik::conversions::string2double(rs->getValue(3),hiy)) mapnik::util::string2double(rs->getValue(3),hiy))
{ {
extent_.init(lox,loy,hix,hiy); extent_.init(lox,loy,hix,hiy);
extent_initialized_ = true; extent_initialized_ = true;

View file

@ -162,7 +162,7 @@ feature_ptr postgis_featureset::next()
{ {
std::string str = mapnik::sql_utils::numeric2string(buf); std::string str = mapnik::sql_utils::numeric2string(buf);
double val; double val;
if (mapnik::conversions::string2double(str,val)) if (mapnik::util::string2double(str,val))
feature->put(name,val); feature->put(name,val);
} }
else else

View file

@ -31,7 +31,7 @@
BOOST_AUTO(name, boost::proto::deep_copy(expr)); \ BOOST_AUTO(name, boost::proto::deep_copy(expr)); \
namespace mapnik { namespace conversions { namespace mapnik { namespace util {
using namespace boost::spirit; using namespace boost::spirit;

View file

@ -158,7 +158,7 @@ void handle_png_options(std::string const& type,
if (*colors < 0) if (*colors < 0)
throw ImageWriterException("invalid color parameter: unavailable for true color images"); 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)); throw ImageWriterException("invalid color parameter: " + t.substr(2));
} }
else if (boost::algorithm::starts_with(t, "t=")) else if (boost::algorithm::starts_with(t, "t="))
@ -166,14 +166,14 @@ void handle_png_options(std::string const& type,
if (*colors < 0) if (*colors < 0)
throw ImageWriterException("invalid trans_mode parameter: unavailable for true color images"); 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)); throw ImageWriterException("invalid trans_mode parameter: " + t.substr(2));
} }
else if (boost::algorithm::starts_with(t, "g=")) else if (boost::algorithm::starts_with(t, "g="))
{ {
if (*colors < 0) if (*colors < 0)
throw ImageWriterException("invalid gamma parameter: unavailable for true color images"); 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)); 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_BEST_COMPRESSION 9
#define Z_DEFAULT_COMPRESSION (-1) #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_DEFAULT_COMPRESSION
|| *compression > Z_BEST_COMPRESSION) || *compression > Z_BEST_COMPRESSION)
{ {
@ -317,7 +317,7 @@ void save_to_stream(T const& image,
std::string const& val = t.substr(4); std::string const& val = t.substr(4);
if (!val.empty()) 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 + "'"); throw ImageWriterException("invalid jpeg quality: '" + val + "'");
} }

View file

@ -54,7 +54,7 @@ template <>
inline boost::optional<int> fast_cast(xml_tree const& tree, std::string const& value) inline boost::optional<int> fast_cast(xml_tree const& tree, std::string const& value)
{ {
int result; int result;
if (mapnik::conversions::string2int(value, result)) if (mapnik::util::string2int(value, result))
return boost::optional<int>(result); return boost::optional<int>(result);
return boost::optional<int>(); return boost::optional<int>();
} }
@ -63,7 +63,7 @@ template <>
inline boost::optional<double> fast_cast(xml_tree const& tree, std::string const& value) inline boost::optional<double> fast_cast(xml_tree const& tree, std::string const& value)
{ {
double result; double result;
if (mapnik::conversions::string2double(value, result)) if (mapnik::util::string2double(value, result))
return boost::optional<double>(result); return boost::optional<double>(result);
return boost::optional<double>(); return boost::optional<double>();
} }
@ -72,7 +72,7 @@ template <>
inline boost::optional<float> fast_cast(xml_tree const& tree, std::string const& value) inline boost::optional<float> fast_cast(xml_tree const& tree, std::string const& value)
{ {
float result; float result;
if (mapnik::conversions::string2float(value, result)) if (mapnik::util::string2float(value, result))
return boost::optional<float>(result); return boost::optional<float>(result);
return boost::optional<float>(); return boost::optional<float>();
} }