本文整理汇总了C++中QQueue::head方法的典型用法代码示例。如果您正苦于以下问题:C++ QQueue::head方法的具体用法?C++ QQueue::head怎么用?C++ QQueue::head使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQueue
的用法示例。
在下文中一共展示了QQueue::head方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main ()
{
QQueue<int> myQQueue;
myQQueue.enqueue(77);
myQQueue.enqueue(16);
assert(myQQueue.head() == 77);
myQQueue.head() -= myQQueue.back(); // 77-16=61
assert(myQQueue.head() == 61);
cout << "myQQueue.head() is now " << myQQueue.head() << endl;
return 0;
}
示例2: sendHelo
void QwwSmtpClientPrivate::sendHelo() {
SMTPCommand &cmd = commandqueue.head();
QString domain = localName;
if (socket->isEncrypted() && localNameEncrypted.isEmpty())
domain = localNameEncrypted;
QByteArray buf = QString("HELO "+domain+"\r\n").toUtf8();
qDebug() << "SMTP >>>" << buf;
socket->write(buf);
cmd.extra = 1;
}
示例3: onDisconnected
// private slot triggered upon disconnection from the server
// - checks the cause of disconnection
// - aborts or continues processing
void QwwSmtpClientPrivate::onDisconnected() {
setState(QwwSmtpClient::Disconnected);
if (commandqueue.isEmpty()) {
inProgress = false;
emit q->done(true);
return;
}
if (commandqueue.head().type == SMTPCommand::Disconnect) {
inProgress = false;
emit q->done(true);
return;
}
emit q->commandFinished(commandqueue.head().id, true);
commandqueue.clear();
inProgress = false;
emit q->done(false);
}
示例4: sendRcpt
void QwwSmtpClientPrivate::sendRcpt() {
SMTPCommand &cmd = commandqueue.head();
QVariantList vlist = cmd.data.toList();
QList<QVariant> rcptlist = vlist.at(1).toList();
QByteArray buf = QByteArray("RCPT TO:<").append(rcptlist.first().toByteArray()).append(">\r\n");
qDebug() << "SMTP >>>" << buf;
socket->write(buf);
rcptlist.removeFirst();
vlist[1] = rcptlist;
cmd.data = vlist;
if (rcptlist.isEmpty()) cmd.extra = 1;
}
示例5: processNextCommand
void QwwSmtpClientPrivate::processNextCommand(bool ok) {
if (inProgress && !commandqueue.isEmpty()) {
emit q->commandFinished(commandqueue.head().id, !ok);
commandqueue.dequeue();
}
if (commandqueue.isEmpty()) {
inProgress = false;
emit q->done(false);
return;
}
const SMTPCommand &cmd = commandqueue.head();
switch (cmd.type) {
case SMTPCommand::Connect: {
QString hostName = cmd.data.toList().at(0).toString();
uint port = cmd.data.toList().at(1).toUInt();
bool ssl = cmd.data.toList().at(2).toBool();
if(ssl){
qDebug() << "SMTP ** connectToHostEncrypted";
socket->connectToHostEncrypted(hostName, port);
} else {
qDebug() << "SMTP ** connectToHost";
socket->connectToHost(hostName, port);
}
setState(QwwSmtpClient::Connecting);
}
break;
case SMTPCommand::Disconnect: {
sendQuit();
}
break;
case SMTPCommand::StartTLS: {
qDebug() << "SMTP >>> STARTTLS";
socket->write("STARTTLS\r\n");
setState(QwwSmtpClient::TLSRequested);
}
break;
case SMTPCommand::Authenticate: {
QwwSmtpClient::AuthMode authmode = (QwwSmtpClient::AuthMode)cmd.data.toList().at(0).toInt();
switch (authmode) {
case QwwSmtpClient::AuthPlain:
qDebug() << "SMTP >>> AUTH PLAIN";
socket->write("AUTH PLAIN\r\n");
setState(QwwSmtpClient::Authenticating);
break;
case QwwSmtpClient::AuthLogin:
qDebug() << "SMTP >>> AUTH LOGIN";
socket->write("AUTH LOGIN\r\n");
setState(QwwSmtpClient::Authenticating);
break;
default:
qWarning("Unsupported or unknown authentication scheme");
//processNextCommand(false);
}
}
break;
case SMTPCommand::Mail:
case SMTPCommand::MailBurl:
{
setState(QwwSmtpClient::Sending);
QByteArray buf = QByteArray("MAIL FROM:<").append(cmd.data.toList().at(0).toByteArray()).append(">\r\n");
qDebug() << "SMTP >>>" << buf;
socket->write(buf);
break;
}
case SMTPCommand::RawCommand: {
QString cont = cmd.data.toString();
if(!cont.endsWith("\r\n")) cont.append("\r\n");
setState(QwwSmtpClient::Sending);
qDebug() << "SMTP >>>" << cont;
socket->write(cont.toUtf8());
} break;
}
inProgress = true;
emit q->commandStarted(cmd.id);
}
示例6: _q_readFromSocket
// main logic of the component - a slot triggered upon data entering the socket
// comments inline...
void QwwSmtpClientPrivate::_q_readFromSocket() {
while (socket->canReadLine()) {
QString line = socket->readLine();
qDebug() << "SMTP <<<" << line.toUtf8().constData();
QRegExp rx("(\\d+)-(.*)\n"); // multiline response (aka 250-XYZ)
QRegExp rxlast("(\\d+) (.*)\n"); // single or last line response (aka 250 XYZ)
bool mid = rx.exactMatch(line);
bool last = rxlast.exactMatch(line);
// multiline
if (mid){
int status = rx.cap(1).toInt();
SMTPCommand &cmd = commandqueue.head();
switch (cmd.type) {
// trying to connect
case SMTPCommand::Connect: {
int stage = cmd.extra.toInt();
// stage 0 completed with success - socket is connected and EHLO was sent
if(stage==1 && status==250){
QString arg = rx.cap(2).trimmed();
parseOption(arg); // we're probably receiving options
}
}
break;
// trying to establish deferred SSL handshake
case SMTPCommand::StartTLS: {
int stage = cmd.extra.toInt();
// stage 0 (negotiation) completed ok
if(stage==1 && status==250){
QString arg = rx.cap(2).trimmed();
parseOption(arg); // we're probably receiving options
}
}
default: break;
}
} else
// single line
if (last) {
int status = rxlast.cap(1).toInt();
SMTPCommand &cmd = commandqueue.head();
switch (cmd.type) {
// trying to connect
case SMTPCommand::Connect: {
int stage = cmd.extra.toInt();
// connection established, server sent its banner
if (stage==0 && status==220) {
sendEhlo(); // connect ok, send ehlo
}
// server responded to EHLO
if (stage==1 && status==250){
// success (EHLO)
parseOption(rxlast.cap(2).trimmed()); // we're probably receiving the last option
errorString.clear();
setState(QwwSmtpClient::Connected);
processNextCommand();
}
// server responded to HELO (EHLO failed)
if (state==2 && status==250) {
// success (HELO)
errorString.clear();
setState(QwwSmtpClient::Connected);
processNextCommand();
}
// EHLO failed, reason given in errorString
if (stage==1 && (status==554 || status==501 || status==502 || status==421)) {
errorString = rxlast.cap(2).trimmed();
sendHelo(); // ehlo failed, send helo
cmd.extra = 2;
}
//abortDialog();
}
break;
// trying to establish a delayed SSL handshake
case SMTPCommand::StartTLS: {
int stage = cmd.extra.toInt();
// received an invitation from the server to enter TLS mode
if (stage==0 && status==220) {
qDebug() << "SMTP ** startClientEncruption";
socket->startClientEncryption();
}
// TLS established, connection is encrypted, EHLO was sent
else if (stage==1 && status==250) {
setState(QwwSmtpClient::Connected);
parseOption(rxlast.cap(2).trimmed()); // we're probably receiving options
errorString.clear();
emit q->tlsStarted();
processNextCommand();
}
// starttls failed
else {
qDebug() << "TLS failed at stage " << stage << ": " << line;
errorString = "TLS failed";
emit q->done(false);
}
}
break;
// trying to authenticate the client to the server
case SMTPCommand::Authenticate: {
int stage = cmd.extra.toInt();
//.........这里部分代码省略.........
示例7: nextChildCount
int QHelpContentProvider::nextChildCount() const
{
return m_rootItems.head()->childCount();
}