提交 486a8e47 编写于 作者: D Dawid Zamirski 提交者: Michal Privoznik

esx: add esxVI_GetInt

Modeled after the already existing esxVI_GetLong.
上级 17ab5bc0
......@@ -2412,6 +2412,38 @@ esxVI_GetBoolean(esxVI_ObjectContent *objectContent, const char *propertyName,
int
esxVI_GetInt(esxVI_ObjectContent *objectContent, const char *propertyName,
esxVI_Int **value, esxVI_Occurrence occurence)
{
esxVI_DynamicProperty *dynamicProperty;
if (!value || *value) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
return -1;
}
for (dynamicProperty = objectContent->propSet; dynamicProperty;
dynamicProperty = dynamicProperty->_next) {
if (STREQ(dynamicProperty->name, propertyName)) {
if (esxVI_Int_CastFromAnyType(dynamicProperty->val, value) < 0)
return -1;
break;
}
}
if (!(*value) && occurence == esxVI_Occurrence_RequiredItem) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing '%s' property"), propertyName);
return -1;
}
return 0;
}
int
esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
esxVI_Long **value, esxVI_Occurrence occurrence)
......
......@@ -338,6 +338,9 @@ int esxVI_GetBoolean(esxVI_ObjectContent *objectContent,
const char *propertyName,
esxVI_Boolean *value, esxVI_Occurrence occurrence);
int esxVI_GetInt(esxVI_ObjectContent *objectContent, const char *propertyName,
esxVI_Int **value, esxVI_Occurrence occurrence);
int esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName,
esxVI_Long **value, esxVI_Occurrence occurrence);
......
......@@ -1376,6 +1376,9 @@ ESX_VI__TEMPLATE__DEEP_COPY(Int,
(*dest)->value = src->value;
})
/* esxVI_Int_CastFromAnyType */
ESX_VI__TEMPLATE__CAST_FROM_ANY_TYPE(Int)
/* esxVI_Int_Serialize */
ESX_VI__TEMPLATE__SERIALIZE(Int,
{
......
......@@ -241,6 +241,7 @@ void esxVI_Int_Free(esxVI_Int **numberList);
int esxVI_Int_Validate(esxVI_Int *number);
int esxVI_Int_AppendToList(esxVI_Int **numberList, esxVI_Int *number);
int esxVI_Int_DeepCopy(esxVI_Int **dest, esxVI_Int *src);
int esxVI_Int_CastFromAnyType(esxVI_AnyType *anyType, esxVI_Int **number);
int esxVI_Int_Serialize(esxVI_Int *number, const char *element,
virBufferPtr output);
int esxVI_Int_SerializeList(esxVI_Int *numberList, const char *element,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册