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
20 /* Size, possibly with a unit. Internally represented as u64. */
22 extern const struct xtype xt_size;
26 XT_SIZE_UNIT_KILOBYTE,
27 XT_SIZE_UNIT_MEGABYTE,
28 XT_SIZE_UNIT_GIGABYTE,
29 XT_SIZE_UNIT_TERABYTE,
33 #define XT_SIZE_FMT_UNIT(_unit) (_unit | XT_SIZE_FMT_FIXED_UNIT)
34 #define XT_SIZE_FMT_FIXED_UNIT XTYPE_FMT_CUSTOM
36 #define TBL_COL_SIZE(_name, _width) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size }
37 #define TBL_COL_SIZE_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = _fmt, .type_def = &xt_size }
39 TABLE_COL_PROTO(size, u64)
41 /* Timestamp. Internally represented as time_t. */
43 #define XT_TIMESTAMP_FMT_EPOCH XTYPE_FMT_RAW
44 #define XT_TIMESTAMP_FMT_DATETIME XTYPE_FMT_PRETTY
46 extern const struct xtype xt_timestamp;
48 #define TBL_COL_TIMESTAMP(_name, _width) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp }
49 #define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = _fmt, .type_def = &xt_timestamp }
51 TABLE_COL_PROTO(timestamp, u64)