add property_serializer impl
This commit is contained in:
parent
8465a78c97
commit
ee58762bd9
3 changed files with 79 additions and 0 deletions
|
@ -53,6 +53,8 @@ void set_property_from_xml(T1 & val, char const* name, xml_node const& node)
|
|||
}
|
||||
}
|
||||
|
||||
void serialize_property(std::string const& name, symbolizer_base::value_type const& val, boost::property_tree::ptree & node);
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_PROPERTIES_UTIL_HPP
|
||||
|
|
|
@ -220,6 +220,7 @@ source = Split(
|
|||
text/scrptrun.cpp
|
||||
text/face.cpp
|
||||
text/placement_finder.cpp
|
||||
text/properties_util.cpp
|
||||
text/renderer.cpp
|
||||
text/symbolizer_helpers.cpp
|
||||
text/text_properties.cpp
|
||||
|
|
76
src/text/properties_util.cpp
Normal file
76
src/text/properties_util.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2014 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <mapnik/text/properties_util.hpp>
|
||||
#include <mapnik/expression_string.hpp>
|
||||
|
||||
namespace mapnik { namespace detail {
|
||||
|
||||
struct property_serializer : public boost::static_visitor<>
|
||||
{
|
||||
property_serializer(std::string const& name, boost::property_tree::ptree & node)
|
||||
: name_(name),
|
||||
node_(node) {}
|
||||
|
||||
void operator() (expression_ptr const& expr) const
|
||||
{
|
||||
if (expr) node_.put("<xmlattr>." + name_, to_expression_string(*expr));
|
||||
}
|
||||
|
||||
void operator() (value_bool val) const
|
||||
{
|
||||
node_.put("<xmlattr>." + name_, val );
|
||||
}
|
||||
|
||||
void operator() (value_integer val) const
|
||||
{
|
||||
node_.put("<xmlattr>." + name_, val );
|
||||
}
|
||||
|
||||
void operator() (value_double val) const
|
||||
{
|
||||
node_.put("<xmlattr>." + name_, val );
|
||||
}
|
||||
|
||||
void operator() (std::string const& val) const
|
||||
{
|
||||
node_.put("<xmlattr>." + name_, val );
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void operator() (T const& val) const
|
||||
{
|
||||
std::cerr << "NOOP" << std::endl;
|
||||
}
|
||||
|
||||
std::string const& name_;
|
||||
boost::property_tree::ptree & node_;
|
||||
};
|
||||
}
|
||||
|
||||
void serialize_property(std::string const& name, symbolizer_base::value_type const& val, boost::property_tree::ptree & node)
|
||||
{
|
||||
boost::apply_visitor(detail::property_serializer(name,node), val);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue