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


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

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


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

示例1: if

void tH3000LinkRx::RxSerialData(const QByteArray& rxData)
{
    bool messageReceived = false;

    // Receive buffer is a QByteArray
    // This could be optimised to be char array to reduce allocs and copies
    m_RxBuffer += rxData;

    int endIndex = m_RxBuffer.indexOf("\r\n");

    while(endIndex != -1)
    {
        QByteArray RxMessage = m_RxBuffer.left(endIndex);

        if(RxMessage.size() > 0)
        {
            bool messageOk = false;

#ifdef LOG_H3000_RX
            DbgPrintf("**** H3000 Rx %s", RxMessage.constData());
#endif
            // Check the checksum
            int checksumIndex = RxMessage.lastIndexOf('*');

            if(checksumIndex != -1)
            {
                unsigned char calcChecksum = static_cast<unsigned char>( tH3000Command::CalculateChecksum( RxMessage.left( checksumIndex) ) );
                unsigned char checksum = static_cast<unsigned char>( RxMessage.mid(checksumIndex + 1, 2).toInt(0, 16) );

                if(checksum == calcChecksum)
                {
                    messageOk = true;
                }
            }

            if(messageOk == true)
            {
                QByteArray strippedMessage = RxMessage.left(checksumIndex);

                if(RxMessage.at(0) == '#')
                {
                    emit H3000ReceivedEchoResponse(RxMessage);
                }
                else if(RxMessage.at(0) == 'V')
                {
                    ProcessReceivedValue(strippedMessage);
                }
                else if(RxMessage.at(0) == 'U') 
                {
                    ProcessReceivedTableData(strippedMessage);
                }
                else if(RxMessage.at(0) == 'L')
                {
                    ProcessReceivedPosition(strippedMessage);
                }
                else if(RxMessage.at(0) == 'T')
                {
                    ProcessReceivedUTC(strippedMessage);
                }
                else if(RxMessage.at(0) == 'M')
                {
                    ProcessReceivedTrueMagSetting(strippedMessage);
                }

                messageReceived = true;
            }
        }

        m_RxBuffer = m_RxBuffer.mid(endIndex + 2);

        endIndex = m_RxBuffer.indexOf("\r\n");
    }

    if((messageReceived) && (!m_DataReceived))
    {
        m_DataReceived = true;

        emit H3000LinkDataReceived();
    }
}
开发者ID:dulton,项目名称:53_hero,代码行数:80,代码来源:tH3000LinkRx.cpp

示例2: getOperandFromMessage

char IoInterface::getOperandFromMessage(QByteArray message)
{
    char operand = message.at(2) & 0xff;
    return operand;
}
开发者ID:syjsmk,项目名称:EmbeddedSoftware1,代码行数:5,代码来源:iointerface.cpp

示例3: raiseError

bool KeePass2Reader::readHeaderField()
{
    QByteArray fieldIDArray = m_headerStream->read(1);
    if (fieldIDArray.size() != 1) {
        raiseError("Invalid header id size");
        return false;
    }
    quint8 fieldID = fieldIDArray.at(0);

    bool ok;
    quint16 fieldLen = Endian::readUInt16(m_headerStream, KeePass2::BYTEORDER, &ok);
    if (!ok) {
        raiseError("Invalid header field length");
        return false;
    }

    QByteArray fieldData;
    if (fieldLen != 0) {
        fieldData = m_headerStream->read(fieldLen);
        if (fieldData.size() != fieldLen) {
            raiseError("Invalid header data length");
            return false;
        }
    }

    switch (fieldID) {
    case KeePass2::EndOfHeader:
        m_headerEnd = true;
        break;

    case KeePass2::CipherID:
        setCipher(fieldData);
        break;

    case KeePass2::CompressionFlags:
        setCompressionFlags(fieldData);
        break;

    case KeePass2::MasterSeed:
        setMasterSeed(fieldData);
        break;

    case KeePass2::TransformSeed:
        setTransformSeed(fieldData);
        break;

    case KeePass2::TransformRounds:
        setTansformRounds(fieldData);
        break;

    case KeePass2::EncryptionIV:
        setEncryptionIV(fieldData);
        break;

    case KeePass2::ProtectedStreamKey:
        setProtectedStreamKey(fieldData);
        break;

    case KeePass2::StreamStartBytes:
        setStreamStartBytes(fieldData);
        break;

    case KeePass2::InnerRandomStreamID:
        setInnerRandomStreamID(fieldData);
        break;

    default:
        qWarning("Unknown header field read: id=%d", fieldID);
        break;
    }

    return !m_headerEnd;
}
开发者ID:ThunderPower,项目名称:keepassx,代码行数:73,代码来源:KeePass2Reader.cpp

示例4: ParseProperty

