font_feature_setting - upgrade parser to boost::spirit::x3
This commit is contained in:
parent
67f5470d3e
commit
ac35166073
1 changed files with 7 additions and 17 deletions
|
@ -26,11 +26,10 @@
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#include <mapnik/warning_ignore.hpp>
|
#include <mapnik/warning_ignore.hpp>
|
||||||
#include <boost/spirit/include/qi.hpp>
|
#include <boost/spirit/home/x3.hpp>
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
@ -52,23 +51,14 @@ font_feature_settings::font_feature_settings()
|
||||||
void font_feature_settings::from_string(std::string const& features)
|
void font_feature_settings::from_string(std::string const& features)
|
||||||
{
|
{
|
||||||
features_.clear();
|
features_.clear();
|
||||||
|
|
||||||
if (std::all_of(features.begin(), features.end(), isspace)) return;
|
if (std::all_of(features.begin(), features.end(), isspace)) return;
|
||||||
|
|
||||||
namespace qi = boost::spirit::qi;
|
namespace x3 = boost::spirit::x3;
|
||||||
qi::char_type char_;
|
auto appender = [&](auto& ctx)
|
||||||
qi::as_string_type as_string;
|
{
|
||||||
|
this->append(_attr(ctx));
|
||||||
#if BOOST_VERSION <= 104800
|
};
|
||||||
// Call correct overload.
|
if (!x3::parse(features.begin(), features.end(), (+(x3::char_ - ','))[appender] % ','))
|
||||||
using std::placeholders::_1;
|
|
||||||
void (font_feature_settings::*append)(std::string const&) = &font_feature_settings::append;
|
|
||||||
if (!qi::parse(features.begin(), features.end(), as_string[+(char_ - ',')][std::bind(append, this, _1)] % ','))
|
|
||||||
#else
|
|
||||||
auto app = [&](std::string const& s) { append(s); };
|
|
||||||
if (!qi::parse(features.begin(), features.end(), as_string[+(char_ - ',')][app] % ','))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
{
|
||||||
throw config_error("failed to parse font-feature-settings: '" + features + "'");
|
throw config_error("failed to parse font-feature-settings: '" + features + "'");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue