本文整理汇总了C++中QSourceLocation::uri方法的典型用法代码示例。如果您正苦于以下问题:C++ QSourceLocation::uri方法的具体用法?C++ QSourceLocation::uri怎么用?C++ QSourceLocation::uri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSourceLocation
的用法示例。
在下文中一共展示了QSourceLocation::uri方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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")));
}
}
示例2: copyConstructor
void tst_QSourceLocation::copyConstructor() const
{
{
QSourceLocation def;
QSourceLocation copy(def);
QCOMPARE(def.line(), qint64(-1));
QCOMPARE(def.column(), qint64(-1));
QCOMPARE(def.uri(), QUrl());
}
{
QSourceLocation val;
val.setLine(5);
val.setColumn(600);
val.setUri(QUrl(QLatin1String("http://example.com/")));
QSourceLocation copy(val);
QCOMPARE(copy.line(), qint64(5));
QCOMPARE(copy.column(), qint64(600));
QCOMPARE(copy.uri(), QUrl(QLatin1String("http://example.com/")));
}
{
/* Construct from a const object. */
const QSourceLocation val;
const QSourceLocation val2(val);
QCOMPARE(val, val2);
}
}
示例3: handleMessage
void XSLTMessageHandler::handleMessage(QtMsgType type, const QString& description,
const QUrl&, const QSourceLocation& sourceLocation)
{
if (!m_document->frame())
return;
MessageLevel level;
switch (type) {
case QtDebugMsg:
level = TipMessageLevel;
break;
case QtWarningMsg:
level = WarningMessageLevel;
break;
case QtCriticalMsg:
case QtFatalMsg:
level = ErrorMessageLevel;
break;
default:
level = LogMessageLevel;
break;
}
Console* console = m_document->frame()->domWindow()->console();
console->addMessage(XMLMessageSource, LogMessageType, level, description,
sourceLocation.line(), sourceLocation.uri().toString());
}
示例4: handleMessage
void MessageValidator::handleMessage(QtMsgType type,
const QString &description,
const QUrl &identifier,
const QSourceLocation &sourceLocation)
{
Q_UNUSED(type);
Q_UNUSED(description);
Q_UNUSED(sourceLocation);
Q_UNUSED(identifier);
QXmlStreamReader reader(description);
m_received = QLatin1String("Type:")
+ QString::number(type)
+ QLatin1String("\nDescription: ")
+ description
+ QLatin1String("\nIdentifier: ")
+ identifier.toString()
+ QLatin1String("\nLocation: ")
+ sourceLocation.uri().toString()
+ QLatin1String("#")
+ QString::number(sourceLocation.line())
+ QLatin1String(",")
+ QString::number(sourceLocation.column());
/* We just walk through it, to check that it's valid. */
while(!reader.atEnd())
reader.readNext();
m_success = !reader.hasError();
}
示例5: QString
void
MyXmlErrorHandler::handleMessage (QtMsgType type, const QString &description,
const QUrl & /*identifier*/,
const QSourceLocation &sourceLocation)
{
QString msg = QString("XML message: %1, at uri= %2 "
"line %3 column %4")
.arg(description)
.arg(sourceLocation.uri ().toString ())
.arg(sourceLocation.line ())
.arg(sourceLocation.column ());
switch (type) {
case QtDebugMsg:
Q_DEBUG(msg);
break;
case QtWarningMsg:
Q_WARN(msg);
break;
case QtCriticalMsg:
case QtFatalMsg:
Q_CRIT(msg);
break;
}
}//MyXmlErrorHandler::handleMessage
示例6: defaultValues
void tst_QSourceLocation::defaultValues() const
{
QSourceLocation def;
QCOMPARE(def.line(), qint64(-1));
QCOMPARE(def.column(), qint64(-1));
QCOMPARE(def.uri(), QUrl());
}
示例7: valueConstructor
void tst_QSourceLocation::valueConstructor() const
{
const QSourceLocation sl(QUrl(QLatin1String("http://example.com/")), 5, 4);
QCOMPARE(sl.uri(), QUrl(QLatin1String("http://example.com/")));
QCOMPARE(sl.line(), qint64(5));
QCOMPARE(sl.column(), qint64(4));
}
示例8: valueConstructorDefaultArguments
void tst_QSourceLocation::valueConstructorDefaultArguments() const
{
/* The line and column arguments are optional. */
const QSourceLocation sl(QUrl(QLatin1String("http://example.com/")));
QCOMPARE(sl.uri(), QUrl(QLatin1String("http://example.com/")));
QCOMPARE(sl.line(), qint64(-1));
QCOMPARE(sl.column(), qint64(-1));
}
示例9:
QDebug operator<<(QDebug debug, const QSourceLocation &sourceLocation)
{
debug << "QSourceLocation("
<< sourceLocation.uri()
<< ", line:"
<< sourceLocation.line()
<< ", column:"
<< sourceLocation.column()
<< ')';
return debug;
}
示例10: 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);
}
示例11: 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;
}
}
}
示例12: setUri
void tst_QSourceLocation::setUri() const
{
QSourceLocation sl;
sl.setUri(QUrl(QLatin1String("http://example.com/")));
QCOMPARE(sl.uri(), QUrl(QLatin1String("http://example.com/")));
}
示例13: qHash
/*!
\since 4.4
Computes a hash key for the QSourceLocation \a location.
\relates QSourceLocation
*/
uint qHash(const QSourceLocation &location)
{
/* Not the world's best hash function exactly. */
return qHash(location.uri().toString()) + location.line() + location.column();
}