]> mj.ucw.cz Git - libucw.git/commitdiff
tableprinter: TBL_COL_ITER_START(END) moved to table.c
authorRobert Kessl <kesslr@centrum.cz>
Mon, 28 Jul 2014 12:10:56 +0000 (14:10 +0200)
committerRobert Kessl <kesslr@centrum.cz>
Mon, 28 Jul 2014 12:10:56 +0000 (14:10 +0200)
ucw/table.c
ucw/table.h

index e2e616968fdbec9b49449684f6206d011a14d872..eefb478587d5197f8069a933451244519008b287 100644 (file)
@@ -296,6 +296,22 @@ const char * table_set_col_order_by_name(struct table *tbl, const char *col_orde
 
 /*** Table cells ***/
 
+/**
+ * The TBL_COL_ITER_START macro are used for iterating over all instances of a particular column in
+ * table _tbl.  _colidx is the column index in _tbl, _instptr is the pointer to the column instance
+ * (struct table_col_instance *), _idxval is the index of current column index. The variables are
+ * enclosed in a block, so they do not introduce variable name collisions.
+ *
+ * The TBL_COL_ITER_END macro must close the block started with TBL_COL_ITER_START.
+ *
+ * These macros are usually used to hide the implementation details of the column instances linked
+ * list. This is usefull for definition of new types.
+ **/
+#define TBL_COL_ITER_START(_tbl, _colidx, _instptr, _idxval) { struct table_col_instance *_instptr = NULL; int _idxval = _tbl->ll_headers[_colidx]; \
+  for(_idxval = _tbl->ll_headers[_colidx], _instptr = _tbl->column_order + _idxval; _idxval != -1; _idxval = _tbl->column_order[_idxval].next_column, _instptr = _tbl->column_order + _idxval)
+
+#define TBL_COL_ITER_END }
+
 static void table_col_raw(struct table *tbl, int col_templ, const char *col_content)
 {
   TBL_COL_ITER_START(tbl, col_templ, curr_col_ptr, curr_col) {
@@ -314,6 +330,9 @@ void table_col_generic_format(struct table *tbl, int col, void *value, const str
   } TBL_COL_ITER_END
 }
 
+#undef TBL_COL_ITER_START
+#undef TBL_COL_ITER_END
+
 void table_col_printf(struct table *tbl, int col, const char *fmt, ...)
 {
   ASSERT_MSG(col < tbl->column_count && col >= 0, "Table column %d does not exist.", col);
index c1bf73e314184d175b8c597de5f3089f8d728f5f..04abd1f347cd8770eeef111f3c6b30c271f50cf6 100644 (file)
@@ -199,22 +199,6 @@ struct table {
 #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
- * table _tbl.  _colidx is the column index in _tbl, _instptr is the pointer to the column instance
- * (struct table_col_instance *), _idxval is the index of current column index. The variables are
- * enclosed in a block, so they do not introduce variable name collisions.
- *
- * The TBL_COL_ITER_END macro must close the block started with TBL_COL_ITER_START.
- *
- * These macros are usually used to hide the implementation details of the column instances linked
- * list. This is usefull for definition of new types.
- **/
-#define TBL_COL_ITER_START(_tbl, _colidx, _instptr, _idxval) { struct table_col_instance *_instptr = NULL; int _idxval = _tbl->ll_headers[_colidx]; \
-  for(_idxval = _tbl->ll_headers[_colidx], _instptr = _tbl->column_order + _idxval; _idxval != -1; _idxval = _tbl->column_order[_idxval].next_column, _instptr = _tbl->column_order + _idxval)
-
-#define TBL_COL_ITER_END }
-
 /**
  * Creates a new table from a table template. The template should already contain
  * the definitions of columns.