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

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.2.1! 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.12.2.1! paf        10:        Array<String> columns
        !            11:        Array<Array<char *>> table
        !            12: 
1.11      paf        13:        hence most of tables are "named", no need to uptimize nameless onces
1.2       paf        14: */
                     15: 
1.1       paf        16: #ifndef PA_TABLE_H
                     17: #define PA_TABLE_H
                     18: 
                     19: #include "pa_types.h"
                     20: #include "pa_array.h"
                     21: #include "pa_hash.h"
1.2       paf        22: #include "pa_string.h"
                     23: #include "pa_request.h"
1.1       paf        24: 
                     25: class Table : public Array {
                     26: public:
                     27: 
1.11      paf        28:        Table(Pool& apool,
1.2       paf        29:                Array *acolumns,
                     30:                int initial_rows=CR_INITIAL_ROWS_DEFAULT);
                     31: 
1.5       paf        32:        const Array *columns() { return fcolumns; }
                     33: 
                     34:        void set_current(int acurrent) { fcurrent=acurrent; }
                     35:        int get_current() { return fcurrent; }
                     36:        void inc_current() { fcurrent++; }
                     37: 
1.12.2.1! paf        38:        const char *item(const String& column_name);
1.2       paf        39: 
1.12      paf        40: private:
1.1       paf        41: 
                     42:        // column name->number lookup table
                     43:        Hash name2number;
                     44: 
1.5       paf        45:        // current row
                     46:        int fcurrent;
                     47: 
                     48:        // columns
                     49:        Array *fcolumns;
                     50: 
1.12      paf        51:        bool valid(int index) { return index>=0 && index<size();        }
                     52: 
1.7       paf        53:        const Array& at(int index);
1.2       paf        54: 
1.12.2.1! paf        55:        const char *item(int column_index) {
        !            56:                return valid(fcurrent)?at(fcurrent).get_cstr(column_index):0;
1.11      paf        57:        }
1.1       paf        58: };
                     59: 
                     60: #endif

E-mail: