Annotation of parser3/src/include/pa_table.h, revision 1.13
1.1 paf 1: /*
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.13 ! paf 6: $Id: pa_table.h,v 1.12 2001/03/12 13:13:20 paf Exp $
1.1 paf 7: */
8:
1.2 paf 9: /*
1.11 paf 10: hence most of tables are "named", no need to uptimize nameless onces
1.2 paf 11: */
12:
13:
1.1 paf 14: #ifndef PA_TABLE_H
15: #define PA_TABLE_H
16:
17: #include "pa_types.h"
18: #include "pa_array.h"
19: #include "pa_hash.h"
1.2 paf 20: #include "pa_string.h"
21: #include "pa_request.h"
1.1 paf 22:
23: class Table : public Array {
24: public:
25:
1.11 paf 26: Table(Pool& apool,
1.12 paf 27: const String& asource,
1.2 paf 28: Array *acolumns,
29: int initial_rows=CR_INITIAL_ROWS_DEFAULT);
30:
1.12 paf 31: // the source of table's data
32: const String& source() { return fsource; }
1.5 paf 33:
34: const Array *columns() { return fcolumns; }
35:
36: void set_current(int acurrent) { fcurrent=acurrent; }
37: int get_current() { return fcurrent; }
38:
1.11 paf 39: const String *item(const String& column_name);
1.2 paf 40:
1.12 paf 41: private:
1.1 paf 42:
1.5 paf 43: // the base origin of table's data
1.12 paf 44: const String& fsource;
1.5 paf 45:
1.1 paf 46: // column name->number lookup table
47: Hash name2number;
48:
1.5 paf 49: // current row
50: int fcurrent;
51:
52: // columns
53: Array *fcolumns;
54:
1.12 paf 55: bool valid(int index) { return index>=0 && index<size(); }
56:
1.7 paf 57: const Array& at(int index);
1.2 paf 58:
1.11 paf 59: const String *item(int column_index) {
1.12 paf 60: return valid(fcurrent)?at(fcurrent).get_string(column_index):0;
1.11 paf 61: }
1.1 paf 62: };
63:
64: #endif
E-mail: