simplify color generators - remove boost::phoenix
usage
(ref: https://github.com/mapbox/windows-builds/issues/81)
This commit is contained in:
parent
ea54876d79
commit
3e8ee9a559
1 changed files with 16 additions and 22 deletions
|
@ -24,18 +24,12 @@
|
||||||
#include <mapnik/color.hpp>
|
#include <mapnik/color.hpp>
|
||||||
#include <mapnik/color_factory.hpp>
|
#include <mapnik/color_factory.hpp>
|
||||||
#include <mapnik/config_error.hpp>
|
#include <mapnik/config_error.hpp>
|
||||||
|
|
||||||
// agg
|
// agg
|
||||||
#include "agg_color_rgba.h"
|
#include "agg_color_rgba.h"
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#include <mapnik/warning_ignore.hpp>
|
#include <mapnik/warning_ignore.hpp>
|
||||||
#include <boost/spirit/include/karma.hpp>
|
#include <boost/spirit/include/karma.hpp>
|
||||||
#include <boost/spirit/include/phoenix_statement.hpp>
|
|
||||||
#include <boost/spirit/include/phoenix_core.hpp>
|
|
||||||
#include <boost/spirit/include/phoenix_operator.hpp>
|
|
||||||
#include <boost/spirit/include/phoenix_fusion.hpp>
|
|
||||||
#include <boost/spirit/include/phoenix_function.hpp>
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
// stl
|
// stl
|
||||||
|
@ -52,22 +46,23 @@ color::color(std::string const& str, bool premultiplied)
|
||||||
std::string color::to_string() const
|
std::string color::to_string() const
|
||||||
{
|
{
|
||||||
namespace karma = boost::spirit::karma;
|
namespace karma = boost::spirit::karma;
|
||||||
boost::spirit::karma::_1_type _1;
|
|
||||||
boost::spirit::karma::eps_type eps;
|
boost::spirit::karma::eps_type eps;
|
||||||
boost::spirit::karma::double_type double_;
|
boost::spirit::karma::double_type double_;
|
||||||
boost::spirit::karma::string_type kstring;
|
boost::spirit::karma::uint_generator<uint8_t,10> color_;
|
||||||
boost::spirit::karma::uint_generator<uint8_t,10> color_generator;
|
|
||||||
std::string str;
|
std::string str;
|
||||||
std::back_insert_iterator<std::string> sink(str);
|
std::back_insert_iterator<std::string> sink(str);
|
||||||
karma::generate(sink,
|
karma::generate(sink, eps(alpha() < 255)
|
||||||
// begin grammar
|
// begin grammar
|
||||||
kstring[ boost::phoenix::if_(alpha()==255) [_1="rgb("].else_[_1="rgba("]]
|
<< "rgba("
|
||||||
<< color_generator[_1 = red()] << ','
|
<< color_(red()) << ','
|
||||||
<< color_generator[_1 = green()] << ','
|
<< color_(green()) << ','
|
||||||
<< color_generator[_1 = blue()]
|
<< color_(blue()) << ','
|
||||||
<< kstring[ boost::phoenix::if_(alpha()==255) [_1 = ')'].else_[_1 =',']]
|
<< double_(alpha()/255.0) << ')'
|
||||||
<< eps(alpha()<255) << double_ [_1 = alpha()/255.0]
|
|
|
||||||
<< ')'
|
"rgb("
|
||||||
|
<< color_(red()) << ','
|
||||||
|
<< color_(green()) << ','
|
||||||
|
<< color_(blue()) << ')'
|
||||||
// end grammar
|
// end grammar
|
||||||
);
|
);
|
||||||
return str;
|
return str;
|
||||||
|
@ -76,7 +71,6 @@ std::string color::to_string() const
|
||||||
std::string color::to_hex_string() const
|
std::string color::to_hex_string() const
|
||||||
{
|
{
|
||||||
namespace karma = boost::spirit::karma;
|
namespace karma = boost::spirit::karma;
|
||||||
boost::spirit::karma::_1_type _1;
|
|
||||||
boost::spirit::karma::hex_type hex;
|
boost::spirit::karma::hex_type hex;
|
||||||
boost::spirit::karma::eps_type eps;
|
boost::spirit::karma::eps_type eps;
|
||||||
boost::spirit::karma::right_align_type right_align;
|
boost::spirit::karma::right_align_type right_align;
|
||||||
|
@ -85,10 +79,10 @@ std::string color::to_hex_string() const
|
||||||
karma::generate(sink,
|
karma::generate(sink,
|
||||||
// begin grammar
|
// begin grammar
|
||||||
'#'
|
'#'
|
||||||
<< right_align(2,'0')[hex[_1 = red()]]
|
<< right_align(2,'0')[hex(red())]
|
||||||
<< right_align(2,'0')[hex[_1 = green()]]
|
<< right_align(2,'0')[hex(green())]
|
||||||
<< right_align(2,'0')[hex[_1 = blue()]]
|
<< right_align(2,'0')[hex(blue())]
|
||||||
<< eps(alpha() < 255) << right_align(2,'0')[hex [_1 = alpha()]]
|
<< eps(alpha() < 255) << right_align(2,'0')[hex(alpha())]
|
||||||
// end grammar
|
// end grammar
|
||||||
);
|
);
|
||||||
return str;
|
return str;
|
||||||
|
|
Loading…
Reference in a new issue