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