void CommandParser::checkNext() {
  if (m_expectingDataSize == -1) {
    if (m_device->canReadLine()) {
      readLine();
      checkNext();
    }
  } else {
    if (m_device->bytesAvailable() >= m_expectingDataSize) {
      readDataBlock();
      checkNext();
    }
  }
}
void Connection::checkNext() {
  if (m_expectingDataSize == -1) {
    if (m_socket->canReadLine()) {
      readLine();
      checkNext();
    }
  } else {
    if (m_socket->bytesAvailable() >= m_expectingDataSize) {
      readDataBlock();
      checkNext();
    }
  }
}
Beispiel #3
0
void HashChecker::append(const QList<QString> &names)
{
    if (checkQueue.isEmpty() && !working.isRunning())
        QTimer::singleShot(0, this, SLOT(checkNext()));

    foreach (QString entry, names)
    {
        checkQueue.enqueue(entry);
    }
Beispiel #4
0
bool EventManager::goBottom(QPoint &next_m)
{
  next_m = QPoint(_snake.getPos().x(), _snake.getPos().y() + 1);
  QPoint next_f = QPoint(next_m.x() - 1, next_m.y() + 1);
  QPoint next_s = QPoint(next_m.x(), next_m.y() + 1);
  QPoint next_t = QPoint(next_m.x() + 1, next_m.y() + 1);

  return checkNext(next_m, next_f, next_s, next_t);
}
Connection::Connection(QTcpSocket *socket, WebPage *page, QObject *parent) :
    QObject(parent) {
  m_socket = socket;
  m_page = page;
  m_command = NULL;
  m_expectingDataSize = -1;
  m_pageSuccess = true;
  m_commandWaiting = false;
  connect(m_socket, SIGNAL(readyRead()), this, SLOT(checkNext()));
  connect(m_page, SIGNAL(loadFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
}
Beispiel #6
0
void BytesTrieTest::checkData(const StringAndValue data[], int32_t dataLength, UStringTrieBuildOption buildOption) {
    LocalPointer<BytesTrie> trie(buildTrie(data, dataLength, buildOption));
    if(trie.isNull()) {
        return;  // buildTrie() reported an error
    }
    checkFirst(*trie, data, dataLength);
    checkNext(*trie, data, dataLength);
    checkNextWithState(*trie, data, dataLength);
    checkNextString(*trie, data, dataLength);
    checkIterator(*trie, data, dataLength);
}
Connection::Connection(QTcpSocket *socket, WebPageManager *manager, QObject *parent) :
    QObject(parent) {
  m_socket = socket;
  m_manager = manager;
  m_commandFactory = new CommandFactory(m_manager, this);
  m_commandParser = new CommandParser(socket, m_commandFactory, this);
  m_pageSuccess = true;
  connect(m_socket, SIGNAL(readyRead()), m_commandParser, SLOT(checkNext()));
  connect(m_commandParser, SIGNAL(commandReady(Command *)), this, SLOT(commandReady(Command *)));
  connect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
}
Beispiel #8
0
Connection::Connection(QTcpSocket *socket, WebPage *page, QObject *parent) :
    QObject(parent) {
  m_socket = socket;
  m_page = page;
  m_commandParser = new CommandParser(socket, this);
  m_commandFactory = new CommandFactory(page, this);
  m_command = NULL;
  m_pageSuccess = true;
  m_commandWaiting = false;
  connect(m_socket, SIGNAL(readyRead()), m_commandParser, SLOT(checkNext()));
  connect(m_commandParser, SIGNAL(commandReady(QString, QStringList)), this, SLOT(commandReady(QString, QStringList)));
  connect(m_page, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
}
Connection::Connection(QTcpSocket *socket, WebPage *page, QObject *parent) :
    QObject(parent) {
  m_socket = socket;
  m_page = page;
  m_commandFactory = new CommandFactory(page, this);
  m_commandParser = new CommandParser(socket, m_commandFactory, this);
  m_runningCommand = NULL;
  m_queuedCommand = NULL;
  m_pageSuccess = true;
  m_commandWaiting = false;
  m_pageLoadingFromCommand = false;
  m_pendingResponse = NULL;
  connect(m_socket, SIGNAL(readyRead()), m_commandParser, SLOT(checkNext()));
  connect(m_commandParser, SIGNAL(commandReady(Command *)), this, SLOT(commandReady(Command *)));
  connect(m_page, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
}
CommandParser::CommandParser(QIODevice *device, QObject *parent) :
    QObject(parent) {
  m_device = device;
  m_expectingDataSize = -1;
  connect(m_device, SIGNAL(readyRead()), this, SLOT(checkNext()));
}
Beispiel #11
0
//------------------------- Private -------------------------------------------
void EditCardPage::connect_all()
{
    connect(copy_checkBox_1,SIGNAL(toggled(bool)),
            reciver_lineEd_1,SLOT(setEnabled(bool))
           );
    connect(copy_checkBox_2,SIGNAL(toggled(bool)),
            reciver_lineEd_2,SLOT(setEnabled(bool))
           );
    connect(copy_checkBox_3,SIGNAL(toggled(bool)),
            reciver_lineEd_3,SLOT(setEnabled(bool))
           );
    connect(copy_checkBox_4,SIGNAL(toggled(bool)),
            reciver_lineEd_4,SLOT(setEnabled(bool))
           );
    connect(copy_checkBox_5,SIGNAL(toggled(bool)),
            reciver_lineEd_5,SLOT(setEnabled(bool))
           );

    connect(docName_lineEd,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(punktLineEd,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(mbNumberLineEd,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(executor_lineEd,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(pressman_lineEd,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(invNumber_lineEd,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(pagesCountLineEd,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(telephone_lineEd,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(reciver_lineEd_1,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(reciver_lineEd_2,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(reciver_lineEd_3,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(reciver_lineEd_4,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );
    connect(reciver_lineEd_5,SIGNAL(editingFinished()),
            this,SLOT(checkNext())
           );

    connect(secretCBox,SIGNAL(currentIndexChanged(int)),
            this,SLOT(checkNext())
           );

    connect(templatesCBox,SIGNAL(currentIndexChanged(int)),
            this,SLOT(checkNext())
           );
    connect(printersCBox,SIGNAL(currentIndexChanged(int)),
            this,SLOT(checkNext())
           );

}
Beispiel #12
0
std::vector<Point> twinkle::labelPoints(cv::Mat mat)
{
    int labelCount[mat.rows*mat.cols];

    std::vector<Point>corners;
    int di, dj;
    int recAns;
    for(int i=0; i<mat.rows; i++)
    {
        for(int j=0; j<mat.cols; j++)
        {
            std::cout<<"(i,j) = ("<<i<<","<<j<<")"<<std::endl;
            labelCount[i*mat.cols+j] = 0;

            if(i>=1 && i<mat.rows-1 && j>=1 && j<mat.cols-1)
            {
                if(mat.at<uchar>(i,j)  == 255)
                {
                    std::vector<bool> checked(9,false);
                    for(int k = 0; k<9; k++)  //foreach point in mask perimeter
                    {
                        if(!checked[k] && k!=4)
                        {
                            std::cout<<"Unchecked point " << k <<": recursive stuff"<<std::endl;
                            recAns = 0;

                            switch(k%3)
                            {
                            case 0: dj = -1;
                                break;
                            case 1: dj = 0;
                                break;
                            case 2: dj = 1;
                                break;
                            }
                            switch(k/3)
                            {
                            case 0: di = -1;
                                break;
                            case 1: di = 0;
                                break;
                            case 2: di = 1;
                                break;
                            }

                            std::cout<<"di = "<<di<<", dj = " <<dj<<std::endl;

                            checked[k] = true;
                            if(mat.at<uchar>(i+di, j+dj) == 0)
                            {
                                recAns++;
                                recAns += checkNext(k, true, checked, mat, i, j);
                                recAns += checkNext(k, false, checked, mat, i, j);
                            }

                            std::cout<<"End of recursion: checked vector is ";
                            for(uint c=0; c<checked.size();c++) std::cout << checked[c] << " - ";
                            std::cout<<std::endl;

                            if(recAns > labelCount[i*mat.cols+j])
                            {
                                labelCount[i*mat.cols+j] = recAns;
                            }
                        }
                    }
                }
            }

            if(labelCount[i*mat.cols+j] > 0)
            {
                std::cout<<"Point is labelled with "<< labelCount[i*mat.cols+j]<<std::endl;
                if(labelCount[i*mat.cols+j] >= 5)
                {
                    Point p(j,i);
                    corners.push_back(p);
                    std::cout<<"----- New corner found!"<<std::endl;
                }
                //cv::waitKey(0);
            }
        }
    }

    std::cout<<"Found " << corners.size() << " corners."<<std::endl;


    //cv::Mat cornerImg(mat.rows, mat.cols, CV_8U);
    cv::Mat cornerImg = Mat::zeros(mat.rows, mat.cols, CV_8U);
    for(uint i=0; i<corners.size(); i++)
    {
        cornerImg.at<uchar>(corners[i]) = 255;
    }

    /// Show in a window
    namedWindow( "Corners", CV_WINDOW_NORMAL );
    imshow( "Corners", cornerImg);
    waitKey(0);

    return corners;

    /*
    cv::Mat labelledImg(dMat.rows, dMat.cols, CV_8U);
    int grayStep = 30;
    for(int i=0; i<dMat.rows;i++)
    {
        for(int j=0; j<dMat.cols; j++)
        {
            labelledImg.at<uchar>(i,j) = grayStep*labelCount[i*dMat.cols+j];
        }
    }

    /// Show in a window
    namedWindow( "Labelled", CV_WINDOW_NORMAL );
    imshow( "Labelled", labelledImg);
    waitKey(0);
    */
}
Beispiel #13
0
int twinkle::checkNext(int k, bool next, std::vector<bool>& checked, cv::Mat mat, int i, int j)
{
    int di, dj;
    int attiguousBlack = 0;
    int nextVal, prevVal;
    int localK;
    bool debug = true;


    if(debug)
    {
        std::cout<<"CheckNext: entered with following checked vector:"<<std::endl;
        for(uint c=0; c<checked.size();c++) std::cout<<"- " <<checked[c]<<" ";
        std::cout<<std::endl;
    }

    switch(k)
    {
    case 0:
        nextVal = 1;
        prevVal = 3;
        break;
    case 1:
        nextVal = 2;
        prevVal = 0;
        break;
    case 2:
        nextVal = 5;
        prevVal = 1;
        break;
    case 3:
        nextVal = 0;
        prevVal = 6;
        break;
    case 4:
        break;
    case 5:
        nextVal = 8;
        prevVal = 2;
        break;
    case 6:
        nextVal = 3;
        prevVal = 7;
        break;
    case 7:
        nextVal = 6;
        prevVal = 8;
        break;
    case 8:
        nextVal = 7;
        prevVal = 5;
        break;
    }

    if(next) localK=nextVal;
    else localK=prevVal;

    switch(localK%3)
    {
    case 0:
        dj = -1;
        break;
    case 1: dj = 0;
        break;
    case 2: dj = 1;
        break;
    }
    switch(localK/3)
    {
    case 0: di = -1;
        break;
    case 1: di = 0;
        break;
    case 2: di = 1;
        break;
    }

    if(!checked[localK])
    {
        if(mat.at<uchar>(i+di, j+dj) == 0)
        {
            attiguousBlack++;
            attiguousBlack += checkNext(localK, next, checked, mat, i, j);
        }

        checked[localK] = true;
    }

    if(debug)
    {
        std::cout<<"CheckNext: exiting with follow checked vector:"<<std::endl;
        for(uint c=0; c<checked.size();c++) std::cout<<"- " <<checked[c]<<" ";
        std::cout<<std::endl;
    }

    return attiguousBlack;
}
Beispiel #14
0
bool ChordAnalyzer::analyze()
{
    // C  Db D	Eb E  F	 F# G  G# A	 Bb B
    // 0  1	 2	3  4  5	 6	7  8  9	 10 11

    QChar tc = name[0];

    // Get tonic
    switch (tc.toAscii())  {
    case 'C':
        tonic = 0;
        break;
    case 'D':
        tonic = 2;
        break;
    case 'E':
        tonic = 4;
        break;
    case 'F':
        tonic = 5;
        break;
    case 'G':
        tonic = 7;
        break;
    case 'A':
        tonic = 9;
        break;
    case 'H':
    case 'B':
        tonic = 11;
        break; // GREYFIX: understand B differently if Jazz active
    default:
        msg = i18n("Can't understand tonic from given chord name");
        return FALSE;
    }

    pos = 1;

    // Try to fix tonic with sharps and flats
    while (name[pos] != QChar::null) {
        if (name[pos] == 'B')  {
            tonic = (tonic - 1) % 12;
        } else if (name[pos] == '#')  {
            tonic = (tonic + 1) % 12;
        } else {
            break;
        }
        pos++;
    }

    // Set default steps (major triad)
    step[0] = 3;
    step[1] = 2;

    // Main analyze loop - ! REMEMBER, UPPERCASE !
    while (name[pos] != QChar::null) {
        int oldpos = pos;

        // Check "maj7" for dominant seventh
        if (checkNext("MAJ7"))
            if (!setStep(2, 3, "maj7"))
                return FALSE;

        // Check "min" for minor third step
        if (checkNext("MIN"))
            if (!setStep(0, 2, "min"))
                return FALSE;

        // Check "m" for minor third step
        if (checkNext("M"))
            if (!setStep(0, 2, "m"))
                return FALSE;

        // Check "7M" for dominant seventh
        if (checkNext("7M"))
            if (!setStep(2, 3, "7M"))
                return FALSE;

        // Check "7" for minor seventh
        if (checkNext("7"))
            if (!setStep(2, 2, "7"))
                return FALSE;

        // Check "6" for sixth
        if (checkNext("6"))
            if (!setStep(2, 1, "6"))
                return FALSE;

        // Check "sus2" for second step
        if (checkNext("SUS2"))
            if (!setStep(0, 1, "sus2"))
                return FALSE;

        // Check "s2" for second step
        if (checkNext("S2"))
            if (!setStep(0, 1, "s2"))
                return FALSE;

        // Check "sus4" for second step
        if (checkNext("SUS4"))
            if (!setStep(0, 4, "sus4"))
                return FALSE;

        // Check "s4" for second step
        if (checkNext("S4"))
            if (!setStep(0, 4, "s4"))
                return FALSE;

        // Check "no3" for no third step
        if (checkNext("NO3"))
            if (!setStep(0, 0, "no3"))
                return FALSE;

        // Check "no5" for no fifth step
        if (checkNext("NO5"))
            if (!setStep(1, 0, "no5"))
                return FALSE;

        // Check "aug" for augmented chord
        if (checkNext("AUG"))
            if (!setStep(1, 3, "aug"))
                return FALSE;

        // Check "dim"
        if (checkNext("DIM"))  {
            if (!setStep(0, 2, "dim"))
                return FALSE;
            if (!setStep(1, 1, "dim"))
                return FALSE;
        }

        // Check "5" power chord
        if (checkNext("5"))  {
            if (!setStep(0, 0, "5"))
                return FALSE;
            if (!setStep(1, 2, "5"))
                return FALSE;
            if (!setStep(2, 0, "5"))
                return FALSE;
            if (!setStep(3, 0, "5"))
                return FALSE;
            if (!setStep(4, 0, "5"))
                return FALSE;
            if (!setStep(5, 0, "5"))
                return FALSE;
        }

        // Stumbled across unrecognizable symbol
        if (oldpos == pos) {
            msg = i18n("Can't understand notation: \"%1\"").arg(name.mid(pos));
            return FALSE;
        }
    }

    return TRUE;
}
Beispiel #15
0
bool Lexer::getNextToken(Tokener &tokener)
{
	bool isComment = false;
	bool loopMark = true;
	while(loopMark)
	{
		peekNext();
		if(endOfFile)
		{
			if(isComment)
			{
				cout << line << ',' << row << " 文件末尾出错:缺少'}\n'" << endl;
				exit(1);
			}
			tokener.putToken(new Token(-1),line,row);
			return false;
		}
		switch(peek)
		{
			    case ' ':
                case '\t':
                case '\n':
                    break;
                case '{':
                    if (isComment)
					{
                       cout << line << ',' << row << " 错误的输入:嵌套的注释\n" << endl;
					   exit(1);
                    } 
                    else
                    {
                        isComment = true;
                    }
                    break;
                case '}':
                    if (isComment) {
                        isComment = false;
                    } 
                    else
                    {
                        cout << line << ',' << row << " 错误的输入:嵌套的注释\n" << endl;
						exit(1);
                    }
                    break;
                default:
                    if (!isComment) 
                    {
                        loopMark = false;
                        break;
                    }
		}
	}

	// 2.识别复合词法符号 ":="
	switch(peek)
	{
        case ':':
			if (!checkNext('='))
			{
		        tokener.putToken(new Symbol(':'), line, row);
		        return true;
		    } 
		    else 
		    {
		        tokener.putToken(&Operator::OP_ASSIGN, line, row - 1);
		        return true;
		    }
	}

	//识别各种符号
	switch(peek)
	{
        case '+':
            tokener.putToken(&Operator::OP_PLUS, line, row);
            return true;
        case '-':
            tokener.putToken(&Operator::OP_MINUS, line, row);
            return true;
        case '*':
            tokener.putToken(&Operator::OP_MUTL, line, row);
            return true;
        case '/':
            tokener.putToken(&Operator::OP_DIV, line, row);
            return true;
        case '=':
            tokener.putToken(&Operator::OP_EQUAL, line, row);
            return true;
        case '<':
            tokener.putToken(&Operator::OP_LESS, line, row);
            return true;
	}

	//读取整数常量
	if(isDigit(peek))
	{
		int startRow = row;

		int value = peek - '0';

		while(true)
		{
			peekNext();
			if(endOfFile)
			{
				break;
			}
			if(!isDigit(peek))
			{
				putBack(peek);
				break;
			}
			value = value * 10 + peek - '0';
		}
		tokener.putToken(new Int(value),line,startRow);
		return true;
	}

	//读取标识符
	if(isLetter(peek))
	{
		int startrow = row;

		string str;
		str.append(string(&peek));
		while(true)
		{
			peekNext();
			if(endOfFile)
			{
				break;
			}
			if(!isLetterOrDigit(peek))
			{
				putBack(peek);
				break;
			}
			str.append(string(&peek));
		}

		Word *word = Word::getReserve(str);
		if( word == NULL)
		{
			word = new Word(Token::TAG_VARIABLE,str);
		}

		tokener.putToken((Word*)word,line,startrow);
		return true;
	}

	//剩余的情况
	tokener.putToken(new Token(peek),line,row);
	return true;
}