本文整理汇总了C++中QSourceLocation::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ QSourceLocation::isNull方法的具体用法?C++ QSourceLocation::isNull怎么用?C++ QSourceLocation::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSourceLocation
的用法示例。
在下文中一共展示了QSourceLocation::isNull方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addLocation
void GenericStaticContext::addLocation(const SourceLocationReflection *const reflection,
const QSourceLocation &location)
{
Q_ASSERT(!location.isNull());
Q_ASSERT_X(reflection, Q_FUNC_INFO,
"The reflection cannot be zero.");
m_locations.insert(reflection, location);
}
示例2: isNull
void tst_QSourceLocation::isNull() const
{
{
QSourceLocation def;
QVERIFY(def.isNull());
def.setColumn(4);
QVERIFY(def.isNull());
}
{
QSourceLocation def2;
def2.setLine(4);
QVERIFY(def2.isNull());
}
{
QSourceLocation def3;
def3.setUri(QUrl(QLatin1String("http://example.com/")));
QVERIFY(!def3.isNull());
}
}
示例3: assignmentOperator
void tst_QSourceLocation::assignmentOperator() const
{
/* Assign to self. */
{
QSourceLocation def;
def = def;
QVERIFY(def.isNull());
QCOMPARE(def.line(), qint64(-1));
QCOMPARE(def.column(), qint64(-1));
QCOMPARE(def.uri(), QUrl());
}
/* Assign to default constructed object. */
{
QSourceLocation val;
val.setLine(3);
val.setColumn(4);
val.setUri(QUrl(QLatin1String("http://example.com/2")));
QSourceLocation assigned;
assigned = val;
QCOMPARE(assigned.line(), qint64(3));
QCOMPARE(assigned.column(), qint64(4));
QCOMPARE(assigned.uri(), QUrl(QLatin1String("http://example.com/2")));
}
/* Assign to modified object. */
{
QSourceLocation val;
val.setLine(3);
val.setColumn(4);
val.setUri(QUrl(QLatin1String("http://example.com/2")));
QSourceLocation assigned;
assigned.setLine(700);
assigned.setColumn(4000);
assigned.setUri(QUrl(QLatin1String("http://example.com/3")));
assigned = val;
QCOMPARE(assigned.line(), qint64(3));
QCOMPARE(assigned.column(), qint64(4));
QCOMPARE(assigned.uri(), QUrl(QLatin1String("http://example.com/2")));
}
}
示例4: constCorrectness
/*!
Call functions that must be const.
*/
void tst_QSourceLocation::constCorrectness() const
{
const QSourceLocation def;
def.line();
def.column();
def.uri();
def.isNull();
const QSourceLocation def2;
/* Equalness operator. */
QVERIFY(def == def2);
QCOMPARE(def, def2);
/* Inverse equalness operator. */
QVERIFY(def != def2);
}
示例5: handleMessage
void handleMessage(QtMsgType type, const QString &description,
const QUrl &, const QSourceLocation &sourceLocation)
{
const char* typeName;
switch(type)
{
case QtDebugMsg: typeName = "Debug"; break;
case QtWarningMsg: typeName = "Warning"; break;
case QtCriticalMsg: typeName = "Critical"; break;
case QtFatalMsg:
default: typeName = "Fatal"; break;
}
QXmlStreamReader xml(description);
QString text;
while (!xml.atEnd())
if (xml.readNext() == QXmlStreamReader::Characters)
text += xml.text();
std::cerr << typeName << ": " << qPrintable(text);
if (!sourceLocation.isNull())
std::cerr << " (line " << sourceLocation.line()
<< ", col " << sourceLocation.column() << ")" << std::endl;
}
示例6: handleMessage
void ColoringMessageHandler::handleMessage(QtMsgType type,
const QString &description,
const QUrl &identifier,
const QSourceLocation &sourceLocation)
{
const bool hasLine = sourceLocation.line() != -1;
switch(type)
{
case QtWarningMsg:
{
if(hasLine)
{
writeUncolored(QXmlPatternistCLI::tr("Warning in %1, at line %2, column %3: %4").arg(sourceLocation.uri().toString(),
QString::number(sourceLocation.line()),
QString::number(sourceLocation.column()),
colorifyDescription(description)));
}
else
{
writeUncolored(QXmlPatternistCLI::tr("Warning in %1: %2").arg(sourceLocation.uri().toString(),
colorifyDescription(description)));
}
break;
}
case QtFatalMsg:
{
const QString errorCode(identifier.fragment());
Q_ASSERT(!errorCode.isEmpty());
QUrl uri(identifier);
uri.setFragment(QString());
QString location;
if(sourceLocation.isNull())
location = QXmlPatternistCLI::tr("Unknown location");
else
location = sourceLocation.uri().toString();
QString errorId;
/* If it's a standard error code, we don't want to output the
* whole URI. */
if(uri.toString() == QLatin1String("http://www.w3.org/2005/xqt-errors"))
errorId = errorCode;
else
errorId = identifier.toString();
if(hasLine)
{
writeUncolored(QXmlPatternistCLI::tr("Error %1 in %2, at line %3, column %4: %5").arg(colorify(errorId, ErrorCode),
colorify(location, Location),
colorify(QString::number(sourceLocation.line()), Location),
colorify(QString::number(sourceLocation.column()), Location),
colorifyDescription(description)));
}
else
{
writeUncolored(QXmlPatternistCLI::tr("Error %1 in %2: %3").arg(colorify(errorId, ErrorCode),
colorify(location, Location),
colorifyDescription(description)));
}
break;
}
case QtCriticalMsg:
/* Fallthrough. */
case QtDebugMsg:
{
Q_ASSERT_X(false, Q_FUNC_INFO,
"message() is not supposed to receive QtCriticalMsg or QtDebugMsg.");
return;
}
}
}