Overpass API regression suite coverage (Nova Scotia) / overpass_api/statements/set_prop.h

overpass_api/statements/set_prop.h

15 of 18 instrumented lines run by the suite (83.3%) at 8edf11b0419c (this file on GitHub).

runnever runcolumns: line, executions, queries (click for the queries that run the line)

1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.
2 *
3 * This file is part of Overpass_API.
4 *
5 * Overpass_API is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * Overpass_API is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
17 */
19#ifndef DE__OSM3S___OVERPASS_API__STATEMENTS__SET_TAG_H
20#define DE__OSM3S___OVERPASS_API__STATEMENTS__SET_TAG_H
23#include "../../expat/escape_json.h"
24#include "../../expat/escape_xml.h"
25#include "../data/tag_store.h"
26#include "../data/utils.h"
27#include "evaluator.h"
28#include "statement.h"
30#include <map>
31#include <string>
32#include <vector>
35struct Set_Prop_Task
37 enum Mode { single_key, set_id, set_geometry, generic };
39537109 q virtual ~Set_Prop_Task() {}
41 virtual void process(Derived_Structure& result, bool& id_set) const = 0;
43 virtual void process(const Element_With_Context< Node_Skeleton >& data,
44 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const = 0;
45 virtual void process(const Element_With_Context< Attic< Node_Skeleton > >& data,
46 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const = 0;
47 virtual void process(const Element_With_Context< Way_Skeleton >& data,
48 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const = 0;
49 virtual void process(const Element_With_Context< Attic< Way_Skeleton > >& data,
50 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const = 0;
51 virtual void process(const Element_With_Context< Relation_Skeleton>& data,
52 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const = 0;
53 virtual void process(const Element_With_Context< Attic< Relation_Skeleton > >& data,
54 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const = 0;
55 virtual void process(const Element_With_Context< Area_Skeleton >& data,
56 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const = 0;
57 virtual void process(const Element_With_Context< Derived_Skeleton >& data,
58 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const = 0;
59};
62struct Set_Prop_Plain_Task : public Set_Prop_Task
64496109 q Set_Prop_Plain_Task(Eval_Task* rhs_, const std::string& key_, Mode mode_) : rhs(rhs_), key(key_), mode(mode_) {}
65496109 q virtual ~Set_Prop_Plain_Task() { delete rhs; }
67 virtual void process(Derived_Structure& result, bool& id_set) const;
69 virtual void process(const Element_With_Context< Node_Skeleton >& data,
70 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
71 virtual void process(const Element_With_Context< Attic< Node_Skeleton > >& data,
72 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
73 virtual void process(const Element_With_Context< Way_Skeleton >& data,
74 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
75 virtual void process(const Element_With_Context< Attic< Way_Skeleton > >& data,
76 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
77 virtual void process(const Element_With_Context< Relation_Skeleton>& data,
78 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
79 virtual void process(const Element_With_Context< Attic< Relation_Skeleton > >& data,
80 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
81 virtual void process(const Element_With_Context< Area_Skeleton >& data,
82 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
83 virtual void process(const Element_With_Context< Derived_Skeleton >& data,
84 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
86private:
87 Set_Prop_Plain_Task(const Set_Prop_Plain_Task&);
88 const Set_Prop_Plain_Task& operator=(const Set_Prop_Plain_Task&);
90 Eval_Task* rhs;
91 std::string key;
92 Mode mode;
93};
96struct Set_Prop_Generic_Task : public Set_Prop_Task
98 virtual void process(Derived_Structure& result, bool& id_set) const;
100 virtual void process(const Element_With_Context< Node_Skeleton >& data,
101 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
102 virtual void process(const Element_With_Context< Attic< Node_Skeleton > >& data,
103 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
104 virtual void process(const Element_With_Context< Way_Skeleton >& data,
105 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
106 virtual void process(const Element_With_Context< Attic< Way_Skeleton > >& data,
107 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
108 virtual void process(const Element_With_Context< Relation_Skeleton>& data,
109 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
110 virtual void process(const Element_With_Context< Attic< Relation_Skeleton > >& data,
111 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
112 virtual void process(const Element_With_Context< Area_Skeleton >& data,
113 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
114 virtual void process(const Element_With_Context< Derived_Skeleton >& data,
115 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
117 void add_key(const std::string& key, Eval_Task* task);
119private:
120 Owning_Array< Eval_Task* > rhs;
121 std::vector< std::string > keys;
122};
125struct Set_Prop_Geometry_Task : public Set_Prop_Task
1274138 q Set_Prop_Geometry_Task(Eval_Geometry_Task* rhs_) : rhs(rhs_) {}
1284138 q virtual ~Set_Prop_Geometry_Task() { delete rhs; }
130 virtual void process(Derived_Structure& result, bool& id_set) const;
132 virtual void process(const Element_With_Context< Node_Skeleton >& data,
133 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
134 virtual void process(const Element_With_Context< Attic< Node_Skeleton > >& data,
135 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
136 virtual void process(const Element_With_Context< Way_Skeleton >& data,
137 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
138 virtual void process(const Element_With_Context< Attic< Way_Skeleton > >& data,
139 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
140 virtual void process(const Element_With_Context< Relation_Skeleton>& data,
141 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
142 virtual void process(const Element_With_Context< Attic< Relation_Skeleton > >& data,
143 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
144 virtual void process(const Element_With_Context< Area_Skeleton >& data,
145 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
146 virtual void process(const Element_With_Context< Derived_Skeleton >& data,
147 const std::vector< std::string >& declared_keys, Derived_Structure& result, bool& id_set) const;
149private:
150 Set_Prop_Geometry_Task(const Set_Prop_Plain_Task&);
151 const Set_Prop_Geometry_Task& operator=(const Set_Prop_Plain_Task&);
153 Eval_Geometry_Task* rhs;
154};
157class Set_Prop_Statement : public Statement
159public:
160 struct Statement_Maker : public Generic_Statement_Maker< Set_Prop_Statement >
161 {
1622448612 q Statement_Maker() : Generic_Statement_Maker< Set_Prop_Statement >("set-prop") {}
163 };
164 static Statement_Maker statement_maker;
166 struct Evaluator_Maker : public Statement::Evaluator_Maker
167 {
168 virtual Statement* create_evaluator(const Token_Node_Ptr& tree_it, QL_Context tree_context,
169 Statement::Factory& stmt_factory, Parsed_Query& global_settings, Error_Output* error_output);
170 Evaluator_Maker()
1712448612 q {
1722448612 q Statement::maker_by_token()["="].push_back(this);
1732448612 q Statement::maker_by_token()["!"].push_back(this);
1742448612 q }
175 };
176 static Evaluator_Maker evaluator_maker;
178 virtual std::string dump_xml(const std::string& indent) const;
179 virtual std::string dump_compact_ql(const std::string&) const;
180478116 q virtual std::string dump_pretty_ql(const std::string&) const { return dump_compact_ql(""); }
182 Set_Prop_Statement(int line_number_, const std::map< std::string, std::string >& input_attributes,
183 Parsed_Query& global_settings);
1841924118 q virtual std::string get_name() const { return "set-prop"; }
1850 virtual std::string get_result_name() const { return ""; }
186 virtual void add_statement(Statement* statement, std::string text);
1870 virtual void execute(Resource_Manager& rman) {}
1881924118 q virtual ~Set_Prop_Statement() { delete key; }
190 virtual Requested_Context request_context() const;
192 Set_Prop_Task* get_task(Prepare_Task_Context& context, const std::vector< std::string >& otherwise_set_keys);
1946642118 q const std::string* get_key() const { return key; }
1950 bool has_value() const { return tag_value; }
19652572 q Set_Prop_Task::Mode get_mode() const { return mode; }
198private:
199 std::string input;
200 std::string* key;
201 Set_Prop_Task::Mode mode;
202 Evaluator* tag_value;
203};
206#endif