ClickHouse/dbms/programs/performance-test/JSONString.h

41 lines
821 B
C++
Raw Normal View History

2019-01-25 11:03:02 +00:00
#pragma once
#include <Core/Types.h>
#include <sys/stat.h>
#include <type_traits>
#include <vector>
#include <map>
namespace DB
{
/// NOTE The code is totally wrong.
class JSONString
{
private:
std::map<std::string, std::string> content;
2019-01-25 11:03:02 +00:00
size_t padding;
public:
explicit JSONString(size_t padding_ = 1) : padding(padding_) {}
void set(const std::string & key, std::string value, bool wrap = true);
2019-01-25 11:03:02 +00:00
template <typename T>
std::enable_if_t<std::is_arithmetic_v<T>> set(const std::string key, T value)
2019-01-25 11:03:02 +00:00
{
set(key, std::to_string(value), /*wrap= */ false);
}
void set(const std::string & key, const std::vector<JSONString> & run_infos);
2019-01-25 11:03:02 +00:00
std::string asString() const
2019-01-25 11:03:02 +00:00
{
return asString(padding);
}
std::string asString(size_t cur_padding) const;
2019-01-25 11:03:02 +00:00
};
2019-01-25 11:03:02 +00:00
}