/usr/include/mapnik/expression_node.hpp is in libmapnik-dev 3.0.12+ds-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | /*****************************************************************************
*
* 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_EXPRESSION_NODE_HPP
#define MAPNIK_EXPRESSION_NODE_HPP
// mapnik
#include <mapnik/value_types.hpp>
#include <mapnik/value.hpp>
#include <mapnik/config.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/function_call.hpp>
#include <mapnik/expression_node_types.hpp>
// stl
#include <memory>
namespace mapnik
{
using value_type = mapnik::value;
template <typename Tag> struct make_op;
template <> struct make_op<mapnik::tags::negate> { using type = std::negate<value_type>;};
template <> struct make_op<mapnik::tags::plus> { using type = std::plus<value_type>;};
template <> struct make_op<mapnik::tags::minus> { using type = std::minus<value_type>;};
template <> struct make_op<mapnik::tags::mult> { using type = std::multiplies<value_type>;};
template <> struct make_op<mapnik::tags::div> { using type = std::divides<value_type>;};
template <> struct make_op<mapnik::tags::mod> { using type = std::modulus<value_type>;};
template <> struct make_op<mapnik::tags::less> { using type = std::less<value_type>;};
template <> struct make_op<mapnik::tags::less_equal> { using type = std::less_equal<value_type>;};
template <> struct make_op<mapnik::tags::greater> { using type = std::greater<value_type>;};
template <> struct make_op<mapnik::tags::greater_equal> { using type = std::greater_equal<value_type>;};
template <> struct make_op<mapnik::tags::equal_to> { using type = std::equal_to<value_type>;};
template <> struct make_op<mapnik::tags::not_equal_to> { using type = std::not_equal_to<value_type>;};
template <> struct make_op<mapnik::tags::logical_not> { using type = std::logical_not<value_type>;};
template <> struct make_op<mapnik::tags::logical_and> { using type = std::logical_and<value_type>;};
template <> struct make_op<mapnik::tags::logical_or> { using type = std::logical_or<value_type>;};
template <typename Tag>
struct unary_node
{
unary_node (expr_node const& a)
: expr(a) {}
static const char* type()
{
return Tag::str();
}
expr_node expr;
};
template <typename Tag>
struct binary_node
{
binary_node(expr_node const& a, expr_node const& b)
: left(a),
right(b) {}
static const char* type()
{
return Tag::str();
}
expr_node left,right;
};
struct unary_function_call
{
using argument_type = expr_node;
unary_function_call() = default;
unary_function_call(unary_function_impl _fun, argument_type const& _arg)
: fun(_fun), arg(_arg) {}
unary_function_impl fun;
argument_type arg;
};
struct binary_function_call
{
using argument_type = expr_node;
binary_function_call() = default;
binary_function_call(binary_function_impl _fun, argument_type const& _arg1, argument_type const& _arg2)
: fun(_fun), arg1(_arg1), arg2(_arg2) {}
binary_function_impl fun;
argument_type arg1;
argument_type arg2;
};
// pimpl
struct _regex_match_impl;
struct _regex_replace_impl;
struct MAPNIK_DECL regex_match_node
{
regex_match_node(transcoder const& tr, expr_node const& a, std::string const& ustr);
mapnik::value apply(mapnik::value const& v) const;
std::string to_string() const;
expr_node expr;
// TODO - use unique_ptr once https://github.com/mapnik/mapnik/issues/2457 is fixed
std::shared_ptr<_regex_match_impl> impl_;
};
struct MAPNIK_DECL regex_replace_node
{
regex_replace_node(transcoder const& tr, expr_node const& a, std::string const& ustr, std::string const& f);
mapnik::value apply(mapnik::value const& v) const;
std::string to_string() const;
expr_node expr;
// TODO - use unique_ptr once https://github.com/mapnik/mapnik/issues/2457 is fixed
std::shared_ptr<_regex_replace_impl> impl_;
};
inline expr_node & operator- (expr_node& expr)
{
return expr = unary_node<mapnik::tags::negate>(expr);
}
inline expr_node & operator += ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::plus>(left,right);
}
inline expr_node & operator -= ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::minus>(left,right);
}
inline expr_node & operator *= ( expr_node &left , expr_node const& right)
{
return left = binary_node<mapnik::tags::mult>(left,right);
}
inline expr_node & operator /= ( expr_node &left , expr_node const& right)
{
return left = binary_node<mapnik::tags::div>(left,right);
}
inline expr_node & operator %= ( expr_node &left , expr_node const& right)
{
return left = binary_node<mapnik::tags::mod>(left,right);
}
inline expr_node & operator < ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::less>(left,right);
}
inline expr_node & operator <= ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::less_equal>(left,right);
}
inline expr_node & operator > ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::greater>(left,right);
}
inline expr_node & operator >= ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::greater_equal>(left,right);
}
inline expr_node & operator == ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::equal_to>(left,right);
}
inline expr_node & operator != ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::not_equal_to>(left,right);
}
inline expr_node & operator ! (expr_node & expr)
{
return expr = unary_node<mapnik::tags::logical_not>(expr);
}
inline expr_node & operator && ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::logical_and>(left,right);
}
inline expr_node & operator || ( expr_node &left, expr_node const& right)
{
return left = binary_node<mapnik::tags::logical_or>(left,right);
}
}
#endif //MAPNIK_EXPRESSION_NODE_HPP
|