• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Q_LIKELY函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Q_LIKELY函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_LIKELY函数的具体用法?C++ Q_LIKELY怎么用?C++ Q_LIKELY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: metaObject

/*!
  Inserts new record into the database, based on the current properties
  of the object.
*/
bool TSqlObject::create()
{
    // Sets the values of 'created_at', 'updated_at' or 'modified_at' properties
    for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); ++i) {
        const char *propName = metaObject()->property(i).name();
        QByteArray prop = QByteArray(propName).toLower();

        if (prop == CreatedAt || prop == UpdatedAt || prop == ModifiedAt) {
            setProperty(propName, QDateTime::currentDateTime());
        } else if (prop == LockRevision) {
            // Sets the default value of 'revision' property
            setProperty(propName, 1);  // 1 : default value
        } else {
            // do nothing
        }
    }

    syncToSqlRecord();

    QString autoValName;
    QSqlRecord record = *this;
    if (autoValueIndex() >= 0) {
        autoValName = field(autoValueIndex()).name();
        record.remove(autoValueIndex()); // not insert the value of auto-value field
    }

    QSqlDatabase &database = Tf::currentSqlDatabase(databaseId());
    QString ins = database.driver()->sqlStatement(QSqlDriver::InsertStatement, tableName(), record, false);
    if (Q_UNLIKELY(ins.isEmpty())) {
        sqlError = QSqlError(QLatin1String("No fields to insert"),
                             QString(), QSqlError::StatementError);
        tWarn("SQL statement error, no fields to insert");
        return false;
    }

    TSqlQuery query(database);
    bool ret = query.exec(ins);
    sqlError = query.lastError();
    if (Q_LIKELY(ret)) {
        // Gets the last inserted value of auto-value field
        if (autoValueIndex() >= 0) {
            QVariant lastid = query.lastInsertId();

            if (!lastid.isValid() && database.driverName().toUpper() == QLatin1String("QPSQL")) {
                // For PostgreSQL without OIDS
                ret = query.exec("SELECT LASTVAL()");
                sqlError = query.lastError();
                if (Q_LIKELY(ret)) {
                    lastid = query.getNextValue();
                }
            }

            if (lastid.isValid()) {
                QObject::setProperty(autoValName.toLatin1().constData(), lastid);
                QSqlRecord::setValue(autoValueIndex(), lastid);
            }
        }
    }
    return ret;
}
开发者ID:ChowZenki,项目名称:treefrog-framework,代码行数:64,代码来源:tsqlobject.cpp


示例2: QSslSocket

void QSslServer::incomingConnection(qintptr socket)
{
    QSslSocket *pSslSocket = new QSslSocket();

    if (Q_LIKELY(pSslSocket)) {
        pSslSocket->setSslConfiguration(m_sslConfiguration);

        if (Q_LIKELY(pSslSocket->setSocketDescriptor(socket)))
        {
            typedef void (QSslSocket::* sslErrorsSignal)(const QList<QSslError> &);

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 2)
            connect(pSslSocket, &QSslSocket::peerVerifyError, this, &QSslServer::peerVerifyError);

            connect(pSslSocket, &QSslSocket::encrypted, this, &QSslServer::newEncryptedConnection);

#else
            connect(pSslSocket,SIGNAL(peerVerifyError(QSslError)), this, SIGNAL(peerVerifyError(QSslError)));
            connect(pSslSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SIGNAL(sslErrors(QList<QSslError>)));
            connect(pSslSocket, SIGNAL(encrypted()), this, SIGNAL(newEncryptedConnection()));
#endif
            addPendingConnection(pSslSocket);

            pSslSocket->startServerEncryption();
        }
        else
        {
            delete pSslSocket;
        }
    }
}
开发者ID:PushoN,项目名称:Coterie,代码行数:31,代码来源:qsslserver.cpp


示例3: QTcpServer

/*!
    \internal
 */
