mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00: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
|
# util/virjson.h
|
||||||
virJSONStringReformat;
|
virJSONStringReformat;
|
||||||
virJSONValueArrayAppend;
|
virJSONValueArrayAppend;
|
||||||
|
virJSONValueArrayAppendString;
|
||||||
virJSONValueArrayForeachSteal;
|
virJSONValueArrayForeachSteal;
|
||||||
virJSONValueArrayGet;
|
virJSONValueArrayGet;
|
||||||
virJSONValueArraySize;
|
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
|
int
|
||||||
virJSONValueObjectHasKey(virJSONValuePtr object,
|
virJSONValueObjectHasKey(virJSONValuePtr object,
|
||||||
const char *key)
|
const char *key)
|
||||||
|
@ -138,6 +138,8 @@ int virJSONValueObjectRemoveKey(virJSONValuePtr object, const char *key,
|
|||||||
virJSONValuePtr *value)
|
virJSONValuePtr *value)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||||
|
|
||||||
|
int virJSONValueArrayAppendString(virJSONValuePtr object, const char *value);
|
||||||
|
|
||||||
virJSONValuePtr virJSONValueFromString(const char *jsonstring);
|
virJSONValuePtr virJSONValueFromString(const char *jsonstring);
|
||||||
char *virJSONValueToString(virJSONValuePtr object,
|
char *virJSONValueToString(virJSONValuePtr object,
|
||||||
bool pretty);
|
bool pretty);
|
||||||
|
Loading…
Reference in New Issue
Block a user