pike.git / lib / modules / ADT.pmod / Table.pmod

version» Context lines:

pike.git/lib/modules/ADT.pmod/Table.pmod:1:   // Table.pmod by Fredrik Noring, 1998 - // $Id: Table.pmod,v 1.8 1998/06/24 17:02:42 noring Exp $ + // $Id: Table.pmod,v 1.9 1998/06/26 16:43:34 noring Exp $      #define TABLE_ERR(msg) throw(({ "(Table) "+msg+"\n", backtrace() }))      class table {    static private mapping fieldmap;    static private array table, fields, types;       static private array|int remap(array|string|int cs, int|void forgive)    {    array v = ({});
pike.git/lib/modules/ADT.pmod/Table.pmod:96:    if(!equal(Array.map(indices(t), lower_case),    Array.map(fields, lower_case)))    TABLE_ERR("Table fields are not equal.");    return copy(table+values(t), fields, types);    }       object append_right(object t)    {    if(sizeof(t) != sizeof(table))    TABLE_ERR("Table sizes are not equal."); -  fields += indices(t); +     array v = values(t);    for(int r = 0; r < sizeof(table); r++) -  table[r] = table[r] + v[r]; -  return this_object(); +  v[r] = table[r] + v[r]; +  return copy(v, fields+indices(t), types+t->all_types());    }       static private mixed op_col(function f, int|string c, mixed ... args)    {    c = remap(c);    mixed x = table[0][c];    for(int r = 1; r < sizeof(table); r++)    f(x, table[r][c], @args);    return x;    }
pike.git/lib/modules/ADT.pmod/Table.pmod:264:    return copy(table, a, types);    }       mapping type(int|string c, void|mapping m)    {    if(query_num_arg() == 2)    types[remap(c)] = copy_value(m);    return copy_value(types[remap(c)]);    }    +  array all_types() +  { +  return copy_value(types); +  } +     void create(array(array) tab, array(string) fie, array|void typ)    {    if(!arrayp(tab))    TABLE_ERR("Table not array");    if(!arrayp(fie))    TABLE_ERR("Fields not array");    if(sizeof(tab) && sizeof(tab[0]) != sizeof(fie))    TABLE_ERR("Table and field sizes differ");    foreach(fie, string s)    if(!stringp(s))