本文整理汇总了C++中QByteArray::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ QByteArray::remove方法的具体用法?C++ QByteArray::remove怎么用?C++ QByteArray::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QByteArray
的用法示例。
在下文中一共展示了QByteArray::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: digest
QByteArray Dialog::digest(const QString s)
{
QByteArray c = s.toLatin1();
int index;
index = 0;
while ((index = c.indexOf("\\n", index)) != -1) {
c.replace(index, 2, "\n");
index += 1;
}
index = 0;
while ((index = c.indexOf("\\t", index)) != -1) {
c.replace(index, 2, "\t");
index += 1;
}
index = 0;
while ((index = c.indexOf("\r", index)) != -1) {
c.remove(index, 1);
}
return c;
}
示例2: handleReceivedForwardedAnnounce
void Dispatcher::handleReceivedForwardedAnnounce(QByteArray &datagram)
{
QByteArray tmp = datagram.mid(2, 4);
QHostAddress announcingHost(getQuint32FromByteArray(&tmp));
datagram.remove(2, 4);
handleReceivedAnnounce(UnicastPacket, announcingHost, datagram);
}
示例3: destroy
/**
* Destroys tweet with id
* @param id tweet ID
* @param trimUser trims users info
* @param includeEntities true to include node entities in response
*/
void QTweetStatusDestroy::destroy(qint64 id,
bool trimUser)
{
if (!isAuthenticationEnabled()) {
qCritical("Needs authentication to be enabled");
return;
}
QUrl url("https://api.twitter.com/1.1/statuses/destroy.json");
QUrl urlQuery(url);
urlQuery.addQueryItem("id", QString::number(id));
if (trimUser)
urlQuery.addQueryItem("trim_user", "true");
QNetworkRequest req(url);
QByteArray oauthHeader = oauthTwitter()->generateAuthorizationHeader(urlQuery, OAuth::POST);
req.setRawHeader(AUTH_HEADER, oauthHeader);
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QByteArray postBody = urlQuery.toEncoded(QUrl::RemoveScheme | QUrl::RemoveAuthority | QUrl::RemovePath);
postBody.remove(0, 1);
QNetworkReply *reply = oauthTwitter()->networkAccessManager()->post(req, postBody);
connect(reply, SIGNAL(finished()), this, SLOT(reply()));
}
示例4: handleReceivedCIDPingForwardRequest
// forward the CID ping to own bucket on request
void Dispatcher::handleReceivedCIDPingForwardRequest(QHostAddress &fromAddr, QByteArray &data)
{
data.remove(0, 2);
QByteArray tmp = data.mid(0, 4);
QHostAddress allegedFromHost = QHostAddress(getQuint32FromByteArray(&tmp));
if (fromAddr != allegedFromHost)
return;
QByteArray datagram;
datagram.reserve(30);
switch(networkBootstrap->getBootstrapStatus())
{
case NETWORK_MCAST:
datagram.append(MulticastPacket);
datagram.append(CIDPingForwardedPacket);
datagram.append(data);
sendMulticastRawDatagram(datagram);
break;
case NETWORK_BCAST:
datagram.append(BroadcastPacket);
datagram.append(CIDPingForwardedPacket);
datagram.append(data);
sendBroadcastRawDatagram(datagram);
break;
}
}
示例5: setFiffData
void BabyMEG::setFiffData(QByteArray DATA)
{
//get the first byte -- the data format
int dformat = DATA.left(1).toInt();
DATA.remove(0,1);
qint32 rows = m_pFiffInfo->nchan;
qint32 cols = (DATA.size()/dformat)/rows;
qDebug() << "[BabyMEG] Matrix " << rows << "x" << cols << " [Data bytes:" << dformat << "]";
MatrixXf rawData(Map<MatrixXf>( (float*)DATA.data(),rows, cols ));
for(qint32 i = 0; i < rows*cols; ++i)
IOUtils::swap_floatp(rawData.data()+i);
if(m_bIsRunning)
{
if(!m_pRawMatrixBuffer)
m_pRawMatrixBuffer = CircularMatrixBuffer<float>::SPtr(new CircularMatrixBuffer<float>(40, rows, cols));
m_pRawMatrixBuffer->push(&rawData);
}
// else
// {
//// std::cout << "Data coming" << std::endl; //"first ten elements \n" << rawData.block(0,0,1,10) << std::endl;
// emit DataToSquidCtrlGUI(rawData);
// }
emit DataToSquidCtrlGUI(rawData);
}
示例6: resetSession
void SessionStore::resetSession(HttpServerRequest &request) const
{
// init variables
QList<QByteArray> headers(request.headers().values("Cookie"));
QByteArray newValue;
// remove old cookies
request.headers().remove("Cookie");
// find cookies that don't match this store's settings
for (int i = 0;i != headers.size();++i) {
QList<QNetworkCookie> cookies(QNetworkCookie::parseCookies(headers[i]));
for (int i = 0;i != cookies.size();++i) {
if (cookies[i].name() != settings.name) {
newValue
+= cookies[i].toRawForm(QNetworkCookie::NameAndValueOnly)
+ "; ";
}
}
}
if (!newValue.isEmpty()) {
// removes the final "; "
newValue.remove(newValue.size() - 2, 2);
}
// update the request headers
request.headers().insert("Cookie", newValue);
}
示例7: sendCoins
void Networking::sendCoins(QString address, QString amount)
{
QString sendRequest;
sendRequest = QString("https://www.instawallet.org/api/v1/w/%1/payment").arg(walletId);
updating = true;
QByteArray data;
QUrl parameters;
double convertedAmount;
long long convertedLongAmount;
QString stringAmount;
convertedAmount = amount.toDouble();
convertedLongAmount = convertedAmount * 1e8 + (convertedAmount < 0.0 ? -.5 : .5);
stringAmount = QString("%1").arg(convertedLongAmount);
qDebug("Amount converted to Satoshis: " + stringAmount.toAscii());
parameters.addQueryItem("address", address);
parameters.addQueryItem("amount", stringAmount);
data.append(parameters.toString());
data.remove(0, 1);
networkPaymentManager->post(QNetworkRequest(QUrl(sendRequest)), data)->ignoreSslErrors();
connect(networkPaymentManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(walletPaymentLoaded(QNetworkReply*)));
}
示例8: openEmail
void UrlOpener::openEmail(const QByteArray &email)
{
QString client;
bool useDefaultEMailClient = config_file.readBoolEntry("Chat", "UseDefaultEMailClient", true);
if (useDefaultEMailClient)
client = config_file.readEntry("Chat", "MailClient");
QByteArray urlForDesktopServices;
QByteArray urlForApplication;
if (email.startsWith("mailto:"))
{
urlForDesktopServices = email;
urlForApplication = email;
urlForApplication.remove(0, 7);
}
else
{
urlForDesktopServices = "mailto:" + email;
urlForApplication = email;
}
if (!openUrl(urlForDesktopServices, urlForApplication, client))
MessageDialog::show("dialog-error", qApp->translate("@default", QT_TR_NOOP("Kadu")),
qApp->translate("@default", QT_TR_NOOP("Could not spawn Mail client process. Check if the Mail client is functional")));
}
示例9: onSongReplyReceived
void LyricWikiPlugin::onSongReplyReceived()
{
QByteArray data = reply->readAll();
reply->deleteLater();
// <div class='lyricbox'>(...)<script>(...)</script>(lyrics)<!--
int i = data.indexOf("<div class='lyricbox'>");
if (i != -1) {
i += 22;
data.remove(data.indexOf("<!--", i), data.length());
if (data.indexOf("Category:Instrumental", i) != -1) {
emit error("According to LyricWiki this track is instrumental.");
return;
}
QTextDocument lyrics; lyrics.setHtml(data.mid(data.indexOf("</script>", i) + 9));
QString plainLyrics = lyrics.toPlainText();
if (plainLyrics.contains("we are not licensed to display the full lyrics for this song")) {
emit error("The lyrics for this song are incomplete on LyricWiki.");
} else {
emit fetched(plainLyrics);
}
} else {
emit error("The lyrics for this song are missing on LyricWiki.");
}
}
示例10: SendToClientFirst
void HWMap::SendToClientFirst()
{
SendIPC(QString("eseed %1").arg(m_seed).toUtf8());
SendIPC(QString("e$template_filter %1").arg(templateFilter).toUtf8());
SendIPC(QString("e$mapgen %1").arg(m_mapgen).toUtf8());
if (!m_script.isEmpty())
{
SendIPC(QString("escript Scripts/Multiplayer/%1.lua").arg(m_script).toUtf8());
}
switch (m_mapgen)
{
case MAPGEN_MAZE:
SendIPC(QString("e$maze_size %1").arg(m_maze_size).toUtf8());
break;
case MAPGEN_DRAWN:
{
QByteArray data = m_drawMapData;
while(data.size() > 0)
{
QByteArray tmp = data;
tmp.truncate(200);
SendIPC("edraw " + tmp);
data.remove(0, 200);
}
break;
}
default:
;
}
SendIPC("!");
}
示例11: sendData
void BoxitSocket::sendData(quint16 msgID, QByteArray data) {
// Send data in multiple data packages, if data is too big...
while (true) {
QByteArray subData = data.mid(0, BOXIT_SOCKET_MAX_SIZE);
data.remove(0, BOXIT_SOCKET_MAX_SIZE);
quint16 subMsgID = msgID;
if (!data.isEmpty())
subMsgID = MSG_DATA_PACKAGE_MULTIPLE;
// Send data
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_6);
out << (quint16)0;
out << (quint16)subMsgID;
out << subData;
out.device()->seek(0);
out << (quint16)(block.size() - 2*sizeof(quint16));
write(block);
flush();
waitForBytesWritten(2000);
if (data.isEmpty())
break;
}
}
示例12: getPacket
QByteArray Parser::getPacket(QByteArray& ta){
const char etx = 0x03;
int n = ta.indexOf(etx);
QByteArray ra = ta.left(n);
ta = ta.remove(0,n+1);
return ra;
}
示例13: shortenTemplates
QByteArray shortenTemplates(const QByteArray& identifier)
{
QByteArray ret = identifier;
Q_ASSERT(KSharedConfig::openConfig());
KConfigGroup conf = KSharedConfig::openConfig()->group(QLatin1String("Settings"));
if (conf.readEntry(QLatin1String("shortenTemplates"), false)) {
// remove template arguments between <...>
int depth = 0;
int open = 0;
for (int i = 0; i < ret.length(); ++i) {
if (ret.at(i) == '<') {
if (!depth) {
open = i;
}
++depth;
} else if (ret.at(i) == '>') {
--depth;
if (!depth) {
ret.remove(open + 1, i - open - 1);
i = open + 1;
open = 0;
}
}
}
}
return ret;
}
示例14: while
ImapMailbox *ImapPrivate::parseMessages (ImapMailbox *mailbox) {
QByteArray response;
while (true) {
// Read Message
response.clear();
do {
if (response.size() > 0) {
response.remove(response.lastIndexOf('}'),
response.size() - response.lastIndexOf('{'));
}
response.append(readLine());
} while (isMultiline(response));
// Break if End Response Found.
if (isResponseEnd(response))
break;
// Parse and Add Message to Mailbox
ImapMessage *message = _imapParseMessage(response.trimmed());
if (message != NULL) mailbox->addMessage(message);
}
return(mailbox);
}
示例15: ipad
QByteArray ImapPrivate::hmacMd5 (const QString& username,
const QString& password,
const QString& serverResponse)
{
QByteArray passwordBytes = password.toLatin1();
QByteArray ipad(64, 0);
QByteArray opad(64, 0);
for (int i = 0; i < 64; ++i) {
if (i < passwordBytes.size()) {
ipad[i] = (quint8)(0x36 ^ passwordBytes[i]);
opad[i] = (quint8)(0x5c ^ passwordBytes[i]);
} else {
ipad[i] = 0x36;
opad[i] = 0x5c;
}
}
QByteArray serverResponseBytes = serverResponse.toLatin1();
while (serverResponseBytes[0] == '+' || serverResponseBytes[0] == ' ')
serverResponseBytes.remove(0, 1);
QCryptographicHash md5hash(QCryptographicHash::Md5);
md5hash.addData(ipad);
md5hash.addData(serverResponseBytes);
QByteArray resultIpad = md5hash.result();
md5hash.reset();
md5hash.addData(opad);
md5hash.addData(resultIpad);
QByteArray resultOpad = md5hash.result();
QByteArray response = username.toLatin1() + ' ' + resultOpad.toHex();
return(response.toBase64());
}