void QWebSocketServerPrivate::init()
{
    if (m_secureMode == NonSecureMode) {
        m_pTcpServer = new QTcpServer(q_ptr);
        if (Q_LIKELY(m_pTcpServer))
            QObjectPrivate::connect(m_pTcpServer, &QTcpServer::newConnection,
                                    this, &QWebSocketServerPrivate::onNewConnection);
        else
            qFatal("Could not allocate memory for tcp server.");
    } else {
#ifndef QT_NO_SSL
        QSslServer *pSslServer = new QSslServer(q_ptr);
        m_pTcpServer = pSslServer;
        if (Q_LIKELY(m_pTcpServer)) {
            QObjectPrivate::connect(pSslServer, &QSslServer::newEncryptedConnection,
                                    this, &QWebSocketServerPrivate::onNewConnection,
                                    Qt::QueuedConnection);
            QObject::connect(pSslServer, &QSslServer::peerVerifyError,
                             q_ptr, &QWebSocketServer::peerVerifyError);
            QObject::connect(pSslServer, &QSslServer::sslErrors,
                             q_ptr, &QWebSocketServer::sslErrors);
            QObject::connect(pSslServer, &QSslServer::preSharedKeyAuthenticationRequired,
                             q_ptr, &QWebSocketServer::preSharedKeyAuthenticationRequired);
        }
#else
        qFatal("SSL not supported on this platform.");
#endif
    }
    QObject::connect(m_pTcpServer, &QTcpServer::acceptError, q_ptr, &QWebSocketServer::acceptError);
}
开发者ID:allenck,项目名称:DecoderPro_app,代码行数:33,代码来源:qwebsocketserver_p.cpp


示例4: onCloseConnection

/*!
    \internal
 */
void QWebSocketServerPrivate::onCloseConnection()
{
    if (Q_LIKELY(currentSender)) {
        QTcpSocket *pTcpSocket = qobject_cast<QTcpSocket*>(currentSender->sender);
        if (Q_LIKELY(pTcpSocket))
            pTcpSocket->close();
    }
}
开发者ID:allenck,项目名称:DecoderPro_app,代码行数:11,代码来源:qwebsocketserver_p.cpp


示例5: ignoreSslErrors

/*!
 * \internal
 */
