25#include <fmt/format.h>
26#include <msgpack_light/output_stream.h>
27#include <msgpack_light/serialize.h>
40class CompressedMsgpackOutputFileStream :
public msgpack_light::output_stream {
47 explicit CompressedMsgpackOutputFileStream(
const std::string& file_path)
48 : file_(gzopen(file_path.c_str(),
"wb9")) {
49 if (file_ ==
nullptr) {
50 throw StatBenchException(
51 fmt::format(FMT_STRING(
"Failed to open {}."), file_path));
55 CompressedMsgpackOutputFileStream(
56 const CompressedMsgpackOutputFileStream&) =
delete;
57 CompressedMsgpackOutputFileStream(
58 CompressedMsgpackOutputFileStream&&) =
delete;
59 auto operator=(
const CompressedMsgpackOutputFileStream&)
60 -> CompressedMsgpackOutputFileStream& =
delete;
61 auto operator=(CompressedMsgpackOutputFileStream&&)
62 -> CompressedMsgpackOutputFileStream& =
delete;
67 ~CompressedMsgpackOutputFileStream() { (void)gzclose(file_); }
75 void write(
const unsigned char* data, std::size_t size)
override {
76 if (gzwrite(file_, data, size) !=
static_cast<int>(size)) {
77 throw StatBenchException(
"Failed to write data.");
93 CompressedMsgpackOutputFileStream stream{file_path};
94 msgpack_light::serialize_to(stream, data);
void write_data_file(const std::string &file_path, const data_file_spec::RootData &data) override
Write a data file.
CompressedMsgPackReporter(std::string file_path)
Constructor.
DataFileReporterBase(std::string file_path)
Constructor.
Definition of CompressedMsgPackReporter class.
Helper of MsgPack data files.
Namespace of reporters of results of benchmarks.
void prepare_directory_for(const std::string &path)
Prepare a directory for a file.
Namespace of stat_bench source codes.
Declaration of prepare_directory function.
Definition of StatBenchException class.
Struct of root objects in data files.