Skip to content

Commit

Permalink
Made methods 'inline' to fix #29
Browse files Browse the repository at this point in the history
  • Loading branch information
p-ranav committed Jan 4, 2020
1 parent 1682244 commit 1b32269
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 47 deletions.
72 changes: 36 additions & 36 deletions include/tabulate/column.hpp
Expand Up @@ -157,217 +157,217 @@ class Column {
std::weak_ptr<class TableInternal> parent_;
};

ColumnFormat &ColumnFormat::width(size_t value) {
inline ColumnFormat &ColumnFormat::width(size_t value) {
for (auto &cell : column_.get().cells_)
cell.get().format().width(value);
return *this;
}

ColumnFormat &ColumnFormat::height(size_t value) {
inline ColumnFormat &ColumnFormat::height(size_t value) {
for (auto &cell : column_.get().cells_)
cell.get().format().height(value);
return *this;
}

ColumnFormat &ColumnFormat::padding(size_t value) {
inline ColumnFormat &ColumnFormat::padding(size_t value) {
for (auto &cell : column_.get().cells_)
cell.get().format().padding(value);
return *this;
}

ColumnFormat &ColumnFormat::padding_left(size_t value) {
inline ColumnFormat &ColumnFormat::padding_left(size_t value) {
for (auto &cell : column_.get().cells_)
cell.get().format().padding_left(value);
return *this;
}

ColumnFormat &ColumnFormat::padding_right(size_t value) {
inline ColumnFormat &ColumnFormat::padding_right(size_t value) {
for (auto &cell : column_.get().cells_)
cell.get().format().padding_right(value);
return *this;
}

ColumnFormat &ColumnFormat::padding_top(size_t value) {
inline ColumnFormat &ColumnFormat::padding_top(size_t value) {
for (auto &cell : column_.get().cells_)
cell.get().format().padding_top(value);
return *this;
}

ColumnFormat &ColumnFormat::padding_bottom(size_t value) {
inline ColumnFormat &ColumnFormat::padding_bottom(size_t value) {
for (auto &cell : column_.get().cells_)
cell.get().format().padding_bottom(value);
return *this;
}

ColumnFormat &ColumnFormat::border(const std::string &value) {
inline ColumnFormat &ColumnFormat::border(const std::string &value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border(value);
return *this;
}

ColumnFormat &ColumnFormat::border_color(Color value) {
inline ColumnFormat &ColumnFormat::border_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_color(value);
return *this;
}

ColumnFormat &ColumnFormat::border_background_color(Color value) {
inline ColumnFormat &ColumnFormat::border_background_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_background_color(value);
return *this;
}

ColumnFormat &ColumnFormat::border_left(const std::string &value) {
inline ColumnFormat &ColumnFormat::border_left(const std::string &value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_left(value);
return *this;
}

ColumnFormat &ColumnFormat::border_left_color(Color value) {
inline ColumnFormat &ColumnFormat::border_left_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_left_color(value);
return *this;
}

ColumnFormat &ColumnFormat::border_left_background_color(Color value) {
inline ColumnFormat &ColumnFormat::border_left_background_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_left_background_color(value);
return *this;
}

ColumnFormat &ColumnFormat::border_right(const std::string &value) {
inline ColumnFormat &ColumnFormat::border_right(const std::string &value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_right(value);
return *this;
}

ColumnFormat &ColumnFormat::border_right_color(Color value) {
inline ColumnFormat &ColumnFormat::border_right_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_right_color(value);
return *this;
}

ColumnFormat &ColumnFormat::border_right_background_color(Color value) {
inline ColumnFormat &ColumnFormat::border_right_background_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_right_background_color(value);
return *this;
}

ColumnFormat &ColumnFormat::border_top(const std::string &value) {
inline ColumnFormat &ColumnFormat::border_top(const std::string &value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_top(value);
return *this;
}

ColumnFormat &ColumnFormat::border_top_color(Color value) {
inline ColumnFormat &ColumnFormat::border_top_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_top_color(value);
return *this;
}

ColumnFormat &ColumnFormat::border_top_background_color(Color value) {
inline ColumnFormat &ColumnFormat::border_top_background_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_top_background_color(value);
return *this;
}

ColumnFormat &ColumnFormat::border_bottom(const std::string &value) {
inline ColumnFormat &ColumnFormat::border_bottom(const std::string &value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_bottom(value);
return *this;
}

ColumnFormat &ColumnFormat::border_bottom_color(Color value) {
inline ColumnFormat &ColumnFormat::border_bottom_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_bottom_color(value);
return *this;
}

ColumnFormat &ColumnFormat::border_bottom_background_color(Color value) {
inline ColumnFormat &ColumnFormat::border_bottom_background_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().border_bottom_background_color(value);
return *this;
}

ColumnFormat &ColumnFormat::corner(const std::string &value) {
inline ColumnFormat &ColumnFormat::corner(const std::string &value) {
for (auto &cell : column_.get().cells_)
cell.get().format().corner(value);
return *this;
}

ColumnFormat &ColumnFormat::corner_color(Color value) {
inline ColumnFormat &ColumnFormat::corner_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().corner_color(value);
return *this;
}

ColumnFormat &ColumnFormat::corner_background_color(Color value) {
inline ColumnFormat &ColumnFormat::corner_background_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().corner_background_color(value);
return *this;
}

ColumnFormat &ColumnFormat::column_separator(const std::string &value) {
inline ColumnFormat &ColumnFormat::column_separator(const std::string &value) {
for (auto &cell : column_.get().cells_)
cell.get().format().column_separator(value);
return *this;
}

ColumnFormat &ColumnFormat::column_separator_color(Color value) {
inline ColumnFormat &ColumnFormat::column_separator_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().column_separator_color(value);
return *this;
}

ColumnFormat &ColumnFormat::column_separator_background_color(Color value) {
inline ColumnFormat &ColumnFormat::column_separator_background_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().column_separator_background_color(value);
return *this;
}

ColumnFormat &ColumnFormat::font_align(FontAlign value) {
inline ColumnFormat &ColumnFormat::font_align(FontAlign value) {
for (auto &cell : column_.get().cells_)
cell.get().format().font_align(value);
return *this;
}

ColumnFormat &ColumnFormat::font_style(const std::vector<FontStyle> &style) {
inline ColumnFormat &ColumnFormat::font_style(const std::vector<FontStyle> &style) {
for (auto &cell : column_.get().cells_)
cell.get().format().font_style(style);
return *this;
}

ColumnFormat &ColumnFormat::font_color(Color value) {
inline ColumnFormat &ColumnFormat::font_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().font_color(value);
return *this;
}

ColumnFormat &ColumnFormat::font_background_color(Color value) {
inline ColumnFormat &ColumnFormat::font_background_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().font_background_color(value);
return *this;
}

ColumnFormat &ColumnFormat::color(Color value) {
inline ColumnFormat &ColumnFormat::color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().color(value);
return *this;
}

ColumnFormat &ColumnFormat::background_color(Color value) {
inline ColumnFormat &ColumnFormat::background_color(Color value) {
for (auto &cell : column_.get().cells_)
cell.get().format().background_color(value);
return *this;
}

ColumnFormat &ColumnFormat::multi_byte_characters(bool value) {
inline ColumnFormat &ColumnFormat::multi_byte_characters(bool value) {
for (auto &cell : column_.get().cells_)
cell.get().format().multi_byte_characters(value);
return *this;
}

ColumnFormat &ColumnFormat::locale(const std::string &value) {
inline ColumnFormat &ColumnFormat::locale(const std::string &value) {
for (auto &cell : column_.get().cells_)
cell.get().format().locale(value);
return *this;
Expand Down
2 changes: 1 addition & 1 deletion include/tabulate/table.hpp
Expand Up @@ -119,7 +119,7 @@ class Table {
std::shared_ptr<TableInternal> table_;
};

std::ostream &operator<<(std::ostream &stream, const Table &table) {
inline std::ostream &operator<<(std::ostream &stream, const Table &table) {
const_cast<Table &>(table).print(stream);
return stream;
}
Expand Down
16 changes: 8 additions & 8 deletions include/tabulate/table_internal.hpp
Expand Up @@ -120,7 +120,7 @@ class TableInternal : public std::enable_shared_from_this<TableInternal> {
Format format_;
};

Format &Cell::format() {
inline Format &Cell::format() {
std::shared_ptr<Row> parent = parent_.lock();
if (!format_.has_value()) { // no cell format
format_ = parent->format(); // Use parent row format
Expand All @@ -132,11 +132,11 @@ Format &Cell::format() {
return format_.value();
}

bool Cell::is_multi_byte_character_support_enabled() {
inline bool Cell::is_multi_byte_character_support_enabled() {
return format().multi_byte_characters_.value();
}

Format &Row::format() {
inline Format &Row::format() {
std::shared_ptr<TableInternal> parent = parent_.lock();
if (!format_.has_value()) { // no row format
format_ = parent->format(); // Use parent table format
Expand All @@ -148,7 +148,7 @@ Format &Row::format() {
return format_.value();
}

std::pair<std::vector<size_t>, std::vector<size_t>>
inline std::pair<std::vector<size_t>, std::vector<size_t>>
Printer::compute_cell_dimensions(TableInternal &table) {
std::pair<std::vector<size_t>, std::vector<size_t>> result;
size_t num_rows = table.size();
Expand Down Expand Up @@ -192,7 +192,7 @@ Printer::compute_cell_dimensions(TableInternal &table) {
return result;
}

void Printer::print_table(std::ostream &stream, TableInternal &table) {
inline void Printer::print_table(std::ostream &stream, TableInternal &table) {
size_t num_rows = table.size();
size_t num_columns = table.estimate_num_columns();
auto dimensions = compute_cell_dimensions(table);
Expand Down Expand Up @@ -249,7 +249,7 @@ void Printer::print_table(std::ostream &stream, TableInternal &table) {
}
}

void Printer::print_row_in_cell(std::ostream &stream, TableInternal &table,
inline void Printer::print_row_in_cell(std::ostream &stream, TableInternal &table,
const std::pair<size_t, size_t> &index,
const std::pair<size_t, size_t> &dimension, size_t num_columns,
size_t row_index) {
Expand Down Expand Up @@ -361,7 +361,7 @@ void Printer::print_row_in_cell(std::ostream &stream, TableInternal &table,
}
}

bool Printer::print_cell_border_top(std::ostream &stream, TableInternal &table,
inline bool Printer::print_cell_border_top(std::ostream &stream, TableInternal &table,
const std::pair<size_t, size_t> &index,
const std::pair<size_t, size_t> &dimension,
size_t num_columns) {
Expand Down Expand Up @@ -403,7 +403,7 @@ bool Printer::print_cell_border_top(std::ostream &stream, TableInternal &table,
return true;
}

bool Printer::print_cell_border_bottom(std::ostream &stream, TableInternal &table,
inline bool Printer::print_cell_border_bottom(std::ostream &stream, TableInternal &table,
const std::pair<size_t, size_t> &index,
const std::pair<size_t, size_t> &dimension,
size_t num_columns) {
Expand Down
4 changes: 2 additions & 2 deletions include/tabulate/utf8.hpp
Expand Up @@ -45,7 +45,7 @@ SOFTWARE.
namespace tabulate {

#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
int get_wcswidth(const std::string &string, const std::string &locale, size_t max_column_width) {
inline int get_wcswidth(const std::string &string, const std::string &locale, size_t max_column_width) {
if (string.size() == 0)
return 0;

Expand All @@ -65,7 +65,7 @@ int get_wcswidth(const std::string &string, const std::string &locale, size_t ma
}
#endif

size_t get_sequence_length(const std::string &text, const std::string &locale,
inline size_t get_sequence_length(const std::string &text, const std::string &locale,
bool is_multi_byte_character_support_enabled) {
if (!is_multi_byte_character_support_enabled)
return text.length();
Expand Down

0 comments on commit 1b32269

Please sign in to comment.