Mapper  0.9.0
API documentation
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
OpenOrienteering::ObjectQuery Class Reference

Utility to match objects based on tag values. More...

#include <object_query.h>

Collaboration diagram for OpenOrienteering::ObjectQuery:
Collaboration graph
[legend]

Classes

struct  LogicalOperands
 
struct  StringOperands
 

Public Types

enum  Operator {
  OperatorAnd = 1, OperatorOr = 2, OperatorIs = 16, OperatorIsNot = 17,
  OperatorContains = 18, OperatorSearch = 19, OperatorObjectText = 20, OperatorSymbol = 32,
  OperatorInvalid = 0
}
 

Public Member Functions

 ObjectQuery () noexcept
 
 ObjectQuery (const ObjectQuery &query)
 
 ObjectQuery (ObjectQuery &&proto) noexcept
 
ObjectQueryoperator= (const ObjectQuery &proto) noexcept
 
ObjectQueryoperator= (ObjectQuery &&proto) noexcept
 
 ~ObjectQuery ()
 
 operator bool () const noexcept
 Returns true if the query is valid. More...
 
 ObjectQuery (const QString &key, Operator op, const QString &value)
 Constructs a query for a key and value. More...
 
 ObjectQuery (Operator op, const QString &value)
 Constructs a query for a value. More...
 
 ObjectQuery (const ObjectQuery &first, Operator op, const ObjectQuery &second)
 Constructs a query which connects two sub-queries. More...
 
 ObjectQuery (ObjectQuery &&first, Operator op, ObjectQuery &&second) noexcept
 Constructs a query which connects two sub-queries. More...
 
 ObjectQuery (const Symbol *symbol) noexcept
 Constructs a query for a particular symbol. More...
 
Operator getOperator () const noexcept
 Returns the underlying operator. More...
 
bool operator() (const Object *object) const
 Evaluates this query on the given object and returns whether it matches. More...
 
const LogicalOperandslogicalOperands () const
 Returns the operands of logical query operations. More...
 
const StringOperandstagOperands () const
 Returns the operands of logical query operations. More...
 
const SymbolsymbolOperand () const
 Returns the operand of symbol operations. More...
 
QString toString () const
 Pretty print the query. More...
 

Static Public Member Functions

static QString labelFor (Operator op)
 Returns a short label for the operator which can be used in the user interface. More...
 

Friends

bool operator== (const ObjectQuery &lhs, const ObjectQuery &rhs)
 

Detailed Description

Utility to match objects based on tag values.

This class can be used with value semantics. It can be move-constructed and move-assigned in O(1). Normal copy-construction and assignment may involve expensive copying of the expression tree.

OperatorAnd and OperatorOr evaluate the left argument first. When constructing complex queries, left sub-query chains should be kept short in order to benefit from short circuiting the evaluation of these logical operators after evaluation of the left argument.

Member Enumeration Documentation

◆ Operator

Enumerator
OperatorAnd 

And-chains two object queries.

OperatorOr 

Or-chains two object queries.

OperatorIs 

Tests an existing tag for equality with the given value (case-sensitive)

OperatorIsNot 

Tests an existing tag for inequality with the given value (case-sensitive)

OperatorContains 

Tests an existing tag for containing the given value (case-sensitive)

OperatorSearch 

Tests if the symbol name, a tag key or a tag value contains the given value (case-insensitive)

OperatorObjectText 

Text object content (case-insensitive)

OperatorSymbol 

Test the symbol for equality.

OperatorInvalid 

Marks an invalid query.

Constructor & Destructor Documentation

◆ ObjectQuery() [1/8]

OpenOrienteering::ObjectQuery::ObjectQuery ( )
noexcept

◆ ObjectQuery() [2/8]

OpenOrienteering::ObjectQuery::ObjectQuery ( const ObjectQuery query)
explicit

◆ ObjectQuery() [3/8]

OpenOrienteering::ObjectQuery::ObjectQuery ( ObjectQuery &&  proto)
noexcept

◆ ~ObjectQuery()

OpenOrienteering::ObjectQuery::~ObjectQuery ( )

◆ ObjectQuery() [4/8]

OpenOrienteering::ObjectQuery::ObjectQuery ( const QString key,
ObjectQuery::Operator  op,
const QString value 
)

Constructs a query for a key and value.

◆ ObjectQuery() [5/8]

OpenOrienteering::ObjectQuery::ObjectQuery ( ObjectQuery::Operator  op,
const QString value 
)

Constructs a query for a value.

Valid for OperatorSearch.

◆ ObjectQuery() [6/8]

OpenOrienteering::ObjectQuery::ObjectQuery ( const ObjectQuery first,
ObjectQuery::Operator  op,
const ObjectQuery second 
)

Constructs a query which connects two sub-queries.

The sub-queries are copied.

◆ ObjectQuery() [7/8]

OpenOrienteering::ObjectQuery::ObjectQuery ( ObjectQuery &&  first,
ObjectQuery::Operator  op,
ObjectQuery &&  second 
)
noexcept

Constructs a query which connects two sub-queries.

◆ ObjectQuery() [8/8]

OpenOrienteering::ObjectQuery::ObjectQuery ( const Symbol symbol)
noexcept

Constructs a query for a particular symbol.

Member Function Documentation

◆ getOperator()

Operator OpenOrienteering::ObjectQuery::getOperator ( ) const
inlinenoexcept

Returns the underlying operator.

◆ labelFor()

QString OpenOrienteering::ObjectQuery::labelFor ( ObjectQuery::Operator  op)
static

Returns a short label for the operator which can be used in the user interface.

◆ logicalOperands()

const ObjectQuery::LogicalOperands * OpenOrienteering::ObjectQuery::logicalOperands ( ) const

Returns the operands of logical query operations.

◆ operator bool()

OpenOrienteering::ObjectQuery::operator bool ( ) const
inlinenoexcept

Returns true if the query is valid.

◆ operator()()

bool OpenOrienteering::ObjectQuery::operator() ( const Object object) const

Evaluates this query on the given object and returns whether it matches.

◆ operator=() [1/2]

ObjectQuery & OpenOrienteering::ObjectQuery::operator= ( const ObjectQuery proto)
noexcept

◆ operator=() [2/2]

ObjectQuery & OpenOrienteering::ObjectQuery::operator= ( ObjectQuery &&  proto)
noexcept

◆ symbolOperand()

const Symbol * OpenOrienteering::ObjectQuery::symbolOperand ( ) const

Returns the operand of symbol operations.

◆ tagOperands()

const ObjectQuery::StringOperands * OpenOrienteering::ObjectQuery::tagOperands ( ) const

Returns the operands of logical query operations.

◆ toString()

QString OpenOrienteering::ObjectQuery::toString ( ) const

Pretty print the query.

The output is meant to be formal language, for possible parsing.

Friends And Related Function Documentation

◆ operator==

bool operator== ( const ObjectQuery lhs,
const ObjectQuery rhs 
)
friend

Member Data Documentation

◆ subqueries

LogicalOperands OpenOrienteering::ObjectQuery::subqueries

◆ symbol

SymbolOperand OpenOrienteering::ObjectQuery::symbol

◆ tags

StringOperands OpenOrienteering::ObjectQuery::tags

The documentation for this class was generated from the following files: