本文整理汇总了C++中KviKvsVariant::asReal方法的典型用法代码示例。如果您正苦于以下问题:C++ KviKvsVariant::asReal方法的具体用法?C++ KviKvsVariant::asReal怎么用?C++ KviKvsVariant::asReal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KviKvsVariant
的用法示例。
在下文中一共展示了KviKvsVariant::asReal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
//.........这里部分代码省略.........
v->appendAsString(tmp);
v = pVariantList->next();
}
*((QByteArray *)(pFmtArray->pContainer)) = tmp.toUtf8();
bDoReturn = true;
}
*((QByteArray *)(pFmtArray->pContainer)) = tmp.toUtf8();
if(((QByteArray *)(pFmtArray->pContainer))->isEmpty())
{
QString szError = QString(__tr2qs_ctx("Invalid data type for parameter \"%1\": found empty string while a non empty one was expected", "kvs")).arg(pFmtArray->szName);
pContext->error(szError);
return false;
}
if(bDoReturn)
return true;
}
break;
case KVS_PT_INT:
if(!v->asInteger(*((kvs_int_t *)(pFmtArray->pContainer))))
{
if(!handleParameterTypeError(pContext, pFmtArray, v, "integer"))
return false;
}
break;
case KVS_PT_UINT:
{
kvs_int_t iTmp;
if(!v->asInteger(iTmp))
{
if(!handleParameterTypeError(pContext, pFmtArray, v, "unsigned integer"))
return false;
}
if(iTmp < 0)
{
QString szError = QString(__tr2qs_ctx("Invalid data type for parameter \"%1\": found signed integer \"%2\" where type 'unsigned integer' was expected", "kvs")).arg(pFmtArray->szName).arg(iTmp);
pContext->error(szError);
return false;
}
*((kvs_uint_t *)(pFmtArray->pContainer)) = (kvs_uint_t)iTmp;
}
break;
case KVS_PT_DOUBLE:
if(!v->asReal(*((kvs_real_t *)(pFmtArray->pContainer))))
{
if(!handleParameterTypeError(pContext, pFmtArray, v, "real"))
return false;
}
break;
case KVS_PT_HASH:
if(!v->isHash())
{
if(!handleParameterTypeError(pContext, pFmtArray, v, "hash"))
return false;
}
else
{
*((KviKvsHash **)(pFmtArray->pContainer)) = v->hash();
}
break;
case KVS_PT_ARRAYCAST:
v->castToArray((KviKvsArrayCast *)(pFmtArray->pContainer));
break;
case KVS_PT_ARRAY:
if(!v->isArray())
{
if(!handleParameterTypeError(pContext, pFmtArray, v, "array"))
return false;
}
else
{
*((KviKvsArray **)(pFmtArray->pContainer)) = v->array();
}
break;
case KVS_PT_BOOL:
// this never fails: anything is converted to a boolean
*((bool *)(pFmtArray->pContainer)) = v->asBoolean();
break;
case KVS_PT_VARIANT:
*((KviKvsVariant **)(pFmtArray->pContainer)) = v;
break;
case KVS_PT_HOBJECT:
if(!v->asHObject(*((kvs_hobject_t *)(pFmtArray->pContainer))))
{
if(!handleParameterTypeError(pContext, pFmtArray, v, "hobject"))
return false;
}
break;
case KVS_PT_IGNORE:
// ignore
break;
default:
qDebug("Internal error in KviKvsParameterProcessor::processAsParameters(): unknown parameter type %d", pFmtArray->uType);
return false;
break;
}
pFmtArray++;
v = pVariantList->next();
}
return true;
}