]> mj.ucw.cz Git - libucw.git/blob - ucw/table-types.h
Extended types: Cleaned up unit name parsing
[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 enum size_units {
20   SIZE_UNIT_BYTE,
21   SIZE_UNIT_KILOBYTE,
22   SIZE_UNIT_MEGABYTE,
23   SIZE_UNIT_GIGABYTE,
24   SIZE_UNIT_TERABYTE,
25   SIZE_UNIT_AUTO
26 };
27
28 #define TIMESTAMP_EPOCH     XTYPE_FMT_RAW
29 #define TIMESTAMP_DATETIME  XTYPE_FMT_PRETTY
30
31 #define SIZE_UNITS_FIXED    0x40000000
32
33 extern const struct xtype xt_size;
34 extern const struct xtype xt_timestamp;
35
36 #define TBL_COL_SIZE(_name, _width)       { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size, .set_col_opt = table_set_col_opt }
37 #define TBL_COL_TIMESTAMP(_name, _width)  { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp, .set_col_opt = table_set_col_opt }
38
39 #define TBL_COL_SIZE_FMT(_name, _width, _units)    { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size, .set_col_opt = table_set_col_opt }
40 #define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp, .set_col_opt = table_set_col_opt}
41
42 TABLE_COL_PROTO(size, u64)
43 TABLE_COL_PROTO(timestamp, u64)
44
45 #endif