17 #include <QtCore/qregexp.h> 52 template <
typename INDEX>
58 QDomNode tn(termNode.hasChildNodes() ? termNode.firstChild() : termNode);
59 String val(tn.nodeValue());
61 return index.begin(val, found);
65 template <
typename INDEX,
typename STR>
71 return index.begin(val, found);
76 template <
typename REFLISTCURSOR,
typename INDEX_ITER>
78 (
const INDEX_ITER& begin,
79 const INDEX_ITER& end)
81 return begin.getRefList(end);
87 template <
typename REFLISTCURSOR,
typename INDEX>
88 REFLISTCURSOR eval_regex(
const INDEX& index, QDomNode node)
90 QDomNode tn(node.hasChildNodes() ? node.firstChild() : node);
91 QString val(tn.nodeValue());
93 static QString regex_chars(
"*?+(){}|.^$\\{}");
95 uint literal_chars(0);
96 bool use_regex(
false);
100 return REFLISTCURSOR();
105 for ( ; ch < val.end(); ++ch)
107 int i(regex_chars.indexOf(*ch));
117 typename INDEX::Iter it, end;
124 if (!regex.isValid())
128 for ( ; it.diff(end); it.move(1))
129 if (regex.exactMatch(it.getTerm()))
131 REFLISTCURSOR refs(it.getRefList());
138 QString start_term(val);
139 start_term.truncate(literal_chars);
140 REVEAL_STRING(sstr, start_term);
141 it = index.begin(start_term);
142 QString end_term(index.next(start_term));
143 REVEAL_STRING(estr, end_term);
144 end = index.begin(end_term);
146 return it.getRefList(end);
154 template <
typename REFLISTCURSOR,
typename INDEXLIST,
typename INDEX>
156 (
const INDEXLIST& indexList,
160 std::function<
const INDEX(
const INDEXLIST& indexList,
161 const QDomNode& node,
162 String* indexName)> getIndex,
166 return REFLISTCURSOR();
168 QString
name(node.nodeName());
169 REVEAL_STRING(n,
name);
175 return eval<REFLISTCURSOR, INDEXLIST, INDEX>(indexList, node.firstChild(), recCount, depth + 1, getIndex);
177 std::vector<REFLISTCURSOR> to_and;
186 result = eval<REFLISTCURSOR, INDEXLIST, INDEX>(indexList, node.firstChild(), recCount, depth + 1, getIndex);
187 result.opNot(recCount);
192 QDomNode child(node.firstChild());
193 result = eval<REFLISTCURSOR, INDEXLIST, INDEX>(indexList, child, recCount, depth + 1, getIndex);
194 while (!(child = child.nextSibling()).isNull())
196 REFLISTCURSOR sibling(eval<REFLISTCURSOR, INDEXLIST, INDEX>(indexList, child, recCount, depth + 1, getIndex));
197 result.opOr(&sibling);
204 const INDEX& index(getIndex(indexList, node, &index_name));
209 if (!index.regexOK())
211 result = eval_regex<REFLISTCURSOR, INDEX>(index, node);
225 typename INDEX::Iter it(
find_term(index, node, &found));
226 result = (found) ? it.getRefList() : REFLISTCURSOR();
229 result.opNot(recCount);
239 typename INDEX::Iter end(
find_term(index, node.firstChild(), &found));
240 result = eval_range<REFLISTCURSOR>(index.begin(), end);
249 typename INDEX::Iter begin(
find_term(index, node.firstChild(), &found));
250 if (!found || begin.move(1))
251 result = eval_range<REFLISTCURSOR>(begin, index.end());
260 typename INDEX::Iter end(
find_term(index, node.firstChild(), &found));
263 result = eval_range<REFLISTCURSOR>(index.begin(), end);
272 QDomNode next(node.nextSibling());
273 if (!next.isNull() && (next.nodeName() ==
SearchNames::OP_LE) && next.nextSibling().isNull() &&
278 typename INDEX::Iter begin(
find_term(index, node.firstChild(), &found));
279 typename INDEX::Iter end(
find_term(index, next.firstChild(), &found));
282 result = eval_range<REFLISTCURSOR>(begin, end);
290 typename INDEX::Iter begin(
find_term(index, node.firstChild(), &found));
291 result = eval_range<REFLISTCURSOR>(begin, index.end());
301 return eval_range<REFLISTCURSOR>(index.begin(), index.end());
305 result = eval<REFLISTCURSOR, INDEXLIST, INDEX>(indexList, node.firstChild(), recCount, depth + 1, getIndex,
true);
315 to_and.push_back(result);
318 return REFLISTCURSOR();
321 if ((node = node.nextSibling()).isNull())
323 name = node.nodeName();
327 return REFLISTCURSOR::opAnd(&to_and);
static const char * OP_PHRASE
static const char * OP_AND
static const char * OP_TERM
static const char * OP_REGEX
static const char * INDEX_TAG
static const char * OP_LT
INDEX::Iter find_term(const INDEX &index, const STR &val, bool *found=0)
static const char * QUERY_TAG
static const char * OP_NOT
static const char * OP_OR
A string, Unicode UTF-16 and reference-counted.
static const char * OP_NE
static const char * SEARCH_TAG
static const char * OP_ALL
unsigned long long uint64
static const char * OP_GE
REFLISTCURSOR eval_range(const INDEX_ITER &begin, const INDEX_ITER &end)
static const char * OP_EQ
const Xpace_Char16 * name
Sink callbacks for table data.
static const char * OP_GT
Xpace_StoreAccess Xpace_Table * result
static const char * OP_LE
static const char * DOCUMENT_TAG
Xpace project main namespace
static const char * PARSE_TREE_TAG