Overpass API regression suite coverage (Saxony) / overpass_api/statements/if.h
overpass_api/statements/if.h
35 of 55 instrumented lines run by the suite (63.6%) 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 modify6 * it under the terms of the GNU Affero General Public License as7 * published by the Free Software Foundation, either version 3 of the8 * 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 of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.17 */19#ifndef DE__OSM3S___OVERPASS_API__STATEMENTS__COMPLETE_H20#define DE__OSM3S___OVERPASS_API__STATEMENTS__COMPLETE_H22#include <map>23#include <string>24#include <vector>26#include "evaluator.h"27#include "statement.h"30/* === The block statement <em>if</em> ===32''since v0.7.55''34The block statement <em>if</em> executes its substatements35only if its condition evaluates to boolean true.36This allows e.g. to try more loosely search conditions37if stricter search conditions did not deliver a result.39The statement does not directly interact with any sets.41The base syntax is43 if (<Evaluator>)44 {45 <List of Substatements>46 }48resp.50 if (<Evaluator>)51 {52 <List of Substatements>53 }54 else55 {56 <List of Substatements>57 }59where <Evaluator> is an evaulator and <List of Substatements> is a list of substatements.61*/63class If_Statement : public Statement64{65public:66 If_Statement(int line_number_, const std::map< std::string, std::string >& attributes,67 Parsed_Query& global_settings);68 virtual void add_statement(Statement* statement, std::string text);71 virtual void execute(Resource_Manager& rman);74 struct Statement_Maker : public Generic_Statement_Maker< If_Statement >75 {77 };78 static Statement_Maker statement_maker;80 virtual std::string dump_xml(const std::string& indent) const850 for (std::vector< Statement* >::const_iterator it = substatements.begin(); it != substatements.end(); ++it)99 virtual std::string dump_compact_ql(const std::string& indent) const1011917 q std::string result = indent + "if(" + (criterion ? criterion->dump_compact_ql("") : "") + "){";1032517 q for (std::vector< Statement* >::const_iterator it = substatements.begin(); it != substatements.end(); ++it)118 virtual std::string dump_pretty_ql(const std::string& indent) const1201917 q std::string result = indent + "if (" + (criterion ? criterion->dump_compact_ql("") : "") + ")\n"1232517 q for (std::vector< Statement* >::const_iterator it = substatements.begin(); it != substatements.end(); ++it)138private:139 Evaluator* criterion;140 bool else_reached;141 std::vector< Statement* > substatements;142 std::vector< Statement* > else_statements;143};146class Else_Statement : public Statement147{148public:149 Else_Statement(int line_number_, const std::map< std::string, std::string >& attributes,155 struct Statement_Maker : public Generic_Statement_Maker< Else_Statement >156 {158 };159 static Statement_Maker statement_maker;1630 virtual std::string dump_pretty_ql(const std::string& indent) const { return indent + "else\n"; }164};167#endif