Skip to content

File column_width_tracker.h

File List > benchmark > exporter > column_width_tracker.h

Go to the documentation of this file

#pragma once

#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>

#include "worksheet.h"

namespace Argos {

class ColumnWidthTracker {
public:
    void measureString(int col, const std::string &text);
    void measureInt(int col, int64_t value);
    void measureDouble(int col, double value, const char *fmt = "%.3f");

    void applyToWorksheet(lxw_worksheet *ws) const;

private:
    void ensureCol(int col);

    std::vector<size_t> widths;
    static constexpr size_t MIN_WIDTH = 8;
    static constexpr double PADDING = 2.0;
};

} // namespace Argos