// Parse property (2 byte property + 2 byte length + value)
QString ChemData::ParseProperty( QByteArray a )
{
    QString propvalue;
    QString sx, sy;

    propvalue = "";

    if ( ( a[0] == '0' ) && ( a[1] == '2' ) ) { // position, p
        int y1 = ( unsigned char ) a[4] + ( unsigned char ) a[5] * 256 + ( unsigned char ) a[6] * 65536 + ( unsigned char ) a[7] * 16777216;
        int x1 = ( unsigned char ) a[8] + ( unsigned char ) a[9] * 256 + ( unsigned char ) a[10] * 65536 + ( unsigned char ) a[11] * 16777216;

        sx.setNum( ( double ) x1 / 65536.0 );
        sy.setNum( ( double ) y1 / 65536.0 );
        propvalue.append( "p=\"" );
        propvalue.append( sx );
        propvalue.append( " " );
        propvalue.append( sy );
        propvalue.append( "\"" );
        return propvalue;
    }
    if ( ( a[0] == '4' ) && ( a[1] == '2' ) ) { // bounding box
        int y1 = ( unsigned char ) a[4] + ( unsigned char ) a[5] * 256 + ( unsigned char ) a[6] * 65536 + ( unsigned char ) a[7] * 16777216;
        int x1 = ( unsigned char ) a[8] + ( unsigned char ) a[9] * 256 + ( unsigned char ) a[10] * 65536 + ( unsigned char ) a[11] * 16777216;
        int y2 = ( unsigned char ) a[12] + ( unsigned char ) a[13] * 256 + ( unsigned char ) a[14] * 65536 + ( unsigned char ) a[15] * 16777216;
        int x2 = ( unsigned char ) a[16] + ( unsigned char ) a[17] * 256 + ( unsigned char ) a[18] * 65536 + ( unsigned char ) a[19] * 16777216;

        sx.setNum( ( double ) x1 / 65536.0 );
        sy.setNum( ( double ) y1 / 65536.0 );
        QString sx2, sy2;

        sx2.setNum( ( double ) x2 / 65536.0 );
        sy2.setNum( ( double ) y2 / 65536.0 );
        propvalue.append( "BoundingBox=\"" );
        propvalue.append( sx );
        propvalue.append( " " );
        propvalue.append( sy );
        propvalue.append( " " );
        propvalue.append( sx2 );
        propvalue.append( " " );
        propvalue.append( sy2 );
        propvalue.append( "\"" );
        return propvalue;
    }
    if ( ( a[0] == '4' ) && ( a[1] == '6' ) ) { // bond begin B
        propvalue.append( "B=\"" );
        int x1 = ( unsigned char ) a[4] + ( unsigned char ) a[5] * 256 + ( unsigned char ) a[6] * 65536 + ( unsigned char ) a[7] * 16777216;

        sx.setNum( x1 );
        propvalue.append( sx );
        propvalue.append( "\"" );
        return propvalue;
    }
    if ( ( a[0] == '5' ) && ( a[1] == '6' ) ) { // bond end E
        propvalue.append( "E=\"" );
        int x1 = ( unsigned char ) a[4] + ( unsigned char ) a[5] * 256 + ( unsigned char ) a[6] * 65536 + ( unsigned char ) a[7] * 16777216;

        sx.setNum( x1 );
        propvalue.append( sx );
        propvalue.append( "\"" );
        return propvalue;
    }
    if ( ( a[0] == '0' ) && ( a[1] == '6' ) ) { // bond order
        propvalue.append( "Order=\"" );
        int x1 = ( unsigned char ) a[4];

        sx.setNum( x1 );
        propvalue.append( sx );
        propvalue.append( "\"" );
        return propvalue;
    }
    if ( ( a[0] == '1' ) && ( a[1] == '6' ) ) { // bond display property
        int x1 = ( unsigned char ) a[4];

        if ( x1 == 3 )
            propvalue = "Display=\"WedgedHashBegin\"";
        if ( x1 == 6 )
            propvalue = "Display=\"WedgeBegin\"";
        return propvalue;
    }
    if ( ( a[0] == '0' ) && ( a[1] == 'a' ) ) { // graphic type
        if ( a[4] == '1' )
            propvalue = "GraphicType=\"Line\"";
        if ( a[4] == '2' )
            propvalue = "GraphicType=\"Arc\"";
        if ( a[4] == '6' )
            propvalue = "GraphicType=\"Bracket\"";
        if ( a[4] == '7' )
            propvalue = "GraphicType=\"Symbol\"";
        return propvalue;
    }
    if ( ( a[0] == '6' ) && ( a[1] == 'a' ) ) { // bracket type
        if ( a[4] == '0' )
            propvalue = "BracketType=\"RoundPair\"";
        if ( a[4] == '1' )
            propvalue = "BracketType=\"SquarePair\"";
        if ( a[4] == '2' )
            propvalue = "BracketType=\"CurlyPair\"";
        return propvalue;
    }
//.........这里部分代码省略.........
开发者ID:parrondo,项目名称:xdrawchem2,代码行数:101,代码来源:cdx2cdxml.cpp

示例5: readMyCom

//读取数据
void MainWindow::readMyCom()
{
    QByteArray temp ;
    QByteArray shiftElement ;
    QByteArray shiftResult ;
    QString buf;

    //if(!temp.isEmpty()){
    if(myCom->bytesAvailable() >=41 )
      {
            shiftElement=myCom->readAll();
            temp=shiftElement;
            for (int i = 0; i <= shiftElement.length (); i++)//读取的19位数据循环移位,再相应输出到LCDNumberWidget显示
            {
                if(shiftElement[i]=='<')

                {
                    for(int j=0;j<40;j++)
                    {
                        if(i+j>40)
                        shiftResult[j]=shiftElement[i+j-41];

                        else
                        shiftResult[j]=shiftElement[i+j];
                    }
                break;
                }
            }
            ui->textBrowser->setTextColor(Qt::black);
            if(ui->ccradioButton->isChecked())
            {
                buf = shiftResult;
            }
            else if(ui->chradioButton->isChecked())
            {
                QString str;
                for(int i = 0; i < temp.count(); i++)
                {
                    QString s;
                    s.sprintf("0x%02x, ", (unsigned char)temp.at(i));
                    buf += s;
                }
            }

        if(!write2fileName.isEmpty())
        {
            QFile file(write2fileName);
            //如果打开失败则给出提示并退出函数
            if(!file.open(QFile::WriteOnly | QIODevice::Text))
            {
                QMessageBox::warning(this, tr("写入文件"), tr("打开文件 %1 失败, 无法写入\n%2").arg(write2fileName).arg(file.errorString()), QMessageBox::Ok);
                return;
            }
            QTextStream out(&file);
            out<<buf;
            file.close();
        }



        Temp=buf.mid(7,2);
        ui->Temp_lcdNumber->display(Temp);

        Humidity=buf.mid(9,2);
        ui->Humidity_lcdNumber->display(Humidity);

        Lux=buf.mid(2,5);
        ui->Lux_lcdNumber->display(Lux);


        Red=buf.mid(12,3);
        ui->Red_lcdNumber->display(Red);

        Green=buf.mid(16,3);
        ui->Green_lcdNumber->display(Green);

        Blue=buf.mid(20,3);
        ui->Blue_lcdNumber->display(Blue);


        Red_SpinBox=Red;
        Green_SpinBox=Green;
        Blue_SpinBox=Blue;
        ALL_SpinBox=Red.append(Green).append(Blue);



        ui->textBrowser->setText(ui->textBrowser->document()->toPlainText() + buf);
        QTextCursor cursor = ui->textBrowser->textCursor();
        cursor.movePosition(QTextCursor::End);
        ui->textBrowser->setTextCursor(cursor);
        ui->recvbyteslcdNumber->display(ui->recvbyteslcdNumber->value() + temp.size());
        ui->statusBar->showMessage(tr("成功读取%1字节数据").arg(temp.size()));
    }
}
开发者ID:JasonDean-1,项目名称:Qt-Training,代码行数:96,代码来源:mainwindow.cpp

示例6: stripCommentsFromJson

/// reads all bytes from the io device, while removing comments and keeping the number of lines
/// quick and dirty 'lexer' that replaces every comment by spaces (so the number of charactes keeps the same)
QByteArray JsonParser::stripCommentsFromJson( const QByteArray& bytesIn )
{
    QByteArray result;
    enum {
        StateNormal,
        StateString,
        StateLineComment,
        StateBlockComment
    } state = StateNormal;
    for( int i=0,cnt=bytesIn.size(); i<cnt; ++i ) {
        char c = bytesIn.at(i);
        switch( state ) {
            case StateNormal:
                // a '/'
                if( c == '/' ) {
                    char c2 = ((i+1)<cnt) ? bytesIn.at(i+1) : 0;
                    if( c2 == '/') {
                        i++;
                        state = StateLineComment;
                        result.append(' ');
                        result.append(' ');
                        break;
                    } else if ( c2 == '*') {
                        i++;
                        state = StateBlockComment;
                        result.append(' ');
                        result.append(' ');
                        break;
                    }
                // start of a string
                } else if( c == '\"') {
                    state = StateString;
                }
                result.append(c);
                break;

            case StateString:
                if( c == '\\' ) {
                    char c2 = ((i+1)<cnt) ? bytesIn.at(i+1) : 0;
                    if( c2 == '\"') {
                        i++;
                        result.append('\\');
                        result.append('\"');
                        break;
                    }
                } else if( c == '\"') {
                    state = StateNormal;
                }
                result.append(c);
                break;

            case StateLineComment:
                if( c == '\r') {
                    result.append('\r');
                }
                else if( c == '\n' ) {
                    result.append(c);
                    state = StateNormal;
                } else {
                    result.append(' ');
                }
                break;

            case StateBlockComment:
                if( c == '*') {
                    char c2 = ((i+1)<cnt) ? bytesIn.at(i+1) : 0;
                    if( c2 == '/') {
                        i++;
                        state = StateNormal;
                        result.append(' ');
                    }
                    result.append(' ');
                } else if( c == '\r' || c == '\n' ) {
                    result.append(c);
                } else {
                    result.append(' ');
                }
                break;
        }
    }
    return result;
}
开发者ID:edbee,项目名称:edbee-lib,代码行数:84,代码来源:jsonparser.cpp

示例7: f

LangLoaderPlain::LangLoaderPlain(const QString &file, const LangLoaderRequest &request) : file(file), request(request), readingAll(request.contains(lngkeys_cnt)) {
	QFile f(file);
	if (!f.open(QIODevice::ReadOnly)) {
		error(qsl("Could not open input file!"));
		return;
	}
	if (f.size() > 1024 * 1024) {
		error(qsl("Too big file: %1").arg(f.size()));
		return;
	}
	QByteArray checkCodec = f.read(3);
	if (checkCodec.size() < 3) {
		error(qsl("Bad lang input file: %1").arg(file));
		return;
	}
	f.seek(0);

	QByteArray data;
	int skip = 0;
	if ((checkCodec.at(0) == '\xFF' && checkCodec.at(1) == '\xFE') || (checkCodec.at(0) == '\xFE' && checkCodec.at(1) == '\xFF') || (checkCodec.at(1) == 0)) {
		QTextStream stream(&f);
		stream.setCodec("UTF-16");

		QString string = stream.readAll();
		if (stream.status() != QTextStream::Ok) {
			error(qsl("Could not read valid UTF-16 file: % 1").arg(file));
			return;
		}
		f.close();

		data = string.toUtf8();
	} else if (checkCodec.at(0) == 0) {
		QByteArray tmp = "\xFE\xFF" + f.readAll(); // add fake UTF-16 BOM
		f.close();

		QTextStream stream(&tmp);
		stream.setCodec("UTF-16");
		QString string = stream.readAll();
		if (stream.status() != QTextStream::Ok) {
			error(qsl("Could not read valid UTF-16 file: % 1").arg(file));
			return;
		}

		data = string.toUtf8();
	} else {
		data = f.readAll();
		if (checkCodec.at(0) == '\xEF' && checkCodec.at(1) == '\xBB' && checkCodec.at(2) == '\xBF') {
			skip = 3; // skip UTF-8 BOM
		}
	}

	const char *text = data.constData() + skip, *end = text + data.size() - skip;
	try {
		while (true) {
			if (!readKeyValue(text, end)) {
				break;
			}
		}
	} catch (std::exception &e) {
		error(QString::fromUtf8(e.what()));
		return;
	}
}
开发者ID:2asoft,项目名称:tdesktop,代码行数:63,代码来源:langloaderplain.cpp

示例8: load

bool CWizRtfReader::load(const QString& strFile, QString& strText)
{
    QByteArray ba = file_load (strFile);

    QString text;
    text.reserve (ba.size());

    int i = 0;
    int l = ba.size();

    QString ansicgp;
    int n = ba.indexOf ("ansicpg");
    if (n != -1)
    {
        int m = ba.indexOf ('\\', n);
        n += 7;
        ansicgp = ba.mid (n, m - n);
    }

    if (ansicgp.isEmpty()) //assuming unicode
    {
        while (i < l)
            if ((ba.at(i) == '\\') && (ba.at(i + 1) == 'u'))
            {
                QByteArray ta = ba.mid (i, 7);
                ta = ta.mid (2, 4);
                QChar c (ta.toInt());
                text.append (c);
                i += 7 + 3;
            }
            else
            {
                text.append (ba.at(i));
                i++;
            }
    }
    else
    {
        ansicgp.prepend ("CP");

        QTextCodec *codec = QTextCodec::codecForName (ansicgp.toUtf8().data());
        qDebug() << "not unicode!";

        while (i < l)
            if ((ba.at(i) == '\\') && (ba.at(i + 1) == '\''))
            {
                QByteArray ta = ba.mid (i, 4);
                ta = ta.mid (2, 2);
                QByteArray bh = ta.fromHex (ta);
                text.append (codec->toUnicode (bh));
                i += 4;
            }
            else
            {
                text.append (ba.at(i));
                i++;
            }
    }

    strText = rtf_strip (text);

    return true;
}
开发者ID:AlvaroSacari,项目名称:WizQTClient,代码行数:63,代码来源:wizRtfReader.cpp

示例9: strncmp

// This code is shared with moc.cpp
static QByteArray normalizeTypeInternalQt47(const char *t, const char *e, bool fixScope = false, bool adjustConst = true)
{
    int len = e - t;
    /*
      Convert 'char const *' into 'const char *'. Start at index 1,
      not 0, because 'const char *' is already OK.
    */
    QByteArray constbuf;
    for (int i = 1; i < len; i++) {
        if ( t[i] == 'c'
             && strncmp(t + i + 1, "onst", 4) == 0
             && (i + 5 >= len || !is_ident_char(t[i + 5]))
             && !is_ident_char(t[i-1])
             ) {
            constbuf = QByteArray(t, len);
            if (is_space(t[i-1]))
                constbuf.remove(i-1, 6);
            else
                constbuf.remove(i, 5);
            constbuf.prepend("const ");
            t = constbuf.data();
            e = constbuf.data() + constbuf.length();
            break;
        }
        /*
          We musn't convert 'char * const *' into 'const char **'
          and we must beware of 'Bar<const Bla>'.
        */
        if (t[i] == '&' || t[i] == '*' ||t[i] == '<')
            break;
    }
    if (adjustConst && e > t + 6 && strncmp("const ", t, 6) == 0) {
        if (*(e-1) == '&') { // treat const reference as value
            t += 6;
            --e;
        } else if (is_ident_char(*(e-1)) || *(e-1) == '>') { // treat const value as value
            t += 6;
        }
    }
    QByteArray result;
    result.reserve(len);

#if 1
    // consume initial 'const '
    if (strncmp("const ", t, 6) == 0) {
        t+= 6;
        result += "const ";
    }
#endif

    // some type substitutions for 'unsigned x'
    if (strncmp("unsigned", t, 8) == 0) {
        // make sure "unsigned" is an isolated word before making substitutions
        if (!t[8] || !is_ident_char(t[8])) {
            if (strncmp(" int", t+8, 4) == 0) {
                t += 8+4;
                result += "uint";
            } else if (strncmp(" long", t+8, 5) == 0) {
                if ((strlen(t + 8 + 5) < 4 || strncmp(t + 8 + 5, " int", 4) != 0) // preserve '[unsigned] long int'
                    && (strlen(t + 8 + 5) < 5 || strncmp(t + 8 + 5, " long", 5) != 0) // preserve '[unsigned] long long'
                   ) {
                    t += 8+5;
                    result += "ulong";
                }
            } else if (strncmp(" short", t+8, 6) != 0  // preserve unsigned short
                && strncmp(" char", t+8, 5) != 0) {    // preserve unsigned char
                //  treat rest (unsigned) as uint
                t += 8;
                result += "uint";
            }
        }
    } else {
        // discard 'struct', 'class', and 'enum'; they are optional
        // and we don't want them in the normalized signature
        struct {
            const char *keyword;
            int len;
        } optional[] = {
            { "struct ", 7 },
            { "class ", 6 },
            { "enum ", 5 },
            { 0, 0 }
        };
        int i = 0;
        do {
            if (strncmp(optional[i].keyword, t, optional[i].len) == 0) {
                t += optional[i].len;
                break;
            }
        } while (optional[++i].keyword != 0);
    }

    bool star = false;
    while (t != e) {
        char c = *t++;
        if (fixScope && c == ':' && *t == ':' ) {
            ++t;
            c = *t++;
            int i = result.size() - 1;
//.........这里部分代码省略.........
开发者ID:BadSingleton,项目名称:shiboken2,代码行数:101,代码来源:shibokennormalize.cpp

示例10: return

static quint32 getBEUint16(const QByteArray &ba, int pos)
{
    Q_ASSERT(ba.size() >= pos + 1);
    return (static_cast<quint16>(static_cast<quint8>(ba.at(pos))) << 8) + static_cast<quint8>(ba.at(pos + 1));
}
开发者ID:ProDataLab,项目名称:qt-creator,代码行数:5,代码来源:abi.cpp

示例11: QByteArray

QByteArray NfcTagType1::processCommand(const QByteArray &command)
{
    lastAccess = QDateTime::currentMSecsSinceEpoch();

    QByteArray response;

    bool tagType1 = (hr0 & 0xf0) == 0x10;
    bool dynamic = (hr0 & 0x0f) != 0x01;

    if (command.length() == 9) {
        // static memory model command
        quint8 opcode = command.at(0);
        quint8 address = command.at(1);
        quint8 data = command.at(2);
        QByteArray uid = command.mid(3, 4);

        // check checksum
        if (qNfcChecksum(command.constData(), command.length()) != 0)
            return QByteArray();

        // check UID
        if (uid != memory.left(4))
            return QByteArray();

        switch (opcode) {
        case 0x00:  // RALL
            response.append(hr0);
            response.append(hr1);
            response.append(memory.left(120));
            break;
        case 0x01:  // READ
            response.append(address);
            if (address & 0x80)
                response.append(char(0x00));
            else
                response.append(memory.at(address));
            break;
        case 0x53: { // WRITE-E
            quint8 block = address >> 3;
            if (block == 0x00 || block == 0x0d || block == 0x0e)    // locked blocks
                break;

            quint16 lock = (readData(0x0e, 0x01) << 8) | readData(0x0e, 0x00);
            if ((0x01 << block) & lock)    // locked blocks
                break;

            // FIXME: Test dynamic lock bytes

            memory[address] = data;

            response.append(address);
            response.append(data);
            break;
        }
        case 0x1a: { // WRITE-NE
            quint8 block = address >> 3;
            if (block == 0x00 || block == 0x0d)  // locked blocks
                break;

            quint16 lock = (readData(0x0e, 0x01) << 8) | readData(0x0e, 0x00);
            if ((0x01 << block) & lock)    // locked blocks
                break;


            // FIXME: Test dynamic lock bytes

            memory[address] = memory.at(address) | data;

            response.append(address);
            response.append(memory.at(address));
            break;
        }
        case 0x78:  // RID
            response.append(hr0);
            response.append(hr1);
            response.append(memory.left(4));
            break;
        }
    } else if (tagType1 && dynamic && command.length() == 16) {
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:79,代码来源:targetemulator.cpp

示例12: parseCoffHeader

static QList<Abi> parseCoffHeader(const QByteArray &data)
{
    QList<Abi> result;
    if (data.size() < 20)
        return result;

    Abi::Architecture arch = Abi::UnknownArchitecture;
    Abi::OSFlavor flavor = Abi::UnknownFlavor;
    int width = 0;

    // Get machine field from COFF file header
    quint16 machine = getLEUint16(data, 0);
    switch (machine) {
    case 0x01c0: // ARM LE
    case 0x01c2: // ARM or thumb
    case 0x01c4: // ARMv7 thumb
        arch = Abi::ArmArchitecture;
        width = 32;
        break;
    case 0x8664: // x86_64
        arch = Abi::X86Architecture;
        width = 64;
        break;
    case 0x014c: // i386
        arch = Abi::X86Architecture;
        width = 32;
        break;
    case 0x0166: // MIPS, little endian
        arch = Abi::MipsArchitecture;
        width = 32;
        break;
    case 0x0200: // ia64
        arch = Abi::ItaniumArchitecture;
        width = 64;
        break;
    }

    if (data.size() >= 24) {
        // Get Major and Minor Image Version from optional header fields
        quint8 minorLinker = data.at(23);
        switch (data.at(22)) {
        case 2:
        case 3: // not yet reached:-)
            flavor = Abi::WindowsMSysFlavor;
            break;
        case 8:
            flavor = Abi::WindowsMsvc2005Flavor;
            break;
        case 9:
            flavor = Abi::WindowsMsvc2008Flavor;
            break;
        case 10:
            flavor = Abi::WindowsMsvc2010Flavor;
            break;
        case 11:
            flavor = Abi::WindowsMsvc2012Flavor;
            break;
        case 12:
            flavor = Abi::WindowsMsvc2013Flavor;
            break;
        default: // Keep unknown flavor
            if (minorLinker != 0)
                flavor = Abi::WindowsMSysFlavor; // MSVC seems to avoid using minor numbers
            else
                qWarning("%s: Unknown MSVC flavour encountered.", Q_FUNC_INFO);
            break;
        }
    }

    if (arch != Abi::UnknownArchitecture && width != 0)
        result.append(Abi(arch, Abi::WindowsOS, flavor, Abi::PEFormat, width));

    return result;
}
开发者ID:ProDataLab,项目名称:qt-creator,代码行数:74,代码来源:abi.cpp

示例13: writeAttribute

bool MStyleSheetAttribute::writeAttribute(MUniqueStringCache::Index filename,
        MStyle *style,
        const QMetaProperty &property,
        M::Orientation orientation) const
{
    // first check if the attribute is cached orientation independent, if not found
    // check for the given orientation
    QVariant cachedVariant = variantCache[M::Landscape + 1][value][property.userType()];
    if (cachedVariant.isValid()) {
        return property.write(style, cachedVariant);
    } else {
        cachedVariant = variantCache[orientation][value][property.userType()];
        if (cachedVariant.isValid()) {
            style->setOrientationDependent(true);
            return property.write(style, cachedVariant);
        }
    }

    bool conversionOK = false;
    // most types are the same in landscape and portrait
    CacheOrientationFlags cacheOrientation = CacheOrientationFlags(PortraitFlag | LandscapeFlag);

    QLatin1String vs = MStyleSheetParser::stringCacheWithoutReverseLookup()->indexToString(value);
    QByteArray valueString = QByteArray::fromRawData(vs.latin1(), strlen(vs.latin1()));

    const int attributeType = property.userType();
    if (attributeType == QMetaType::Bool) {
        bool result = booleanFromString(valueString, &conversionOK);
        if (conversionOK) {
            return fillProperty(property, style, cacheOrientation, result);
        }
    } else if (attributeType == QMetaType::Int) {
        int integer = attributeToInt(valueString, &conversionOK);
        if (conversionOK) {
            return fillProperty(property, style, cacheOrientation, integer);
        }
    } else if (attributeType == QMetaType::QColor) {
        if(valueString == "none")
            return fillProperty(property, style, cacheOrientation, QColor());

        QColor color = colorFromString(valueString, &conversionOK);
        if (conversionOK) {
            return fillProperty(property, style, cacheOrientation, color);
        }
    } else if (attributeType == QMetaType::QReal) {
        qreal real = attributeToFloat(valueString, &conversionOK);
        if (conversionOK) {
            return fillProperty(property, style, cacheOrientation, real);
        }
    } else if (attributeType == qMetaTypeId<const QPixmap*>()) {
        if(valueString == "none")
            return fillProperty(property, style, cacheOrientation, qVariantFromValue((const QPixmap *) NULL));

        //"image: image_id;"
        //"image: image_id 64px 64px;"
        //"image: "image id";"
        //"image: "image id" 64px 64px;"

        QList<QByteArray> list;
        if (valueString.startsWith('\"')) {
            //parse name inside quotes
            int idx = valueString.indexOf('\"', 1);
            if (idx != -1) {
                //get quoted image_id
                QByteArray imageid = valueString.mid(1, idx - 1);

                //split rest of the parameters
                QByteArray values = valueString.mid(idx + 1).trimmed();
                list = values.split(' ');
                list.removeAll("");

                //insert image_id as first parameter
                list.insert(0, imageid);
            }
        } else {
            //no quotes, just split the parameters
            list = valueString.split(' ');
            list.removeAll("");
        }

        //only image_id
        if (list.size() == 1) {
            const QPixmap *pixmap = MTheme::pixmap(list.at(0));
            return fillProperty(property, style, cacheOrientation, qVariantFromValue(pixmap), false);
        }
        //image_id + width + height
        else if (list.size() == 3) {
            int width = attributeToInt(list.at(1), &conversionOK, WidthAttribute, orientation, &cacheOrientation);
            int height = attributeToInt(list.at(2), &conversionOK, HeightAttribute, orientation, &cacheOrientation);
            const QPixmap *pixmap = MTheme::pixmap(list.at(0), QSize(width, height));
            return fillProperty(property, style, cacheOrientation, qVariantFromValue(pixmap), false);
        }
        //no parameters
        else if (list.size() == 0) {
            //init null pixmap which is ok if someone does not want to use it
            return fillProperty(property, style, cacheOrientation, qVariantFromValue((const QPixmap *) NULL));
        }
    } else if (attributeType == qMetaTypeId<const MScalableImage*>() || attributeType == qMetaTypeId<MBackgroundTiles>()) {
        //"background: image_id left right top bottom;"
        //"background: image_id;"
//.........这里部分代码省略.........
开发者ID:dudochkin-victor,项目名称:libgogootouch,代码行数:101,代码来源:mstylesheetattribute.cpp

示例14: processAnswer

void SensorAgent::processAnswer( const char *buf, int buflen )
{
  //It is possible for an answer/error message  to be split across multiple processAnswer calls.  This makes our life more difficult
  //We have to keep track of the state we are in.  Any characters that we have not parsed yet we put in
  //mLeftOverBuffer
  QByteArray buffer = QByteArray::fromRawData(buf, buflen);
  if(!mLeftOverBuffer.isEmpty()) {
	buffer = mLeftOverBuffer + buffer; //If we have data left over from a previous processAnswer, then we have to prepend this on
	mLeftOverBuffer.clear();
  }
  
#if SA_TRACE
  qDebug() << "<- " << QString::fromUtf8(buffer, buffer.size());
#endif
  int startOfAnswer = 0;  //This can become >= buffer.size(), so check before using!
  for ( int i = 0; i < buffer.size(); ++i ) {
    if ( buffer.at(i) == '\033' ) {  // 033 in octal is the escape character.  The signifies the start of an error
      int startOfError = i;
      bool found = false;
      while(++i < buffer.size()) {
        if(buffer.at(i) == '\033') {
	  QString error = QString::fromUtf8(buffer.constData() + startOfError+1, i-startOfError-1);
	  if ( error.startsWith(QLatin1String("RECONFIGURE")) ) {
            emit reconfigure( this );
 	  }
          else {
            /* We just received the end of an error message, so we
             * can display it. */
            SensorMgr->notify( i18nc( "%1 is a host name", "Message from %1:\n%2",
                               mHostName ,
                               error ) );
          }
          found = true;
	  break;
	}
      }
      if(found) {
        buffer.remove(startOfError, i-startOfError+1);
	i = startOfAnswer - 1;
	continue;
      } else {
        //We have not found the end of the escape string.  Try checking in the next packet
        mLeftOverBuffer = QByteArray(buffer.constData()+startOfAnswer, buffer.size()-startOfAnswer);
        return;
      }
    }

    //The spec was supposed to be that it returned "\nksysguardd> " but some seem to forget the space, so we have to compensate.  Sigh 
    if( (i==startOfAnswer && buffer.size() -i >= (signed)(sizeof("ksysguardd>"  ))-1 && qstrncmp(buffer.constData()+i, "ksysguardd>",   sizeof("ksysguardd>"  )-1) == 0) ||
	(buffer.size() -i >= (signed)(sizeof("\nksysguardd>"))-1 && qstrncmp(buffer.constData()+i, "\nksysguardd>", sizeof("\nksysguardd>")-1) == 0)) {

	QByteArray answer(buffer.constData()+startOfAnswer, i-startOfAnswer);
	if(!answer.isEmpty())
		mAnswerBuffer << answer;
#if SA_TRACE
	qDebug() << "<= " << mAnswerBuffer
		<< "(" << mInputFIFO.count() << "/"
		<< mProcessingFIFO.count() << ")" << endl;
#endif
	if(buffer.at(i) == '\n')
		i++;
	i += sizeof("ksysguardd>") -2;  //Move i on to the next answer (if any). -2 because sizeof adds one for \0  and the for loop will increment by 1 also
	if(i+1 < buffer.size() && buffer.at(i+1) == ' ') i++;
	startOfAnswer = i+1;

	//We have found the end of one reply
	if ( !mDaemonOnLine ) {
		/* First '\nksysguardd> ' signals that the daemon is
	  	 * ready to serve requests now. */
		mDaemonOnLine = true;
#if SA_TRACE
		qDebug() << "Daemon now online!";
#endif
		mAnswerBuffer.clear();
		continue;
	}

	//Deal with the answer we have now read in

	// remove pending request from FIFO
	if ( mProcessingFIFO.isEmpty() ) {
		qDebug()	<< "ERROR: Received answer but have no pending "
				<< "request!" << endl;
		mAnswerBuffer.clear();
		continue;
	}
		
	SensorRequest *req = mProcessingFIFO.dequeue();
	// we are now responsible for the memory of req - we must delete it!
	if ( !req->client() ) {
		/* The client has disappeared before receiving the answer
		 * to his request. */
		delete req;
		mAnswerBuffer.clear();
		continue;
	}
		
	if(!mAnswerBuffer.isEmpty() && mAnswerBuffer[0] == "UNKNOWN COMMAND") {
		/* Notify client that the sensor seems to be no longer available. */
        qDebug() << "Received UNKNOWN COMMAND for: " << req->request();
//.........这里部分代码省略.........
开发者ID:aarontc,项目名称:kde-workspace,代码行数:101,代码来源:SensorAgent.cpp

示例15: while

QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByteArray &cookieString)
{
    // According to http://wp.netscape.com/newsref/std/cookie_spec.html,<
    // the Set-Cookie response header is of the format:
    //
    //   Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure
    //
    // where only the NAME=VALUE part is mandatory
    //
    // We do not support RFC 2965 Set-Cookie2-style cookies

    QList<QNetworkCookie> result;
    QDateTime now = QDateTime::currentDateTime().toUTC();

    int position = 0;
    const int length = cookieString.length();
    while (position < length) {
        QNetworkCookie cookie;

        // The first part is always the "NAME=VALUE" part
        QPair<QByteArray,QByteArray> field = nextField(cookieString, position, true);
        if (field.first.isEmpty() || field.second.isNull())
            // parsing error
            break;
        cookie.setName(field.first);
        cookie.setValue(field.second);

        position = nextNonWhitespace(cookieString, position);
        while (position < length) {
            switch (cookieString.at(position++)) {
            case ';':
                // new field in the cookie
                field = nextField(cookieString, position, false);
                field.first = field.first.toLower(); // everything but the NAME=VALUE is case-insensitive

                if (field.first == "expires") {
                    position -= field.second.length();
                    int end;
                    for (end = position; end < length; ++end)
                        if (isValueSeparator(cookieString.at(end)))
                            break;

                    QByteArray dateString = cookieString.mid(position, end - position).trimmed();
                    position = end;
                    QDateTime dt = parseDateString(dateString.toLower());
                    if (!dt.isValid()) {
                        return result;
                    }
                    cookie.setExpirationDate(dt);
                } else if (field.first == "domain") {
                    QByteArray rawDomain = field.second;
                    QString maybeLeadingDot;
                    if (rawDomain.startsWith('.')) {
                        maybeLeadingDot = QLatin1Char('.');
                        rawDomain = rawDomain.mid(1);
                    }

                    QString normalizedDomain = QUrl::fromAce(QUrl::toAce(QString::fromUtf8(rawDomain)));
                    if (normalizedDomain.isEmpty() && !rawDomain.isEmpty())
                        return result;
                    cookie.setDomain(maybeLeadingDot + normalizedDomain);
                } else if (field.first == "max-age") {
                    bool ok = false;
                    int secs = field.second.toInt(&ok);
                    if (!ok)
                        return result;
                    cookie.setExpirationDate(now.addSecs(secs));
                } else if (field.first == "path") {
                    QString path = QUrl::fromPercentEncoding(field.second);
                    cookie.setPath(path);
                } else if (field.first == "secure") {
                    cookie.setSecure(true);
                } else if (field.first == "httponly") {
                    cookie.setHttpOnly(true);
                } else if (field.first == "comment") {
                    //cookie.setComment(QString::fromUtf8(field.second));
                } else if (field.first == "version") {
                    if (field.second != "1") {
                        // oops, we don't know how to handle this cookie
                        return result;
                    }
                } else {
                    // got an unknown field in the cookie
                    // what do we do?
                }

                position = nextNonWhitespace(cookieString, position);
            }
        }

        if (!cookie.name().isEmpty())
            result += cookie;
    }

    return result;
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:96,代码来源:qnetworkcookie.cpp


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