2 * UCW Library -- Extended types - extra types
4 * (c) 2014 Robert Kessl <robert.kessl@economia.cz>
7 #ifndef _UCW_XTYPES_EXTRA_H
8 #define _UCW_XTYPES_EXTRA_H
10 #include <ucw/xtypes.h>
11 #include <ucw/table.h>
13 #ifdef CONFIG_UCW_CLEAN_ABI
14 #define table_col_size ucw_table_col_size
15 #define table_col_timestamp ucw_table_col_timestamp
16 #define xt_size ucw_xt_size
17 #define xt_timestamp ucw_xt_timestamp
24 * `xt_size` is a size, possibly with a unit. Internally, it is represented
28 extern const struct xtype xt_size;
33 XT_SIZE_UNIT_KILOBYTE,
34 XT_SIZE_UNIT_MEGABYTE,
35 XT_SIZE_UNIT_GIGABYTE,
36 XT_SIZE_UNIT_TERABYTE,
40 /** Custom formatting mode: use a specified unit (`XT_SIZE_UNIT_`'xxx') **/
41 #define XT_SIZE_FMT_UNIT(_unit) (_unit | XT_SIZE_FMT_FIXED_UNIT)
42 #define XT_SIZE_FMT_FIXED_UNIT XTYPE_FMT_CUSTOM
44 #define TBL_COL_SIZE(_name, _width) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size }
45 #define TBL_COL_SIZE_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = _fmt, .type_def = &xt_size }
47 TABLE_COL_PROTO(size, u64)
53 * `xt_timestamp` is a timestamp, internally represented as `time_t`.
56 #define XT_TIMESTAMP_FMT_EPOCH XTYPE_FMT_RAW
57 #define XT_TIMESTAMP_FMT_DATETIME XTYPE_FMT_PRETTY
59 extern const struct xtype xt_timestamp;
61 #define TBL_COL_TIMESTAMP(_name, _width) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp }
62 #define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = _fmt, .type_def = &xt_timestamp }
64 TABLE_COL_PROTO(timestamp, u64)