Overpass API regression suite coverage (Saxony) / 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() 3025815691 q for (std::vector< Statement_Dump* >::iterator it = substatements.begin(); 3149557691 q it != substatements.end(); ++it) 36void Statement_Dump::add_statement(Statement_Dump* statement, std::string text) 3823742689 q substatements.push_back(statement); 42Statement* Statement_Dump::create_non_dump_stmt(Statement::Factory& stmt_factory) 4712768688 q non_dump_stmt = stmt_factory.create_statement(name_, line_number, attributes); 5117252688 q for (std::vector< Statement_Dump* >::const_iterator it = substatements.begin(); it != substatements.end(); ++it) 534484623 q Statement* substmt = (*it)->create_non_dump_stmt(stmt_factory); 554484623 q non_dump_stmt->add_statement(substmt, ""); 63std::string indent(const std::string& subresult) 677914689 q std::string::size_type pos = 0; 687914689 q std::string::size_type next = subresult.find('\n', pos); 6929867689 q while (next != std::string::npos) 7121953689 q result += " " + subresult.substr(pos, next-pos) + '\n'; 7321953689 q next = subresult.find('\n', pos); 757914689 q if (subresult.substr(pos) != "") 760 result += " " + subresult.substr(pos); 82std::string Statement_Dump::dump_xml() const 851530603 q return non_dump_stmt->dump_xml(""); 897075691 q if (substatements.empty()) 915150687 q result = std::string("<") + name_; 925150687 q for (std::map< std::string, std::string >::const_iterator it = attributes.begin(); 9348472687 q it != attributes.end(); ++it) 9443322686 q result += std::string(" ") + it->first + "=\"" + escape_xml(it->second) + "\""; 991925689 q result = std::string("<") + name_; 1001925689 q for (std::map< std::string, std::string >::const_iterator it = attributes.begin(); 1014975689 q it != attributes.end(); ++it) 1023050662 q result += std::string(" ") + it->first + "=\"" + escape_xml(it->second) + "\""; 1051925689 q for (std::vector< Statement_Dump* >::const_iterator it = substatements.begin(); 1069839689 q it != substatements.end(); ++it) 1077914689 q result += indent((*it)->dump_xml()); 1091925689 q result += std::string("</") + name_ + ">\n"; 116std::string Statement_Dump::dump_compact_map_ql(Statement::Factory& stmt_factory) 123691691 q for (std::map< std::string, std::string >::const_iterator it = attributes.begin(); 1241345691 q it != attributes.end(); ++it) 1272828 q result += "[timeout:" + it->second + "]"; 128626357 q else if (it->first == "element-limit") 12988 q result += "[maxsize:" + it->second + "]"; 130618352 q else if (it->first == "output") 132129129 q if (stmt_factory.global_settings.get_output_handler()) 133129129 q result += "[out:" + it->second + stmt_factory.global_settings.get_output_handler()->dump_config() + "]"; 1350 output_val = it->second; 137489352 q else if (it->first == "output-config") 139360297 q else if (it->first == "bbox") 1402323 q result += "[bbox:" + it->second + "]"; 1430 result += "[out:" + output_val + output_config + "]"; 145691691 q if (attributes.find("augmented") != attributes.end() && 146691691 q attributes.find("augmented")->second == "deletions" && 147691691 q attributes.find("from") != attributes.end()) 1493333 q result += "[adiff:\"" + attributes.find("from")->second; 1503333 q if (attributes.find("date") != attributes.end()) 1511212 q result += "\",\"" + attributes.find("date")->second; 154658658 q else if (attributes.find("from") != attributes.end()) 1564848 q result += "[diff:\"" + attributes.find("from")->second; 1574848 q if (attributes.find("date") != attributes.end()) 1581111 q result += "\",\"" + attributes.find("date")->second; 161610610 q else if (attributes.find("date") != attributes.end()) 162200200 q result += "[date:\"" + attributes.find("date")->second + "\"]"; 166691691 q for (std::vector< Statement_Dump* >::const_iterator it = substatements.begin(); 1676363691 q it != substatements.end(); ++it) 1685672689 q result += (*it)->dump_compact_map_ql(stmt_factory); 1725672689 q Statement* stmt = create_non_dump_stmt(stmt_factory); 1745672689 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) 264691691 q for (std::map< std::string, std::string >::const_iterator it = attributes.begin(); 2651345691 q it != attributes.end(); ++it) 2682828 q result += "[timeout:" + it->second + "]\n"; 269626357 q else if (it->first == "element-limit") 27088 q result += "[maxsize:" + it->second + "]\n"; 271618352 q else if (it->first == "output") 273129129 q if (stmt_factory.global_settings.get_output_handler()) 274129129 q result += "[out:" + it->second + stmt_factory.global_settings.get_output_handler()->dump_config() + "]\n"; 2760 output_val = it->second; 278489352 q else if (it->first == "output-config") 280360297 q else if (it->first == "bbox") 2812323 q result += "[bbox:" + it->second + "]\n"; 2840 result += "[out:" + output_val + output_config + "]\n"; 286691691 q if (attributes.find("augmented") != attributes.end() && 287691691 q attributes.find("augmented")->second == "deletions" && 288691691 q attributes.find("from") != attributes.end()) 2903333 q result += "[adiff:\"" + attributes.find("from")->second; 2913333 q if (attributes.find("date") != attributes.end()) 2921212 q result += "\",\"" + attributes.find("date")->second; 295658658 q else if (attributes.find("from") != attributes.end()) 2974848 q result += "[diff:\"" + attributes.find("from")->second; 2984848 q if (attributes.find("date") != attributes.end()) 2991111 q result += "\",\"" + attributes.find("date")->second; 302610610 q else if (attributes.find("date") != attributes.end()) 303200200 q result += "[date:\"" + attributes.find("date")->second + "\"]\n"; 307691691 q for (std::vector< Statement_Dump* >::const_iterator it = substatements.begin(); 3086363691 q it != substatements.end(); ++it) 3095672689 q result += (*it)->dump_pretty_map_ql(stmt_factory) + "\n"; 3135672689 q Statement* stmt = create_non_dump_stmt(stmt_factory); 3155672689 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) 32721228692 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) 3351875170 q Statement* stmt = stmt_factory->create_evaluator(tree_it, tree_context, eval_type); 3371863170 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) 3462736570 q Statement* stmt = stmt_factory->create_criterion(tree_it, type, can_standalone, into); 3482727567 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())