All Projects β†’ DenisSamilton β†’ CppConsoleTable

DenisSamilton / CppConsoleTable

Licence: MIT license
C++ Console Table: make text table in console easy and set up as you need

Programming Languages

C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to CppConsoleTable

Tkintertable
A pure python library for adding tables to a Tkinter application
Stars: ✭ 199 (+275.47%)
Mutual labels:  table
Js Equality Game
The Worst Minesweeper πŸ’£ Ever
Stars: ✭ 246 (+364.15%)
Mutual labels:  table
tabled
An easy to use library for pretty print tables of Rust structs and enums.
Stars: ✭ 1,337 (+2422.64%)
Mutual labels:  table
Vue Easytable
πŸ‰ Table Component/ Data Grid / Data Table.Support Virtual Scroll,Column Fixed,Header Fixed,Header Grouping,Filter,Sort,Cell Ellipsis,Row Expand,Row Checkbox ...
Stars: ✭ 2,501 (+4618.87%)
Mutual labels:  table
Griddle
Simple Grid Component written in React
Stars: ✭ 2,494 (+4605.66%)
Mutual labels:  table
contentful-reference-matrix-field-app
Contentful App that adds UI for a table-like list of references with other associated data.
Stars: ✭ 28 (-47.17%)
Mutual labels:  table
Flask table
Because writing HTML is fiddly and all of your tables are basically the same
Stars: ✭ 187 (+252.83%)
Mutual labels:  table
table-link
πŸ“‚ The easiest way to add links in your table rows, cells or elements that are not anchors!
Stars: ✭ 25 (-52.83%)
Mutual labels:  table
Tty Table
Terminal table for Windows, Linux, and MacOS. Written in nodejs. Also works in browser console. Word wrap, padding, alignment, colors, Asian character support, per-column callbacks, and you can pass rows as objects or arrays. Backwards compatible with Automattic/cli-table.
Stars: ✭ 233 (+339.62%)
Mutual labels:  table
ng-treetable
A treetable module for angular 5
Stars: ✭ 32 (-39.62%)
Mutual labels:  table
React Table
βš›οΈ Hooks for building fast and extendable tables and datagrids for React
Stars: ✭ 15,739 (+29596.23%)
Mutual labels:  table
Csview
πŸ“  A high performance csv viewer with cjk/emoji support.
Stars: ✭ 208 (+292.45%)
Mutual labels:  table
au-datatable
Aurelia Datatable, A highly customizable html datatable, build for the Aurelia Framework.
Stars: ✭ 21 (-60.38%)
Mutual labels:  table
Heyui
πŸŽ‰UI Toolkit for Web, Vue2.0 http://www.heyui.top
Stars: ✭ 2,373 (+4377.36%)
Mutual labels:  table
react-datasheet-grid
An Airtable-like / Excel-like component to create beautiful spreadsheets.
Stars: ✭ 227 (+328.3%)
Mutual labels:  table
React Bootstrap Table
A Bootstrap table built with React.js
Stars: ✭ 2,238 (+4122.64%)
Mutual labels:  table
Blazortable
Blazor Table Component with Sorting, Paging and Filtering
Stars: ✭ 249 (+369.81%)
Mutual labels:  table
tallboy
Declarative API for drawing unicode/ascii character tables in crystal lang
Stars: ✭ 49 (-7.55%)
Mutual labels:  table
termtable
Simple and highly customizable library to display tables in the terminal.
Stars: ✭ 41 (-22.64%)
Mutual labels:  table
react-bolivianite-grid
React grid component for virtualized rendering large tabular data.
Stars: ✭ 95 (+79.25%)
Mutual labels:  table



πŸ‡·πŸ‡ΊΠΠ° русском

With this tool you can make text table in console easily and set up as you need.

Integration

The single required source, file CppConsoleTable.hpp is in the root directory or released here. All you need to do is add

#include "CppConsoleTable.hpp"

// for convenience
using ConsoleTable = samilton::ConsoleTable;

to the files you want to use ConsoleTable.

CppConsoleTable uses C++17 standard, so it's necessary to enable C++17.

Examples

