Refactoring: Changed all check parameters starting with a 'p' to the new rulespec...
[check_mk.git] / livestatus / src / RendererBrokenCSV.h
blobeef6011e353f29129add8735dacb226e781e4554
1 // +------------------------------------------------------------------+
2 // | ____ _ _ __ __ _ __ |
3 // | / ___| |__ ___ ___| | __ | \/ | |/ / |
4 // | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
5 // | | |___| | | | __/ (__| < | | | | . \ |
6 // | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
7 // | |
8 // | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
9 // +------------------------------------------------------------------+
11 // This file is part of Check_MK.
12 // The official homepage is at http://mathias-kettner.de/check_mk.
14 // check_mk is free software; you can redistribute it and/or modify it
15 // under the terms of the GNU General Public License as published by
16 // the Free Software Foundation in version 2. check_mk is distributed
17 // in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
18 // out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
19 // PARTICULAR PURPOSE. See the GNU General Public License for more de-
20 // tails. You should have received a copy of the GNU General Public
21 // License along with GNU Make; see the file COPYING. If not, write
22 // to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 // Boston, MA 02110-1301 USA.
25 #ifndef RendererBrokenCSV_h
26 #define RendererBrokenCSV_h
28 #include "config.h" // IWYU pragma: keep
29 #include <iosfwd>
30 #include <string>
31 #include <utility>
32 #include <vector>
33 #include "Renderer.h"
34 #include "data_encoding.h"
35 class Logger;
37 class CSVSeparators {
38 public:
39 CSVSeparators(std::string dataset, std::string field, std::string list,
40 std::string host_service)
41 : _dataset(std::move(dataset))
42 , _field(std::move(field))
43 , _list(std::move(list))
44 , _host_service(std::move(host_service)) {}
46 std::string dataset() const { return _dataset; }
47 std::string field() const { return _field; }
48 std::string list() const { return _list; }
49 std::string hostService() const { return _host_service; }
51 private:
52 std::string _dataset;
53 std::string _field;
54 std::string _list;
55 std::string _host_service;
58 // A broken CSV renderer, just for backwards compatibility with old Livestatus
59 // versions.
60 class RendererBrokenCSV : public Renderer {
61 public:
62 RendererBrokenCSV(std::ostream& os, Logger* logger,
63 CSVSeparators separators, Encoding data_encoding)
64 : Renderer(os, logger, data_encoding)
65 , _separators(std::move(separators)) {}
67 void outputNull() override;
68 void outputBlob(const std::vector<char>& value) override;
69 void outputString(const std::string& value) override;
71 void beginQuery() override;
72 void separateQueryElements() override;
73 void endQuery() override;
75 void beginRow() override;
76 void beginRowElement() override;
77 void endRowElement() override;
78 void separateRowElements() override;
79 void endRow() override;
81 void beginList() override;
82 void separateListElements() override;
83 void endList() override;
85 void beginSublist() override;
86 void separateSublistElements() override;
87 void endSublist() override;
89 void beginDict() override;
90 void separateDictElements() override;
91 void separateDictKeyValue() override;
92 void endDict() override;
94 private:
95 const CSVSeparators _separators;
98 #endif // RendererBrokenCSV_h