Merge branch 'master' into mapnik-geometry
This commit is contained in:
commit
74fb3ddde0
5 changed files with 78 additions and 2 deletions
|
@ -53,6 +53,12 @@ struct extract_value
|
|||
s << "No conversion from std::string to " << typeid(T).name();
|
||||
throw std::runtime_error(s.str());
|
||||
}
|
||||
static inline boost::optional<T> do_extract_from_bool(value_bool const& /*source*/)
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "No conversion from boolean to " << typeid(T).name();
|
||||
throw std::runtime_error(s.str());
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -65,6 +71,11 @@ struct extract_value<value_bool>
|
|||
return boost::optional<value_bool>(result);
|
||||
return boost::optional<value_bool>();
|
||||
}
|
||||
|
||||
static inline boost::optional<value_bool> do_extract_from_bool(value_bool const& source)
|
||||
{
|
||||
return boost::optional<value_bool>(source);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -77,6 +88,11 @@ struct extract_value<mapnik::boolean_type>
|
|||
return boost::optional<mapnik::boolean_type>(result);
|
||||
return boost::optional<mapnik::boolean_type>();
|
||||
}
|
||||
|
||||
static inline boost::optional<mapnik::boolean_type> do_extract_from_bool(value_bool const& source)
|
||||
{
|
||||
return boost::optional<mapnik::boolean_type>(source);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -89,6 +105,10 @@ struct extract_value<mapnik::value_integer>
|
|||
return boost::optional<mapnik::value_integer>(result);
|
||||
return boost::optional<mapnik::value_integer>();
|
||||
}
|
||||
static inline boost::optional<mapnik::value_integer> do_extract_from_bool(value_bool const& source)
|
||||
{
|
||||
return boost::optional<mapnik::value_integer>(boost::lexical_cast<mapnik::value_integer>(source));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -101,6 +121,11 @@ struct extract_value<mapnik::value_double>
|
|||
return boost::optional<double>(result);
|
||||
return boost::optional<double>();
|
||||
}
|
||||
|
||||
static inline boost::optional<mapnik::value_double> do_extract_from_bool(value_bool const& source)
|
||||
{
|
||||
return boost::optional<double>(boost::lexical_cast<double>(source));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
|
@ -110,6 +135,11 @@ struct extract_value<mapnik::value_null>
|
|||
{
|
||||
return boost::optional<mapnik::value_null>(); // FIXME
|
||||
}
|
||||
|
||||
static inline boost::optional<mapnik::value_null> do_extract_from_bool(value_bool const&)
|
||||
{
|
||||
return boost::optional<mapnik::value_null>(); // FIXME
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -120,6 +150,14 @@ struct extract_value<std::string>
|
|||
{
|
||||
return boost::optional<std::string>(source);
|
||||
}
|
||||
|
||||
static inline boost::optional<std::string> do_extract_from_bool(value_bool const& source)
|
||||
{
|
||||
if (source) {
|
||||
return boost::optional<std::string>("true");
|
||||
}
|
||||
return boost::optional<std::string>("false");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -130,6 +168,12 @@ boost::optional<T> param_cast(std::string const& source)
|
|||
return extract_value<T>::do_extract_from_string(source);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
boost::optional<T> param_cast(value_bool const& source)
|
||||
{
|
||||
return extract_value<T>::do_extract_from_bool(source);
|
||||
}
|
||||
|
||||
} // end namespace detail
|
||||
|
||||
template <typename T>
|
||||
|
@ -144,6 +188,12 @@ struct value_extractor_visitor
|
|||
var_ = detail::param_cast<T>(val);
|
||||
|
||||
}
|
||||
|
||||
void operator() (value_bool const& val) const
|
||||
{
|
||||
var_ = detail::param_cast<T>(val);
|
||||
|
||||
}
|
||||
|
||||
template <typename T1>
|
||||
void operator () (T1 const& val) const
|
||||
|
|
|
@ -227,6 +227,7 @@ template <typename MultiGeometry>
|
|||
|
||||
struct geometry_to_wkb
|
||||
{
|
||||
|
||||
using result_type = wkb_buffer_ptr;
|
||||
|
||||
geometry_to_wkb(wkbByteOrder byte_order)
|
||||
|
|
|
@ -43,6 +43,16 @@ public:
|
|||
{
|
||||
out_ << operand;
|
||||
}
|
||||
|
||||
/// specialized visitor for boolean
|
||||
void operator()(bool const & val) const
|
||||
{
|
||||
if (val) {
|
||||
out_ << "true";
|
||||
} else {
|
||||
out_ << "false";
|
||||
}
|
||||
}
|
||||
private:
|
||||
Out & out_;
|
||||
};
|
||||
|
|
|
@ -717,6 +717,11 @@ struct convert<std::string>
|
|||
return str;
|
||||
}
|
||||
|
||||
std::string operator() (value_bool val) const
|
||||
{
|
||||
return val ? "true": "false";
|
||||
}
|
||||
|
||||
std::string operator() (value_null const&) const
|
||||
{
|
||||
return "";
|
||||
|
@ -746,6 +751,16 @@ struct to_unicode
|
|||
util::to_string(str,val);
|
||||
return value_unicode_string(str.c_str());
|
||||
}
|
||||
|
||||
value_unicode_string operator() (value_bool val) const
|
||||
{
|
||||
if (val) {
|
||||
std::string str("true");
|
||||
return value_unicode_string(str.c_str());
|
||||
}
|
||||
std::string str("false");
|
||||
return value_unicode_string(str.c_str());
|
||||
}
|
||||
|
||||
value_unicode_string operator() (value_null const&) const
|
||||
{
|
||||
|
|
|
@ -382,8 +382,8 @@ void map_parser::parse_map_include(Map & map, xml_node const& node)
|
|||
mapnik::value_bool b;
|
||||
mapnik::value_integer i;
|
||||
mapnik::value_double d;
|
||||
if (mapnik::util::string2bool(val,b)) params[key] = b;
|
||||
else if (mapnik::util::string2int(val,i)) params[key] = i;
|
||||
if (mapnik::util::string2int(val,i)) params[key] = i;
|
||||
else if (mapnik::util::string2bool(val,b)) params[key] = b;
|
||||
else if (mapnik::util::string2double(val,d)) params[key] = d;
|
||||
else params[key] = val;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue