当前位置: 首页>>代码示例>>C++>>正文


C++ QByteArray::toULongLong方法代码示例

本文整理汇总了C++中QByteArray::toULongLong方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::toULongLong方法的具体用法?C++ QByteArray::toULongLong怎么用?C++ QByteArray::toULongLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QByteArray的用法示例。


在下文中一共展示了QByteArray::toULongLong方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read

void Bdecoder::read(qulonglong *value, bool &bSigned)
{
    if (m_pos >= m_len || m_buf[m_pos] != 'i') {
        setError("expected integer, got %c", char(m_buf[m_pos]));
        return;
    }
    m_pos++;
    int end = m_buf.indexOf('e', m_pos);
    if (end <= m_pos || end >= m_len) {
        setError("buffer overrun");
        return;
    }

    if (value) {
        QByteArray s = m_buf.mid(m_pos, end - m_pos);
        if (!validateInt(s))
            return;
        bool ok;
		if(bSigned = (s.left(1) == "-"))
			*value = s.toLongLong(&ok, 10);
		else
			*value = s.toULongLong(&ok, 10);
        if (!ok) {
            setError("Invalid integer (%s)", s.constData());
            return;
        }
    }
    m_pos = end + 1;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:29,代码来源:bencode.cpp

示例2: contentLength

qint64 QHttpNetworkHeaderPrivate::contentLength() const
{
    bool ok = false;
    // We are not using the headerField() method here because servers might send us multiple content-length
    // headers which is crap (see QTBUG-15311). Therefore just take the first content-length header field.
    QByteArray value;
    QList<QPair<QByteArray, QByteArray> >::ConstIterator it = fields.constBegin(),
                                                        end = fields.constEnd();
    for ( ; it != end; ++it)
        if (qstricmp("content-length", it->first) == 0) {
            value = it->second;
            break;
        }

    qint64 length = value.toULongLong(&ok);
    if (ok)
        return length;
    return -1; // the header field is not set
}
开发者ID:AlekSi,项目名称:phantomjs,代码行数:19,代码来源:qhttpnetworkheader.cpp

示例3: getRecvFileSize

quint64 getRecvFileSize(const QByteArray &data)
{
    int nPos = 0;
    QByteArray temp;
    const char *conL="Content-Length:";

    nPos = data.indexOf(conL);
    if(nPos != -1)
    {
        temp = data.mid(nPos + strlen(conL));
        nPos = temp.indexOf("\n");

        if(nPos != -1)
        {
            temp = temp.left(nPos);
            temp=temp.trimmed();

            return (temp.toULongLong());
        }
    }

    return -1;
}
开发者ID:SiteView,项目名称:genieautorun,代码行数:23,代码来源:SvtHttpDownload.cpp

示例4: processClient

void clientHandler::processClient(QTcpSocket *socket, QList<FileExec>fileExecList)
{
    //QByteArray inData;
    //QString inStr;
    //QStringList list;
    //QStringList ops;
    bool getProcess;
    //bool processHeader;
    //QString resultStr;
    executeData ed;
    QByteArray inData;
    qint64 loc;
    qint64 contentLength;
    qint64 requestLength;
    qint64 headerLength;
    quint64 timeout;
    bool processHeader;
    bool dataRecieved;

    processHeader = false;
    this->clientTCP = socket;
    this->fileExecList = fileExecList;
    contentLength = 0;
    requestLength = 0;
    loc = 0;
    getProcess = false;
    dataRecieved = false;
    timeout = 0;

    connect(this->clientTCP,SIGNAL(disconnected()),this,SLOT(socketDisconnected()));
    if (!this->clientTCP->waitForReadyRead(100)){
        this->clientTCP->disconnectFromHost();
        this->clientTCP->deleteLater();
        return;
    }


    inData.clear();
    while(1){

        if (timeout == 30000){
            break;
        }

        //we need to read the first data and determined content length
        if (this->clientTCP->bytesAvailable() > 0){
            qDebug() << this->clientTCP->bytesAvailable();
            timeout = 0;
            inData.append(this->clientTCP->readAll());
            QCoreApplication::processEvents();

            if (!processHeader){

                headerLength = inData.indexOf("\r\n\r\n",0);
                if (headerLength > 0){
                    processHeader = true;

                    //find content length;
                    loc = inData.indexOf("Content-Length:");
                    if (loc < 0){
                        contentLength = 0;
                    }

                    if (loc > 0){
                        //get the size;
                        qint64 loc2 = inData.indexOf("\r\n",loc);
                        if (loc2 < 0){
                            contentLength = 0;
                        }
                        else
                        {
                            QByteArray size;
                            size.clear();
                            size.append(inData.mid(loc,loc2 - loc).replace("Content-Length:","").trimmed());
                            contentLength = size.toULongLong();
                        }
                    }
                }
            }

            if (processHeader){
                requestLength = headerLength + contentLength;
                if (inData.size() >= requestLength){
                    dataRecieved = true;
                    break;
                }
            }
        }
        QCoreApplication::processEvents();
        timeout++;
    }

    if (!dataRecieved){
        this->clientTCP->disconnectFromHost();
        this->clientTCP->deleteLater();
        return;
    }

    //qDebug() << "DEBUG STOP" << requestLength << timeout;
    //qDebug() << "inData size" << inData.size();
//.........这里部分代码省略.........
开发者ID:azrilrahim,项目名称:TodakServer,代码行数:101,代码来源:clienthandler.cpp

示例5: yylex


//.........这里部分代码省略.........
        return -1;
       }
#endif
      m_io->read(1); // consume
      raw += nextCh;
      prevCh = nextCh;
      if (escape_on)
        escape_on = false;
      else
        escape_on = (prevCh == '\\') ? true : false;
#if 0
      if (nextCh == '\\') {
        char buf;
        if (m_io->getChar (&buf)) {
          yylloc->columns();
          if (((buf != '"') && (buf != '\\') && (buf != '/') &&
              (buf != 'b') && (buf != 'f') && (buf != 'n') &&
              (buf != 'r') && (buf != 't') && (buf != 'u'))) {
                qjsonDebug() << "Just read" << buf;
                qjsonDebug() << "JSonScanner::yylex - error decoding escaped sequence";
                return -1;
          }
        } else {
          qCritical() << "JSonScanner::yylex - error decoding escaped sequence : io error";
          return -1;
        }
      }
#endif
    }
  }
  else if (isdigit(ch) != 0 && m_quotmarkClosed) {
    bool ok;
    QByteArray numArray = QByteArray::fromRawData( &ch, 1 * sizeof(char) );
    qulonglong number = numArray.toULongLong(&ok);
    if (!ok) {
      //This shouldn't happen
      qCritical() << "JSonScanner::yylex - error while converting char to ulonglong, returning -1";
      return -1;
    }
    if (number == 0) {
      // we have to return immediately otherwise numbers like
      // 2.04 will be converted to 2.4
      *yylval = QVariant(number);
      qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DIGIT";
      return yy::json_parser::token::DIGIT;
    }

    char nextCh;
    qint64 ret = m_io->peek(&nextCh, 1);
    while (ret == 1 && isdigit(nextCh)) {
      m_io->read(1); //consume
      yylloc->columns(1);
      numArray = QByteArray::fromRawData( &nextCh, 1 * sizeof(char) );
      number = number * 10 + numArray.toULongLong(&ok);
      if (!ok) {
        //This shouldn't happen
        qCritical() << "JSonScanner::yylex - error while converting char to ulonglong, returning -1";
        return -1;
      }
      ret = m_io->peek(&nextCh, 1);
    }

    *yylval = QVariant(number);
    qjsonDebug() << "JSonScanner::yylex - yy::json_parser::token::DIGIT";
    return yy::json_parser::token::DIGIT;
  }
开发者ID:LosYear,项目名称:Ferriage,代码行数:67,代码来源:json_scanner.cpp


注:本文中的QByteArray::toULongLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。