For automatic section scoping
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
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);