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

overpass_api/statements/complete.h

22 of 31 instrumented lines run by the suite (71.0%) 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__COMPLETE_H
20#define DE__OSM3S___OVERPASS_API__STATEMENTS__COMPLETE_H
22#include <map>
23#include <string>
24#include <vector>
26#include "../data/utils.h"
27#include "statement.h"
30/* === The block statement <em>complete</em> ===
32''since v0.7.55''
34The block statement <em>complete</em> loops through its substatements
35until the results of the loop stabilize.
36This allows to track a group of loosely or tightly connected elements
37like all sections of a way with the same name or a system of tributary rivers.
39The statement delivers the accumulated elements in its output set
40both at the beginning of each loop execution and as output of the whole statement.
42The elements are accumulated from the input set before entering the loop
43and again from the input set at the end of the loop.
44If the input set contains extra elements then the loop is executed again.
46The base syntax is
48 complete
49 {
50 <List of Substatements>
51 }
53where <List of Substatements> is a list of substatements.
55The maximum number of loops defaults to 4096.
56This value can be changed to any value between 1 and 1048576 for this loop.
57To do so, put the desired value in parentheses after the "complete" keyword:
59 complete(<Number>)
60 {
61 <List of Substatements>
62 }
64The input and output set can be specified between complete and the opening parenthesis,
65i.e. you set the input set
67 complete.<Name of Input Set>
68 {
69 <List of Substatements>
70 }
72or the output set
74 complete->.<Name of Output Set>
75 {
76 <List of Substatements>
77 }
79or both
81 complete.<Name of Input Set>->.<Name of Output Set>
82 {
83 <List of Substatements>
84 }
86resp.
88 complete(<Number>).<Name of Input Set>->.<Name of Output Set>
89 {
90 <List of Substatements>
91 }
93*/
95class Complete_Statement : public Output_Statement
97public:
98 Complete_Statement(int line_number_, const std::map< std::string, std::string >& attributes,
99 Parsed_Query& global_settings);
100 virtual void add_statement(Statement* statement, std::string text);
10129957 q virtual std::string get_name() const { return "complete"; }
102 virtual void execute(Resource_Manager& rman);
10319557 q virtual ~Complete_Statement() {}
105 static Generic_Statement_Maker< Complete_Statement > statement_maker;
107 virtual std::string dump_xml(const std::string& indent) const
1080 {
1090 std::string result = indent + "<complete"
1100 + (input != "_" ? " from=\"" + input + "\"" : "")
1110 + (max_loop_num != 4096 ? " maxnum=\"" + to_string(max_loop_num) + "\"" : "")
1120 + dump_xml_result_name() + ">\n";
1140 for (std::vector< Statement* >::const_iterator it = substatements.begin(); it != substatements.end(); ++it)
1150 result += *it ? (*it)->dump_xml(indent + " ") : "";
1170 return result + indent + "</complete>\n";
1180 }
120 virtual std::string dump_compact_ql(const std::string& indent) const
1226557 q std::string result = indent + "complete"
1236557 q + (max_loop_num != 4096 ? "(" + to_string(max_loop_num) + ")" : "")
1246557 q + (input != "_" ? "." + input : "")
1256557 q + dump_ql_result_name() + "{";
1277857 q for (std::vector< Statement* >::const_iterator it = substatements.begin(); it != substatements.end(); ++it)
128139 q result += (*it)->dump_compact_ql(indent);
1296557 q result += "}";
1316557 q return result;
134 virtual std::string dump_pretty_ql(const std::string& indent) const
1366557 q std::string result = indent + "complete"
1376557 q + (max_loop_num != 4096 ? "(" + to_string(max_loop_num) + ")" : "")
1386557 q + (input != "_" ? "." + input : "")
1396557 q + dump_ql_result_name() + "{";
1417857 q for (std::vector< Statement* >::const_iterator it = substatements.begin(); it != substatements.end(); ++it)
142139 q result += "\n" + (*it)->dump_pretty_ql(indent + " ");
1436557 q result += "\n}";
1456557 q return result;
148private:
149 std::string input;
150 uint max_loop_num;
151 std::vector< Statement* > substatements;
152};
155#endif