本文整理汇总了C++中QByteArray::right方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::right方法的具体用法?C++ QByteArray::right怎么用?C++ QByteArray::right使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::right方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decodeMetadataMessage
void MaxCube::decodeMetadataMessage(QByteArray data)
{
QList<QByteArray> list = data.left(data.length()-2).split(',');
QByteArray dataDecoded = QByteArray::fromBase64(list.at(2));
qCDebug(dcEQ3) << "====================================================";
qCDebug(dcEQ3) << " METADATA message:";
qCDebug(dcEQ3) << "====================================================";
// parse room list
int roomCount = dataDecoded.toHex().mid(4,2).toInt(0,16);
QByteArray roomRawData = dataDecoded.toHex();
roomRawData = roomRawData.right(roomRawData.length()-6);
for(int i = 0; i < roomCount; i++){
Room *room = new Room(this);
room->setRoomId(roomRawData.left(2).toInt(0,16));
int roomNameLength = roomRawData.mid(2,2).toInt(0,16);
room->setRoomName(QByteArray::fromHex(roomRawData.mid(4,roomNameLength*2)));
room->setGroupRfAddress(roomRawData.mid(roomNameLength*2 + 4, 6));
m_roomList.append(room);
roomRawData = roomRawData.right(roomRawData.length() - ((roomNameLength*2) + 10));
}
qCDebug(dcEQ3) << "-------------------------|-------------------------";
qCDebug(dcEQ3) << "found " << m_roomList.count() << "rooms";
qCDebug(dcEQ3) << "-------------------------|-------------------------";
foreach (Room *room, m_roomList) {
qCDebug(dcEQ3) << " Room Name | " << room->roomName();
qCDebug(dcEQ3) << " Room ID | " << room->roomId();
qCDebug(dcEQ3) << " Group RF Address | " << room->groupRfAddress();
qCDebug(dcEQ3) << "-------------------------|-------------------------";
}
示例2: processNewMessage
void HeadlessHubIntegration::processNewMessage(QByteArray message) {
qDebug() << "HeadlessHubIntegration::processNewMessage: message: " << message;
bool notify = false;
QString priority("");
QString from("Test");
QString title("");
QString body("");
do {
int index = message.indexOf('|');
qDebug() << "HeadlessHubIntegration::processNewMessage: index: " << index << "\n";
if (index > 0) {
if (priority.size() == 0) {
priority = message.left(index);
message = message.right(message.size() - index - 1);
qDebug() << "HeadlessHubIntegration::processNewMessage: priority: " << priority << "\n";
qDebug() << "HeadlessHubIntegration::processNewMessage: message: " << message << "\n";
} else
if (title.size() == 0) {
title = message.left(index);
message = message.right(message.size() - index - 1);
qDebug() << "HeadlessHubIntegration::processNewMessage: title: " << title << "\n";
qDebug() << "HeadlessHubIntegration::processNewMessage: message: " << message << "\n";
}
} else {
if (body.size() == 0) {
body += message;
qDebug() << "HeadlessHubIntegration::processNewMessage: body: " << body << "\n";
}
message.clear();
}
} while (message.size() > 0);
//The first part of the push denotes the priority of the message
switch (priority.toInt()) {
case PushManager::Low:
break;
case PushManager::Medium:
break;
case PushManager::High:
notify = true;
break;
default:
break;
}
QVariantMap* itemMap = new QVariantMap();
(*itemMap)["body"] = body;
_itemCounter++;
bool retVal = _testAccount->addHubItem(_testAccount->categoryId(), *itemMap, from, title, QDateTime::currentDateTime().toMSecsSinceEpoch(), QString::number(_itemCounter),"", "", notify);
}
示例3: getALine
char KGrGameIO::getALine (const bool kgr3, QByteArray & line)
{
char c;
line = "";
while (openFile.getChar (&c)) {
line = line.append (c);
if (c == '\n') {
break;
}
}
// kDebug() << "Raw line:" << line;
if (line.size() <= 0) {
// Return a '\0' byte if end-of-file.
return ('\0');
}
if (kgr3) {
// In KGr 3 format, strip off leading and trailing syntax.
if (line.startsWith ("// ")) {
line = line.right (line.size() - 3);
// kDebug() << "Stripped comment is:" << line;
}
else {
if (line.startsWith (" i18n(\"")) {
line = ' ' + line.right (line.size() - 7);
}
else if (line.startsWith (" NOTi18n(\"")) {
line = ' ' + line.right (line.size() - 10);
}
else if (line.startsWith (" \"")) {
line = ' ' + line.right (line.size() - 2);
}
if (line.endsWith ("\");\n")) {
line = line.left (line.size() - 4) + '\n';
}
else if (line.endsWith ("\\n\"\n")) {
line = line.left (line.size() - 4) + '\n';
}
else if (line.endsWith ("\"\n")) {
line = line.left (line.size() - 2);
}
// kDebug() << "Stripped syntax is:" << line;
}
// In Kgr 3 format, return the first byte if not end-of-file.
c = line.at (0);
line = line.right (line.size() - 1);
return (c);
}
else {
// In KGr 2 format, return a space if not end-of-file.
return (' ');
}
}
示例4: getFullSequence
//This function gets the node's sequence. The full parameter only has an effect
//for Velvet LastGraph files where the sequences are shifted from their reverse
//complement. If full is true and the graph is from Velvet, this function will
//extend the sequence using either the reverse complement or upstream nodes.
QByteArray DeBruijnNode::getFullSequence() const
{
if (g_assemblyGraph->m_graphFileType != LAST_GRAPH)
return getSequence();
//If the code got here, then we are getting a full sequence from a Velvet
//LastGraph graph, so we need to extend the beginning of the sequence.
int extensionLength = g_assemblyGraph->m_kmer - 1;
//If the node is at least k-1 in length, then the necessary sequence can be
//deduced from the reverse complement node.
if (getLength() >= extensionLength)
{
QByteArray revCompSeq = getReverseComplement()->getSequence();
QByteArray endOfRevCompSeq = revCompSeq.right(extensionLength);
QByteArray extension = AssemblyGraph::getReverseComplement(endOfRevCompSeq);
return extension + getSequence();
}
//If the node is not long enough, then we must look in upstream nodes for
//the rest of the sequence.
else
{
QByteArray extension = getUpstreamSequence(extensionLength);
if (extension.length() < extensionLength)
{
int additionalBases = extensionLength - extension.length();
QByteArray n;
n.fill('N', additionalBases);
extension = n + extension;
}
return extension + getSequence();
}
}
示例5: getUriFromUriRecordPayload
QString NdefFactory::getUriFromUriRecordPayload(const QByteArray &payload) {
QString uri;
qDebug() << "XXXX Uri - raw: " << payload.toHex();
uchar_t uriType;
int uriLength;
uriType = payload[0];
uriLength = payload.length() - 1;
qDebug() << "XXXX UriType: " << uriType;
qDebug() << "XXXX UriLength: " << uriLength;
uri = QString::fromUtf8(payload.right(uriLength).constData(), uriLength);
if (prefixMapContains(uriType)) {
uri.prepend(prefixMapFromType(uriType));
} else {
qDebug() << QString("URI Prefix %1 not implemented").arg(uriType);
}
qDebug() << "XXXX Uri: " << uri;
return uri;
}
示例6: LogMessageToConsle
RSUERRORCODE rsutransframe::TransB6(QFrame_B6 &rsuB6, const QByteArray message)
{
int len;
QFrame_B6Raw raw;
len=message.length()-3;
rsuB6.initQFrame_B6();
if(len != sizeof(QFrame_B6Raw))
{
LogMessageToConsle(QObject::tr("B6帧数据的长度ERROR:QFrame_B6Raw:%1,QFrame_B6:%2")
.arg(sizeof(QFrame_B6Raw)).arg(len));
return rsuLenghError;
}
else
{
memcpy(&raw,message.right(message.length()-2).data(),sizeof(QFrame_B6Raw));
}
if(raw.ErrorCode != 0x00)
{
LogMessageToConsle(QObject::tr("B6帧数据CodeError"));
return rsuRecivedB6CodeError;
}
rsuB6.OBUID=Swapquint32(raw.OBUID);
rsuB6.ErrorCode=raw.ErrorCode;
memcpy(&rsuB6.FileData0ARaw, &raw.FileData0ARaw, sizeof(raw.FileData0ARaw));
LogMessageToConsle(QObject::tr("B6帧数据解析:正确"));
return rsuNoError;
}
示例7: f
void
setupLogfile()
{
if ( QFileInfo( logFile().toLocal8Bit() ).size() > LOGFILE_SIZE )
{
QByteArray lc;
{
QFile f( logFile().toLocal8Bit() );
f.open( QIODevice::ReadOnly | QIODevice::Text );
lc = f.readAll();
f.close();
}
QFile::remove( logFile().toLocal8Bit() );
{
QFile f( logFile().toLocal8Bit() );
f.open( QIODevice::WriteOnly | QIODevice::Text );
f.write( lc.right( LOGFILE_SIZE - ( LOGFILE_SIZE / 4 ) ) );
f.close();
}
}
logfile.open( logFile().toLocal8Bit(), ios::app );
qInstallMsgHandler( TomahawkLogHandler );
}
示例8: bytesToColor
// The following constants change the appearance of the identicon
// they have been choosen by trying to make the output look nice.
Identicon::Identicon(const QByteArray& data)
{
// static_assert(Identicon::COLORS == 2, "Only two colors are implemented");
// hash with sha256
QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Sha256);
for (int colorIndex = 0; colorIndex < COLORS; ++colorIndex) {
const QByteArray hashPart = hash.right(IDENTICON_COLOR_BYTES);
hash.truncate(hash.length() - IDENTICON_COLOR_BYTES);
const qreal hue = bytesToColor(hashPart);
// change offset when COLORS != 2
const qreal lig = static_cast<qreal>(colorIndex) / COLORS + 0.2;
const qreal sat = 0.5;
colors[colorIndex].setHslF(hue, sat, lig);
}
const uint8_t* const hashBytes = reinterpret_cast<const uint8_t*>(hash.constData());
// compute the block colors from the hash
for (int row = 0; row < IDENTICON_ROWS; ++row) {
for (int col = 0; col < ACTIVE_COLS; ++col) {
const int hashIdx = row * ACTIVE_COLS + col;
const uint8_t colorIndex = hashBytes[hashIdx] % COLORS;
identiconColors[row][col] = colorIndex;
}
}
}
示例9: TagMessage
TagMessage
TagMessage::fromVarLengthMessage( const QByteArray & data )
{
QString tag = data.constData();
VarLengthMessage ba = data.right( data.size() - tag.size() - 1 );
return TagMessage( tag, ba );
}
示例10: decodeMessage
bool KeyStream::decodeMessage(QByteArray& buffer, int macOffset, int offset, int length)
{
//qDebug() << "decodeMessage seq:" << seq;
QByteArray base = buffer.left(buffer.size() - 4);
QByteArray hmac = buffer.right(4);
QByteArray buffer2 = processBuffer(base, seq++);
buffer2 = mac->hmacSha1(buffer2);
QByteArray origBuffer = buffer;
buffer = base;
rc4->Cipher(buffer.data(),0,buffer.size());
for (int i = 0; i < 4; i++)
{
if (buffer2[macOffset + i] != hmac[i])
{
qDebug() << "error decoding message. macOffset:" << macOffset << "offset:" << offset << "length:" << length << "bufferSize:" << buffer.size();
qDebug() << "buffer mac:" << buffer2.toHex() << "hmac:" << hmac.toHex();
qDebug() << "buffer:" << buffer.toHex();
qDebug() << "origBuffer:" << origBuffer.toHex();
return false;
}
}
return true;
}
示例11: responderParseHalfKeyAndResponderIntegrity
void HandshakeResponder::responderParseHalfKeyAndResponderIntegrity(){ //R:2 parse
m_timeout.stop();
QByteArray encryptedSymKey;
m_socketStream >> encryptedSymKey;
if(isError(encryptedSymKey)) return;
QByteArray clearSymKey = rsaDecrypt(encryptedSymKey);
if(clearSymKey.size()<32){
processError(BadSymmetricKey);
return;
}
m_gcmKey.append(clearSymKey.left(16)); //second half key
m_gcmBaseIV.append(clearSymKey.right(16)); //second half IV
QByteArray encryptedRespIntegrity, responderIntegrity;
m_socketStream >> encryptedRespIntegrity;
responderIntegrity = gcmDecrypt(encryptedRespIntegrity);
if(responderIntegrity != m_responderIntegrityHash){
processError(DataCorrupted);
return;
}
updateIntegrityHash(&m_starterIntegrityHash, clearSymKey+responderIntegrity);
responderSendStarterIntegrity();
}
示例12: decrypt
QByteArray RSAKeyPair::decrypt(QByteArray cryptotext) {
Q_D(RSAKeyPair);
QByteArray output;
int rsize = d->key.len;
unsigned char *chunk = new unsigned char[rsize];
for(; cryptotext.size() > 0; ) {
int dlen = qMin<int>(rsize, cryptotext.size());
int dec;
rsa_pkcs1_decrypt(&d->key, RSA_PRIVATE, &dec, (unsigned char *) cryptotext.data(), chunk, dlen);
output += QByteArray((char *) chunk, dec);
cryptotext = cryptotext.right(cryptotext.size() - rsize);
}
delete chunk;
return output;
}
示例13: 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;
}
示例14: setupLogfile
void setupLogfile()
{
if ( QFileInfo( LOGFILE ).size() > LOGFILE_SIZE )
{
QByteArray lc;
{
QFile f( LOGFILE );
f.open( QIODevice::ReadOnly | QIODevice::Text );
lc = f.readAll();
f.close();
}
QFile::remove( LOGFILE );
{
QFile f( LOGFILE );
f.open( QIODevice::WriteOnly | QIODevice::Text );
f.write( lc.right( LOGFILE_SIZE - (LOGFILE_SIZE / 4) ) );
f.close();
}
}
logfile.open( LOGFILE, std::ios::app );
qInstallMsgHandler( LogHandler );
}
示例15: clean_my_name_lable
void UCHome_Main_SiteConst::clean_my_name_lable()
{
//<my:name uid="1673222" />
//<my:name uid="1673222"></my:name>
//QString unis = this->codec->toUnicode(this->feed_page_html);
//QByteArray u8s = this->u8codec->fromUnicode(unis);
//unis = u8s;
QByteArray tarr = this->feed_page_html;
QRegExp exp1 ("<my:name uid=\"[0-9]{1,12}\" />");
QRegExp exp2 ( "<my:name uid=\"[0-9]{1,12}\"></my:name>");
tarr = tarr.trimmed();
if(tarr.startsWith("f5b")) {
tarr = tarr.right(tarr.length()-3);
}
if(tarr.endsWith("0")) {
tarr = tarr.left(tarr.length()-1);
}
//unis = unis.replace(exp1, QString(""));
//unis = unis.replace(exp2, QString(""));
//u8s = this->u8codec->fromUnicode(unis);
QString unis = this->codec->toUnicode(tarr);
this->feed_page_utf8_html = this->u8codec->fromUnicode(unis);
this->feed_page_utf8_html = this->u8codec->fromUnicode(this->codec->toUnicode(this->feed_page_html));
}