Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
lib::query Namespace Reference

Namespaces

namespace  anonymous_namespace{query-util.cpp}
 
namespace  test
 

Functions

void normaliseID (string &id)
 ensure standard format for a given id string.
 
string extractID (Symbol sym, const string &termString)
 (preliminary) helper: instead of really parsing and evaluating the terms, just do a regular expression match to extract the literal argument behind the given predicate symbol.
 
string removeTerm (Symbol sym, string &queryString)
 (preliminary) helper: cut a term with the given symbol.
 
bool hasTerm (Symbol sym, string const &queryString)
 
uint countPred (const string &)
 count the top-level predicates in the query string.
 
string appendTerms (string const &pred1, string const &pred2)
 
template<typename TY >
const string buildTypeID ()
 

Function Documentation

◆ normaliseID()

void normaliseID ( string &  id)

ensure standard format for a given id string.

Trim, sanitise and ensure the first letter is lower case.

Note
modifies the given string ref in place

Definition at line 52 of file query-util.cpp.

References normaliseID(), and util::sanitise().

Referenced by buildTypeID(), QueryUtils_test::check_normaliseID(), and normaliseID().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extractID()

string extractID ( Symbol  sym,
const string &  termString 
)

(preliminary) helper: instead of really parsing and evaluating the terms, just do a regular expression match to extract the literal argument behind the given predicate symbol.

e.g calling extractID ("stream", "id(abc), stream(mpeg)") yields "mpeg"

Definition at line 92 of file query-util.cpp.

References extractID().

Referenced by QueryUtils_test::check_extractID(), Query< RES >::Builder::extractID(), and extractID().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeTerm()

string removeTerm ( Symbol  sym,
string &  queryString 
)

(preliminary) helper: cut a term with the given symbol.

The term is matched, removed from the original string and returned

Note
parameter termString will be modified!
Todo:
as it seems we're not using the extracted term anymore, we could save the effort of rebuilding that term.

Definition at line 109 of file query-util.cpp.

References removeTerm().

Referenced by QueryUtils_test::CHECK_removeTerm(), removeTerm(), and Query< RES >::Builder::removeTerm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasTerm()

bool hasTerm ( Symbol  sym,
string const &  queryString 
)

Definition at line 124 of file query-util.cpp.

Referenced by Query< RES >::usesPredicate().

+ Here is the caller graph for this function:

◆ countPred()

uint countPred ( const string &  q)

count the top-level predicates in the query string.

Note
this is a very hackish preliminary implementation. The regex used will flounder when applied to nested terms. We need a real parser for predicate logic terms (which we probably get for free when we embed a prolog system)...

usable for ordering queries, as more predicates usually mean more conditions, i.e. more constriction

Definition at line 137 of file query-util.cpp.

Referenced by QueryUtils_test::check_countPred(), and QueryText::degree_of_constriction().

+ Here is the caller graph for this function:

◆ appendTerms()

string appendTerms ( string const &  pred1,
string const &  pred2 
)
Note
preliminary implementation without any syntax checks
Returns
a conjunction of the predicates

Definition at line 152 of file query-util.cpp.

Referenced by Query< RES >::Builder::prependConditions(), and Query< RES >::Builder::withConditions().

+ Here is the caller graph for this function:

◆ buildTypeID()

template<typename TY >
const string buildTypeID ( )

Definition at line 68 of file query-util.hpp.

References normaliseID().

+ Here is the call graph for this function: