overte-JulianGro/libraries/shared/src/ScriptValueUtils.cpp
Anthony J. Thibault 38418d0169 Moved isListOfStrings into shared/ScriptValueUtils
Also fixed some single line ifs.
2016-04-15 13:47:30 -07:00

34 lines
777 B
C++

//
// ScriptValueUtils.cpp
// libraries/shared/src
//
// Created by Anthony Thibault on 4/15/16.
// Copyright 2016 High Fidelity, Inc.
//
// Utilities for working with QtScriptValues
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "ScriptValueUtils.h"
bool isListOfStrings(const QScriptValue& arg) {
if (!arg.isArray()) {
return false;
}
auto lengthProperty = arg.property("length");
if (!lengthProperty.isNumber()) {
return false;
}
int length = lengthProperty.toInt32();
for (int i = 0; i < length; i++) {
if (!arg.property(i).isString()) {
return false;
}
}
return true;
}