aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/json.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/json.h')
-rw-r--r--kernel/json.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/kernel/json.h b/kernel/json.h
index 3ba355327..ae86b3aa6 100644
--- a/kernel/json.h
+++ b/kernel/json.h
@@ -38,18 +38,26 @@ class PrettyJson
ARRAY,
};
+ struct Target {
+ virtual void emit(const char *data) = 0;
+ virtual void flush() {};
+ virtual ~Target() {};
+ };
+
std::string newline_indent = "\n";
- std::vector<std::function<void(const char *)>> targets;
+ std::vector<std::unique_ptr<Target>> targets;
std::vector<Scope> state = {VALUE};
public:
void emit_to_log();
void append_to_string(std::string &target);
+ bool write_to_file(const std::string &path);
bool active() { return !targets.empty(); }
void line();
void raw(const char *raw_json);
+ void flush();
void begin_object();
void begin_array();
void end_object();