Changeset View
Changeset View
Standalone View
Standalone View
src/services/ktraderparsetree.cpp
Show First 20 Lines • Show All 432 Lines • ▼ Show 20 Line(s) | 432 | if (!m_pLeft->eval(&c1)) { | |||
---|---|---|---|---|---|
433 | return false; | 433 | return false; | ||
434 | } | 434 | } | ||
435 | if (!m_pRight->eval(&c2)) { | 435 | if (!m_pRight->eval(&c2)) { | ||
436 | return false; | 436 | return false; | ||
437 | } | 437 | } | ||
438 | if (c1.type != ParseContext::T_STRING || c2.type != ParseContext::T_STRING) { | 438 | if (c1.type != ParseContext::T_STRING || c2.type != ParseContext::T_STRING) { | ||
439 | return false; | 439 | return false; | ||
440 | } | 440 | } | ||
441 | _context->b = ParseTreeSubsequenceMATCH::isSubseq(c1.str, c2.str, m_cs); | 441 | _context->b = KService::isSubseq(c1.str, c2.str, m_cs); | ||
442 | return true; | 442 | return true; | ||
443 | } | 443 | } | ||
444 | 444 | | |||
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 | 445 | bool ParseTreeIN::eval(ParseContext *_context) const | ||
463 | { | 446 | { | ||
464 | _context->type = ParseContext::T_BOOL; | 447 | _context->type = ParseContext::T_BOOL; | ||
465 | 448 | | |||
466 | ParseContext c1(_context); | 449 | ParseContext c1(_context); | ||
467 | ParseContext c2(_context); | 450 | ParseContext c2(_context); | ||
468 | if (!m_pLeft->eval(&c1)) { | 451 | if (!m_pLeft->eval(&c1)) { | ||
469 | return false; | 452 | return false; | ||
▲ Show 20 Lines • Show All 339 Lines • Show Last 20 Lines |