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

overpass_api/statements/complete.cc

42 of 44 instrumented lines run by the suite (95.5%) 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#include <map>
20#include <string>
21#include <vector>
23#include "../data/abstract_processing.h"
24#include "complete.h"
27Generic_Statement_Maker< Complete_Statement > Complete_Statement::statement_maker("complete");
30Complete_Statement::Complete_Statement
31 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)
3219557 q : Output_Statement(line_number_), max_loop_num(4096)
3319557 q{
3419557 q std::map< std::string, std::string > attributes;
3619557 q attributes["from"] = "_";
3719557 q attributes["into"] = "_";
3819557 q attributes["maxnum"] = "";
4019557 q eval_attributes_array(get_name(), attributes, input_attributes);
4219557 q input = attributes["from"];
4319557 q set_output(attributes["into"]);
4519557 q if (!attributes["maxnum"].empty())
4619557 q {
4719557 q long long maxnum = atoi(attributes["maxnum"].c_str());
4819557 q if (maxnum <= 0 || maxnum > 1048576)
490 add_static_error("Maximum loop number for complete must be an integer between \"1\" and \"1048576\".");
5019557 q else
5119557 q max_loop_num = maxnum;
5219557 q }
5319557 q}
56void Complete_Statement::add_statement(Statement* statement, std::string text)
58399 q assure_no_text(text, this->get_name());
60399 q if (statement)
61399 q {
62399 q if (statement->get_name() == "newer")
630 add_static_error("\"newer\" can appear only inside \"query\" statements.");
65399 q substatements.push_back(statement);
66399 q }
70void Complete_Statement::execute(Resource_Manager& rman)
727757 q bool new_elements_found = false;
747757 q rman.push_stack_frame();
767757 q uint cnt = 0;
777757 q do
787757 q {
797757 q rman.copy_outward(input, get_result_name());
819457 q for (std::vector< Statement* >::iterator it = substatements.begin(); it != substatements.end(); ++it)
82179 q (*it)->execute(rman);
847757 q new_elements_found = rman.union_inward(input, input);
857757 q }
867757 q while (new_elements_found && ++cnt <= max_loop_num);
887757 q rman.copy_outward(input, get_result_name());
897757 q rman.move_all_inward();
907757 q rman.pop_stack_frame();
927757 q rman.health_check(*this);