コード例 #1
0
ファイル: testEgi.c プロジェクト: jsjohnst/appweb
static void queryString(MprTestGroup *gp)
{
    char    *post;

    post = "name=Peter&address=777+Mulberry+Lane";
    assert(simpleForm(gp, "/egi/egiProgram.egi?var1=a+a&var2=b%20b&var3=c", post, 0));
    assert(match(gp, "QUERY_STRING", "var1=a+a&var2=b%20b&var3=c"));
    assert(match(gp, "QVAR var1", "a a"));
    assert(match(gp, "QVAR var2", "b b"));
    assert(match(gp, "QVAR var3", "c"));
    assert(match(gp, "PVAR name", "Peter"));
    assert(match(gp, "PVAR address", "777 Mulberry Lane"));

    assert(simpleGet(gp, "/egi/egiProgram.egi?var1=a+a&var2=b%20b&var3=c", 0));

    /*
     *  Query string vars should not be turned into variables for GETs
     */
    assert(matchAnyCase(gp, "SCRIPT_NAME", "/egi/egiProgram.egi"));
    assert(match(gp, "QUERY_STRING", "var1=a+a&var2=b%20b&var3=c"));
    assert(match(gp, "QVAR var1", "a a"));
    assert(match(gp, "QVAR var2", "b b"));
    assert(match(gp, "QVAR var3", "c"));
}
コード例 #2
0
ファイル: HockeyGame.cpp プロジェクト: db4soundman/HockeyQt
void HockeyGame::parseAllSportCG(QByteArray data)
{
    try {
        QString NO_PEN="xxxxxxxx";
        QString clock = data.mid(1, 7).trimmed();
        bool stopped = data.mid(8,1) == "s";
        int homeScoreS = data.mid(9,2).trimmed().toInt();
        int awayScoreS = data.mid(11,2).trimmed().toInt();
        int homeTol = data.mid(13,1).toInt();
        int awayTol = data.mid(14,1).toInt();
        int hSog = data.mid(15,2).toInt();
        int aSog = data.mid(17,2).toInt();
        int cgPeriod = data.mid(19,2).toInt();
        QString penClock="";

        bool penH1,penH2,penA1,penA2;
        int homePlayer1 = data.mid(21,2).toInt(&penH1);
        QString homePen1 = data.mid(23,5).trimmed();
        int homePlayer2 = data.mid(28,2).toInt(&penH2);
        QString homePen2 = data.mid(30,5).trimmed();
        int awayPlayer1 = data.mid(35,2).toInt(&penA1);
        QString awayPen1 = data.mid(37,5).trimmed();
        int awayPlayer2 = data.mid(42,2).toInt(&penA2);
        QString awayPen2 = data.mid(44,5).trimmed();

        int awayInTheBox = 0;
        int homeInTheBox = 0;
        QSet<int>awayTemp,homeTemp;
        bool penalty = false;
        emit clockIsRunning(stopped);
        if (penaltiesActive || (!penaltiesActive && stopped)) {
            if (penA1){
                awayInTheBox++;
                awayTemp.insert(awayPlayer1);
                if (!awayPlayersInBox.contains(awayPlayer1)) triggerNewPenalty();
                awayPlayersInBox.insert(awayPlayer1);
                penalty = true;
            }
            if (penA2) {
                awayInTheBox++;
                awayTemp.insert(awayPlayer2);
                if (!awayPlayersInBox.contains(awayPlayer2)) triggerNewPenalty();
                awayPlayersInBox.insert(awayPlayer2);
                penalty = true;
            }
            awayPlayersInBox = awayPlayersInBox.intersect(awayTemp);

            if (penH1){
                homeInTheBox++;
                homeTemp.insert(homePlayer1);
                if (!homePlayersInBox.contains(homePlayer1)) triggerNewPenalty();
                homePlayersInBox.insert(homePlayer1);
                penalty = true;
            }
            if (penH2){
                homeInTheBox++;
                homeTemp.insert(homePlayer2);
                if (!homePlayersInBox.contains(homePlayer2)) triggerNewPenalty();
                homePlayersInBox.insert(homePlayer2);
                penalty = true;
            }
             homePlayersInBox = homePlayersInBox.intersect(homeTemp);
            if (penalty) {
                penClock = std::min({penA1 ? awayPen1.trimmed() : NO_PEN, penA2 ? awayPen2.trimmed() : NO_PEN,
                                    penH1 ? homePen1.trimmed() : NO_PEN, penH2 ? homePen2.trimmed() : NO_PEN});
            } else if (penaltiesActive) {
                // There were active penalties, but not anymore
            }
            penaltiesActive = penalty;
            determinePpClockAllSport(penClock);
        }
        gameClock.setClock(clock);
        if (homeScore != homeScoreS) {
            while (homeScore < homeScoreS) {
                homeGoal();
            }
            while (homeScore > homeScoreS) {
                homeLoseGoal();
            }

        }
        if (awayScore != awayScoreS) {
            while (awayScore < awayScoreS) {
                awayGoal();
            }
            while (awayScore > awayScoreS) {
                awayLoseGoal();
            }

        }
        if (homeSOG != hSog) {
            while (homeSOG < hSog) {
                addHomeSOG();
            }
            while (homeSOG > hSog) {
                subHomeSOG();
            }
        }
        if (awaySOG != aSog) {
            while (awaySOG < aSog) {
                addAwaySOG();
            }
            while (awaySOG > aSog) {
                subAwaySOG();
            }
        }

        if (stopped) {
            if (!firedPeriodChange) {
                QRegularExpression simpleForm("^0.0$");
                if (gameClock.toString() == "00.0" || simpleForm.match(gameClock.toString()).hasMatch()) {
                    firePeriodChange();
                }
            } else if (waitingForPeriodStart) {
                QRegularExpression simpleForm("^0.0$");
                if (gameClock.toString() != "00.0" && !simpleForm.match(gameClock.toString()).hasMatch()) {
                    waitingForPeriodStart=false;
                    emit automatedScoreboard();
                }
            }
        } else {
            firedPeriodChange = false;
        }

        //toggleCgPenaltyClocks(!stopped);
    } catch (...) {
        serialConsole->getConsole()->putData(data);
        serialConsole->closeSerialPort();
        serialConsole->openSerialPort();
    }

}