Overpass API regression suite coverage (Saxony) / overpass_api/statements/tag_value.cc
overpass_api/statements/tag_value.cc
369 of 520 instrumented lines run by the suite (71.0%) 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#include "../data/tag_store.h"20#include "../data/utils.h"21#include "tag_value.h"24Evaluator_Fixed::Statement_Maker Evaluator_Fixed::statement_maker;25Evaluator_Fixed::Evaluator_Maker Evaluator_Fixed::evaluator_maker;28Statement* Evaluator_Fixed::Evaluator_Maker::create_evaluator(29 const Token_Node_Ptr& tree_it, Statement::QL_Context tree_context,30 Statement::Factory& stmt_factory, Parsed_Query& global_settings, Error_Output* error_output)53Evaluator_Fixed::Evaluator_Fixed54 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)67std::string Evaluator_Fixed::dump_compact_ql(const std::string&) const81//-----------------------------------------------------------------------------84Evaluator_Id::Statement_Maker Evaluator_Id::statement_maker;85Element_Function_Maker< Evaluator_Id > Evaluator_Id::evaluator_maker;88Evaluator_Id::Evaluator_Id89 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)97//-----------------------------------------------------------------------------100Evaluator_Type::Statement_Maker Evaluator_Type::statement_maker;101Element_Function_Maker< Evaluator_Type > Evaluator_Type::evaluator_maker;104Evaluator_Type::Evaluator_Type105 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)114//-----------------------------------------------------------------------------117std::string find_value(const std::vector< std::pair< std::string, std::string > >* tags, const std::string& key)122221419183 q for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags->begin();133Evaluator_Value::Statement_Maker Evaluator_Value::statement_maker;134Evaluator_Value::Evaluator_Maker Evaluator_Value::evaluator_maker;137Statement* Evaluator_Value::Evaluator_Maker::create_evaluator(138 const Token_Node_Ptr& tree_it, Statement::QL_Context tree_context,139 Statement::Factory& stmt_factory, Parsed_Query& global_settings, Error_Output* error_output)1441032103 q if (!tree_it->lhs || tree_it.lhs()->lhs || tree_it.lhs()->rhs || tree_it.lhs()->token != "t")1470 error_output->add_parse_error("Tag evaulation needs function name \"t\" before the left bracket",1540 error_output->add_parse_error("Operator \"[\" needs a tag key as argument", tree_it->line_col.first);1591032103 q Statement* result = new Evaluator_Value(tree_it->line_col.first, attributes, global_settings);1631032103 q tree_it.rhs(), tree_context, Statement::Single_Return_Type_Checker(Statement::string));174Evaluator_Value::Evaluator_Value175 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)183void Evaluator_Value::add_statement(Statement* statement, std::string text)195Requested_Context Evaluator_Value::request_context() const203Eval_Task* Evaluator_Value::get_string_task(Prepare_Task_Context& context, const std::string* key)210std::string Value_Eval_Task::eval(const std::string* key) const216std::string Value_Eval_Task::eval(const Element_With_Context< Node_Skeleton >& data, const std::string* key) const222std::string Value_Eval_Task::eval(const Element_With_Context< Attic< Node_Skeleton > >& data, const std::string* key) const228std::string Value_Eval_Task::eval(const Element_With_Context< Way_Skeleton >& data, const std::string* key) const234std::string Value_Eval_Task::eval(const Element_With_Context< Attic< Way_Skeleton > >& data, const std::string* key) const240std::string Value_Eval_Task::eval(const Element_With_Context< Relation_Skeleton >& data, const std::string* key) const246std::string Value_Eval_Task::eval(const Element_With_Context< Attic< Relation_Skeleton > >& data, const std::string* key) const252std::string Value_Eval_Task::eval(const Element_With_Context< Area_Skeleton >& data, const std::string* key) const258std::string Value_Eval_Task::eval(const Element_With_Context< Derived_Skeleton >& data, const std::string* key) const264//-----------------------------------------------------------------------------267std::string exists_value(const std::vector< std::pair< std::string, std::string > >* tags, const std::string& key)27220980717 q for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags->begin();283Evaluator_Is_Tag::Statement_Maker Evaluator_Is_Tag::statement_maker;284Evaluator_Is_Tag::Evaluator_Maker Evaluator_Is_Tag::evaluator_maker;287Statement* Evaluator_Is_Tag::Evaluator_Maker::create_evaluator(288 const Token_Node_Ptr& tree_it, Statement::QL_Context tree_context,289 Statement::Factory& stmt_factory, Parsed_Query& global_settings, Error_Output* error_output)29110826 q if (!tree_it.assert_is_function(error_output) || !tree_it.assert_has_input_set(error_output, false)2990 error_output->add_parse_error("is_tag(key) needs a simple string as argument", tree_it->line_col.first);308Evaluator_Is_Tag::Evaluator_Is_Tag309 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)322//-----------------------------------------------------------------------------325Evaluator_All_Keys::Statement_Maker Evaluator_All_Keys::statement_maker;326Element_Function_Maker< Evaluator_All_Keys > Evaluator_All_Keys::evaluator_maker;329std::vector< std::string > all_keys(const std::vector< std::pair< std::string, std::string > >* tags)3355025 q for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags->begin();346Evaluator_All_Keys::Evaluator_All_Keys347 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)355//-----------------------------------------------------------------------------358Evaluator_Version::Statement_Maker Evaluator_Version::statement_maker;359Element_Function_Maker< Evaluator_Version > Evaluator_Version::evaluator_maker;362Evaluator_Version::Evaluator_Version363 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)371Evaluator_Timestamp::Statement_Maker Evaluator_Timestamp::statement_maker;372Element_Function_Maker< Evaluator_Timestamp > Evaluator_Timestamp::evaluator_maker;375Evaluator_Timestamp::Evaluator_Timestamp376 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)384Evaluator_Changeset::Statement_Maker Evaluator_Changeset::statement_maker;385Element_Function_Maker< Evaluator_Changeset > Evaluator_Changeset::evaluator_maker;388Evaluator_Changeset::Evaluator_Changeset389 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)397Evaluator_Uid::Statement_Maker Evaluator_Uid::statement_maker;398Element_Function_Maker< Evaluator_Uid > Evaluator_Uid::evaluator_maker;401Evaluator_Uid::Evaluator_Uid402 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)410Evaluator_User::Statement_Maker Evaluator_User::statement_maker;411Element_Function_Maker< Evaluator_User > Evaluator_User::evaluator_maker;414Evaluator_User::Evaluator_User415 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)423//-----------------------------------------------------------------------------426Evaluator_Generic::Statement_Maker Evaluator_Generic::statement_maker;427Evaluator_Generic::Evaluator_Maker Evaluator_Generic::evaluator_maker;430Statement* Evaluator_Generic::Evaluator_Maker::create_evaluator(431 const Token_Node_Ptr& tree_it, Statement::QL_Context tree_context,432 Statement::Factory& stmt_factory, Parsed_Query& global_settings, Error_Output* error_output)441Evaluator_Generic::Evaluator_Generic442 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)451//-----------------------------------------------------------------------------454Evaluator_Properties_Count::Statement_Maker Evaluator_Properties_Count::statement_maker;455Evaluator_Properties_Count::Evaluator_Maker Evaluator_Properties_Count::evaluator_maker;458Statement* Evaluator_Properties_Count::Evaluator_Maker::create_evaluator(459 const Token_Node_Ptr& tree_it, Statement::QL_Context tree_context,460 Statement::Factory& stmt_factory, Parsed_Query& global_settings, Error_Output* error_output)46243283 q if (!tree_it.assert_is_function(error_output) || !tree_it.assert_has_input_set(error_output, false)4830 + "() needs a single literal expression as argument for the wanted role", tree_it->line_col.first);5060 + "() needs a single literal expression as argument for the wanted role", tree_it->line_col.first);54242882 q return new Evaluator_Properties_Count(tree_it->line_col.first, attributes, global_settings);546std::string Evaluator_Properties_Count::to_string(Evaluator_Properties_Count::Objects objects)563std::string Evaluator_Properties_Count::to_string(Evaluator_Properties_Count::Members_Type type_to_count)576Evaluator_Properties_Count::Evaluator_Properties_Count577 (int line_number_, const std::map< std::string, std::string >& input_attributes, Parsed_Query& global_settings)623Requested_Context Evaluator_Properties_Count::request_context() const6277352 q else if (to_count == Evaluator_Properties_Count::members || to_count == Evaluator_Properties_Count::distinct_members)6294034 q else if (to_count == Evaluator_Properties_Count::by_role || to_count == Evaluator_Properties_Count::distinct_by_role)636Eval_Task* Evaluator_Properties_Count::get_string_task(Prepare_Task_Context& context, const std::string* key)63811879 q if (to_count == Evaluator_Properties_Count::by_role || to_count == Evaluator_Properties_Count::distinct_by_role)645std::string Prop_Count_Eval_Task::eval(const Element_With_Context< Node_Skeleton >& data, const std::string* key) const653std::string Prop_Count_Eval_Task::eval(const Element_With_Context< Attic< Node_Skeleton > >& data,654 const std::string* key) const662std::string Prop_Count_Eval_Task::eval(const Element_With_Context< Way_Skeleton >& data,663 const std::string* key) const67393192 q return to_string(std::distance(distinct.begin(), std::unique(distinct.begin(), distinct.end())));681std::string Prop_Count_Eval_Task::eval(const Element_With_Context< Attic< Way_Skeleton > >& data,682 const std::string* key) const69249671 q return to_string(std::distance(distinct.begin(), std::unique(distinct.begin(), distinct.end())));700bool matches_criterion(const Relation_Entry& member, Evaluator_Properties_Count::Objects to_count,701 Evaluator_Properties_Count::Members_Type type_to_count, uint32 role_id)7090 if (type_to_count == Evaluator_Properties_Count::relations && member.type != Relation_Entry::RELATION)7144101828 q (to_count == Evaluator_Properties_Count::by_role || to_count == Evaluator_Properties_Count::distinct_by_role))721struct Relation_Member_Comparer722{723 bool operator()(const Relation_Entry& lhs, const Relation_Entry& rhs) const730};733std::string Prop_Count_Eval_Task::eval(const Element_With_Context< Relation_Skeleton >& data,734 const std::string* key) const73617925618 q if (to_count == Evaluator_Properties_Count::members || to_count == Evaluator_Properties_Count::by_role)7415990110 q if (to_count == Evaluator_Properties_Count::members && type_to_count == Evaluator_Properties_Count::all)7451971995 q for (std::vector< Relation_Entry >::const_iterator it = data.object->members.begin(); it != data.object->members.end(); ++it)760601908 q if (to_count != Evaluator_Properties_Count::distinct_members || type_to_count != Evaluator_Properties_Count::all)773601908 q return to_string(std::distance(distinct.begin(), std::unique(distinct.begin(), distinct.end())));781std::string Prop_Count_Eval_Task::eval(const Element_With_Context< Attic< Relation_Skeleton > >& data,782 const std::string* key) const7844692 q if (to_count == Evaluator_Properties_Count::members || to_count == Evaluator_Properties_Count::by_role)7890 if (to_count == Evaluator_Properties_Count::members && type_to_count == Evaluator_Properties_Count::all)7930 for (std::vector< Relation_Entry >::const_iterator it = data.object->members.begin(); it != data.object->members.end(); ++it)8080 if (to_count != Evaluator_Properties_Count::distinct_members || type_to_count != Evaluator_Properties_Count::all)8210 return to_string(std::distance(distinct.begin(), std::unique(distinct.begin(), distinct.end())));829std::string Prop_Count_Eval_Task::eval(const Element_With_Context< Area_Skeleton >& data, const std::string* key) const837std::string Prop_Count_Eval_Task::eval(const Element_With_Context< Derived_Skeleton >& data, const std::string* key) const