rm ingored
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
void OutputOptions::update_column(Column &column, unsigned short index) {
|
||||
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;
|
||||
}
|
||||
|
||||
Column &OutputOptions::get_column(ColumnType t) {
|
||||
return this->order[find_column(t)];
|
||||
}
|
||||
|
||||
std::vector<Column> &OutputOptions::get_columns() { return this->order; }
|
||||
|
||||
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; }
|
||||
@@ -1,62 +0,0 @@
|
||||
#ifndef OUTPUT_OPTIONS_H
|
||||
#define OUTPUT_OPTIONS_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../net/net.h"
|
||||
#include "../settings/settings.h"
|
||||
|
||||
enum class ColumnType {
|
||||
goods_name,
|
||||
goods_price_per_unit,
|
||||
goods_quantity,
|
||||
goods_net_weight,
|
||||
goods_total
|
||||
};
|
||||
|
||||
struct Column { // Example:
|
||||
ColumnType type; // goods_name
|
||||
std::string name; // "Товар"
|
||||
unsigned int position; // "0" <-- 0 = "A", 1 = "B", etc.. column letter in
|
||||
// table processor (i.e. excel or libreoffice)
|
||||
} typedef Column;
|
||||
enum class OutputFormat { csv, ods, xlsx, plaintext } typedef OutputFormat;
|
||||
|
||||
class OutputOptions {
|
||||
|
||||
std::vector<Column> order;
|
||||
bool print_header;
|
||||
bool print_total;
|
||||
OutputFormat format;
|
||||
std::string path;
|
||||
|
||||
public:
|
||||
OutputOptions();
|
||||
|
||||
void add_or_update_column(Column &);
|
||||
void update_column(Column&, unsigned short);
|
||||
void remove_column(unsigned short);
|
||||
void remove_column(ColumnType);
|
||||
unsigned short find_column(ColumnType);
|
||||
bool column_exist(ColumnType);
|
||||
Column& get_column(ColumnType);
|
||||
std::vector<Column>& get_columns();
|
||||
|
||||
void set_print_header(bool);
|
||||
bool get_print_header();
|
||||
|
||||
void set_print_total(bool);
|
||||
bool get_print_total();
|
||||
|
||||
void set_output_format(OutputFormat);
|
||||
OutputFormat get_output_format();
|
||||
|
||||
void set_path(std::string);
|
||||
std::string &get_path();
|
||||
};
|
||||
|
||||
#endif // OUTPUT_OPTIONS_H
|
||||
Reference in New Issue
Block a user