Annotation of parser3/src/include/pa_table.h, revision 1.12

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.12    ! paf         6:        $Id: pa_table.h,v 1.11 2001/03/12 12:00:05 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:        void inc_current() { fcurrent++; }
                     39: 
1.11      paf        40:        const String *item(const String& column_name);
1.2       paf        41: 
1.12    ! paf        42: private:
1.1       paf        43: 
1.5       paf        44:        // the base origin of table's data
1.12    ! paf        45:        const String& fsource;
1.5       paf        46: 
1.1       paf        47:        // column name->number lookup table
                     48:        Hash name2number;
                     49: 
1.5       paf        50:        // current row
                     51:        int fcurrent;
                     52: 
                     53:        // columns
                     54:        Array *fcolumns;
                     55: 
1.12    ! paf        56:        bool valid(int index) { return index>=0 && index<size();        }
        !            57: 
1.7       paf        58:        const Array& at(int index);
1.2       paf        59: 
1.11      paf        60:        const String *item(int column_index) {
1.12    ! paf        61:                return valid(fcurrent)?at(fcurrent).get_string(column_index):0;
1.11      paf        62:        }
1.1       paf        63: };
                     64: 
                     65: #endif

E-mail: