zoukankan      html  css  js  c++  java
  • QRegExp

     这段代码会越界,百思不得七姐(过了N久时间 之后^^)原来是把i写成了1  --!

    //#if 0
            QRegExp re1("AT+CGATT?");
            QRegExp re2("AT+CGATT=([0-9])");
            if (re1.exactMatch(list[1])) {
                qDebug()<<"list[i]"<<list[i];
            }
            else if (re2.exactMatch(list[i])) {
                // set
                int state;
                bool ok;
                state = re2.cap(1).toInt(&ok);
                if (ok && state >= 0 && state <= 1) {
                    ue->cgatt.state = state;
                    response.append("OK");
                }
                else
                    response.append("ERROR");
            }
    //#endif

     这个for + switch 的用法回味好久之后还是美

               QRegExp ref1("AT+COPS?");
                QRegExp ref2("AT+COPS=([0-9])(.*)"); //[<mode>[,<format> [,<oper>[,<AcT>]]]]
                if (ref1.exactMatch(list[i]))
                    response.append("+COPS:")
                            .append(QString::number(ue->cops.mode)).append(",")
                            .append(QString::number(ue->cops.format)).append(",")
                            .append(ue->cops.oper_numeric).append(",")
                            .append(QString::number(ue->cops.act)).append("
    OK");
                else if (ref2.exactMatch(list[i]))
                {   
                    ue->cops.mode = ref2.cap(1).toInt();
                    if (!ref2.cap(2).isEmpty()) {
                        QStringList pa;
                        pa = ref2.cap(2).split(",");
                        for (i = 0; i < pa.size(); i++) {
                            switch (i) {
                            case 0: ue->cops.format = pa.at(i).toInt(); break;
                            case 1: strcpy(ue->cops.oper_long, pa.at(i).toAscii().constData()); break;
                            case 2: ue->cops.act = pa.at(i).toInt(); break;
                            default:
                                break;
                            }
                        }
                    }

    由于 win 没有实现loopback   so wireshock cannot capture  raw sockets .  

    alternative tool : RawCAp  easily to use .

    如果有人能在我读研的第一天跟我讲万物在维基,也就不愁会发几个AAA的论文了。

    三步曲,,,,./ configure  make make install 

    如果程序員真的愛一個語言,怎能不害怕有一天會忘記它

    而我們又必須接受時間的事實  於是長大了 寂寞就是沒有機會再使用它

    比沒有接觸過電腦時還要寂寞  即使短暫也刻骨銘心

    那些點亮我們生命的語言  就如同傳說中發生在星羅的愛情故事 

     

  • 相关阅读:
    Leetcode Spiral Matrix
    Leetcode Sqrt(x)
    Leetcode Pow(x,n)
    Leetcode Rotate Image
    Leetcode Multiply Strings
    Leetcode Length of Last Word
    Topcoder SRM 626 DIV2 SumOfPower
    Topcoder SRM 626 DIV2 FixedDiceGameDiv2
    Leetcode Largest Rectangle in Histogram
    Leetcode Set Matrix Zeroes
  • 原文地址:https://www.cnblogs.com/iamgoodman/p/3844854.html
Copyright © 2011-2022 走看看