/***************************************************************************** * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2012 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ // mapnik #include #include #include // boost #include #include #include #include #include namespace mapnik { namespace params_detail { template struct converter { typedef boost::optional return_type; static return_type extract(parameters const& params, std::string const& name, boost::optional const& default_opt_value) { boost::optional result(default_opt_value); parameters::const_iterator itr = params.find(name); if (itr != params.end()) { boost::apply_visitor(value_extractor_visitor(result),itr->second); } return result; } }; } // end namespace params_detail // parameters parameters::parameters() {} template boost::optional parameters::get(std::string const& key) const { return params_detail::converter::extract(*this,key, boost::none); } template boost::optional parameters::get(std::string const& key, T const& default_opt_value) const { return params_detail::converter::extract(*this,key,boost::optional(default_opt_value)); } #define compile_params_get(T) template boost::optional parameters::get(std::string const& key) const; template boost::optional parameters::get(std::string const& key, T const& default_opt_value) const compile_params_get(std::string); compile_params_get(value_double); compile_params_get(int); #ifdef BIGINT compile_params_get(value_integer); #endif compile_params_get(mapnik::boolean); }