]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: buffer: Add init macro for automatically setting child XML indent
authorPeter Krempa <pkrempa@redhat.com>
Fri, 25 Oct 2019 13:22:12 +0000 (15:22 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 13 Nov 2019 08:10:29 +0000 (09:10 +0100)
Add a new macro which initializes a virBuffer on the stack and also sets
the indent level to be used for child XML element formatting.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virbuffer.h

index 8eb9608c71676883bdb18f308bc254696f0ca39f..a2e30c07dcbab71d4d51fa1af4e42392f9e2ddfd 100644 (file)
@@ -35,6 +35,15 @@ typedef virBuffer *virBufferPtr;
 
 #define VIR_BUFFER_INITIALIZER { NULL, 0 }
 
+/**
+ * VIR_BUFFER_INIT_CHILD:
+ * @parentbuf: parent buffer for XML element formatting
+ *
+ * Intitialize a virBuffer structure and set up the indentation level for
+ * formatting XML subelements of @parentbuf.
+ */
+#define VIR_BUFFER_INIT_CHILD(parentbuf) { NULL, (parentbuf)->indent + 2 }
+
 struct _virBuffer {
     GString *str;
     int indent;