Updated param to allow value_boolean

This commit is contained in:
Blake Thompson 2015-03-09 16:33:20 -05:00
parent e7843ba471
commit 7ee9745a8f
3 changed files with 22 additions and 1 deletions

View file

@ -40,7 +40,7 @@ namespace mapnik
// fwd declare
class boolean_type;
using value_holder_base = util::variant<value_null,value_integer,value_double,std::string>;
using value_holder_base = util::variant<value_null,value_integer,value_double,std::string,value_bool>;
struct value_holder : value_holder_base
{
@ -87,6 +87,12 @@ template MAPNIK_DECL
boost::optional<value_integer> parameters::get(std::string const& key,
value_integer const& default_opt_value) const;
template MAPNIK_DECL
boost::optional<value_bool> parameters::get(std::string const& key) const;
template MAPNIK_DECL
boost::optional<value_bool> parameters::get(std::string const& key,
value_bool const& default_opt_value) const;
template MAPNIK_DECL
boost::optional<mapnik::boolean_type> parameters::get(std::string const& key) const;
template MAPNIK_DECL

View file

@ -55,6 +55,18 @@ struct extract_value
}
};
template <>
struct extract_value<value_bool>
{
static inline boost::optional<value_bool> do_extract_from_string(std::string const& source)
{
bool result;
if (mapnik::util::string2bool(source, result))
return boost::optional<value_bool>(result);
return boost::optional<value_bool>();
}
};
template <>
struct extract_value<mapnik::boolean_type>
{

View file

@ -34,6 +34,9 @@ template boost::optional<std::string> parameters::get(std::string const& key, st
template boost::optional<value_double> parameters::get(std::string const& key) const;
template boost::optional<value_double> parameters::get(std::string const& key, value_double const& default_opt_value) const;
template boost::optional<value_bool> parameters::get(std::string const& key) const;
template boost::optional<value_bool> parameters::get(std::string const& key, value_bool const& default_opt_value) const;
template boost::optional<boolean_type> parameters::get(std::string const& key) const;
template boost::optional<boolean_type> parameters::get(std::string const& key, boolean_type const& default_opt_value) const;