|
solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
|
Generic pretty table printer library for C. More...
#include <stdbool.h>#include <stdio.h>Go to the source code of this file.
Classes | |
| struct | prettytable_style |
| struct | prettytable_config |
Typedefs | |
| typedef const char *(* | prettytable_header_fn) (void *user_data, int col) |
| typedef const char *(* | prettytable_cell_fn) (void *user_data, int row, int col) |
| typedef int(* | prettytable_strlen_fn) (void *user_data, const char *text) |
Functions | |
| int | prettytable_print (const prettytable_config *config) |
| void | prettytable_config_init (prettytable_config *config) |
Variables | |
| const prettytable_style | PRETTYTABLE_STYLE_BOX |
Generic pretty table printer library for C.
A fast, minimal library for printing formatted tables with box-drawing characters. Uses callback functions to support any data source.
Example usage:
const char* get_cell(void* data, int row, int col) { MyData* d = (MyData*)data; return d->cells[row][col]; }
const char* get_header(void* data, int col) { const char* headers[] = {"ID", "Name", "Age"}; return headers[col]; }
prettytable_config cfg = { .num_rows = 3, .num_cols = 3, .get_header = get_header, .get_cell = get_cell, .user_data = &my_data };
prettytable_print(&cfg);
Definition in file prettytable.h.
| typedef const char *(* prettytable_cell_fn) (void *user_data, int row, int col) |
Callback to get cell value.
| user_data | User-provided context data |
| row | Row index (0-based) |
| col | Column index (0-based) |
Definition at line 56 of file prettytable.h.
| typedef const char *(* prettytable_header_fn) (void *user_data, int col) |
Callback to get header text for a column.
| user_data | User-provided context data |
| col | Column index (0-based) |
Definition at line 47 of file prettytable.h.
| typedef int(* prettytable_strlen_fn) (void *user_data, const char *text) |
Optional callback to get custom cell length (for wide chars, etc.) If NULL, strlen() is used.
| user_data | User-provided context data |
| text | Cell text |
Definition at line 65 of file prettytable.h.
| void prettytable_config_init | ( | prettytable_config * | config | ) |
Initialize config with default values.
| config | Config to initialize |
Definition at line 68 of file prettytable.c.
References PRETTYTABLE_STYLE_BOX.
| int prettytable_print | ( | const prettytable_config * | config | ) |
Print a formatted table.
| config | Table configuration |
Definition at line 158 of file prettytable.c.
References PRETTYTABLE_STYLE_BOX.
|
extern |
Predefined border styles.
Definition at line 12 of file prettytable.c.
Referenced by prettytable_config_init(), and prettytable_print().