本文整理汇总了C++中QScriptValue::toDateTime方法的典型用法代码示例。如果您正苦于以下问题:C++ QScriptValue::toDateTime方法的具体用法?C++ QScriptValue::toDateTime怎么用?C++ QScriptValue::toDateTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScriptValue
的用法示例。
在下文中一共展示了QScriptValue::toDateTime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fromScriptValue
static JSAgentWatchData fromScriptValue(const QString &expression,
const QScriptValue &value)
{
static const QString arrayStr = QCoreApplication::translate
("Debugger::JSAgentWatchData", "[Array of length %1]");
static const QString undefinedStr = QCoreApplication::translate
("Debugger::JSAgentWatchData", "<undefined>");
JSAgentWatchData data;
data.exp = expression.toUtf8();
data.name = data.exp;
data.hasChildren = false;
data.value = value.toString().toUtf8();
data.objectId = value.objectId();
if (value.isArray()) {
data.type = "Array";
data.value = arrayStr.arg(value.property(QLatin1String("length")).toString()).toUtf8();
data.hasChildren = true;
} else if (value.isBool()) {
data.type = "Bool";
// data.value = value.toBool() ? "true" : "false";
} else if (value.isDate()) {
data.type = "Date";
data.value = value.toDateTime().toString().toUtf8();
} else if (value.isError()) {
data.type = "Error";
} else if (value.isFunction()) {
data.type = "Function";
} else if (value.isUndefined()) {
data.type = undefinedStr.toUtf8();
} else if (value.isNumber()) {
data.type = "Number";
} else if (value.isRegExp()) {
data.type = "RegExp";
} else if (value.isString()) {
data.type = "String";
} else if (value.isVariant()) {
data.type = "Variant";
} else if (value.isQObject()) {
const QObject *obj = value.toQObject();
data.type = "Object";
data.value += '[';
data.value += obj->metaObject()->className();
data.value += ']';
data.hasChildren = true;
} else if (value.isObject()) {
data.type = "Object";
data.hasChildren = true;
data.value = "[Object]";
} else if (value.isNull()) {
data.type = "<null>";
} else {
data.type = "<unknown>";
}
return data;
}
示例2: if
bool operator==(const QScriptValue& first, const QScriptValue& second) {
if (first.isUndefined()) {
return second.isUndefined();
} else if (first.isNull()) {
return second.isNull();
} else if (first.isBool()) {
return second.isBool() && first.toBool() == second.toBool();
} else if (first.isNumber()) {
return second.isNumber() && first.toNumber() == second.toNumber();
} else if (first.isString()) {
return second.isString() && first.toString() == second.toString();
} else if (first.isVariant()) {
return second.isVariant() && first.toVariant() == second.toVariant();
} else if (first.isQObject()) {
return second.isQObject() && first.toQObject() == second.toQObject();
} else if (first.isQMetaObject()) {
return second.isQMetaObject() && first.toQMetaObject() == second.toQMetaObject();
} else if (first.isDate()) {
return second.isDate() && first.toDateTime() == second.toDateTime();
} else if (first.isRegExp()) {
return second.isRegExp() && first.toRegExp() == second.toRegExp();
} else if (first.isArray()) {
if (!second.isArray()) {
return false;
}
int length = first.property(ScriptCache::getInstance()->getLengthString()).toInt32();
if (second.property(ScriptCache::getInstance()->getLengthString()).toInt32() != length) {
return false;
}
for (int i = 0; i < length; i++) {
if (first.property(i) != second.property(i)) {
return false;
}
}
return true;
} else if (first.isObject()) {
if (!second.isObject()) {
return false;
}
int propertyCount = 0;
for (QScriptValueIterator it(first); it.hasNext(); ) {
it.next();
if (second.property(it.scriptName()) != it.value()) {
return false;
}
propertyCount++;
}
// make sure the second has exactly as many properties as the first
for (QScriptValueIterator it(second); it.hasNext(); ) {
it.next();
if (--propertyCount < 0) {
return false;
}
}
return true;
} else {
// if none of the above tests apply, first must be invalid
return !second.isValid();
}
}
示例3: marshall_basetype
//.........这里部分代码省略.........
m->item().s_enum = value.property("value").toUInt32();
} else {
m->item().s_enum = value.toUInt32();
}
break;
}
case Marshall::ToQScriptValue:
{
QScriptValueList args;
args << (uint) m->item().s_enum << m->type().name();
*(m->var()) = JSmoke::Global::QtEnum.call(QScriptValue(), args);
break;
}
default:
m->unsupported();
break;
}
break;
case Smoke::t_class:
switch(m->action()) {
case Marshall::FromQScriptValue:
{
QScriptValue value = *(m->var());
if (value.isNull()) {
m->item().s_class = 0;
return;
}
if (value.isDate()) {
Smoke::ModuleIndex classId = Smoke::findClass(m->smoke()->classes[m->type().classId()].className);
if (classId == JSmoke::Global::QDateClassId) {
m->item().s_class = new QDate(value.toDateTime().date());
} else if (classId == JSmoke::Global::QDateTimeClassId) {
m->item().s_class = new QDateTime(value.toDateTime());
} else if (classId == JSmoke::Global::QTimeClassId) {
m->item().s_class = new QTime(value.toDateTime().time());
} else {
m->item().s_class = 0;
}
return;
} else if (value.isRegExp()) {
m->item().s_class = new QRegExp(value.toRegExp());
return;
}
if (!Object::Instance::isSmokeObject(value)) {
m->item().s_class = 0;
return;
}
Object::Instance * instance = Object::Instance::get(value);
void * ptr = instance->value;
if (!m->cleanup() && m->type().isStack()) {
ptr = constructCopy(instance);
}
ptr = instance->classId.smoke->cast( ptr,
instance->classId,
Smoke::ModuleIndex(m->smoke(), m->type().classId()) );
m->item().s_class = ptr;
break;