Branch: Tag:

2017-11-15

2017-11-15 18:14:56 by Martin Nilsson <nilsson@fastmail.com>

Improved types and visibility modifiers

17:      //! The table base-class.   class table { -  protected private mapping fieldmap; -  protected private array table, fields, types; +  protected mapping fieldmap; +  protected array table, fields, types;    -  protected private array|int remap(array|string|int cs, int|void forgive) +  protected array|int remap(array|string|int cs, int|void forgive)    {    array v = ({});    int ap = arrayp(cs);
67:       //! This method returns the column names for the table. The case used when    //! the table was created will be returned. -  array(string) _indices() +  protected array(string) _indices()    {    return copy_value(fields);    }       //! This method returns the contents of a table as a two dimensional array.    //! The format is an array of rows. Each row is an array of columns. -  array(array) _values() +  protected array(array) _values()    {    return copy_value(table);    }       //! This method returns the number of rows in the table. -  int _sizeof() +  protected int _sizeof()    {    return sizeof(table);    }       //! This method reverses the rows of the table and returns a    //! new table object. -  object reverse() +  protected this_program reverse()    {    return copy(predef::reverse(table), fields, types);    }
105:    }       //! Same as @[col()]. -  array `[](int|string column) +  protected array `[](int|string column)    {    return col(column);    }
113:    //! This method compares two tables. They are equal if the contents    //! of the tables and the column names are equal. The column name    //! comparison is case insensitive. -  int `==(object table) +  protected int(0..1) `==(object table)    {    return (equal(Array.map(fields, lower_case),    Array.map(indices(table), lower_case)) &&
123:    //! This method appends two tables. The table given as an argument will be    //! added at the bottom of the current table. Note, the column names must    //! be equal. The column name comparison is case insensitive. -  object append_bottom(object table) +  this_program append_bottom(object table)    {    if(!equal(Array.map(indices(table), lower_case),    Array.map(fields, lower_case)))
134:    //! This method appends two tables. The table given as an argument will be    //! added on the right side of the current table. Note that the number of    //! rows in both tables must be equal. -  object append_right(object table) +  this_program append_right(object table)    {    if(sizeof(table) != sizeof(this::table))    TABLE_ERR("Table sizes are not equal.");
144:    return copy(v, fields+indices(table), types+table->all_types());    }    -  protected private mixed op_col(function f, int|string c, mixed ... args) +  protected mixed op_col(function f, int|string c, mixed ... args)    {    c = remap(c);    mixed x = table[0][c];
174:    }       //! This method returns a new table object with the selected columns only. -  object select(int|string ... columns) +  this_program select(int|string ... columns)    {    array t = ({});    columns = remap(columns);
185:       //! Like @[select()], but the given @[columns] will not be in the    //! resulting table. -  object remove(int|string ... columns) +  this_program remove(int|string ... columns)    {    return select(@remap(fields) - remap(columns, 1));    }
194:    //! returns zero, the row will be thrown away. If the function    //! returns something non-zero, the row will be kept. The result    //! will be returned as a new table object. -  object where(array(int|string)|int|string columns, function f, +  this_program where(array(int|string)|int|string columns, function f,    mixed ... args)    {    array t = ({});
280:    return copy(t, fields, types);    }    -  protected private this_program _sort(int is_reversed, int|string ... cs) +  protected this_program _sort(int is_reversed, int|string ... cs)    {    if(!sizeof(cs))    return this;
315:    //! @seealso    //! @[rsort()]    //! -  object sort(int|string ... columns) +  this_program sort(int|string ... columns)    {    return _sort(0, @columns);    }
328:       //! This method truncates the table to the first @[n] rows and returns    //! a new object. -  object limit(int n) +  this_program limit(int n)    {    return copy(table[0..(n-1)], fields, types);    }
336:    //! This method renames the column named @[from] to @[to] and    //! returns a new table object. Note that @[from] can be the column    //! position. -  object rename(string|int from, string to) +  this_program rename(string|int from, string to)    {    array a = copy_value(fields);    a[remap(from)] = to;
388:    //! @seealso    //! @[ADT.Table.ASCII.encode()]    //! -  void create(array(array) table, array(string) column_names, +  protected void create(array(array) table, array(string) column_names,    array(mapping(string:string))|void column_types)    {    if(!arrayp(table))
418:   }      object Separated = class { -  protected private string _string(mixed x) { return (string)x; } +  protected string _string(mixed x) { return (string)x; }       object decode(string s, void|mapping options)    {