本文整理汇总了C++中al::ALValue::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ ALValue::getType方法的具体用法?C++ ALValue::getType怎么用?C++ ALValue::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类al::ALValue
的用法示例。
在下文中一共展示了ALValue::getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseWordRecognizedArray
void ParseWordRecognizedArray(std::vector<WordConfidencePair>& results, const AL::ALValue& value, float recognitionThreshold)
{
// unexpected data
if (value.getType() != AL::ALValue::TypeArray)
MODULE_ERROR("invalid array type");
// unexpected data
if (value.getSize() % 2 != 0)
MODULE_ERROR("invalid array size");
for (int i = 0; i < (int)value.getSize(); i += 2)
{
AL::ALValue wordValue = value[i];
AL::ALValue confidenceValue = value[i + 1];
float confidence = confidenceValue.operator float &();
if (confidence >= recognitionThreshold)
{
WordConfidencePair pair = { wordValue.toString(), confidence };
results.push_back(pair);
}
}
std::sort(results.begin(), results.end(), WordConfidencePairComparison());
}
示例2: CallReturnVariable
gmVariable GMALProxy::CallReturnVariable(const char* function, gmVariable arg)
{
const std::string function_string = std::string(function);
AL::ALValue result = AL::ALValue();
switch (arg.m_type)
{
case GM_INT: result = _proxy.call<AL::ALValue>(function_string, arg.GetInt()); break;
case GM_FLOAT: result = _proxy.call<AL::ALValue>(function_string, arg.GetFloat()); break;
case GM_VEC2: result = _proxy.call<AL::ALValue>(function_string, arg.GetVec2().x, arg.GetVec2().y); break;
case GM_STRING: result = _proxy.call<AL::ALValue>(function_string, std::string(arg.GetCStringSafe())); break;
default: result = _proxy.call<AL::ALValue>(function_string); break;
}
gmVariable result_variable;
result_variable.Nullify();
switch (result.getType())
{
case AL::ALValue::TypeBool: result_variable = gmVariable(int(result.operator bool &() ? 1 : 0)); break;
case AL::ALValue::TypeInt: result_variable = gmVariable(int(result.operator int &())); break;
case AL::ALValue::TypeFloat: result_variable = gmVariable(float(result.operator float &())); break;
case AL::ALValue::TypeString: result_variable = gmVariable(VirtualMachine::Get()->GetVM().AllocStringObject(result.toString().c_str())); break;
default:
break;
}
return result_variable;
}
示例3: fromALValue
void Variant::fromALValue(const AL::ALValue &val)
{
if (val.getType() == AL::ALValue::TypeInvalid)
{
// nothing to do
}
else if (val.getType() == AL::ALValue::TypeArray)
{
fType = VARRAY;
fValue = val;
}
else if (val.getType()==AL::ALValue::TypeInt)
{
fType = VINT;
fValue = val;
}
else if (val.getType()== AL::ALValue::TypeString)
{
fType == VSTRING;
fValue = val;
}
else if (val.getType()== AL::ALValue::TypeBinary)
{
fType == VCHARARRAY;
fValue = val;
}
else if (val.getType()== AL::ALValue::TypeBool)
{
fType == VBOOL;
fValue = val;
}
else if (val.getType()== AL::ALValue::TypeFloat)
{
fType == VFLOAT;
fValue = val;
}
else
{
printf("unknow type %d\n",val.getType());
}
}