#define TBL_FMT_HUMAN_READABLE .formatter = &table_fmt_human_readable
#define TBL_FMT_BLOCKLINE .formatter = &table_fmt_blockline
#define TBL_FMT_MACHINE_READABLE .formatter = &table_fmt_machine_readable
+#define TBL_FMT(_fmt) .formatter = _fmt
/**
* The TBL_COL_ITER_START macro are used for iterating over all instances of a particular column in
* For each column type, there are functions for filling of cells
* of the particular type:
*
- * * `table_col_`'type'`(table, idx, value)` sets the cell in column `idx`
+ * * `table_col_`'type'`(table, col_def_idx, value)` sets the cell in column `col_def_idx`
* to the `value`
***/
***/
/**
- * Find the index of a column with name @col_name. Returns -1 if there is no such column.
+ * Find the index of a column definition with name @col_name. Returns -1 if there is no such column.
**/
int table_get_col_idx(struct table *tbl, const char *col_name);
-
/**
* Sets a string option to an instance of a column 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
* RK: that is the current solution the only confusion can be that
* the hook and this function has the same prototype.
**/
-const char *table_set_col_opt(struct table *tbl, uint col_idx, const char *col_opt);
+const char *table_set_col_opt(struct table *tbl, uint col_inst_idx, const char *col_opt);
/**
* Returns a comma-and-space-separated list of column names, allocated from table's internal
const char *table_get_col_list(struct table *tbl);
/**
+ * Sets the order in which the columns are printed. The columns are specified by struct
+ *
* Sets the order in which the columns are printed.
* The table converts the integers in @col_order into an internal representation stored
* in `column_order`. Options to column instances can be set using @table_set_col_opt().
*
- * FIXME: add a function to the interface that accepts a pointer to an
- * array of table_col_instance.
- **/
-void table_set_col_order(struct table *tbl, int *col_order, int col_order_size);
-
-/**
- * Returns true if col_idx will be printed, false otherwise.
- *
- * FIXME: Naming of arguments is confusing. @col_idx sometimes indexes
- * columns, but sometimes their instances.
+ * @table_col_instance. This allows specification of format. The user should make an array of struct
+ * @table_col_instance and fill the array using the TBL_COL and TBL_COL_FMT.
**/
-bool table_col_is_printed(struct table *tbl, uint col_def_idx);
+void table_set_col_order(struct table *tbl, const struct table_col_instance *col_order, uint cols_to_output);
/**
* Sets the order in which the columns are printed. The specification is a string with comma-separated column
**/
const char *table_set_col_order_by_name(struct table *tbl, const char *col_order);
+/**
+ * Returns true if col_idx will be printed, false otherwise.
+ *
+ * FIXME: Naming of arguments is confusing. @col_idx sometimes indexes
+ * columns, but sometimes their instances.
+ **/
+bool table_col_is_printed(struct table *tbl, uint col_def_idx);
+
/**
* Sets table formatter. See below for the list of formatters.
**/