restore local variant_io.hpp with specialisation for bool (https://github.com/mapnik/node-mapnik/issues/582)

This commit is contained in:
artemp 2016-01-15 09:26:42 +00:00
parent 5a6de7627b
commit c615708a2a
2 changed files with 75 additions and 1 deletions

View file

@ -0,0 +1,74 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 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
*
*****************************************************************************/
#ifndef MAPNIK_UTIL_VARIANT_IO_HPP
#define MAPNIK_UTIL_VARIANT_IO_HPP
namespace mapnik { namespace util {
namespace detail {
// operator<< helper
template <typename Out>
class printer
{
public:
explicit printer(Out & out)
: out_(out) {}
printer& operator=(printer const&) = delete;
// visitor
template <typename T>
void operator()(T const& operand) const
{
out_ << operand;
}
/// specialized visitor for boolean
void operator()(bool const & val) const
{
if (val) {
out_ << "true";
} else {
out_ << "false";
}
}
private:
Out & out_;
};
} // namespace detail
// operator<<
template <typename charT, typename traits, typename... Types>
VARIANT_INLINE std::basic_ostream<charT, traits>&
operator<< (std::basic_ostream<charT, traits>& out, variant<Types...> const& rhs)
{
detail::printer<std::basic_ostream<charT, traits>> visitor(out);
mapnik::util::apply_visitor(visitor, rhs);
return out;
}
}}
#endif // MAPNIK_UTIL_VARIANT_IO_HPP

View file

@ -46,7 +46,7 @@
#include <mapnik/group/group_layout.hpp>
#include <mapnik/group/group_symbolizer_properties.hpp>
#include <mapnik/util/variant.hpp>
#include <mapbox/variant/variant_io.hpp>
#include <mapnik/util/variant_io.hpp>
#pragma GCC diagnostic push
#include <mapnik/warning_ignore.hpp>
#include <boost/algorithm/string.hpp>