extern const struct xtype xt_size;
extern const struct xtype xt_timestamp;
-#define TBL_COL_SIZE(_name, _width) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size, .set_col_instance_option = table_set_col_opt_default }
-#define TBL_COL_TIMESTAMP(_name, _width) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp, .set_col_instance_option = table_set_col_opt_default }
-
-#define TBL_COL_SIZE_FMT(_name, _width, _units) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_size, .set_col_instance_option = table_set_col_opt_default }
-#define TBL_COL_TIMESTAMP_FMT(_name, _width, _fmt) { .name = _name, .width = _width, .fmt = XTYPE_FMT_DEFAULT, .type_def = &xt_timestamp, .set_col_instance_option = table_set_col_opt_default}
+#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 }
+#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 }
+#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 }
+#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}
TABLE_COL_PROTO(size, u64)
TABLE_COL_PROTO(timestamp, u64)
return left_br;
}
-/**
- * Setting options for basic table types (as defined in table.h)
- **/
-const char *table_set_col_opt_default(struct table *tbl, uint col_idx, const char *col_opt)
+const char *table_set_col_opt(struct table *tbl, uint col_idx, const char *col_opt)
{
const struct table_column *col_def = tbl->column_order[col_idx].col_def;
+ if(col_def && col_def->set_col_opt && col_def->set_col_opt != table_set_col_opt) {
+ return col_def->set_col_opt(tbl, col_idx, col_opt);
+ }
if(col_def && col_def->type_def && col_def->type_def->parse_fmt) {
uint fmt = 0;
tbl->column_order[curr_col_idx].col_def = tbl->columns + col_idx;
tbl->column_order[curr_col_idx].idx = col_idx;
tbl->column_order[curr_col_idx].fmt = tbl->columns[col_idx].fmt;
- if(tbl->columns[col_idx].type_def && tbl->columns[col_idx].set_col_instance_option) {
+ if(tbl->columns[col_idx].type_def && tbl->columns[col_idx].set_col_opt) {
const char *err = NULL;
- err = tbl->columns[col_idx].set_col_instance_option(tbl, curr_col_idx, arg);
+ err = tbl->columns[col_idx].set_col_opt(tbl, curr_col_idx, arg);
if(err) return mp_printf(tbl->pool, "Error occured while setting column option: %s.", err);
}
uint fmt; // [*] default format of the column
const struct xtype *type_def; // [*] pointer to xtype of this column
- const char * (*set_col_instance_option)(struct table *tbl, uint col, const char *value);
+ const char * (*set_col_opt)(struct table *tbl, uint col, const char *value);
// [*] process table option for a column instance
};
const struct table_column *col_def; // this is pointer to the column definition, located in the array struct table::columns
const char *cell_content; // content of the cell of the current row
int next_column; // index of next column in linked list of columns of the same type
- uint fmt; // format of this column
+ uint fmt; // format of this column
};
/**
/**
- * Sets a string argument to a column instance
+ * Sets a string option to an instance of a columnt type. This is the default version that checks
+ * whether the xtype::parse_fmt can be called and calls it. However, there are situation in which
+ * the xtype::parse_fmt is not sufficient, e.g., column decoration, post-processing, etc.
**/
-const char *table_set_col_opt_default(struct table *tbl, uint col_idx, const char *col_opt);
+const char *table_set_col_opt(struct table *tbl, uint col_idx, const char *col_opt);
/**
* Returns a comma-and-space-separated list of column names, allocated from table's internal