move const char string2value interface to use iterators

This commit is contained in:
Dane Springmeyer 2013-02-26 12:07:36 -05:00
parent 712ff50abe
commit d861636fbc
3 changed files with 21 additions and 23 deletions

View file

@ -32,22 +32,28 @@
namespace mapnik { namespace util {
MAPNIK_DECL bool string2bool(const char * value, bool & result);
MAPNIK_DECL bool string2bool(std::string const& value, bool & result);
/*
Note: this file intentionally provides non-templated methods
to avoid the compile time overhead given it is included
by many other headers inside mapnik.
*/
MAPNIK_DECL bool string2bool(std::string const& value, bool & result);
MAPNIK_DECL bool string2bool(const char * iter, const char * end, bool & result);
MAPNIK_DECL bool string2int(const char * value, int & result);
MAPNIK_DECL bool string2int(std::string const& value, int & result);
MAPNIK_DECL bool string2int(const char * iter, const char * end, int & result);
#ifdef BIGINT
MAPNIK_DECL bool string2int(const char * value, mapnik::value_integer & result);
MAPNIK_DECL bool string2int(std::string const& value, mapnik::value_integer & result);
MAPNIK_DECL bool string2int(const char * iter, const char * end, mapnik::value_integer & result);
#endif
MAPNIK_DECL bool string2double(std::string const& value, double & result);
MAPNIK_DECL bool string2double(const char * value, double & result);
MAPNIK_DECL bool string2double(const char * iter, const char * end, double & result);
MAPNIK_DECL bool string2float(std::string const& value, float & result);
MAPNIK_DECL bool string2float(const char * value, float & result);
MAPNIK_DECL bool string2float(const char * iter, const char * end, float & result);
MAPNIK_DECL bool to_string(std::string & str, int value);
#ifdef BIGINT

View file

@ -178,7 +178,8 @@ postgis_datasource::postgis_datasource(parameters const& params)
if (srid_c != NULL)
{
int result = 0;
if (mapnik::util::string2int(srid_c, result))
const char * end = srid_c + std::strlen(srid_c);
if (mapnik::util::string2int(srid_c, end, result))
{
srid_ = result;
}
@ -209,7 +210,8 @@ postgis_datasource::postgis_datasource(parameters const& params)
if (srid_c != NULL)
{
int result = 0;
if (mapnik::util::string2int(srid_c, result))
const char * end = srid_c + std::strlen(srid_c);
if (mapnik::util::string2int(srid_c, end, result))
{
srid_ = result;
}

View file

@ -78,11 +78,9 @@ struct bool_symbols : qi::symbols<char,bool>
}
};
bool string2bool(const char * value, bool & result)
bool string2bool(const char * iter, const char * end, bool & result)
{
using boost::spirit::qi::no_case;
const char *iter = value;
const char *end = value + std::strlen(value);
bool r = qi::phrase_parse(iter,end, no_case[bool_symbols()] ,ascii::space,result);
return r && (iter == end);
}
@ -96,10 +94,8 @@ bool string2bool(std::string const& value, bool & result)
return r && (str_beg == str_end);
}
bool string2int(const char * value, int & result)
bool string2int(const char * iter, const char * end, int & result)
{
const char *iter = value;
const char *end = value + std::strlen(value);
bool r = qi::phrase_parse(iter,end,INTEGER,ascii::space,result);
return r && (iter == end);
}
@ -113,10 +109,8 @@ bool string2int(std::string const& value, int & result)
}
#ifdef BIGINT
bool string2int(const char * value, mapnik::value_integer & result)
bool string2int(const char * iter, const char * end, mapnik::value_integer & result)
{
const char *iter = value;
const char *end = value + std::strlen(value);
bool r = qi::phrase_parse(iter,end,LONGLONG,ascii::space,result);
return r && (iter == end);
}
@ -138,10 +132,8 @@ bool string2double(std::string const& value, double & result)
return r && (str_beg == str_end);
}
bool string2double(const char * value, double & result)
bool string2double(const char * iter, const char * end, double & result)
{
const char *iter = value;
const char *end = value + std::strlen(value);
bool r = qi::phrase_parse(iter,end,DOUBLE,ascii::space,result);
return r && (iter == end);
}
@ -154,10 +146,8 @@ bool string2float(std::string const& value, float & result)
return r && (str_beg == str_end);
}
bool string2float(const char * value, float & result)
bool string2float(const char * iter, const char * end, float & result)
{
const char *iter = value;
const char *end = value + std::strlen(value);
bool r = qi::phrase_parse(iter,end,FLOAT,ascii::space,result);
return r && (iter == end);
}