From: Yehuda Sadeh Date: Mon, 15 Jan 2018 22:22:07 +0000 (-0800) Subject: formatter: add two utility classes X-Git-Tag: v13.1.0~270^2~29 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=28bc88b7cd5988bd9df722b1382833c8890a7e79;p=ceph.git formatter: add two utility classes For automatic section scoping Signed-off-by: Yehuda Sadeh --- diff --git a/src/common/Formatter.h b/src/common/Formatter.h index 8cfcc0b0a77..4a9ac3210e0 100644 --- a/src/common/Formatter.h +++ b/src/common/Formatter.h @@ -23,6 +23,29 @@ namespace ceph { class Formatter { public: + class ObjectSection { + Formatter& formatter; + + public: + ObjectSection(Formatter& f, const char *name) : formatter(f) { + formatter.open_object_section(name); + } + ~ObjectSection() { + formatter.close_section(); + } + }; + class ArraySection { + Formatter& formatter; + + public: + ArraySection(Formatter& f, const char *name) : formatter(f) { + formatter.open_array_section(name); + } + ~ArraySection() { + formatter.close_section(); + } + }; + static Formatter *create(std::string_view type, std::string_view default_type, std::string_view fallback);