Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
query-util.hpp
Go to the documentation of this file.
1/*
2 QUERY-UTIL.hpp - support for working with terms and queries
3
4 Copyright (C)
5 2008, 2012 Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
20#ifndef LIB_QUERY_UTIL_H
21#define LIB_QUERY_UTIL_H
22
23
24#include "lib/symbol.hpp"
25#include "lib/meta/util.hpp"
26
27#include <typeinfo>
28#include <string>
29
30
31namespace lib {
32
33 using lib::Symbol;
34 using lib::Literal;
35 using std::string;
36
37
38
39
40
41
42 namespace query {
43
48 void normaliseID (string& id);
49
50
55 uint countPred (const string&);
56
57
58 string extractID (Symbol, string const& termString);
59
60 string removeTerm (Symbol, string& queryString);
61 bool hasTerm (Symbol sym, string const& queryString);
62
63 string appendTerms (string const& pred1, string const& pred2);
64
65
66 template<typename TY>
67 const string
69 {
70 string typeID {util::typeStr<TY>()};
71 normaliseID (typeID);
72 return typeID;
73 }
74
75
76
77 }} // namespace lib::query
78#endif
Inline string literal.
Definition symbol.hpp:78
Token or Atom with distinct identity.
Definition symbol.hpp:120
unsigned int uint
Definition integral.hpp:29
Simple and lightweight helpers for metaprogramming and type detection.
bool hasTerm(Symbol sym, string const &queryString)
string appendTerms(string const &pred1, string const &pred2)
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 expressio...
uint countPred(const string &q)
count the top-level predicates in the query string.
const string buildTypeID()
string removeTerm(Symbol sym, string &queryString)
(preliminary) helper: cut a term with the given symbol.
Implementation namespace for support and library code.
Marker types to indicate a literal string and a Symbol.