* Implemented missing date parsing; queries like "last_modified > %-5 minutes%"

are now working as they should.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31711 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-07-23 10:05:20 +00:00
parent 8315ac2417
commit b8e5a675e5
2 changed files with 41 additions and 2 deletions

View File

@ -99,6 +99,7 @@ private:
bool deleteOnError);
status_t _SetPredicate(const char* expression);
status_t _EvaluateStack();
void _ParseDates(BString& parsedPredicate);
// FBC
virtual void _QwertyQuery1();

View File

@ -518,8 +518,11 @@ BQuery::Fetch()
if (!fPredicate || fDevice < 0)
return B_NO_INIT;
fQueryFd = _kern_open_query(fDevice, fPredicate, strlen(fPredicate),
fLive ? B_LIVE_QUERY : 0, fPort, fToken);
BString parsedPredicate;
_ParseDates(parsedPredicate);
fQueryFd = _kern_open_query(fDevice, parsedPredicate.String(),
parsedPredicate.Length(), fLive ? B_LIVE_QUERY : 0, fPort, fToken);
if (fQueryFd < 0)
return fQueryFd;
@ -761,6 +764,41 @@ BQuery::_EvaluateStack()
}
void
BQuery::_ParseDates(BString& parsedPredicate)
{
const char* start = fPredicate;
const char* pos = start;
bool quotes = false;
while (pos[0]) {
if (pos[0] == '\\') {
pos++;
continue;
}
if (pos[0] == '"')
quotes = !quotes;
else if (!quotes && pos[0] == '%') {
const char* end = strchr(pos + 1, '%');
if (end == NULL)
continue;
parsedPredicate.Append(start, pos - start);
start = end + 1;
// We have a date string
BString date(pos + 1, start - 1 - pos);
parsedPredicate << parsedate(date.String(), time(NULL));
pos = end;
}
pos++;
}
parsedPredicate.Append(start, pos - start);
}
// FBC
void BQuery::_QwertyQuery1() {}
void BQuery::_QwertyQuery2() {}