With the ConsoleTable class, you could write:

// create an empty structure (null)
ConsoleTable table;

// add a number of double type
table[0][1] = 3.141;

// add a Boolean 
table[1][0] = true;

// add a number of int type
table[2][1] = 56;

// add a "const char[]" string (it also could be an std::string)
table[2][0] = "some";

If you want to add new row, column to existence table, or assign new table, you should try this methods:

// add new column to table using initializer_list
table.addColumn({ 1, 2, 3 }); 

// add new row to table from vector
std::vector<char> vec = { 'a', 'b', 'c' };
table.addRow(vec);

// add new column to table from vanilla dynamic array
double *arr = new double[3];
arr[0] = 1.3; arr[1] = 2.34; arr[2] = 3.14;
table.addColumn(arr, 3);

// assign new table with elements by function using initializer_list
table.assign({ {"stringA1", "stringA2"}, {"stringB1"}, {"stringC1", "stringC2", "stringC3"} }); 

// assign new table with elements by function using vanilla dynamic array
std::string **arr = new std::string*[3];
for (auto i = 0; i < 3; ++i) {
	arr[i] = new std::string[2];
	for (auto j = 0; j < 2; ++j) { arr[i][j] = std::to_string(i+j); }
}
table.assign(arr, 2, 3);

// assign new table with elements by overloaded assign operator using initializer_list
table = { {1, 22}, {33}, {37, 74, 945} }; 

// assign new table with elements from vector
std::vector<std::vector<int>> vec = { {1, 4, 6}, {2, 3} };
table = vec;

You can also change the alignment of all objects in table (for default it's left):

// using constructor
ConsoleTable table(samilton::Alignment::center);

// or using a method
table.setAlignment(samilton::Alignment::right);

Or, you can change alignment of specific row or cell:

// set alignment to specific row
table[0](samilton::Alignment::center);

// set alignment to specific row with element assign
table[0](samilton::Alignment::right)[1] = 3.14;

// set alignment to specific cell
table[1][2](samilton::Alignment::left) = "ExampleString";

If you need indent before or after your elements, you can change it:

// using constructor
ConsoleTable table(2, 3);

// or using a method
table.setIndent(2, 3);

If you need to change the characters of table, you can easily do it with TableChars struct:

// creating struct
ConsoleTable::TableChars chars;

// modifying characters
chars.topDownSimple = '-';
chars.leftSeparation = '+';

// changing characters in table
table.setTableChars(chars);

Then, all you need to do is out this table to stream:

// using iostream
std::cout << table;

// you can also out it to file using fstream
std::fstream file("test.txt");
file << table;

// of course you can out it also to stringstream
std::stringstream stream;
stream << table;

Full example of using:

#include <iostream>

#include "CppConsoleTable.hpp"

using namespace std;
using ConsoleTable = samilton::ConsoleTable;

int main()
{
	ConsoleTable table(1, 1, samilton::Alignment::centre);

	table[0][0] = "Some String";
	table[1][3] = true;
	table[2][1] = 10;
	table[3][3] = "Some\nMulti String";
	table[2][2] = 2.354;
	table[0][1] = false;

	cout << table;

	system("pause");
}

Output:

╔═════════════╦═══════╦══════════╦══════════════╗
β•‘ Some String β•‘ false β•‘          β•‘              β•‘
╠═════════════╬═══════╬══════════╬══════════════╣
β•‘             β•‘       β•‘          β•‘     true     β•‘
╠═════════════╬═══════╬══════════╬══════════════╣
β•‘             β•‘  10   β•‘ 2.354000 β•‘              β•‘
╠═════════════╬═══════╬══════════╬══════════════╣
β•‘             β•‘       β•‘          β•‘     Some     β•‘
β•‘             β•‘       β•‘          β•‘ Multi String β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•©β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

License

The class is licensed under the MIT License:

Copyright Β© 2019 DenisSamilton

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the β€œSoftware”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contact

If you have questions regarding the library, I would like to invite you to open an issue at Github. Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at Github allows other users and contributors to this library to collaborate.

Only if your request would contain confidential information, please send me an email.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].