fpmas 1.6
json_output.h
Go to the documentation of this file.
1#ifndef FPMAS_JSON_OUTPUT_H
2#define FPMAS_JSON_OUTPUT_H
3
4#include "output.h"
5
10namespace fpmas { namespace io {
11
18 template<typename T>
19 class JsonOutput : public OutputBase {
20 private:
21 Watcher<T> watcher;
22 int indent_level;
23
24 public:
34 JsonOutput(api::io::OutputStream& output_stream, Watcher<T> watcher, bool indent = false)
35 : OutputBase(output_stream), watcher(watcher), indent_level(indent ? 4 : -1) {
36 }
37
44 void dump() override {
45 nlohmann::json j = watcher();
46 output_stream.get() << j.dump(indent_level);
47 }
48 };
49}}
50#endif
Definition: json_output.h:19
JsonOutput(api::io::OutputStream &output_stream, Watcher< T > watcher, bool indent=false)
Definition: json_output.h:34
void dump() override
Definition: json_output.h:44
Definition: output.h:571
api::io::OutputStream & output_stream
Definition: output.h:580
Definition: fpmas.cpp:3
Definition: output.h:67
virtual std::ostream & get()=0