--- parser3/src/include/pa_table.h 2001/01/29 20:10:32 1.2 +++ parser3/src/include/pa_table.h 2001/03/24 19:12:18 1.19 @@ -1,11 +1,12 @@ -/* - $Id: pa_table.h,v 1.2 2001/01/29 20:10:32 paf Exp $ -*/ +/** @file + Parser: table class decl. -/* - hence most of tables are "named", no need to uptimize unnamed onces -*/ + Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexander Petrosyan (http://design.ru/paf) + + $Id: pa_table.h,v 1.19 2001/03/24 19:12:18 paf Exp $ +*/ #ifndef PA_TABLE_H #define PA_TABLE_H @@ -16,35 +17,61 @@ #include "pa_string.h" #include "pa_request.h" +/** + VTable backend. + + holds: + - column names[if any] + - data rows + - current row pointer + + uses String for column names and data items + + hence most of tables are "named", no need to uptimize nameless onces +*/ class Table : public Array { public: - // request I'm processed on - Request& request; + Table(Pool& apool, + const String& asource, + Array *acolumns, + int initial_rows=CR_INITIAL_ROWS_DEFAULT); - // the base origin of table data - Origin origin; + /// the string source of table's data + //const String& source() { return fsource; } - int current; + /// column names + const Array *columns() { return fcolumns; } - // columns - Array *columns; + /// moves @a current pointer + void set_current(int acurrent) { fcurrent=acurrent; } + /// @return current pointer + int get_current() { return fcurrent; } - Table(Request& request, - char *afile, uint aline, - Array *acolumns, - int initial_rows=CR_INITIAL_ROWS_DEFAULT); + /// @return item from @a column_name + const String *item(const String& column_name); - char *item(int column_index); - char *item(String column_name); +private: -protected: + // the base origin of table's data + const String& fsource; // column name->number lookup table Hash name2number; - Array *at(int index); + // current row + int fcurrent; + + // columns + Array *fcolumns; + + bool valid(int index) { return index>=0 && index