Annotation of parser3/src/include/pa_table.h, revision 1.14
1.14 ! paf 1: /** @file
1.9 paf 2: Parser
3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.10 paf 4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.9 paf 5:
1.14 ! paf 6: $Id: pa_table.h,v 1.13 2001/03/12 20:55:15 paf Exp $
1.1 paf 7: */
8:
9: #ifndef PA_TABLE_H
10: #define PA_TABLE_H
11:
12: #include "pa_types.h"
13: #include "pa_array.h"
14: #include "pa_hash.h"
1.2 paf 15: #include "pa_string.h"
16: #include "pa_request.h"
1.1 paf 17:
1.14 ! paf 18: /// parser \b table class backend
! 19: /**
! 20: holds
! 21: - column names[if any]
! 22: - data rows
! 23: - current row pointer
! 24:
! 25: uses String for column names and data items
! 26:
! 27: hence most of tables are "named", no need to uptimize nameless onces
! 28: */
1.1 paf 29: class Table : public Array {
30: public:
31:
1.11 paf 32: Table(Pool& apool,
1.12 paf 33: const String& asource,
1.2 paf 34: Array *acolumns,
35: int initial_rows=CR_INITIAL_ROWS_DEFAULT);
36:
1.14 ! paf 37: /// the string source of table's data
! 38: //const String& source() { return fsource; }
1.5 paf 39:
1.14 ! paf 40: /// column names
1.5 paf 41: const Array *columns() { return fcolumns; }
42:
1.14 ! paf 43: /// moves \a current pointer
1.5 paf 44: void set_current(int acurrent) { fcurrent=acurrent; }
1.14 ! paf 45: /// \return current pointer
1.5 paf 46: int get_current() { return fcurrent; }
47:
1.14 ! paf 48: /// \return item from \a column_name
1.11 paf 49: const String *item(const String& column_name);
1.2 paf 50:
1.12 paf 51: private:
1.1 paf 52:
1.5 paf 53: // the base origin of table's data
1.12 paf 54: const String& fsource;
1.5 paf 55:
1.1 paf 56: // column name->number lookup table
57: Hash name2number;
58:
1.5 paf 59: // current row
60: int fcurrent;
61:
62: // columns
63: Array *fcolumns;
64:
1.12 paf 65: bool valid(int index) { return index>=0 && index<size(); }
66:
1.7 paf 67: const Array& at(int index);
1.2 paf 68:
1.11 paf 69: const String *item(int column_index) {
1.12 paf 70: return valid(fcurrent)?at(fcurrent).get_string(column_index):0;
1.11 paf 71: }
1.1 paf 72: };
73:
74: #endif
E-mail: