Received: from eggs.gnu.org ([2001:4830:134:3::10]:55326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axELe-0007ip-2E for qemu-devel@nongnu.org; Mon, 02 May 2016 09:57:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axELS-00025e-Dr for qemu-devel@nongnu.org; Mon, 02 May 2016 09:57:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axELS-00023v-8l for qemu-devel@nongnu.org; Mon, 02 May 2016 09:57:06 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C89F563177 for ; Mon, 2 May 2016 13:56:54 +0000 (UTC) From: Markus Armbruster References: <1461903820-3092-1-git-send-email-eblake@redhat.com> <1461903820-3092-13-git-send-email-eblake@redhat.com> Date: Mon, 02 May 2016 15:56:52 +0200 In-Reply-To: <1461903820-3092-13-git-send-email-eblake@redhat.com> (Eric Blake's message of "Thu, 28 Apr 2016 22:23:33 -0600") Message-ID: <87h9egk1gb.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v3 12/18] qapi: Add qobject_to_json_pretty_prefix() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, famz@redhat.com, Luiz Capitulino Eric Blake writes: > The next patch will add pretty indentation to the JSON visitor. > But in order to support pretty output in the type_any() callback, > we need to prefix every line of the QObject visitor by the current > indentation in the JSON visitor. Hence, a new function > qobject_to_json_pretty_indent(), and the old function becomes a > thin wrapper to the expanded behavior. > > While at it, change 'pretty' to be a bool, to match its usage. > > Note that the new simple_pretty() test is a bit sensitive to our > current notion of prettiness, as well as to the hash ordering in > QDict (most of the tests in check-qobject-json intentionally do > not compare the original string to the round-trip string, because > we liberally accept more input forms than the canonical form that > we output). > > Signed-off-by: Eric Blake > > --- > v3: no change > v2: no change > --- > include/qapi/qmp/qobject-json.h | 1 + > qobject/qobject-json.c | 40 ++++++++++++++++++------- > tests/check-qobject-json.c | 65 +++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 95 insertions(+), 11 deletions(-) > > diff --git a/include/qapi/qmp/qobject-json.h b/include/qapi/qmp/qobject-json.h > index 02b1f2c..d420c71 100644 > --- a/include/qapi/qmp/qobject-json.h > +++ b/include/qapi/qmp/qobject-json.h > @@ -23,5 +23,6 @@ QObject *qobject_from_jsonv(const char *string, va_list *ap) GCC_FMT_ATTR(1, 0); > > QString *qobject_to_json(const QObject *obj); > QString *qobject_to_json_pretty(const QObject *obj); > +QString *qobject_to_json_pretty_prefix(const QObject *obj, const char *prefix); Why a string prefix, and not indentation? > > #endif /* QJSON_H */ [...]