Changeset View
Changeset View
Standalone View
Standalone View
src/services/ktraderparsetree.cpp
Show All 12 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
13 | 13 | | |||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 17 | Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "ktraderparsetree_p.h" | 20 | #include "ktraderparsetree_p.h" | ||
21 | #include "kapplicationtrader.h" | ||||
21 | 22 | | |||
22 | namespace KTraderParse | 23 | namespace KTraderParse | ||
23 | { | 24 | { | ||
24 | 25 | | |||
25 | QVariant ParseContext::property(const QString &_key) const | 26 | QVariant ParseContext::property(const QString &_key) const | ||
26 | { | 27 | { | ||
27 | if (service) { | 28 | if (service) { | ||
28 | return service->property(_key); | 29 | return service->property(_key); | ||
▲ Show 20 Lines • Show All 404 Lines • ▼ Show 20 Line(s) | 433 | if (!m_pLeft->eval(&c1)) { | |||
433 | return false; | 434 | return false; | ||
434 | } | 435 | } | ||
435 | if (!m_pRight->eval(&c2)) { | 436 | if (!m_pRight->eval(&c2)) { | ||
436 | return false; | 437 | return false; | ||
437 | } | 438 | } | ||
438 | if (c1.type != ParseContext::T_STRING || c2.type != ParseContext::T_STRING) { | 439 | if (c1.type != ParseContext::T_STRING || c2.type != ParseContext::T_STRING) { | ||
439 | return false; | 440 | return false; | ||
440 | } | 441 | } | ||
441 | _context->b = ParseTreeSubsequenceMATCH::isSubseq(c1.str, c2.str, m_cs); | 442 | _context->b = KApplicationTrader::isSubsequence(c1.str, c2.str, m_cs); | ||
442 | return true; | 443 | return true; | ||
443 | } | 444 | } | ||
444 | 445 | | |||
445 | bool ParseTreeSubsequenceMATCH:: | | |||
446 | isSubseq(const QString& pattern, const QString& text, Qt::CaseSensitivity cs) | | |||
447 | { | | |||
448 | if (pattern.isEmpty()) { | | |||
449 | return false; | | |||
450 | } | | |||
451 | bool chk_case = cs == Qt::CaseSensitive; | | |||
452 | | ||||
453 | QString::const_iterator i = text.constBegin(), j = pattern.constBegin(); | | |||
454 | for (; i != text.constEnd() && j != pattern.constEnd(); ++i) { | | |||
455 | if ((chk_case && *i == *j) || (!chk_case && i->toLower() == j->toLower())) { | | |||
456 | ++j; | | |||
457 | } | | |||
458 | } | | |||
459 | return j == pattern.constEnd(); | | |||
460 | } | | |||
461 | | ||||
462 | bool ParseTreeIN::eval(ParseContext *_context) const | 446 | bool ParseTreeIN::eval(ParseContext *_context) const | ||
463 | { | 447 | { | ||
464 | _context->type = ParseContext::T_BOOL; | 448 | _context->type = ParseContext::T_BOOL; | ||
465 | 449 | | |||
466 | ParseContext c1(_context); | 450 | ParseContext c1(_context); | ||
467 | ParseContext c2(_context); | 451 | ParseContext c2(_context); | ||
468 | if (!m_pLeft->eval(&c1)) { | 452 | if (!m_pLeft->eval(&c1)) { | ||
469 | return false; | 453 | return false; | ||
▲ Show 20 Lines • Show All 339 Lines • Show Last 20 Lines |