From 7ee9745a8fe6e429316bf8d7d58657db87f96cc2 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Mon, 9 Mar 2015 16:33:20 -0500 Subject: [PATCH] Updated param to allow value_boolean --- include/mapnik/params.hpp | 8 +++++++- include/mapnik/params_impl.hpp | 12 ++++++++++++ src/params.cpp | 3 +++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/mapnik/params.hpp b/include/mapnik/params.hpp index 240192c94..84076677b 100644 --- a/include/mapnik/params.hpp +++ b/include/mapnik/params.hpp @@ -40,7 +40,7 @@ namespace mapnik // fwd declare class boolean_type; -using value_holder_base = util::variant; +using value_holder_base = util::variant; struct value_holder : value_holder_base { @@ -87,6 +87,12 @@ template MAPNIK_DECL boost::optional parameters::get(std::string const& key, value_integer const& default_opt_value) const; +template MAPNIK_DECL +boost::optional parameters::get(std::string const& key) const; +template MAPNIK_DECL +boost::optional parameters::get(std::string const& key, + value_bool const& default_opt_value) const; + template MAPNIK_DECL boost::optional parameters::get(std::string const& key) const; template MAPNIK_DECL diff --git a/include/mapnik/params_impl.hpp b/include/mapnik/params_impl.hpp index 58ae52b00..a4aa77bf3 100644 --- a/include/mapnik/params_impl.hpp +++ b/include/mapnik/params_impl.hpp @@ -55,6 +55,18 @@ struct extract_value } }; +template <> +struct extract_value +{ + static inline boost::optional do_extract_from_string(std::string const& source) + { + bool result; + if (mapnik::util::string2bool(source, result)) + return boost::optional(result); + return boost::optional(); + } +}; + template <> struct extract_value { diff --git a/src/params.cpp b/src/params.cpp index 39b36fdbd..014a5c272 100644 --- a/src/params.cpp +++ b/src/params.cpp @@ -34,6 +34,9 @@ template boost::optional parameters::get(std::string const& key, st template boost::optional parameters::get(std::string const& key) const; template boost::optional parameters::get(std::string const& key, value_double const& default_opt_value) const; +template boost::optional parameters::get(std::string const& key) const; +template boost::optional parameters::get(std::string const& key, value_bool const& default_opt_value) const; + template boost::optional parameters::get(std::string const& key) const; template boost::optional parameters::get(std::string const& key, boolean_type const& default_opt_value) const;