本文整理汇总了C++中QScriptString::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptString::isValid方法的具体用法?C++ QScriptString::isValid怎么用?C++ QScriptString::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptString
的用法示例。
在下文中一共展示了QScriptString::isValid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: propertyFlags
/*!
Returns the flags of the property with the given \a name, using the
given \a mode to resolve the property.
\sa property()
*/
QScriptValue::PropertyFlags QScriptValue::propertyFlags(const QScriptString &name,
const ResolveFlags &mode) const
{
if (!name.isValid())
return 0;
QScriptStringPrivate *s = QScriptStringPrivate::get(name);
return QScriptValuePrivate::valueOf(*this).propertyFlags(s->nameId, mode);
}
示例2: propertyFlags
/*!
\since 4.4
Returns the flags of the property with the given \a name, using the
given \a mode to resolve the property.
\sa property()
*/
QScriptValue::PropertyFlags QScriptValue::propertyFlags(const QScriptString &name,
const ResolveFlags &mode) const
{
Q_D(const QScriptValue);
if (!d)
return 0;
if (!name.isValid())
return 0;
QScriptStringPrivate *s = QScriptStringPrivate::get(name);
return d->value.propertyFlags(s->nameId, mode);
}
示例3: property
/*!
\since 4.4
Returns the value of this QScriptValue's property with the given \a name,
using the given \a mode to resolve the property.
This overload of property() is useful when you need to look up the
same property repeatedly, since the lookup can be performed faster
when the name is represented as an interned string.
\sa QScriptEngine::toStringHandle(), setProperty()
*/
QScriptValue QScriptValue::property(const QScriptString &name,
const ResolveFlags &mode) const
{
Q_D(const QScriptValue);
if (!d || !d->value.isObject())
return QScriptValue();
if (!name.isValid())
return QScriptValue();
QScriptStringPrivate *s = QScriptStringPrivate::get(name);
QScriptEnginePrivate *eng = QScriptEnginePrivate::get(engine());
return eng->toPublic(d->value.property(s->nameId, mode));
}
示例4: setProperty
/*!
\since 4.4
Sets the value of this QScriptValue's property with the given \a
name to the given \a value. The given \a flags specify how this
property may be accessed by script code.
This overload of setProperty() is useful when you need to set the
same property repeatedly, since the operation can be performed
faster when the name is represented as an interned string.
\sa QScriptEngine::toStringHandle()
*/
void QScriptValue::setProperty(const QScriptString &name,
const QScriptValue &value,
const PropertyFlags &flags)
{
Q_D(QScriptValue);
if (!d || !d->value.isObject() || !name.isValid())
return;
if (value.engine() && (value.engine() != engine())) {
qWarning("QScriptValue::setProperty() failed: "
"cannot set value created in a different engine");
return;
}
QScriptStringPrivate *s = QScriptStringPrivate::get(name);
d->value.setProperty(s->nameId, d->value.engine()->toImpl(value), flags);
}
示例5: setProperty
/*!
Sets the value of this QScriptValue's property with the given \a
name to the given \a value. The given \a flags specify how this
property may be accessed by script code.
This overload of setProperty() is useful when you need to set the
same property repeatedly, since the operation can be performed
faster when the name is represented as an interned string.
\sa QScriptEngine::toStringHandle()
*/
void QScriptValue::setProperty(const QScriptString &name,
const QScriptValue &value,
const PropertyFlags &flags)
{
if (!name.isValid())
return;
if (isValid() && value.isValid() && (value.engine() != engine())) {
qWarning("QScriptValue::setProperty() failed: "
"cannot set value created in a different engine");
return;
}
QScriptStringPrivate *s = QScriptStringPrivate::get(name);
QScriptValuePrivate::valueOf(*this).setProperty(
s->nameId, QScriptValuePrivate::valueOf(value), flags);
}
示例6: test
void tst_QScriptString::test()
{
QScriptEngine eng;
{
QScriptString str;
QVERIFY(!str.isValid());
QVERIFY(str == str);
QVERIFY(!(str != str));
QVERIFY(str.toString().isNull());
QScriptString str1(str);
QVERIFY(!str1.isValid());
QScriptString str2 = str;
QVERIFY(!str2.isValid());
QCOMPARE(str.toArrayIndex(), quint32(0xffffffff));
}
for (int x = 0; x < 2; ++x) {
QString ciao = QString::fromLatin1("ciao");
QScriptString str = eng.toStringHandle(ciao);
QVERIFY(str.isValid());
QVERIFY(str == str);
QVERIFY(!(str != str));
QCOMPARE(str.toString(), ciao);
QScriptString str1(str);
QCOMPARE(str, str1);
QScriptString str2 = str;
QCOMPARE(str, str2);
QScriptString str3 = eng.toStringHandle(ciao);
QVERIFY(str3.isValid());
QCOMPARE(str, str3);
eng.collectGarbage();
QVERIFY(str.isValid());
QCOMPARE(str.toString(), ciao);
QVERIFY(str1.isValid());
QCOMPARE(str1.toString(), ciao);
QVERIFY(str2.isValid());
QCOMPARE(str2.toString(), ciao);
QVERIFY(str3.isValid());
QCOMPARE(str3.toString(), ciao);
}
{
QScriptEngine* eng2 = new QScriptEngine;
QString one = QString::fromLatin1("one");
QString two = QString::fromLatin1("two");
QScriptString oneInterned = eng2->toStringHandle(one);
QCOMPARE(oneInterned.toString(), one);
QScriptString twoInterned = eng2->toStringHandle(two);
QCOMPARE(twoInterned.toString(), two);
QVERIFY(oneInterned != twoInterned);
QVERIFY(!(oneInterned == twoInterned));
delete eng2;
}
}