ENUM_FROM_STRING macro to keep things tidy and scalable
This commit is contained in:
parent
79fa672843
commit
2271e7413c
2 changed files with 21 additions and 37 deletions
|
@ -277,43 +277,26 @@ struct enum_traits<composite_mode_e>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
#define ENUM_FROM_STRING( e ) \
|
||||||
struct enum_traits<line_join_enum>
|
template <> struct enum_traits<e> { \
|
||||||
{
|
typedef boost::optional<e> result_type; \
|
||||||
typedef boost::optional<line_join_enum> result_type;
|
static result_type from_string(std::string const& str) \
|
||||||
static result_type from_string(std::string const& str)
|
{ \
|
||||||
{
|
enumeration<e, e ## _MAX> enum_; \
|
||||||
enumeration<line_join_enum,line_join_enum_MAX> e;
|
try \
|
||||||
try
|
{ \
|
||||||
{
|
enum_.from_string(str); \
|
||||||
e.from_string(str);
|
return result_type(e(enum_)); \
|
||||||
return result_type(line_join_enum(e));
|
} \
|
||||||
}
|
catch (...) \
|
||||||
catch (...)
|
{ \
|
||||||
{
|
return result_type(); \
|
||||||
return result_type();
|
} \
|
||||||
}
|
} \
|
||||||
}
|
};\
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
ENUM_FROM_STRING( line_join_enum )
|
||||||
struct enum_traits<line_cap_enum>
|
ENUM_FROM_STRING( line_cap_enum )
|
||||||
{
|
|
||||||
typedef boost::optional<line_cap_enum> result_type;
|
|
||||||
static result_type from_string(std::string const& str)
|
|
||||||
{
|
|
||||||
enumeration<line_cap_enum,line_cap_enum_MAX> e;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
e.from_string(str);
|
|
||||||
return result_type(line_cap_enum(e));
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
return result_type();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// enum
|
// enum
|
||||||
template <typename T, bool is_enum = true>
|
template <typename T, bool is_enum = true>
|
||||||
|
|
|
@ -891,12 +891,13 @@ struct set_symbolizer_property_impl<Symbolizer, T, true>
|
||||||
{
|
{
|
||||||
optional<expression_ptr> val = node.get_opt_attr<expression_ptr>(name);
|
optional<expression_ptr> val = node.get_opt_attr<expression_ptr>(name);
|
||||||
if (val) put(sym, key, *val);
|
if (val) put(sym, key, *val);
|
||||||
|
else MAPNIK_LOG_ERROR(Symbolizer) << " failed to parse:" << name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (config_error const& ex)
|
catch (config_error const& ex)
|
||||||
{
|
{
|
||||||
MAPNIK_LOG_ERROR(composite_mode_e) << ex.what();
|
MAPNIK_LOG_ERROR(Symbolizer) << ex.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue