/* * Copyright (c) International Business Machines Corp., 2014 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #define COLS 5 int main(void) { table_t t = INIT_TABLE; table_init(&t, "table", COLS); const char * str = "column4 is a really long assed string"; table_name(&t, 0, "column0"); table_name(&t, 1, "column1"); table_name(&t, 2, "column2"); table_name(&t, 3, "column3"); table_name(&t, 4, str); printf("%s\n", table_name(&t, 4)); printf("cols: %d\n", table_columns(&t)); printf("rows: %d\n", table_rows(&t)); table_dump(&t, stdout); table_iter_t it; table_iter_init(&it, &t, TI_FLAG_FWD); size_t r, c; value_t * val; table_for_each(&it, val) { for (c=0; c %d\n", r, c, r * COLS + c); value_i32(v+c, r * COLS + c); value_dump(v+c, stdout); } table_row(&t, r, v); } table_dump(&t, stdout); printf("yyy =================\n"); table_for_each(&it, val) { for (c=0; c