]> mj.ucw.cz Git - libucw.git/blob - ucw/table-types.h
tableprinter: removed some obsolete FIXME, added some comments
[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 #ifdef CONFIG_UCW_CLEAN_ABI
13 #define table_col_size ucw_table_col_size
14 #define table_col_timestamp ucw_table_col_timestamp
15 #define xt_size ucw_xt_size
16 #define xt_timestamp ucw_xt_timestamp
17 #endif
18
19 /* Size, possibly with a unit. Internally represented as u64. */
20
21 extern const struct xtype xt_size;
22
23 enum size_units {
24   XT_SIZE_UNIT_BYTE,
25   XT_SIZE_UNIT_KILOBYTE,
26   XT_SIZE_UNIT_MEGABYTE,
27   XT_SIZE_UNIT_GIGABYTE,
28   XT_SIZE_UNIT_TERABYTE,
29   XT_SIZE_UNIT_AUTO
30 };
31
32 #define XT_SIZE_FMT_UNIT(_unit) (_unit | XT_SIZE_FMT_FIXED_UNIT)
33 #define XT_SIZE_FMT_FIXED_UNIT XTYPE_FMT_CUSTOM
34
35 #define TBL_COL_SIZE(_name, _width)       { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size }
36 #define TBL_COL_SIZE_FMT(_name, _width, _fmt)      { .name = _name, .width = _width, .fmt = _fmt, .type_def = &xt_size }
37
38 TABLE_COL_PROTO(size, u64)
39
40 /* Timestamp. Internally represented as time_t. */
41
42 #define XT_TIMESTAMP_FMT_EPOCH     XTYPE_FMT_RAW
43 #define XT_TIMESTAMP_FMT_DATETIME  XTYPE_FMT_PRETTY
44
45 extern const struct xtype xt_timestamp;
46
47 #define TBL_COL_TIMESTAMP(_name, _width)  { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp }
48 #define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = _fmt, .type_def = &xt_timestamp }
49
50 TABLE_COL_PROTO(timestamp, u64)
51
52 #endif