Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Implementation of helpers for working with predicate queries.
Definition in file query-util.cpp.
#include "lib/error.hpp"
#include "lib/query-util.hpp"
#include "lib/util.hpp"
#include <boost/algorithm/string.hpp>
#include <functional>
#include <regex>
#include <map>
Typedefs | |
using | ChPredicate = std::function< bool(string::value_type)> |
Functions | |
string | appendTerms (string const &pred1, string const &pred2) |
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... | |
regex & | getTermRegex (Symbol sym) |
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... | |
Namespaces | |
lib | |
Implementation namespace for support and library code. | |
void normaliseID | ( | string & | id | ) |
ensure standard format for a given id string.
Trim, sanitise and ensure the first letter is lower case.
Definition at line 61 of file query-util.cpp.
References lib::query::normaliseID().
Referenced by QueryUtils_test::check_normaliseID(), and lib::query::normaliseID().
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 101 of file query-util.cpp.
References lib::query::extractID().
Referenced by QueryUtils_test::check_extractID(), and lib::query::extractID().
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
Definition at line 118 of file query-util.cpp.
References lib::query::removeTerm().
Referenced by QueryUtils_test::check_removeTerm(), and lib::query::removeTerm().
uint countPred | ( | const string & | q | ) |
count the top-level predicates in the query string.
usable for ordering queries, as more predicates usually mean more conditions, i.e. more constriction
Definition at line 146 of file query-util.cpp.
References lib::query::countPred().
Referenced by QueryUtils_test::check_countPred(), and lib::query::countPred().
string appendTerms | ( | string const & | pred1, |
string const & | pred2 | ||
) |
Definition at line 161 of file query-util.cpp.
References lib::query::appendTerms().
Referenced by lib::query::appendTerms().