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

1.14      paf         1: /** @file
1.15      paf         2:        Parser: table class decl.
                      3: 
1.48.2.9  paf         4:        Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
1.41      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1       paf         6: */
                      7: 
                      8: #ifndef PA_TABLE_H
                      9: #define PA_TABLE_H
1.45      paf        10: 
1.48.2.11.2.2! (paf       11:: static const char* IDENT_TABLE_H="$Date: 2003/03/18 15:14:17 $";
1.1       paf        12: 
                     13: #include "pa_types.h"
                     14: #include "pa_hash.h"
1.2       paf        15: #include "pa_string.h"
1.1       paf        16: 
1.16      paf        17: /** 
1.19      paf        18:        VTable backend.
1.16      paf        19: 
                     20:        holds:
1.14      paf        21:        - column names[if any]
                     22:        - data rows
                     23:        - current row pointer
                     24: 
                     25:        uses String for column names and data items
                     26: 
1.28      paf        27:        hence most of tables are "named", no need to uptimize nameless onces.
                     28:        rows and strings stored are read-only. once stored they can be removed,
                     29:        but not altered. that's handy for quick copying & co. see table:join
1.14      paf        30: */
1.48.2.11.2.1  (paf       31:: class Table: public Array<ArrayString* > {
1.1       paf        32: public:
1.48.2.11.2.1  (paf       33::       typedef ArrayString*  columns_type;
1.1       paf        34: 
1.48.2.1  paf        35:        Table(
1.48.2.4  paf        36:                columns_type acolumns,
1.48.2.1  paf        37:                int initial_rows=3);
                     38:        Table(const Table& src, int offset=0, int limit=0);
1.2       paf        39: 
1.42      paf        40:        /// gets column names
1.48.2.4  paf        41:        columns_type columns() { return fcolumns; }
1.5       paf        42: 
1.18      paf        43:        /// moves @a current pointer
1.5       paf        44:        void set_current(int acurrent) { fcurrent=acurrent; }
1.17      paf        45:        /// @return current pointer
1.47      paf        46:        int current() const { return fcurrent; }
1.37      paf        47:        void offset(bool absolute, int offset);
1.5       paf        48: 
1.32      paf        49:        /** @return column index from @a column_name. '<0' if no such column
1.48.2.1  paf        50:                if no such - 'bark'
1.32      paf        51:        */
1.48.2.11.2.1  (paf       52::       int column_name2index(const String& column, bool bark) const;
1.30      paf        53: 
1.26      paf        54:        /// @return item from @a column
1.48.2.11.2.1  (paf       55::       const String* item(int column);
1.30      paf        56: 
                     57:        /// @return item from @a column. '0' if no such column
1.48.2.11.2.1  (paf       58::       const String* item(const String& column) {
1.32      paf        59:                int index=column_name2index(column, false);
1.48.2.11.2.1  (paf       60::               return index>=0?item(index):0;
1.24      paf        61:        }
1.23      paf        62: 
                     63:        /// saves to text file
1.48.2.11.2.1  (paf       64::       void save(bool nameless_save, const String& file_spec);
1.2       paf        65: 
1.48.2.11.2.1  (paf       66::       bool locate(int column, const String& value);
                     67::       bool locate(const String& column, const String& value);
1.27      paf        68: 
1.12      paf        69: private:
1.21      paf        70:        
1.5       paf        71:        // current row
                     72:        int fcurrent;
                     73: 
                     74:        // columns
1.48.2.4  paf        75:        columns_type fcolumns;
1.48.2.1  paf        76: 
                     77:        // column names are already referenced in fcolumns, no need to doublecheck references here
                     78:        // column name->number lookup table
1.48.2.5  paf        79:        typedef Hash<const String&, int> name2number_hash_class;
1.48.2.11.2.1  (paf       80::       name2number_hash_class* name2number;
1.48.2.1  paf        81: 
                     82:        // we own columns?
1.5       paf        83: 
1.48.2.1  paf        84:        bool valid(int index) const { return index>=0 && index<count(); }
1.2       paf        85: 
1.1       paf        86: };
                     87: 
                     88: #endif

E-mail: