| 1 |
/** |
| 2 |
* table.h: Table rendering class. |
| 3 |
* |
| 4 |
* Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team |
| 5 |
* Rights to this code are as documented in COPYING. |
| 6 |
* |
| 7 |
* |
| 8 |
* Portions of this file were derived from sources bearing the following license: |
| 9 |
* Copyright © 2007 William Pitcock <nenolod -at- sacredspiral.co.uk> |
| 10 |
* Rights to this code are as documented in doc/pod/license.pod. |
| 11 |
* |
| 12 |
* $Id: table.h,v 1.3 2007-08-28 17:08:07 pippijn Exp $ |
| 13 |
*/ |
| 14 |
|
| 15 |
#ifndef ATHEME_TABLE_H |
| 16 |
#define ATHEME_TABLE_H |
| 17 |
|
| 18 |
struct table_t : zero_initialised |
| 19 |
{ |
| 20 |
object_t parent; |
| 21 |
list_t rows; |
| 22 |
}; |
| 23 |
|
| 24 |
struct table_row_t : zero_initialised |
| 25 |
{ |
| 26 |
int id; |
| 27 |
list_t cells; |
| 28 |
}; |
| 29 |
|
| 30 |
struct table_cell_t : zero_initialised |
| 31 |
{ |
| 32 |
int width; /* only if first row. */ |
| 33 |
char *name; |
| 34 |
char *value; |
| 35 |
}; |
| 36 |
|
| 37 |
/* |
| 38 |
* Creates a new table object. Use object_unref() to destroy it. |
| 39 |
*/ |
| 40 |
E table_t *table_new (char const * const fmt, ...); |
| 41 |
|
| 42 |
/* |
| 43 |
* Renders a table, each line going to callback(). |
| 44 |
*/ |
| 45 |
E void table_render (table_t * t, void (*callback) (char const * const line, void *data), void *data); |
| 46 |
|
| 47 |
/* |
| 48 |
* Associates a value with a row. |
| 49 |
*/ |
| 50 |
E void table_cell_associate (table_row_t * r, char const * const name, char const * const value); |
| 51 |
|
| 52 |
/* |
| 53 |
* Associates a row with a table. |
| 54 |
*/ |
| 55 |
E table_row_t *table_row_new (table_t * t); |
| 56 |
|
| 57 |
#endif |