本文整理汇总了C++中QScriptString类的典型用法代码示例。如果您正苦于以下问题:C++ QScriptString类的具体用法?C++ QScriptString怎么用?C++ QScriptString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QScriptString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_D
/*!
Returns true if this QScriptString is equal to \a other;
otherwise returns false.
*/
bool QScriptString::operator==(const QScriptString &other) const
{
Q_D(const QScriptString);
if (!d || !other.d_func())
return d == other.d_func();
return d->identifier == other.d_func()->identifier;
}
示例2: propertyFlags
QScriptValue::PropertyFlags DefaultScriptClass::propertyFlags(const QScriptValue& object, const QScriptString& name, uint id)
{
QScriptValue::PropertyFlags result;
const ScriptHandlerInfo::Mode mode = mHandlerInfo->mode();
Q_ASSERT(mode != ScriptHandlerInfo::None);
DataInformation* data = toDataInformation(object);
if (!data)
{
mHandlerInfo->logger()->error() << "could not cast data from" << object.data().toString();
engine()->currentContext()->throwError(QScriptContext::ReferenceError,
QStringLiteral("Attempting to access an invalid object"));
return 0;
}
if (name == s_valid || name == s_validationError)
{
if (mode != ScriptHandlerInfo::Validating)
result |= QScriptValue::ReadOnly;
}
else if (mode != ScriptHandlerInfo::Updating)
{
result |= QScriptValue::ReadOnly;
}
for (int i = 0, size = mIterableProperties.size(); i < size; ++i) {
if (mIterableProperties.at(i).first == name)
return result | mIterableProperties.at(i).second;
}
if (additionalPropertyFlags(data, name, id, &result))
return result; //is a child element
else
{
data->logError() << "could not find flags for property with name" << name.toString();
return 0;
}
}
示例3: setProperty
void ScriptDataItem::setProperty(QScriptValue &object, const QScriptString &name,
uint id, const QScriptValue &value)
{
Q_UNUSED(id);
DataItem *item = get_data_item(object);
item->setProperty(name.toString().toUtf8(), value.toVariant());
}
示例4: queryProperty
QScriptClass::QueryFlags ScShiftPropertyContainer::queryProperty(const QScriptValue &object, const QScriptString &name, QueryFlags flags, uint *id)
{
ScProfileFunction
SPropertyContainer *prop = (*unpackValue(object))->uncheckedCastTo<SPropertyContainer>();
if (!prop)
{
xAssertFail();
return 0;
}
*id = (uint)-1;
bool isArrayIndex = false;
qint32 pos = name.toArrayIndex(&isArrayIndex);
if(isArrayIndex)
{
*id = pos;
return flags;
}
else
{
SProperty *child = prop->findChild(name);
if(child)
{
return flags;
}
}
return 0;
}
示例5: property
QScriptValue ScriptMessage::property(const QScriptValue &object, const QScriptString &name, uint id)
{
Q_UNUSED(id);
Message *msg = message_get_value(object);
if (name == m_incoming)
return msg->isIncoming();
return engine()->toScriptValue(msg->property(name.toString().toUtf8()));
}
示例6: property
/*!
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);
}
示例7: queryProperty
QScriptClass::QueryFlags DefaultScriptClass::queryProperty(const QScriptValue& object,
const QScriptString& name, QScriptClass::QueryFlags flags, uint* id)
{
const ScriptHandlerInfo::Mode mode = mHandlerInfo->mode();
Q_ASSERT(mode != ScriptHandlerInfo::None);
DataInformation* data = toDataInformation(object);
if (!data)
{
mHandlerInfo->logger()->error() << "could not cast data from" << object.data().toString();
engine()->currentContext()->throwError(QScriptContext::ReferenceError,
QStringLiteral("Attempting to access an invalid object"));
return 0;
}
if (name == s_valid || name == s_validationError)
{
return mode == ScriptHandlerInfo::Validating ? flags : flags & ~HandlesWriteAccess;
}
if (mode != ScriptHandlerInfo::Updating)
{
//the only properties that are possibly writable when not updating are valid and validationError
//but we checked them before so we remove handlesWriteAccess from the flags
flags &= ~HandlesWriteAccess;
}
if (name == s_byteOrder || name == s_name || name == s_updateFunc || name == s_validationFunc
|| name == s_datatype || name == s_customTypeName || name == s_asStringFunc)
{
return flags;
}
else if (name == s_wasAbleToRead || name == s_parent)
{
return flags & ~HandlesWriteAccess;
}
else if (queryAdditionalProperty(data, name, &flags, id))
{
return flags;
}
else
{
data->logError() << "could not find property with name" << name.toString();
engine()->currentContext()->throwError(QScriptContext::ReferenceError,
QStringLiteral("Could not find property with name ") + name.toString());
return 0;
}
}
示例8: property
QScriptValue ScriptDataItem::property(const QScriptValue &object, const QScriptString &name, uint id)
{
Q_UNUSED(id);
if (name == m_subitem)
return m_subitemFunc;
if (name == m_subitems)
return m_subitemsFunc;
DataItem *item = get_data_item(object);
debug() << Q_FUNC_INFO << item << (object.objectId() == m_prototype.objectId());
Q_ASSERT(item);
QVariant data = item->property(name.toString().toUtf8());
if (data.isNull()) {
DataItem subitem = item->subitem(name.toString());
if (!subitem.isNull())
return engine()->toScriptValue(subitem);
return engine()->undefinedValue();
}
return engine()->newVariant(data);
}
示例9: setProperty
/*
var conference = qutim.protocol("jabber").account("[email protected]").unit("[email protected]", false);
var msg = new Message;
msg.text = "Hi!";
conference.sendMessage(msg);
*/
void ScriptMessage::setProperty(QScriptValue &object, const QScriptString &name,
uint id, const QScriptValue &value)
{
Q_UNUSED(id);
Message *msg = message_get_value(object);
if (name == m_incoming)
msg->setIncoming(value.toBool());
else
msg->setProperty(name.toString().toUtf8(), value.toVariant());
}
示例10: setProperty
void QDeclarativeGlobalScriptClass::setProperty(QScriptValue &object,
const QScriptString &name,
uint id, const QScriptValue &value)
{
Q_UNUSED(object);
Q_UNUSED(id);
Q_UNUSED(value);
QString error = QLatin1String("Invalid write to global property \"") +
name.toString() + QLatin1Char('\"');
engine()->currentContext()->throwError(error);
}
示例11: property
/*!
\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);
}
示例12: propertyHelper
QScriptValue propertyHelper(const QByteArray* arrayBuffer, const QScriptString& name, uint id) {
bool ok = false;
name.toArrayIndex(&ok);
if (ok && arrayBuffer) {
QDataStream stream(*arrayBuffer);
stream.skipRawData(id);
T result;
stream >> result;
return result;
}
示例13: 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);
}
示例14: 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);
}
示例15: queryProperty
QScriptClass::QueryFlags ByteArrayClass::queryProperty(const QScriptValue &object,
const QScriptString &name,
QueryFlags flags, uint *id) {
QByteArray *ba = qscriptvalue_cast<QByteArray*>(object.data());
if (!ba)
return 0;
if (name == length) {
return flags;
} else {
bool isArrayIndex;
qint32 pos = name.toArrayIndex(&isArrayIndex);
if (!isArrayIndex)
return 0;
*id = pos;
if ((flags & HandlesReadAccess) && (pos >= ba->size()))
flags &= ~HandlesReadAccess;
return flags;
}
}