From 1211dda9b078c1e82e32484adbe11955d9d85bb2 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 5 Jan 2016 23:04:59 -0500 Subject: [PATCH] Table: Made more methods and args const --- src/common/Table.cpp | 8 ++++---- src/common/Table.h | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/common/Table.cpp b/src/common/Table.cpp index 7d1f28dc..f3762fcd 100644 --- a/src/common/Table.cpp +++ b/src/common/Table.cpp @@ -58,7 +58,7 @@ int Table::addRow () } //////////////////////////////////////////////////////////////////////////////// -void Table::set (int row, int col, const std::string& value, Color color) +void Table::set (int row, int col, const std::string& value, const Color color) { _data[row][col] = value; @@ -67,7 +67,7 @@ void Table::set (int row, int col, const std::string& value, Color color) } //////////////////////////////////////////////////////////////////////////////// -void Table::set (int row, int col, int value, Color color) +void Table::set (int row, int col, int value, const Color color) { std::string string_value = format (value); _data[row][col] = string_value; @@ -77,7 +77,7 @@ void Table::set (int row, int col, int value, Color color) } //////////////////////////////////////////////////////////////////////////////// -void Table::set (int row, int col, Color color) +void Table::set (int row, int col, const Color color) { if (color.nontrivial ()) _color[row][col] = color; @@ -292,7 +292,7 @@ void Table::renderCell ( const std::string& value, int width, bool alignLeft, - Color& color) const + const Color& color) const { std::vector raw; wrapText (raw, value, width, false); diff --git a/src/common/Table.h b/src/common/Table.h index 8fcceb54..02ed8557 100644 --- a/src/common/Table.h +++ b/src/common/Table.h @@ -40,15 +40,15 @@ public: void add (const std::string& col, bool alignLeft = true) { _columns.push_back (col); _align.push_back (alignLeft); } void width (int width) { _width = width; } void leftMargin (int margin) { _left_margin = margin; } - void colorHeader (Color& c) { _header = c; } - void colorOdd (Color& c) { _odd = c; } - void colorEven (Color& c) { _even = c; } + void colorHeader (const Color& c) { _header = c; } + void colorOdd (const Color& c) { _odd = c; } + void colorEven (const Color& c) { _even = c; } void intraPadding (int padding) { _intra_padding = padding; } - void intraColorOdd (Color& c) { _intra_odd = c; } - void intraColorEven (Color& c) { _intra_even = c; } + void intraColorOdd (const Color& c) { _intra_odd = c; } + void intraColorEven (const Color& c) { _intra_even = c; } void extraPadding (int padding) { _extra_padding = padding; } - void extraColorOdd (Color& c) { _extra_odd = c; } - void extraColorEven (Color& c) { _extra_even = c; } + void extraColorOdd (const Color& c) { _extra_odd = c; } + void extraColorEven (const Color& c) { _extra_even = c; } void truncateLines (int n) { _truncate_lines = n; } void truncateRows (int n) { _truncate_rows = n; } int lines () { return _lines; } @@ -56,16 +56,16 @@ public: // Data provision. int addRow (); - void set (int, int, const std::string&, Color color = Color::nocolor); - void set (int, int, int, Color color = Color::nocolor); - void set (int, int, Color); + void set (int, int, const std::string&, const Color color = Color::nocolor); + void set (int, int, int, const Color color = Color::nocolor); + void set (int, int, const Color); // View rendering. std::string render (); private: void measureCell (const std::string&, unsigned int&, unsigned int&) const; - void renderCell (std::vector &, const std::string&, int, bool, Color&) const; + void renderCell (std::vector &, const std::string&, int, bool, const Color&) const; private: std::vector > _data;