solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
Loading...
Searching...
No Matches
prettytable.h
Go to the documentation of this file.
1
31#ifndef PRETTYTABLE_H
32#define PRETTYTABLE_H
33
34#include <stdbool.h>
35#include <stdio.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
47typedef const char* (*prettytable_header_fn)(void* user_data, int col);
48
56typedef const char* (*prettytable_cell_fn)(void* user_data, int row, int col);
57
65typedef int (*prettytable_strlen_fn)(void* user_data, const char* text);
66
70typedef struct {
71 const char* top_left; // ┌
72 const char* top_mid; // ┬
73 const char* top_right; // ┐
74 const char* mid_left; // ├
75 const char* mid_mid; // ┼
76 const char* mid_right; // ┤
77 const char* bottom_left; // └
78 const char* bottom_mid; // ┴
79 const char* bottom_right; // ┘
80 const char* horizontal; // ─
81 const char* vertical; // │
83
87typedef struct {
88 int num_rows; // Number of data rows
89 int num_cols; // Number of columns
90 prettytable_header_fn get_header; // Callback for headers
91 prettytable_cell_fn get_cell; // Callback for cell values
92 prettytable_strlen_fn get_length; // Optional: custom length function
93 void* user_data; // User context passed to callbacks
94 const prettytable_style* style; // Optional: custom border style
95 bool show_header; // Show header row (default: true)
96 bool show_row_count; // Show row count at bottom (default: true)
97 FILE* output; // Output stream (default: stdout)
99
103extern const prettytable_style PRETTYTABLE_STYLE_BOX; // ┌─┬─┐ (default)
104extern const prettytable_style PRETTYTABLE_STYLE_ASCII; // +-+-+
105extern const prettytable_style PRETTYTABLE_STYLE_MINIMAL; // No borders
106extern const prettytable_style PRETTYTABLE_STYLE_DOUBLE; // ╔═╦═╗
107
113int prettytable_print(const prettytable_config* config);
114
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif // PRETTYTABLE_H
const prettytable_style PRETTYTABLE_STYLE_BOX
Definition prettytable.c:12
int prettytable_print(const prettytable_config *config)
const char *(* prettytable_header_fn)(void *user_data, int col)
Definition prettytable.h:47
const char *(* prettytable_cell_fn)(void *user_data, int row, int col)
Definition prettytable.h:56
void prettytable_config_init(prettytable_config *config)
Definition prettytable.c:68
int(* prettytable_strlen_fn)(void *user_data, const char *text)
Definition prettytable.h:65