MCPcopy Create free account
hub / github.com/ceph/ceph / JSONFormatterFile

Class JSONFormatterFile

src/common/JSONFormatterFile.h:12–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10namespace ceph {
11
12 class JSONFormatterFile : public JSONFormatter {
13public:
14 JSONFormatterFile(const std::string& path, bool pretty=false) :
15 JSONFormatter(pretty),
16 path(path),
17 file(path, std::ios::out | std::ios::trunc)
18 {
19 }
20 ~JSONFormatterFile() {
21 flush();
22 }
23
24 void flush(std::ostream& os) override {
25 flush();
26 }
27 void flush() {
28 JSONFormatter::finish_pending_string();
29 file.flush();
30 }
31
32 void reset() override {
33 JSONFormatter::reset();
34 file = std::ofstream(path, std::ios::out | std::ios::trunc);
35 }
36 int get_len() const override {
37 return file.tellp();
38 }
39 std::ofstream const& get_ofstream() const {
40 return file;
41 }
42
43protected:
44 std::ostream& get_ss() override {
45 return file;
46 }
47
48private:
49 std::string path;
50 mutable std::ofstream file; // mutable for get_len
51 };
52
53}
54

Callers 2

handle_asok_commandMethod · 0.85
command_dump_treeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected