예제 #1
0
파일: main.cpp 프로젝트: FlavioFalcao/qt5
#include <QtCore/QLibraryInfo>

#include <iostream>

// Can't have an array of QStaticByteArrayData<N> for different N, so
// use QByteArray, which requires constructor calls. Doesn't matter
// much, since this is in an app, not a lib:
static const QByteArray defaultTrFunctionNames[] = {
// MSVC can't handle the lambda in this array if QByteArrayLiteral expands
// to a lambda. In that case, use a QByteArray instead.
#if defined(Q_CC_MSVC) && defined(Q_COMPILER_LAMBDA)
#define BYTEARRAYLITERAL(F) QByteArray(#F),
#else
#define BYTEARRAYLITERAL(F) QByteArrayLiteral(#F),
#endif
    LUPDATE_FOR_EACH_TR_FUNCTION(BYTEARRAYLITERAL)
#undef BYTEARRAYLITERAL
};
Q_STATIC_ASSERT((TrFunctionAliasManager::NumTrFunctions == sizeof defaultTrFunctionNames / sizeof *defaultTrFunctionNames));

static int trFunctionByDefaultName(const QByteArray &trFunctionName)
{
    for (int i = 0; i < TrFunctionAliasManager::NumTrFunctions; ++i)
        if (trFunctionName == defaultTrFunctionNames[i])
            return i;
    return -1;
}

static int trFunctionByDefaultName(const QString &trFunctionName)
{
    return trFunctionByDefaultName(trFunctionName.toLatin1());
예제 #2
0
파일: main.cpp 프로젝트: xjohncz/qt5
#include <QtCore/QLibraryInfo>

#include <iostream>

// Can't have an array of QStaticStringData<N> for different N, so
// use QString, which requires constructor calls. Doesn't matter
// much, since this is in an app, not a lib:
static const QString defaultTrFunctionNames[] = {
// MSVC can't handle the lambda in this array if QStringLiteral expands
// to a lambda. In that case, use a QString instead.
#if defined(Q_CC_MSVC) && defined(Q_COMPILER_LAMBDA)
#define STRINGLITERAL(F) QLatin1String(#F),
#else
#define STRINGLITERAL(F) QStringLiteral(#F),
#endif
    LUPDATE_FOR_EACH_TR_FUNCTION(STRINGLITERAL)
#undef STRINGLITERAL
};
Q_STATIC_ASSERT((TrFunctionAliasManager::NumTrFunctions == sizeof defaultTrFunctionNames / sizeof *defaultTrFunctionNames));

static int trFunctionByDefaultName(const QString &trFunctionName)
{
    for (int i = 0; i < TrFunctionAliasManager::NumTrFunctions; ++i)
        if (trFunctionName == defaultTrFunctionNames[i])
            return i;
    return -1;
}

TrFunctionAliasManager::TrFunctionAliasManager()
    : m_trFunctionAliases()
{