gxXmlTable.h

Go to the documentation of this file.
00001 /*  Copyright (C) 2004  Guido Simone
00002  *
00003  *  This program is free software; you can redistribute it and/or modify
00004  *  it under the terms of the GNU General Public License as published by
00005  *  the Free Software Foundation; either version 2 of the License, or
00006  *  (at your option) any later version.
00007  *
00008  *  This program is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *  GNU General Public License for more details.
00012 
00013  *  You should have received a copy of the GNU General Public License
00014  *  along with this program; if not, write to the Free Software
00015  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016  */
00017 
00018 #ifndef GXLIB_GXXMLTABLE_H
00019 #define GXLIB_GXXMLTABLE_H
00020 
00021 
00033 class gxXmlTable
00034 {
00035 public:
00036    gxXmlTable();
00037    virtual ~gxXmlTable();
00038 
00039    int addHeaders( std::list<std::string> & items );
00040 
00044    int addHeaders( const char * item1, const char * item2 = NULL,
00045       const char * item3 = NULL, const char * item4 = NULL);
00046 
00047    int addRow( std::list<std::string> & items );
00051    int addRow( const char * item1, const char * item2 = NULL,
00052       const char * item3 = NULL, const char * item4 = NULL);
00057    int getColumnCount();
00061    std::string getColumnText(int index);
00066    int getColumnIndex(const char * text);
00070    std::string getId()
00071    {
00072       return m_tableId;
00073    }
00077    int getRowCount();
00081    std::string getItem( int rowIndex, int columnIndex );
00082 
00083    enum error_codes_t {
00084       TABLE_OK = 0,
00085       TABLE_NOHEADERS    = 1, // attempting to add data before headers
00086       TABLE_MULTIHEADERS = 2, // attempting to add more than one header row
00087       TABLE_TOOFEW = 3,       // adding a row with too few data elements
00088       TABLE_TOOMANY = 4,      // adding a row with too many data elements
00089    };
00090    typedef std::vector<std::string> strings_t;
00091 
00092    void setId( const char * id )
00093    {
00094       m_tableId = id;
00095    }
00100    void write( std::ostream & out );
00101 private:
00102    void copyStrings( std::list<std::string> & items, gxXmlTable::strings_t * result );
00103 
00104    strings_t * m_headers;
00105 
00106    typedef std::vector<strings_t> rows_t;
00107    rows_t m_rows;
00108 
00109    std::string m_tableId;
00110    gxXmlTable( const gxXmlTable & rhs);
00111    gxXmlTable & operator=( const gxXmlTable & rhs);
00112 };
00113 
00114 
00115 #endif

Generated on Mon Nov 21 01:01:35 2005 for gxLib by  doxygen 1.4.5