From 70ef017f8ccbd2120b02fc7556808e541bc479a5 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 4 Jan 2013 00:07:57 -0800 Subject: [PATCH] move karma out of header to radically speed up compile times of files including image_filter_types.hpp --- include/mapnik/image_filter_types.hpp | 34 ++------------ src/build.py | 1 + src/image_filter_types.cpp | 66 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 30 deletions(-) create mode 100644 src/image_filter_types.cpp diff --git a/include/mapnik/image_filter_types.hpp b/include/mapnik/image_filter_types.hpp index bb19f5392..185f0337e 100644 --- a/include/mapnik/image_filter_types.hpp +++ b/include/mapnik/image_filter_types.hpp @@ -26,9 +26,10 @@ // boost #include #include -#include + // stl #include +#include namespace mapnik { namespace filter { @@ -121,36 +122,9 @@ inline std::ostream& operator<< (std::ostream& os, invert) return os; } -template -struct to_string_visitor : boost::static_visitor -{ - to_string_visitor(Out & out) - : out_(out) {} +inline std::ostream& operator<< (std::ostream& os, filter_type const& filter); - template - void operator () (T const& filter_tag) - { - out_ << filter_tag; - } - - Out & out_; -}; - -inline std::ostream& operator<< (std::ostream& os, filter_type const& filter) -{ - to_string_visitor visitor(os); - boost::apply_visitor(visitor, filter); - return os; -} - -template -bool generate_image_filters(OutputIterator& sink, Container const& v) -{ - using boost::spirit::karma::stream; - using boost::spirit::karma::generate; - bool r = generate(sink, stream % ' ', v); - return r; -} +bool generate_image_filters(std::back_insert_iterator & sink, std::vector const& v); }} diff --git a/src/build.py b/src/build.py index d6ba1969f..3003fb455 100644 --- a/src/build.py +++ b/src/build.py @@ -100,6 +100,7 @@ else: # unix, non-macos source = Split( """ + image_filter_types.cpp miniz_png.cpp color.cpp css_color_grammar.cpp diff --git a/src/image_filter_types.cpp b/src/image_filter_types.cpp new file mode 100644 index 000000000..cfb8cc0dc --- /dev/null +++ b/src/image_filter_types.cpp @@ -0,0 +1,66 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2012 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ +// mapnik +#include + +// boost +#include +#include + +// stl +#include + +namespace mapnik { + +namespace filter { + +template +struct to_string_visitor : boost::static_visitor +{ + to_string_visitor(Out & out) + : out_(out) {} + + template + void operator () (T const& filter_tag) + { + out_ << filter_tag; + } + + Out & out_; +}; + +inline std::ostream& operator<< (std::ostream& os, filter_type const& filter) +{ + to_string_visitor visitor(os); + boost::apply_visitor(visitor, filter); + return os; +} + +bool generate_image_filters(std::back_insert_iterator& sink, std::vector const& filters) +{ + using boost::spirit::karma::stream; + using boost::spirit::karma::generate; + bool r = generate(sink, stream % ' ', filters); + return r; +} + +}}