mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
util: json: Introduce virJSONValueObjectAppendStringPrintf
Add a variant similar to virJSONValueObjectAppendString which also formats more complex value strings with printf syntax. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
003f063dd6
commit
9c9732d03a
@ -2361,6 +2361,7 @@ virJSONValueObjectAppendNumberLong;
|
|||||||
virJSONValueObjectAppendNumberUint;
|
virJSONValueObjectAppendNumberUint;
|
||||||
virJSONValueObjectAppendNumberUlong;
|
virJSONValueObjectAppendNumberUlong;
|
||||||
virJSONValueObjectAppendString;
|
virJSONValueObjectAppendString;
|
||||||
|
virJSONValueObjectAppendStringPrintf;
|
||||||
virJSONValueObjectCreate;
|
virJSONValueObjectCreate;
|
||||||
virJSONValueObjectCreateVArgs;
|
virJSONValueObjectCreateVArgs;
|
||||||
virJSONValueObjectDeflatten;
|
virJSONValueObjectDeflatten;
|
||||||
|
@ -649,6 +649,23 @@ virJSONValueObjectAppendString(virJSONValuePtr object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virJSONValueObjectAppendStringPrintf(virJSONValuePtr object,
|
||||||
|
const char *key,
|
||||||
|
const char *fmt,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
g_autofree char *str = NULL;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
str = g_strdup_vprintf(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return virJSONValueObjectInsertString(object, key, str, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virJSONValueObjectPrependString(virJSONValuePtr object,
|
virJSONValueObjectPrependString(virJSONValuePtr object,
|
||||||
const char *key,
|
const char *key,
|
||||||
|
@ -127,6 +127,8 @@ int virJSONValueObjectGetBoolean(virJSONValuePtr object, const char *key, bool *
|
|||||||
int virJSONValueObjectIsNull(virJSONValuePtr object, const char *key);
|
int virJSONValueObjectIsNull(virJSONValuePtr object, const char *key);
|
||||||
|
|
||||||
int virJSONValueObjectAppendString(virJSONValuePtr object, const char *key, const char *value);
|
int virJSONValueObjectAppendString(virJSONValuePtr object, const char *key, const char *value);
|
||||||
|
int virJSONValueObjectAppendStringPrintf(virJSONValuePtr object, const char *key, const char *fmt, ...)
|
||||||
|
G_GNUC_PRINTF(3, 4);
|
||||||
int virJSONValueObjectPrependString(virJSONValuePtr object, const char *key, const char *value);
|
int virJSONValueObjectPrependString(virJSONValuePtr object, const char *key, const char *value);
|
||||||
int virJSONValueObjectAppendNumberInt(virJSONValuePtr object, const char *key, int number);
|
int virJSONValueObjectAppendNumberInt(virJSONValuePtr object, const char *key, int number);
|
||||||
int virJSONValueObjectAppendNumberUint(virJSONValuePtr object, const char *key, unsigned int number);
|
int virJSONValueObjectAppendNumberUint(virJSONValuePtr object, const char *key, unsigned int number);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user