Lumiera  0.pre.03
»edityourfreedom«
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lib::query Namespace Reference

Namespaces

 test
 

Functions

string appendTerms (string const &pred1, string const &pred2)
 
template<typename TY >
const string buildTypeID ()
 
uint countPred (const string &)
 count the top-level predicates in the query string. More...
 
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. More...
 
bool hasTerm (Symbol sym, string const &queryString)
 
void normaliseID (string &id)
 ensure standard format for a given id string. More...
 
string removeTerm (Symbol sym, string &queryString)
 (preliminary) helper: cut a term with the given symbol. More...
 

Function Documentation

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 60 of file query-util.cpp.

References util::first(), util::isnil(), and util::sanitise().

Referenced by buildTypeID(), QueryUtils_test::check_normaliseID(), BasicPipe_test::create_or_ref(), BasicPipe_test::createExplicit(), StructFactory::newPipe(), and DefsManager_test::run().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 100 of file query-util.cpp.

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

+ Here is the caller graph for this function:

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 117 of file query-util.cpp.

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

+ Here is the caller graph for this function:

bool hasTerm ( Symbol  sym,
string const &  queryString 
)

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

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

+ Here is the caller graph for this function:

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 145 of file query-util.cpp.

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

+ Here is the caller graph for this function:

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

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

References util::isnil().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const string lib::query::buildTypeID ( )

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

References normaliseID().

+ Here is the call graph for this function: