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

overpass_api/statements/convert.h

27 of 39 instrumented lines run by the suite (69.2%) 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__CONVERT_H
20#define DE__OSM3S___OVERPASS_API__STATEMENTS__CONVERT_H
23#include "set_prop.h"
24#include "statement.h"
26#include <map>
27#include <string>
28#include <vector>
31class Set_Prop_Statement;
34/* === The statement <em>convert</em> ===
36The statement <em>convert</em> produces per element in its input set one derived element.
37The content of this output element is controlled by the parameters of the statement.
39It is necessary to set a fixed type as type for all the generated elements.
40After that, an arbitrary number of tags can be set.
41In addition, it can be specified to copy all keys from the originating object.
42In this case, it is also possible to selectively suppress some tags.
44Finally, it is possible to explicitly set the id of the generated objects.
45If you do not set an id then an unique id from a global ascending counter is assigned.
47The base syntax is
49 convert <Type> <List of Tags>
51where <List of Tags> is a comma separated list of items,
52each of which must be one the following
54 <Key> = <Evaluator>
55 ::id = <Evaluator>
56 :: = <Evaluator>
57 !<Key>
58*/
60class Convert_Statement : public Output_Statement
62public:
63 Convert_Statement(int line_number_, const std::map< std::string, std::string >& attributes,
64 Parsed_Query& global_settings);
6530268 q virtual std::string get_name() const { return "convert"; }
66 virtual void add_statement(Statement* statement, std::string text);
67 virtual void execute(Resource_Manager& rman);
68 virtual ~Convert_Statement();
69 static Generic_Statement_Maker< Convert_Statement > statement_maker;
710 std::string get_source_name() const { return input; }
73 virtual std::string dump_xml(const std::string& indent) const
740 {
750 std::string result = indent + "<convert"
760 + (input != "_" ? " from=\"" + input + "\"" : "")
770 + dump_xml_result_name() + " type=\"" + type;
780 if (evaluators.empty())
790 return result + "\"/>\n";
800 result += "\">\n";
820 for (std::vector< Set_Prop_Statement* >::const_iterator it = evaluators.begin(); it != evaluators.end(); ++it)
830 result += *it ? (*it)->dump_xml(indent + " ") : "";
840 return result + "</convert>\n";
850 }
87 virtual std::string dump_compact_ql(const std::string& indent) const
887568 q {
897568 q std::string result = indent + (input == "_" ? "" : "." + input + " ")
907568 q + "convert " + type;
917568 q std::vector< Set_Prop_Statement* >::const_iterator it = evaluators.begin();
927568 q if (it != evaluators.end())
937568 q {
947568 q result += " " + (*it ? (*it)->dump_compact_ql(indent + " ") : "");
957568 q ++it;
967568 q }
9730968 q for (; it != evaluators.end(); ++it)
9823465 q result += "," + (*it ? (*it)->dump_compact_ql(indent + " ") : "");
997568 q return result + dump_ql_result_name() + ";";
102 virtual std::string dump_pretty_ql(const std::string& indent) const
1047568 q std::string result = indent + (input == "_" ? "" : "." + input + " ")
1057568 q + "convert " + type;
1067568 q std::vector< Set_Prop_Statement* >::const_iterator it = evaluators.begin();
1077568 q if (it != evaluators.end())
1097568 q result += "\n " + indent + (*it ? (*it)->dump_pretty_ql(indent + " ") : "");
1107568 q ++it;
11230968 q for (; it != evaluators.end(); ++it)
11323465 q result += ",\n " + indent + (*it ? (*it)->dump_pretty_ql(indent + " ") : "");
1147568 q return result + dump_ql_result_name() + ";";
117private:
118 std::string input;
119 std::string type;
120 std::vector< Set_Prop_Statement* > evaluators;
121 Set_Prop_Statement* geom_evaluator;
122 Set_Prop_Statement* id_evaluator;
123 Set_Prop_Statement* multi_evaluator;
124};
127#endif