Overpass API regression suite coverage (Nova Scotia) / overpass_api/statements/filter.h

overpass_api/statements/filter.h

13 of 14 instrumented lines run by the suite (92.9%) 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#ifndef DE__OSM3S___OVERPASS_API__STATEMENTS__FILTER_H
20#define DE__OSM3S___OVERPASS_API__STATEMENTS__FILTER_H
22#include <map>
23#include <string>
24#include <vector>
25#include "statement.h"
26#include "tag_value.h"
29/* === The Query Filter ===
31The query filter can be added as condition to a query statement.
32It has an evaluator as argument
33and it lets pass only those elements for which the expression returns boolean true.
35At the moment, the query filter cannot be the only condition in a query.
36This is due to implementation reasons and will change in future versions.
38It is technically possible to have multiple query filters in a single query.
39But it does not make sense:
40Their evaulators can be combined with a conjunction in a single query filter.
41This has the same semantics and is faster.
43Its syntax is
45 (if: <Evaluator>)
47The whitespace is optional.
48*/
50class Filter_Statement : public Output_Statement
52 public:
53 Filter_Statement(int line_number_, const std::map< std::string, std::string >& attributes,
54 Parsed_Query& global_settings);
5557666 q virtual std::string get_name() const { return "filter"; }
56 virtual void add_statement(Statement* statement, std::string text);
57 virtual void execute(Resource_Manager& rman);
58 virtual ~Filter_Statement();
60 struct Statement_Maker : public Generic_Statement_Maker< Filter_Statement >
61 {
622448612 q Statement_Maker() : Generic_Statement_Maker< Filter_Statement >("filter") {}
63 };
64 static Statement_Maker statement_maker;
66 struct Criterion_Maker : public Statement::Criterion_Maker
67 {
6830069 q virtual bool can_standalone(const std::string& type) { return false; }
69 virtual Statement* create_criterion(const Token_Node_Ptr& tree_it,
70 const std::string& type, const std::string& into,
71 Statement::Factory& stmt_factory, Parsed_Query& global_settings, Error_Output* error_output);
722448612 q Criterion_Maker() { Statement::maker_by_ql_criterion()["if"] = this; }
73 };
74 static Criterion_Maker criterion_maker;
76 virtual Query_Constraint* get_query_constraint();
7823762 q Evaluator* get_criterion() { return criterion; }
80 virtual std::string dump_xml(const std::string& indent) const
817266 q {
827266 q return indent + "<filter>\n"
837266 q + (criterion ? criterion->dump_xml(indent + " ") : "")
847266 q + indent + "</filter>\n";
857266 q }
87 virtual std::string dump_compact_ql(const std::string&) const
8814466 q {
8914466 q return std::string("(if:") + (criterion ? criterion->dump_compact_ql("") : "") + ")";
9014466 q }
910 virtual std::string dump_pretty_ql(const std::string& indent) const { return dump_compact_ql(indent); }
93 private:
94 std::vector< Query_Constraint* > constraints;
95 Evaluator* criterion;
96};
99#endif