提交 484370dc 编写于 作者: E Eric Blake

virjson: add convenience wrapper for appending string to array

Upcoming patches need an array of strings for use in QMP
block-dirty-bitmap-merge.  A convenience wrapper cuts down
on the verbosity of creating the array, similar to the
existing virJSONValueObjectAppendString().
Signed-off-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 4ea5a41e
......@@ -2092,6 +2092,7 @@ virISCSIScanTargets;
# util/virjson.h
virJSONStringReformat;
virJSONValueArrayAppend;
virJSONValueArrayAppendString;
virJSONValueArrayForeachSteal;
virJSONValueArrayGet;
virJSONValueArraySize;
......
......@@ -795,6 +795,21 @@ virJSONValueArrayAppend(virJSONValuePtr array,
}
int
virJSONValueArrayAppendString(virJSONValuePtr object,
const char *value)
{
virJSONValuePtr jvalue = virJSONValueNewString(value);
if (!jvalue)
return -1;
if (virJSONValueArrayAppend(object, jvalue) < 0) {
virJSONValueFree(jvalue);
return -1;
}
return 0;
}
int
virJSONValueObjectHasKey(virJSONValuePtr object,
const char *key)
......
......@@ -138,6 +138,8 @@ int virJSONValueObjectRemoveKey(virJSONValuePtr object, const char *key,
virJSONValuePtr *value)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
int virJSONValueArrayAppendString(virJSONValuePtr object, const char *value);
virJSONValuePtr virJSONValueFromString(const char *jsonstring);
char *virJSONValueToString(virJSONValuePtr object,
bool pretty);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册