--- parser3/src/include/pa_table.h 2001/01/29 20:10:32 1.2 +++ parser3/src/include/pa_table.h 2001/03/26 09:53:42 1.22 @@ -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.22 2001/03/26 09:53:42 paf Exp $ +*/ #ifndef PA_TABLE_H #define PA_TABLE_H @@ -16,35 +17,61 @@ #include "pa_string.h" #include "pa_request.h" -class Table : public Array { -public: +/** + VTable backend. - // request I'm processed on - Request& request; + holds: + - column names[if any] + - data rows + - current row pointer - // the base origin of table data - Origin origin; + uses String for column names and data items - int current; - - // columns - Array *columns; + hence most of tables are "named", no need to uptimize nameless onces +*/ +class Table : public Array { +public: - Table(Request& request, - char *afile, uint aline, + Table(Pool& apool, + const String *aorigin, Array *acolumns, int initial_rows=CR_INITIAL_ROWS_DEFAULT); - char *item(int column_index); - char *item(String column_name); + /// where this table came from, may be NULL + const String *origin_string() { return forigin_string; } + + /// column names + const Array *columns() { return fcolumns; } -protected: + /// moves @a current pointer + void set_current(int acurrent) { fcurrent=acurrent; } + /// @return current pointer + int get_current() { return fcurrent; } + + /// @return item from @a column_name + const String *item(const String& column_name); + +private: + + // where this table came from, may be NULL + const String *forigin_string; // 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