| 1 | #pragma once |
|---|---|
| 2 | #include <Core/Types.h> |
| 3 | |
| 4 | #include <sys/stat.h> |
| 5 | #include <type_traits> |
| 6 | #include <vector> |
| 7 | #include <map> |
| 8 | |
| 9 | namespace DB |
| 10 | { |
| 11 | |
| 12 | /// NOTE The code is totally wrong. |
| 13 | class JSONString |
| 14 | { |
| 15 | private: |
| 16 | std::map<std::string, std::string> content; |
| 17 | size_t padding; |
| 18 | |
| 19 | public: |
| 20 | explicit JSONString(size_t padding_ = 1) : padding(padding_) {} |
| 21 | |
| 22 | void set(const std::string & key, std::string value, bool wrap = true); |
| 23 | |
| 24 | template <typename T> |
| 25 | std::enable_if_t<is_arithmetic_v<T>> set(const std::string key, T value) |
| 26 | { |
| 27 | set(key, std::to_string(value), /*wrap= */ false); |
| 28 | } |
| 29 | |
| 30 | void set(const std::string & key, const std::vector<JSONString> & run_infos); |
| 31 | |
| 32 | std::string asString() const |
| 33 | { |
| 34 | return asString(padding); |
| 35 | } |
| 36 | |
| 37 | std::string asString(size_t cur_padding) const; |
| 38 | }; |
| 39 | |
| 40 | } |
| 41 |