2024-08-30 05:03:32 +03:00
|
|
|
#include "output_options.h"
|
|
|
|
|
|
|
|
OutputOptions::OutputOptions() {}
|
|
|
|
|
|
|
|
void OutputOptions::add_or_update_column(Column &column) {
|
|
|
|
if (column_exist(column.type)) {
|
|
|
|
update_column(column, find_column(column.type));
|
|
|
|
} else {
|
|
|
|
this->order.push_back(column);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-05 13:52:44 +03:00
|
|
|
void OutputOptions::update_column(Column &column, unsigned short index) {
|
2024-08-30 05:03:32 +03:00
|
|
|
this->order[index] = column;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OutputOptions::remove_column(unsigned short index) {
|
|
|
|
this->order.erase(this->order.begin() + index);
|
|
|
|
}
|
|
|
|
void OutputOptions::remove_column(ColumnType t) {
|
|
|
|
this->order.erase(this->order.begin() + find_column(t));
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned short OutputOptions::find_column(ColumnType t) {
|
|
|
|
for (unsigned short i = 0; i < this->order.size(); i++) {
|
|
|
|
if (this->order[i].type == t)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OutputOptions::column_exist(ColumnType t) {
|
|
|
|
for (unsigned short i = 0; i < this->order.size(); i++) {
|
|
|
|
if (this->order[i].type == t)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-10-05 13:52:44 +03:00
|
|
|
Column &OutputOptions::get_column(ColumnType t) {
|
2024-08-30 05:03:32 +03:00
|
|
|
return this->order[find_column(t)];
|
|
|
|
}
|
|
|
|
|
2024-10-05 13:52:44 +03:00
|
|
|
std::vector<Column> &OutputOptions::get_columns() { return this->order; }
|
2024-08-30 05:03:32 +03:00
|
|
|
|
|
|
|
void OutputOptions::set_print_header(bool value) { this->print_header = value; }
|
|
|
|
bool OutputOptions::get_print_header() { return this->print_header; }
|
|
|
|
|
|
|
|
void OutputOptions::set_print_total(bool value) { this->print_total = value; }
|
|
|
|
bool OutputOptions::get_print_total() { return this->print_total; }
|
|
|
|
|
|
|
|
OutputFormat OutputOptions::get_output_format() { return this->format; }
|
|
|
|
void OutputOptions::set_output_format(OutputFormat format) {
|
|
|
|
this->format = format;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OutputOptions::set_path(std::string path) { this->path = path; }
|
|
|
|
std::string &OutputOptions::get_path() { return this->path; }
|