]> mj.ucw.cz Git - libucw.git/blob - ucw/table-types.h
tableprinter: code cleanup
[libucw.git] / ucw / table-types.h
1 /*
2  *      UCW Library -- Table printer
3  *
4  *      (c) 2014 Robert Kessl <robert.kessl@economia.cz>
5  */
6
7 #ifndef _UCW_TABLE_TYPES_H
8 #define _UCW_TABLE_TYPES_H
9
10 #include <ucw/table.h>
11
12 enum size_units {
13   UNIT_SIZE_BYTE,
14   UNIT_SIZE_KILOBYTE,
15   UNIT_SIZE_MEGABYTE,
16   UNIT_SIZE_GIGABYTE,
17   UNIT_SIZE_TERABYTE,
18   UNIT_SIZE_AUTO
19 };
20
21 enum timestamp_format {
22   TIMESTAMP_EPOCH,
23   TIMESTAMP_DATETIME
24 };
25
26 #define COL_TYPE_SIZE       COL_TYPE_UCW
27 #define COL_TYPE_TIMESTAMP  (COL_TYPE_UCW+1)
28
29 extern struct table_user_type table_type_timestamp;
30 extern struct table_user_type table_type_size;
31
32 #define TBL_COL_SIZE(_name, _width)           { .name = _name, .width = _width, .fmt = "%llu", .type = COL_TYPE_SIZE, .type_def = &table_type_size }
33 #define TBL_COL_TIMESTAMP(_name, _width)      { .name = _name, .width = _width, .fmt = "%lld", .type = COL_TYPE_TIMESTAMP, .type_def = &table_type_timestamp }
34
35 #define TBL_COL_SIZE_FMT(_name, _width, _units)         { .name = _name, .width = _width, .fmt = "%llu", .type = COL_TYPE_SIZE, .type_def = &table_type_size }
36 #define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt)      { .name = _name, .width = _width, .fmt = "%lld", .type = COL_TYPE_TIMESTAMP, .type_def = &table_type_timestamp }
37
38 void table_col_size_name(struct table *tbl, const char *col_name, u64 val);
39 void table_col_timestamp_name(struct table *tbl, const char * col_name, u64 val);
40
41 void table_col_size(struct table *tbl, int col, u64 val);
42 void table_col_timestamp(struct table *tbl, int col, u64 val);
43
44 #endif