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_factory.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_color_rgba.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore.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
|
||||
|
||||
// stl
|
||||
|
@ -52,22 +46,23 @@ color::color(std::string const& str, bool premultiplied)
|
|||
std::string color::to_string() const
|
||||
{
|
||||
namespace karma = boost::spirit::karma;
|
||||
boost::spirit::karma::_1_type _1;
|
||||
boost::spirit::karma::eps_type eps;
|
||||
boost::spirit::karma::double_type double_;
|
||||
boost::spirit::karma::string_type kstring;
|
||||
boost::spirit::karma::uint_generator<uint8_t,10> color_generator;
|
||||
boost::spirit::karma::uint_generator<uint8_t,10> color_;
|
||||
std::string str;
|
||||
std::back_insert_iterator<std::string> sink(str);
|
||||
karma::generate(sink,
|
||||
karma::generate(sink, eps(alpha() < 255)
|
||||
// begin grammar
|
||||
kstring[ boost::phoenix::if_(alpha()==255) [_1="rgb("].else_[_1="rgba("]]
|
||||
<< color_generator[_1 = red()] << ','
|
||||
<< color_generator[_1 = green()] << ','
|
||||
<< color_generator[_1 = blue()]
|
||||
<< kstring[ boost::phoenix::if_(alpha()==255) [_1 = ')'].else_[_1 =',']]
|
||||
<< eps(alpha()<255) << double_ [_1 = alpha()/255.0]
|
||||
<< ')'
|
||||
<< "rgba("
|
||||
<< color_(red()) << ','
|
||||
<< color_(green()) << ','
|
||||
<< color_(blue()) << ','
|
||||
<< double_(alpha()/255.0) << ')'
|
||||
|
|
||||
"rgb("
|
||||
<< color_(red()) << ','
|
||||
<< color_(green()) << ','
|
||||
<< color_(blue()) << ')'
|
||||
// end grammar
|
||||
);
|
||||
return str;
|
||||
|
@ -76,7 +71,6 @@ std::string color::to_string() const
|
|||
std::string color::to_hex_string() const
|
||||
{
|
||||
namespace karma = boost::spirit::karma;
|
||||
boost::spirit::karma::_1_type _1;
|
||||
boost::spirit::karma::hex_type hex;
|
||||
boost::spirit::karma::eps_type eps;
|
||||
boost::spirit::karma::right_align_type right_align;
|
||||
|
@ -85,10 +79,10 @@ std::string color::to_hex_string() const
|
|||
karma::generate(sink,
|
||||
// begin grammar
|
||||
'#'
|
||||
<< right_align(2,'0')[hex[_1 = red()]]
|
||||
<< right_align(2,'0')[hex[_1 = green()]]
|
||||
<< right_align(2,'0')[hex[_1 = blue()]]
|
||||
<< eps(alpha() < 255) << right_align(2,'0')[hex [_1 = alpha()]]
|
||||
<< right_align(2,'0')[hex(red())]
|
||||
<< right_align(2,'0')[hex(green())]
|
||||
<< right_align(2,'0')[hex(blue())]
|
||||
<< eps(alpha() < 255) << right_align(2,'0')[hex(alpha())]
|
||||
// end grammar
|
||||
);
|
||||
return str;
|
||||
|
|
Loading…
Reference in a new issue