Overpass API regression suite coverage (Nova Scotia) / overpass_api/statements/statement_dump.cc
overpass_api/statements/statement_dump.cc
189 of 275 instrumented lines run by the suite (68.7%) 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. 3 * This file is part of Overpass_API. 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. 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. 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/>. 19#include "../frontend/output.h" 20#include "statement_dump.h" 28Statement_Dump::~Statement_Dump() 3022833611 q for (std::vector< Statement_Dump* >::iterator it = substatements.begin(); 3143833611 q it != substatements.end(); ++it) 36void Statement_Dump::add_statement(Statement_Dump* statement, std::string text) 3821000608 q substatements.push_back(statement); 42Statement* Statement_Dump::create_non_dump_stmt(Statement::Factory& stmt_factory) 4711378607 q non_dump_stmt = stmt_factory.create_statement(name_, line_number, attributes); 5115226607 q for (std::vector< Statement_Dump* >::const_iterator it = substatements.begin(); it != substatements.end(); ++it) 533848558 q Statement* substmt = (*it)->create_non_dump_stmt(stmt_factory); 553848558 q non_dump_stmt->add_statement(substmt, ""); 63std::string indent(const std::string& subresult) 677000608 q std::string::size_type pos = 0; 687000608 q std::string::size_type next = subresult.find('\n', pos); 6926862608 q while (next != std::string::npos) 7119862608 q result += " " + subresult.substr(pos, next-pos) + '\n'; 7319862608 q next = subresult.find('\n', pos); 757000608 q if (subresult.substr(pos) != "") 760 result += " " + subresult.substr(pos); 82std::string Statement_Dump::dump_xml() const 851311530 q return non_dump_stmt->dump_xml(""); 896300611 q if (substatements.empty()) 914599605 q result = std::string("<") + name_; 924599605 q for (std::map< std::string, std::string >::const_iterator it = attributes.begin(); 9343286605 q it != attributes.end(); ++it) 9438687604 q result += std::string(" ") + it->first + "=\"" + escape_xml(it->second) + "\""; 991701608 q result = std::string("<") + name_; 1001701608 q for (std::map< std::string, std::string >::const_iterator it = attributes.begin(); 1014395608 q it != attributes.end(); ++it) 1022694583 q result += std::string(" ") + it->first + "=\"" + escape_xml(it->second) + "\""; 1051701608 q for (std::vector< Statement_Dump* >::const_iterator it = substatements.begin(); 1068701608 q it != substatements.end(); ++it) 1077000608 q result += indent((*it)->dump_xml()); 1091701608 q result += std::string("</") + name_ + ">\n"; 116std::string Statement_Dump::dump_compact_map_ql(Statement::Factory& stmt_factory) 123611611 q for (std::map< std::string, std::string >::const_iterator it = attributes.begin(); 1241173611 q it != attributes.end(); ++it) 1271010 q result += "[timeout:" + it->second + "]"; 128552316 q else if (it->first == "element-limit") 12999 q result += "[maxsize:" + it->second + "]"; 130543311 q else if (it->first == "output") 132112112 q if (stmt_factory.global_settings.get_output_handler()) 133112112 q result += "[out:" + it->second + stmt_factory.global_settings.get_output_handler()->dump_config() + "]"; 1350 output_val = it->second; 137431311 q else if (it->first == "output-config") 139319259 q else if (it->first == "bbox") 1402020 q result += "[bbox:" + it->second + "]"; 1430 result += "[out:" + output_val + output_config + "]"; 145611611 q if (attributes.find("augmented") != attributes.end() && 146611611 q attributes.find("augmented")->second == "deletions" && 147611611 q attributes.find("from") != attributes.end()) 1493232 q result += "[adiff:\"" + attributes.find("from")->second; 1503232 q if (attributes.find("date") != attributes.end()) 1511616 q result += "\",\"" + attributes.find("date")->second; 154579579 q else if (attributes.find("from") != attributes.end()) 1564444 q result += "[diff:\"" + attributes.find("from")->second; 1574444 q if (attributes.find("date") != attributes.end()) 15844 q result += "\",\"" + attributes.find("date")->second; 161535535 q else if (attributes.find("date") != attributes.end()) 162171171 q result += "[date:\"" + attributes.find("date")->second + "\"]"; 166611611 q for (std::vector< Statement_Dump* >::const_iterator it = substatements.begin(); 1675687611 q it != substatements.end(); ++it) 1685076608 q result += (*it)->dump_compact_map_ql(stmt_factory); 1725076608 q Statement* stmt = create_non_dump_stmt(stmt_factory); 1745076608 q result += stmt->dump_compact_ql(""); 1760 result += "(" + name_ + ":)"; 183std::string Statement_Dump::dump_bbox_map_ql(Statement::Factory& stmt_factory) 1860 bool auto_timeout = true; 1870 if (name_ == "osm-script") 1890 std::string output_val; 1900 std::string output_config; 1910 for (std::map< std::string, std::string >::const_iterator it = attributes.begin(); 1920 it != attributes.end(); ++it) 1940 if (it->first == "timeout") 1960 result += "[timeout:" + it->second + "]"; 1970 auto_timeout = false; 1990 else if (it->first == "element-limit") 2000 result += "[maxsize:" + it->second + "]"; 2010 else if (it->first == "output") 2030 if (stmt_factory.global_settings.get_output_handler()) 2040 result += "[out:" + it->second + stmt_factory.global_settings.get_output_handler()->dump_config() + "]"; 2060 output_val = it->second; 2080 else if (it->first == "output-config") 2090 output_config = it->second; 2100 else if (it->first == "bbox") 2110 result += "[bbox:" + it->second + "]"; 2130 if (output_val != "") 2140 result += "[out:" + output_val + output_config + "]"; 2160 if (attributes.find("augmented") != attributes.end() && 2170 attributes.find("augmented")->second == "deletions" && 2180 attributes.find("from") != attributes.end()) 2200 result += "[adiff:\"" + attributes.find("from")->second; 2210 if (attributes.find("date") != attributes.end()) 2220 result += "\",\"" + attributes.find("date")->second; 2250 else if (attributes.find("from") != attributes.end()) 2270 result += "[diff:\"" + attributes.find("from")->second; 2280 if (attributes.find("date") != attributes.end()) 2290 result += "\",\"" + attributes.find("date")->second; 2320 else if (attributes.find("date") != attributes.end()) 2330 result += "[date:\"" + attributes.find("date")->second + "\"]"; 2360 result += "[timeout:1]"; 2380 for (std::vector< Statement_Dump* >::const_iterator it = substatements.begin(); 2390 it != substatements.end(); ++it) 2400 result += (*it)->dump_bbox_map_ql(stmt_factory); 2440 Statement* stmt = create_non_dump_stmt(stmt_factory); 2460 result += stmt->dump_compact_ql( 2470 name_ == "complete" || name_ == "difference" || name_ == "for" || name_ == "foreach" 2480 || name_ == "if" || name_ == "query" || name_ == "union" ? "(bbox)" : ""); 2500 result += "(" + name_ + ":)"; 257std::string Statement_Dump::dump_pretty_map_ql(Statement::Factory& stmt_factory) 264611611 q for (std::map< std::string, std::string >::const_iterator it = attributes.begin(); 2651173611 q it != attributes.end(); ++it) 2681010 q result += "[timeout:" + it->second + "]\n"; 269552316 q else if (it->first == "element-limit") 27099 q result += "[maxsize:" + it->second + "]\n"; 271543311 q else if (it->first == "output") 273112112 q if (stmt_factory.global_settings.get_output_handler()) 274112112 q result += "[out:" + it->second + stmt_factory.global_settings.get_output_handler()->dump_config() + "]\n"; 2760 output_val = it->second; 278431311 q else if (it->first == "output-config") 280319259 q else if (it->first == "bbox") 2812020 q result += "[bbox:" + it->second + "]\n"; 2840 result += "[out:" + output_val + output_config + "]\n"; 286611611 q if (attributes.find("augmented") != attributes.end() && 287611611 q attributes.find("augmented")->second == "deletions" && 288611611 q attributes.find("from") != attributes.end()) 2903232 q result += "[adiff:\"" + attributes.find("from")->second; 2913232 q if (attributes.find("date") != attributes.end()) 2921616 q result += "\",\"" + attributes.find("date")->second; 295579579 q else if (attributes.find("from") != attributes.end()) 2974444 q result += "[diff:\"" + attributes.find("from")->second; 2984444 q if (attributes.find("date") != attributes.end()) 29944 q result += "\",\"" + attributes.find("date")->second; 302535535 q else if (attributes.find("date") != attributes.end()) 303171171 q result += "[date:\"" + attributes.find("date")->second + "\"]\n"; 307611611 q for (std::vector< Statement_Dump* >::const_iterator it = substatements.begin(); 3085687611 q it != substatements.end(); ++it) 3095076608 q result += (*it)->dump_pretty_map_ql(stmt_factory) + "\n"; 3135076608 q Statement* stmt = create_non_dump_stmt(stmt_factory); 3155076608 q result += stmt->dump_pretty_ql(""); 3170 result += "(" + name_ + ":)"; 324Statement_Dump* Statement_Dump::Factory::create_statement 325 (std::string element, int line_number, const std::map< std::string, std::string >& attributes) 32718903612 q return new Statement_Dump(element, attributes, line_number); 331Statement_Dump* Statement_Dump::Factory::create_evaluator( 332 const Token_Node_Ptr& tree_it, Statement::QL_Context tree_context, 333 const Statement::Return_Type_Checker& eval_type) 3351644158 q Statement* stmt = stmt_factory->create_evaluator(tree_it, tree_context, eval_type); 3371629158 q return new Statement_Dump("universal_dump", std::map< std::string, std::string >(), tree_it->line_col.first, stmt); 343Statement_Dump* Statement_Dump::Factory::create_criterion(const Token_Node_Ptr& tree_it, 344 const std::string& type, bool& can_standalone, const std::string& into) 3462313497 q Statement* stmt = stmt_factory->create_criterion(tree_it, type, can_standalone, into); 3482304495 q return new Statement_Dump("universal_dump", std::map< std::string, std::string >(), tree_it->line_col.first, stmt); 354std::string Statement_Dump::attribute(const std::string& key) const 3560 std::map< std::string, std::string >::const_iterator it = attributes.find(key); 3570 if (it == attributes.end())