]> mj.ucw.cz Git - libucw.git/blob - ucw/table-types.h
tableprinter: first shot on update of internals
[libucw.git] / ucw / table-types.h
1 #ifndef _UCW_TABLE_TYPES_H
2 #define _UCW_TABLE_TYPES_H
3
4 #include <ucw/table.h>
5
6 enum size_units {
7   UNIT_BYTE,
8   UNIT_KILOBYTE,
9   UNIT_MEGABYTE,
10   UNIT_GIGABYTE,
11   UNIT_TERABYTE,
12   UNIT_AUTO
13 };
14
15 enum timestamp_format {
16   TIMESTAMP_EPOCH,
17   TIMESTAMP_DATETIME
18 };
19
20
21 #define COL_TYPE_SIZE       COL_TYPE_CUSTOM
22 #define COL_TYPE_TIMESTAMP  (COL_TYPE_CUSTOM+1)
23
24 #define TBL_COL_SIZE(_name, _width)           { .name = _name, .width = _width, .fmt = "%llu", .type = COL_TYPE_SIZE }
25 #define TBL_COL_TIMESTAMP(_name, _width)      { .name = _name, .width = _width, .fmt = "%lld", .type = COL_TYPE_TIMESTAMP }
26
27 #define TBL_COL_SIZE_FMT(_name, _width, _units)         { .name = _name, .width = _width, .fmt = "%llu", .type = COL_TYPE_SIZE }
28 #define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt)      { .name = _name, .width = _width, .fmt = "%lld", .type = COL_TYPE_TIMESTAMP }
29
30 /*
31   union {
32     enum size_units units;
33     enum timestamp_format ts_fmt;
34   };
35 */
36 /*
37 #define TBL_COL_SIZE(_name, _width)           { .name = _name, .width = _width, .fmt = "%llu", .type = COL_TYPE_SIZE }
38 #define TBL_COL_TIMESTAMP(_name, _width)      { .name = _name, .width = _width, .fmt = "%lld", .type = COL_TYPE_TIMESTAMP }
39
40 #define TBL_COL_SIZE_FMT(_name, _width, _units)         { .name = _name, .width = _width, .fmt = "%llu", .type = COL_TYPE_SIZE }
41 #define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt)      { .name = _name, .width = _width, .fmt = "%lld", .type = COL_TYPE_TIMESTAMP }
42
43 #define TABLE_COL_PROTO(_name_, _type_) void table_col_##_name_(struct table *tbl, int col, _type_ val);\
44   void table_col_##_name_##_name(struct table *tbl, const char *col_name, _type_ val);\
45   void table_col_##_name_##_fmt(struct table *tbl, int col, _type_ val) FORMAT_CHECK(printf, 3, 0);
46 //TABLE_COL_PROTO(size, u64);
47 //TABLE_COL_PROTO(timestamp, u64);
48 #undef TABLE_COL_PROTO
49 */
50
51 void table_col_size_name(struct table *tbl, const char *col_name, u64 val);
52 void table_col_timestamp_name(struct table *tbl, const char * col_name, u64 val);
53
54 void table_col_size(struct table *tbl, int col, u64 val);
55 void table_col_timestamp(struct table *tbl, int col, u64 val);
56
57 //TABLE_COL(size, u64, COL_TYPE_SIZE)
58 //TABLE_COL_STR(size, u64, COL_TYPE_SIZE)
59
60 //TABLE_COL(timestamp, u64, COL_TYPE_TIMESTAMP)
61 //TABLE_COL_STR(timestamp, u64, COL_TYPE_TIMESTAMP)
62
63
64 #endif