algorithm is a somewhat large stl header, move it to cpp

This commit is contained in:
Dane Springmeyer 2015-05-06 06:37:06 -07:00
parent b11eeef4b6
commit 4c76edaef7
3 changed files with 30 additions and 31 deletions

View file

@ -28,10 +28,7 @@
// std
#include <iosfwd>
#include <algorithm>
#include <string>
//#include <istream>
//#include <ostream>
namespace mapnik
{

View file

@ -28,8 +28,7 @@
#include <mapnik/value_types.hpp>
// stl
#include <string>
#include <algorithm>
#include <iosfwd>
namespace mapnik { namespace util {
@ -39,32 +38,8 @@ to avoid the compile time overhead given it is included
by many other headers inside mapnik.
*/
MAPNIK_DECL inline bool string2bool(std::string const& value, bool & result)
{
if (value.empty() || value.size() > 5) {
return false;
} else if (value == "true") {
return result = true;
} else if (value == "false") {
result = false;
return true;
}
std::string val(value);
std::transform(val.begin(), val.end(), val.begin(), ::tolower);
if (val == "true" || val == "yes" || val == "1" || val == "on") {
return result = true;
} else if (val == "false" || val == "no" || val == "0" || val == "off") {
result = false;
return true;
}
return false;
}
MAPNIK_DECL inline bool string2bool(const char * iter, const char * end, bool & result)
{
std::string val(iter,end);
return string2bool(val,result);
}
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(std::string const& value, int & result);
MAPNIK_DECL bool string2int(const char * iter, const char * end, int & result);

View file

@ -56,6 +56,33 @@ auto LONGLONG = qi::long_long_type();
auto FLOAT = qi::float_type();
auto DOUBLE = qi::double_type();
bool string2bool(std::string const& value, bool & result)
{
if (value.empty() || value.size() > 5) {
return false;
} else if (value == "true") {
return result = true;
} else if (value == "false") {
result = false;
return true;
}
std::string val(value);
std::transform(val.begin(), val.end(), val.begin(), ::tolower);
if (val == "true" || val == "yes" || val == "1" || val == "on") {
return result = true;
} else if (val == "false" || val == "no" || val == "0" || val == "off") {
result = false;
return true;
}
return false;
}
bool string2bool(const char * iter, const char * end, bool & result)
{
std::string val(iter,end);
return string2bool(val,result);
}
bool string2int(const char * iter, const char * end, int & result)
{
ascii::space_type space;