Overpass API regression suite coverage (Saxony) / overpass_api/statements/difference.cc

overpass_api/statements/difference.cc

29 of 39 instrumented lines run by the suite (74.4%) 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 <algorithm>
20#include <list>
21#include <map>
22#include <set>
23#include <sstream>
24#include <string>
25#include <vector>
27#include "../data/abstract_processing.h"
28#include "difference.h"
31Generic_Statement_Maker< Difference_Statement > Difference_Statement::statement_maker("difference");
34Difference_Statement::Difference_Statement
35 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)
366621 q : Output_Statement(line_number_)
386621 q std::map< std::string, std::string > attributes;
406621 q attributes["into"] = "_";
426621 q eval_attributes_array(get_name(), attributes, input_attributes);
446621 q set_output(attributes["into"]);
48void Difference_Statement::add_statement(Statement* statement, std::string text)
4913221 q{
5013221 q assure_no_text(text, this->get_name());
5213221 q if (substatements.size() >= 2)
530 {
540 std::ostringstream temp;
550 temp<<"A set difference always requires exactly two substatements: "
560 "the set of elements to copy to the result minus "
570 "the set of elements to leave out in the result.";
580 add_static_error(temp.str());
590 }
6113221 q if (statement->get_result_name() != "")
6213221 q substatements.push_back(statement);
630 else
640 substatement_error(get_name(), statement);
6513221 q}
68void Difference_Statement::execute(Resource_Manager& rman)
702521 q if (substatements.empty())
710 return;
732521 q rman.push_stack_frame();
752521 q std::vector< Statement* >::iterator it = substatements.begin();
762521 q (*it)->execute(rman);
782521 q rman.copy_inward((*it)->get_result_name(), get_result_name());
802521 q ++it;
812521 q if (it != substatements.end())
822521 q {
832521 q (*it)->execute(rman);
842521 q rman.substract_from_inward((*it)->get_result_name(), get_result_name());
852521 q }
872521 q rman.move_all_inward_except(get_result_name());
882521 q rman.pop_stack_frame();
902521 q rman.health_check(*this);