void QWebSocketPrivate::ignoreSslErrors()
{
    m_configuration.m_ignoreSslErrors = true;
    if (Q_LIKELY(m_pSocket)) {
        QSslSocket *pSslSocket = qobject_cast<QSslSocket *>(m_pSocket.data());
        if (Q_LIKELY(pSslSocket))
            pSslSocket->ignoreSslErrors();
    }
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:12,代码来源:qwebsocket_p.cpp


示例6: Q_D

void QEventDispatcherBlackberry::wakeUp()
{
    Q_D(QEventDispatcherBlackberry);
    if (d->wakeUps.testAndSetAcquire(0, 1)) {
        bps_event_t *event;
        if (Q_LIKELY(bps_event_create(&event, bpsUnblockDomain, 0, 0, 0) == BPS_SUCCESS)) {
            if (Q_LIKELY(bps_channel_push_event(d->bps_channel, event) == BPS_SUCCESS))
                return;
            else
                bps_event_destroy(event);
        }
        qWarning("QEventDispatcherBlackberry: wakeUp failed");
    }
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:14,代码来源:qeventdispatcher_blackberry.cpp


示例7: min

void Arguments::copyToRegisters(ExecState* exec, Register* buffer, uint32_t maxSize)
{
    if (Q_UNLIKELY(d->overrodeLength)) {
        unsigned length = min(get(exec, exec->propertyNames().length).toUInt32(exec), maxSize);
        for (unsigned i = 0; i < length; i++)
            buffer[i] = get(exec, i);
        return;
    }

    if (Q_LIKELY(!d->deletedArguments)) {
        unsigned parametersLength = min(min(d->numParameters, d->numArguments), maxSize);
        unsigned i = 0;
        for (; i < parametersLength; ++i)
            buffer[i] = d->registers[d->firstParameterIndex + i].jsValue();
        for (; i < d->numArguments; ++i)
            buffer[i] = d->extraArguments[i - d->numParameters].jsValue();
        return;
    }

    unsigned parametersLength = min(min(d->numParameters, d->numArguments), maxSize);
    unsigned i = 0;
    for (; i < parametersLength; ++i) {
        if (!d->deletedArguments[i])
            buffer[i] = d->registers[d->firstParameterIndex + i].jsValue();
        else
            buffer[i] = get(exec, i);
    }
    for (; i < d->numArguments; ++i) {
        if (!d->deletedArguments[i])
            buffer[i] = d->extraArguments[i - d->numParameters].jsValue();
        else
            buffer[i] = get(exec, i);
    }
}
开发者ID:fluxer,项目名称:katie,代码行数:34,代码来源:Arguments.cpp


示例8: select_all

void TabManager::select_all()
{
    codeEditor *current=qobject_cast<codeEditor *>(currentWidget());

    if(Q_LIKELY(current!=NULL))
        current->selectAll();
}
开发者ID:AG3,项目名称:Lucky_OIer,代码行数:7,代码来源:tabmanager.cpp


示例9: paste

void TabManager::paste()
{
    codeEditor *current=qobject_cast<codeEditor *>(currentWidget());

    if(Q_LIKELY(current!=NULL))
        current->paste();
}
开发者ID:AG3,项目名称:Lucky_OIer,代码行数:7,代码来源:tabmanager.cpp


示例10: dumpStringToFile

void FileAndDirectoryUtils::dumpStringToFile(QFile *f, QString &str) {
    if (Q_LIKELY(f == NULL || str.length() <= minLengthToWrite)) {
        return;
    }
    f->write(str.toLocal8Bit());
    str.clear();
}
开发者ID:ugeneunipro,项目名称:ugene,代码行数:7,代码来源:FileAndDirectoryUtils.cpp


示例11: Q_D

// AspectThread
bool QPostman::shouldNotifyFrontend(const QSceneChangePtr &e)
{
    Q_D(QPostman);
    const QPropertyUpdatedChangePtr propertyChange = qSharedPointerDynamicCast<QPropertyUpdatedChange>(e);
    if (Q_LIKELY(d->m_scene != nullptr) && !propertyChange.isNull()) {
        const QScene::NodePropertyTrackData propertyTrackData
                = d->m_scene->lookupNodePropertyTrackData(e->subjectId());

        const QNode::PropertyTrackingMode trackMode = propertyTrackData.trackedPropertiesOverrides.value(QLatin1String(propertyChange->propertyName()),
                                                                                                      propertyTrackData.defaultTrackMode);

        switch (trackMode) {
        case QNode::TrackAllValues:
            return true;

        case QNode::DontTrackValues:
            return false;

        case QNode::TrackFinalValues: {
            const bool isIntermediate
                = QPropertyUpdatedChangeBasePrivate::get(propertyChange.data())->m_isIntermediate;
            return !isIntermediate;
        }

        default:
            Q_UNREACHABLE();
            return false;
        }
    }
    return true;
}
开发者ID:RSATom,项目名称:Qt,代码行数:32,代码来源:qpostman.cpp


示例12: Starts

/*!
    \overload

    Starts (or restarts) the timer with a \a msec milliseconds timeout and the
    given \a timerType. See Qt::TimerType for information on the different
    timer types.

    \a obj will receive timer events.

    \sa stop(), isActive(), QObject::timerEvent(), Qt::TimerType
 */
void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
{
    QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
    if (Q_UNLIKELY(msec < 0)) {
        qWarning("QBasicTimer::start: Timers cannot have negative timeouts");
        return;
    }
    if (Q_UNLIKELY(!eventDispatcher)) {
        qWarning("QBasicTimer::start: QBasicTimer can only be used with threads started with QThread");
        return;
    }
    if (Q_UNLIKELY(obj && obj->thread() != eventDispatcher->thread())) {
        qWarning("QBasicTimer::start: Timers cannot be started from another thread");
        return;
    }
    if (id) {
        if (Q_LIKELY(eventDispatcher->unregisterTimer(id)))
            QAbstractEventDispatcherPrivate::releaseTimerId(id);
        else
            qWarning("QBasicTimer::start: Stopping previous timer failed. Possibly trying to stop from a different thread");
    }
    id = 0;
    if (obj)
        id = eventDispatcher->registerTimer(msec, timerType, obj);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:36,代码来源:qbasictimer.cpp


示例13: writeFrame

/*!
    \internal
 */
qint64 QWebSocketPrivate::writeFrame(const QByteArray &frame)
{
    qint64 written = 0;
    if (Q_LIKELY(m_pSocket))
        written = m_pSocket->write(frame);
    return written;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:10,代码来源:qwebsocket_p.cpp


示例14: peerAddress

/*!
    \internal
 */
QHostAddress QWebSocketPrivate::peerAddress() const
{
    QHostAddress address;
    if (Q_LIKELY(m_pSocket))
        address = m_pSocket->peerAddress();
    return address;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:10,代码来源:qwebsocket_p.cpp


示例15: peerName

/*!
    \internal
 */
QString QWebSocketPrivate::peerName() const
{
    QString name;
    if (Q_LIKELY(m_pSocket))
        name = m_pSocket->peerName();
    return name;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:10,代码来源:qwebsocket_p.cpp


示例16: error

/*!
    \internal
 */
QAbstractSocket::SocketError QWebSocketPrivate::error() const
{
    QAbstractSocket::SocketError err = QAbstractSocket::UnknownSocketError;
    if (Q_LIKELY(m_pSocket))
        err = m_pSocket->error();
    return err;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:10,代码来源:qwebsocket_p.cpp


示例17: futexFlags

static inline int futexFlags()
{
    int value = futexFlagSupport.load();
    if (Q_LIKELY(value != -1))
        return value;
    return checkFutexPrivateSupport();
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:7,代码来源:qmutex_linux.cpp


示例18:

/*!
    \internal
 */
QWebSocket *QWebSocketServerPrivate::nextPendingConnection()
{
    QWebSocket *pWebSocket = Q_NULLPTR;
    if (Q_LIKELY(!m_pendingConnections.isEmpty()))
        pWebSocket = m_pendingConnections.dequeue();
    return pWebSocket;
}
开发者ID:allenck,项目名称:DecoderPro_app,代码行数:10,代码来源:qwebsocketserver_p.cpp


示例19: flush

/*!
    \internal
 */
bool QWebSocketPrivate::flush()
{
    bool result = true;
    if (Q_LIKELY(m_pSocket))
        result = m_pSocket->flush();
    return result;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:10,代码来源:qwebsocket_p.cpp


示例20: unixCheckClockType

static int unixCheckClockType()
{
#if (_POSIX_MONOTONIC_CLOCK-0 == 0) && defined(_SC_MONOTONIC_CLOCK)
    // we need a value we can store in a clockid_t that isn't a valid clock
    // check if the valid ones are both non-negative or both non-positive
#  if CLOCK_MONOTONIC >= 0 && CLOCK_REALTIME >= 0
#    define IS_VALID_CLOCK(clock)    (clock >= 0)
#    define INVALID_CLOCK            -1
#  elif CLOCK_MONOTONIC <= 0 && CLOCK_REALTIME <= 0
#    define IS_VALID_CLOCK(clock)    (clock <= 0)
#    define INVALID_CLOCK            1
#  else
#    error "Sorry, your system has weird values for CLOCK_MONOTONIC and CLOCK_REALTIME"
#  endif

    static QBasicAtomicInt clockToUse = Q_BASIC_ATOMIC_INITIALIZER(INVALID_CLOCK);
    int clock = clockToUse.loadAcquire();
    if (Q_LIKELY(IS_VALID_CLOCK(clock)))
        return clock;

    // detect if the system supports monotonic timers
    clock = sysconf(_SC_MONOTONIC_CLOCK) > 0 ? CLOCK_MONOTONIC : CLOCK_REALTIME;
    clockToUse.storeRelease(clock);
    return clock;

#  undef INVALID_CLOCK
#  undef IS_VALID_CLOCK
#elif (_POSIX_MONOTONIC_CLOCK-0) > 0
    return CLOCK_MONOTONIC;
#else
    return CLOCK_REALTIME;
#endif
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:33,代码来源:qelapsedtimer_unix.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Q_Q函数代码示例发布时间:2022-05-30
下一篇:
C++ Q_IsColorString函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap