mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 13:17:58 +03:00
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: Eric Blake <eblake@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
4ea5a41e16
commit
484370dcf1
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user