本文整理汇总了C++中var::isArray方法的典型用法代码示例。如果您正苦于以下问题:C++ var::isArray方法的具体用法?C++ var::isArray怎么用?C++ var::isArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类var
的用法示例。
在下文中一共展示了var::isArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkValueIsTheSame
bool Parameter::checkValueIsTheSame(var newValue, var oldValue)
{
if (oldValue.isArray())
{
if (!newValue.isArray()) return false;
if (newValue.size() != oldValue.size()) return false;
for (int i = 0; i < oldValue.size(); i++) if (oldValue[i] != newValue[i]) return false;
return true;
}
return newValue == oldValue;
}
示例2: createAndOwnIcon
Array<DrawableButton *> AppListComponent::createIconsFromJsonArray(const var &json) {
Array<DrawableButton *> buttons;
if (json.isArray()) {
for (const auto &item : *json.getArray()) {
auto name = item["name"];
auto shell = item["shell"];
auto iconPath = item["icon"];
if (name.isString() && shell.isString() && iconPath.isString()) {
auto icon = createAndOwnIcon(name, iconPath, shell);
if (icon) {
buttons.add(icon);
}
}
}
}
checkShowPageNav();
return buttons;
}
示例3: equality
bool compare::equality(var& x, var& y) {
// 1. If Type(x) is the same as Type(y), then
if (x.adapter->type == y.adapter->type) {
// 1. If Type(x) is Undefined, return true.
if (x.isUndefined())
return true;
// 2. If Type(x) is Null, return true.
if (x.isNull())
return true;
// 3. If Type(x) is Number, then
if (x.isNumber()) {
// 1. If x is NaN, return false.
// 2. If y is NaN, return false.
// (TODO: NaN checks?)
// 3. If x is the same Number value as y, return true.
if (x.numberValue == y.numberValue)
return true;
// 4. If x is +0 and y is -0, return true.
if (x.numberValue == +0 && y.numberValue == -0)
return true;
// 5. If x is -0 and y is +0, return true.
if (x.numberValue == -0 && y.numberValue == +0)
return true;
// 6. Return false.
return false;
}
// 4. If Type(x) is String, then return true if x and y are exactly the same sequence of characters
// (same length and same characters in corresponding positions). Otherwise, return false.
if (x.isString())
return x.stringValue == y.stringValue;
// 5. If Type(x) is Boolean, return true if x and y are both true or both false. Otherwise, return false.
if (x.isBoolean())
return x.booleanValue == y.booleanValue;
// 6. Return true if x and y refer to the same object. Otherwise, return false.
if (x.isObject())
return x.objectValue == y.objectValue;
if (x.isArray())
return x.arrayValue == y.arrayValue;
return false;
}
// 2. If x is null and y is undefined, return true.
if (x.isNull() && y.isUndefined())
return true;
// 3. If x is undefined and y is null, return true.
if (x.isUndefined() && y.isNull())
return true;
// 4. If Type(x) is Number and Type(y) is String,
// return the result of the comparison x == ToNumber(y).
if (x.isNumber() && y.isString())
return x == (number) y;
// 5. If Type(x) is String and Type(y) is Number,
// return the result of the comparison ToNumber(x) == y.
if (x.isString() && y.isNumber())
return (var) (number) x == y;
// 6. If Type(x) is Boolean,
// return the result of the comparison ToNumber(x) == y.
if (x.isBoolean())
return (var) (number) x == y;
// 7. If Type(y) is Boolean,
// return the result of the comparison x == ToNumber(y).
if (y.isBoolean())
return x == (number) y;
// 8. If Type(x) is either String or Number and Type(y) is Object,
// return the result of the comparison x == ToPrimitive(y).
if ((x.isString() || x.isNumber()) && (y.isObject() || y.isArray()))
return x == (string) y;
// 9. If Type(x) is Object and Type(y) is either String or Number,
// return the result of the comparison ToPrimitive(x) == y.
if ((x.isObject() || x.isArray()) && (y.isString() || y.isNumber()))
return (var) (string) x == y;
// 10. Return false.
return false;
}
示例4: toPrimitive
var compare::toPrimitive(var& x) {
if (!(x.isArray() || x.isObject()))
return x;
return (string) x;
}