本文整理汇总了C++中QByteArray::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::count方法的具体用法?C++ QByteArray::count怎么用?C++ QByteArray::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
void
BufferIODevice::addData( int block, const QByteArray& ba )
{
Q_D( BufferIODevice );
{
QMutexLocker lock( &d->mut );
while ( d->buffer.count() <= block )
d->buffer << QByteArray();
d->buffer.replace( block, ba );
}
// If this was the last block of the transfer, check if we need to fill up gaps
if ( block + 1 == maxBlocks() )
{
if ( nextEmptyBlock() >= 0 )
{
emit blockRequest( nextEmptyBlock() );
}
}
d->received += ba.count();
emit bytesWritten( ba.count() );
emit readyRead();
}
示例2: parse
/*!
Parses the \a header. This function is for internal use only.
*/
void TInternetMessageHeader::parse(const QByteArray &header)
{
int i = 0;
while (i < header.count()) {
int j = header.indexOf(':', i); // field-name
if (j < 0)
break;
const QByteArray field = header.mid(i, j - i).trimmed();
// any number of LWS is allowed before and after the value
++j;
QByteArray value;
do {
i = header.indexOf('\n', j);
if (i < 0) {
i = header.length();
}
if (!value.isEmpty())
value += ' ';
value += header.mid(j, i - j).trimmed();
j = ++i;
} while (i < header.count() && (header.at(i) == ' ' || header.at(i) == '\t'));
headerPairList << qMakePair(field, value);
}
}
示例3: processText
void NoSpacesProcessor::processText()
{
QFile file(m_filename);
if(!file.open(QIODevice::ReadOnly)) {
emit error(tr("Could not open file %1").arg(m_filename));
return;
}
const int totalLineCount = detectLineCount();
int lineNumber(1);
while(!file.atEnd()) {
emit progress(lineNumber,totalLineCount,tr("Parsing text with no spaces"));
QByteArray line = file.readLine();
emit lineFound(line, lineNumber);
line = line.simplified();
if(line.isEmpty()) {
++lineNumber;
continue;
}
for(int pos=0;pos<line.count();++pos) {
emit progress(pos,line.count(),tr("Line %1 of %2").arg(lineNumber).arg(totalLineCount));
for(int len=1;len<14;++len) {
emit combinationFound(processorName(),line.mid(pos,len),lineNumber);
}
}
//emit combinationFound(processorName(), word,lineNumber);
++lineNumber;
}
file.close();
}
示例4: EncodeBytes
Element IntegerGroup::EncodeBytes(const QByteArray &in) const
{
// We can store p bytes minus 2 bytes for padding and one more to be safe
const int can_read = BytesPerElement();
if(can_read < 1) qFatal("Illegal parameters");
if(in.count() > can_read) qFatal("Cannot encode: string is too long");
// Add initial 0xff byte and trailing 0x00 byte
QByteArray padded;
padded.append(0xff);
padded.append(in.left(can_read));
padded.append((char)0x00);
padded.append(0xff);
// Change byte of padded string until the
// integer represented by the byte arry is a quadratic
// residue. We need to be sure that every plaintext
// message is a quadratic residue modulo p
const int last = padded.count()-2;
for(unsigned char pad=0x00; pad < 0xff; pad++) {
padded[last] = pad;
Element element(new IntegerElementData(Integer(padded)));
if(IsElement(element)) {
return element;
}
}
qFatal("Could not encode message as quadratic residue");
return Element(new IntegerElementData(Integer(1)));
}
示例5: fromByteArray
TlvList Tlv::fromByteArray(const QByteArray& data, quint64 offset)
{
TlvList list;
QByteArray buffer = data.left(data.count() - offset);
qint32 count = buffer.count();
qint32 index = 0;
while (count > index)
{
quint8 type = buffer.at(index);
++index;
switch (type)
{
case Tlv::Null:
break;
case Tlv::Terminator:
{
list.append(Tlv::createTerminatorTlv());
index = count;
}
break;
default:
{
if ((count - index) > 0)
{
quint16 length = buffer.at(index);
++index;
if (length > 0xfe)
{
length = 0;
if ((count - index) > 2)
{
length = (quint8(buffer.at(index)) << 8) | quint8(buffer.at(index + 1));
index += 2;
}
}
if ((count - index) >= length)
{
list.append(Tlv(type, buffer.mid(index, length)));
index += length;
}
else
{
index = count;
}
}
}
break;
}
}
return list;
}
示例6: execute
bool UdpDecorator::execute(Request &req, QIODevice &io)
{
form(req);
io.readAll();
io.write(req.getBody());
QByteArray rxData;
int cnt = 0;
while(1) {
int wait = 15;
if(req.getWaitTime()!=0) wait = req.getWaitTime();
int length=0;
for(int i=0; i<wait; i++) {
QThread::currentThread()->msleep(1);
rxData+=io.readAll();
if(rxData.count()) {
if(length==rxData.count()) break;
length = rxData.count();
}
}
if(rxData.count()) {
req.updateRdData(rxData);
req.setAnswerData(rxData);
if(checkAnAnswer(req)) {
getAnAnswer(req);
return true;
}
} else cnt++;
if(cnt>=20) {
req.setAnswerData(QByteArray());
break;
}
}
return false;
}
示例7: DecodeBytes
bool CppECGroup::DecodeBytes(const Element &a, QByteArray &out) const
{
// output value = floor( x/k )
CryptoPP::Integer x = GetPoint(a).x;
// x = floor(x/k)
CryptoPP::Integer remainder, quotient;
CryptoPP::Integer::Divide(remainder, quotient, x, CryptoPP::Integer(_k));
QByteArray data = FromCppInteger(quotient).GetByteArray();
if(data.count() < 2) {
qWarning() << "Data is too short";
return false;
}
const unsigned char c = 0xff;
const unsigned char d0 = data[0];
const unsigned char dlast = data[data.count()-1];
if((d0 != c) || (dlast != c)) {
qWarning() << "Data has improper padding";
return false;
}
out = data.mid(1, data.count()-2);
return true;
}
示例8: OutputByteArray
QVariant QNearFieldTagType4Symbian::decodeResponse(const QByteArray &command, const QByteArray &response)
{
BEGIN
QVariant result;
OutputByteArray(response);
if ((command.count() > 2) && (0x00 == command.at(0)))
{
if ( (0xA4 == command.at(1)) || (0xD6 == command.at(1)) )
{
if (response.count() >= 2)
{
LOG("select or write command");
QByteArray resp = response.right(2);
result = ((resp.at(0) == 0x90) && (resp.at(1) == 0x00));
}
}
else
{
LOG("read command");
result = response;
}
}
END
return result;
}
示例9: writeSysEx
void CoreMidiOutputDevice::writeSysEx(QByteArray message)
{
if(message.isEmpty())
return;
if (isOpen() == false)
return;
int bufferSize = message.count() + 100; // Todo this is not correct
Byte buffer[bufferSize]; // osx max=65536
MIDIPacketList* list = (MIDIPacketList*) buffer;
MIDIPacket* packet = MIDIPacketListInit(list);
/* Add the MIDI command to the packet list */
packet = MIDIPacketListAdd(list, bufferSize, packet, 0, message.count(), (Byte *)message.data());
if (packet == 0)
{
qWarning() << "MIDIOut buffer overflow";
return;
}
/* Send the MIDI packet list */
OSStatus s = MIDISend(m_outPort, m_destination, list);
if (s != 0)
qWarning() << Q_FUNC_INFO << "Unable to send MIDI data to" << name();
}
示例10: traiterRequete
void ServeurUdpPull::traiterRequete(QByteArray requete, QHostAddress hostAddress)
{
if (requete.count("\r\n")>3)
{
struct ClientUdp nouveauClient;
nouveauClient.addresse=hostAddress;
nouveauClient.port = requete.split('\n')[1].trimmed().
split(' ')[1].trimmed().toInt();
nouveauClient.tailleFragment = requete.split('\n')[2].trimmed().
split(' ')[1].trimmed().toInt();// Kev dit -64, WTF?
nouveauClient.numImage=1;
clientsConnectes.append(nouveauClient);
/*
qDebug()<<clientsConnectes[0].addresse;
qDebug()<<clientsConnectes[0].port;
qDebug()<<clientsConnectes[0].tailleFragment;
*/
}
else if (requete.count("\r\n")==2)
{
if (requete.startsWith("END"))
{
//detruire le client proprement (s'il existe!!)
}
else
{
envoieImage(hostAddress);
}
}
}
示例11: parseSimple
// only accept CTCPs in their simplest form, i.e. one ctcp, from start to
// end, no text around it; not as per the 'specs', but makes people happier
void CtcpParser::parseSimple(IrcEventRawMessage *e, Message::Type messagetype, QByteArray dequotedMessage, CtcpEvent::CtcpType ctcptype, Message::Flags flags)
{
if (dequotedMessage.count(XDELIM) != 2 || dequotedMessage[0] != '\001' || dequotedMessage[dequotedMessage.count() -1] != '\001') {
displayMsg(e, messagetype, targetDecode(e, dequotedMessage), e->prefix(), e->target(), flags);
} else {
int spacePos = -1;
QString ctcpcmd, ctcpparam;
QByteArray ctcp = xdelimDequote(dequotedMessage.mid(1, dequotedMessage.count() - 2));
spacePos = ctcp.indexOf(' ');
if (spacePos != -1) {
ctcpcmd = targetDecode(e, ctcp.left(spacePos));
ctcpparam = targetDecode(e, ctcp.mid(spacePos + 1));
} else {
ctcpcmd = targetDecode(e, ctcp);
ctcpparam = QString();
}
ctcpcmd = ctcpcmd.toUpper();
// we don't want to block /me messages by the CTCP ignore list
if (ctcpcmd == QLatin1String("ACTION") || !coreSession()->ignoreListManager()->ctcpMatch(e->prefix(), e->network()->networkName(), ctcpcmd)) {
QUuid uuid = QUuid::createUuid();
_replies.insert(uuid, CtcpReply(coreNetwork(e), nickFromMask(e->prefix())));
CtcpEvent *event = new CtcpEvent(EventManager::CtcpEvent, e->network(), e->prefix(), e->target(),
ctcptype, ctcpcmd, ctcpparam, e->timestamp(), uuid);
emit newEvent(event);
CtcpEvent *flushEvent = new CtcpEvent(EventManager::CtcpEventFlush, e->network(), e->prefix(), e->target(),
ctcptype, "INVALID", QString(), e->timestamp(), uuid);
emit newEvent(flushEvent);
}
}
}
示例12: parseHeader
void QHttpNetworkReplyPrivate::parseHeader(const QByteArray &header)
{
// see rfc2616, sec 4 for information about HTTP/1.1 headers.
// allows relaxed parsing here, accepts both CRLF & LF line endings
const QByteArrayMatcher lf("\n");
const QByteArrayMatcher colon(":");
int i = 0;
while (i < header.count()) {
int j = colon.indexIn(header, i); // field-name
if (j == -1)
break;
const QByteArray field = header.mid(i, j - i).trimmed();
j++;
// any number of LWS is allowed before and after the value
QByteArray value;
do {
i = lf.indexIn(header, j);
if (i == -1)
break;
if (!value.isEmpty())
value += ' ';
// check if we have CRLF or only LF
bool hasCR = (i && header[i-1] == '\r');
int length = i -(hasCR ? 1: 0) - j;
value += header.mid(j, length).trimmed();
j = ++i;
} while (i < header.count() && (header.at(i) == ' ' || header.at(i) == '\t'));
if (i == -1)
break; // something is wrong
fields.append(qMakePair(field, value));
}
}
示例13: readyRead
void Server::readyRead()
{
QTcpSocket * socket = static_cast<QTcpSocket *>(sender());
QByteArray * buffer = _buffers.value(socket);
qint32 size = *_sizes.value(socket);
while(socket->bytesAvailable() > 0)
{
buffer->append(socket->readAll());
// While can process data, process it
while ((buffer->count() >= 4 && size == 0) || (buffer->count() >= size && size > 0))
{
// If size of data has received completely, then store it on global variable
if (buffer->count() >= 4 && size == 0)
{
size = arrayToInt(buffer->mid(0, 4));
buffer->remove(0, 4);
}
// If data has received completely
if (buffer->count() >= size && size > 0)
{
QByteArray data = buffer->mid(0, size);
buffer->remove(0, size);
size = 0;
processData(data, socket);
}
}
}
}
示例14: toByteArray
QByteArray MultipleSequenceAlignmentRowData::toByteArray(U2OpStatus &os, qint64 length) const {
if (length < getCoreEnd()) {
coreLog.trace("Incorrect length was passed to MultipleSequenceAlignmentRowData::toByteArray");
os.setError("Failed to get row data");
return QByteArray();
}
if (gaps.isEmpty() && sequence.length() == length) {
return sequence.constSequence();
}
QByteArray bytes = joinCharsAndGaps(true, true);
// Append additional gaps, if necessary
if (length > bytes.count()) {
QByteArray gapsBytes;
gapsBytes.fill(U2Msa::GAP_CHAR, length - bytes.count());
bytes.append(gapsBytes);
}
if (length < bytes.count()) {
// cut extra trailing gaps
bytes = bytes.left(length);
}
return bytes;
}
示例15: ClearBuffer
void CIEC104DeliverQuery::SetData(const QByteArray &bytearrayFrame_)
{
ClearBuffer();
memcpy(m_ByteBuffer,bytearrayFrame_.data(),bytearrayFrame_.count());
m_pBufferHead = m_ByteBuffer;
m_nInfomationSize = bytearrayFrame_.count();
}