STable.h

Go to the documentation of this file.
00001 //$$FILE$$
00002 //$$VERSION$$
00003 //$$DATE$$
00004 //$$LICENSE$$
00005 
00006 
00014 #ifndef STABLE_H
00015 #define STABLE_H
00016 
00017 
00018 #include <string>
00019 #include <vector>
00020 
00021 #include "GenString.h"
00022 #include "TableError.h"
00023 
00024 
00025 using namespace std;
00026 
00027 
00042 class STable
00043 {
00044   public:
00060     STable(const StringCompare::eCompareType colCaseSense =
00061       StringCompare::eCASE_SENSITIVE);
00062 
00078     STable(const string& name,
00079       const StringCompare::eCompareType colCaseSense =
00080       StringCompare::eCASE_SENSITIVE);
00081 
00095     STable(const STable& inTable);
00096 
00108     virtual ~STable();
00109 
00122     virtual STable& operator=(const STable& inTable);
00123 
00134     virtual void Clear();
00135 
00147     inline const string GetName() const; 
00148 
00160     void Rename(const string& name);
00161 
00173     inline unsigned int GetNumColumns() const;
00174 
00186     void GetColumnNames(vector<string>& colNames) const;
00187 
00199     bool IsColumnPresent(const string& colName);
00200 
00229     void AddColumn(const string& colName, const vector<string>& col =
00230       vector<string> (0));
00231 
00274     void InsertColumn(const string& colName, const string& atColName,
00275       const vector<string>& col = vector<string> (0));
00276 
00305     virtual void FillColumn(const string& colName, const vector<string>& col);
00306 
00332     virtual void AppendToColumn(const string& colName, const string& cell);
00333 
00359     virtual void AppendToColumn(const string& colName,
00360       const vector<string>& col);
00361 
00378     virtual void GetColumn(vector<string>& col, const string& colName);
00379 
00411     virtual void GetColumn(vector<string>& col, const string& colName,
00412       const unsigned int fromRowIndex, unsigned int toRowIndex);
00413 
00437     virtual void GetColumn(vector<string>& col,
00438       const string& colName, const vector<unsigned int>& rowIndices);
00439 
00456     unsigned int ColumnLength(const string& colName) const;
00457 
00480     void RenameColumn(const string& oldColName, const string& newColName);
00481 
00498     virtual void ClearColumn(const string& colName);
00499 
00516     virtual void DeleteColumn(const string& colName);
00517 
00521     unsigned int GetColumnIndex(const string& colName) const;
00522 
00526     void GetColumnsIndices(vector<unsigned int>& colIndices,
00527       const vector<string>& colNames = vector<string> (0));
00528 
00529 
00541     virtual inline unsigned int GetNumRows() const;
00542 
00572     virtual unsigned int AddRow(const vector<string>& row =
00573       vector<string> (0));
00574 
00615     virtual unsigned int InsertRow(const unsigned int atRowIndex,
00616       const vector<string>& row = vector<string> (0));
00617 
00642     virtual void FillRow(const unsigned int rowIndex,
00643       const vector<string>& row);
00644 
00684     virtual void GetRow(vector<string>& row, const unsigned int rowIndex,
00685       const string& fromColName = String::Empty, const string& toColName =
00686       String::Empty);
00687 
00703     virtual void ClearRow(const unsigned int rowIndex);
00704 
00722     virtual void DeleteRow(const unsigned int rowIndex);
00723 
00745     virtual void UpdateCell(const unsigned int rowIndex, const string& colName,
00746       const string& cell);
00747 
00769     virtual const string& operator()(const unsigned int rowIndex,
00770       const string& colName) const;
00771 
00772   protected:
00773     string _name;
00774 
00775     StringCompare::eCompareType _colCaseSense;
00776 
00777     vector<string> _colNames;
00778 
00779     unsigned int _numRows;
00780 
00781     unsigned int _numNonEmptyCols;
00782 
00783     vector<vector<string>*> _data;
00784 
00785     void InsertColumn(const string& colName, const unsigned int colIndex,
00786       const vector<string>& col = vector<string> (0));
00787     void FillColumn(const vector<string>& col, const unsigned int colIndex);
00788     void CreateColumn(const unsigned int colIndex,
00789       const vector<string>& col = vector<string> (0));
00790     void AppendToColumn(const string& cell, const unsigned int colIndex);
00791     void AppendToColumn(const vector<string>& col,
00792       const unsigned int colIndex);
00793     void ClearColumn(const unsigned int colIndex);
00794     void DeleteColumn(const unsigned int colIndex);
00795 
00796     void VerifyColumnsIndices(const vector<unsigned int>& colIndices);
00797     void _GetColumnsIndices(vector<unsigned int>& colIndices,
00798       const vector<string>& colNames);
00799 
00800     void FillRow(const vector<string>& row,
00801       const unsigned int rowIndex, const unsigned int fromColIndex,
00802       const unsigned int toColIndex);
00803     void GetSubRow(vector<string>& subRow, const unsigned int rowIndex,
00804       const unsigned int fromColIndex, unsigned int toColIndex);
00805 
00806     void UpdateCell(const string& cell, const unsigned int colIndex,
00807       const unsigned int rowIndex);
00808     void GetCell(string& cell, const unsigned int colIndex,
00809       const unsigned int rowIndex);
00810 };
00811 
00812 
00813 ostream& operator<<(ostream& out, const STable& sTable);
00814 
00815 
00816 inline const string STable::GetName() const
00817 {
00818     return(_name);
00819 }
00820 
00821 
00822 inline unsigned int STable::GetNumColumns() const
00823 {
00824     return(_colNames.size());
00825 }
00826 
00827 
00828 inline unsigned int STable::GetNumRows() const
00829 {
00830     return(_numRows);
00831 }
00832 
00833 
00834 #endif // STABLE_H

Generated on Mon Apr 2 09:28:50 2007 for cif-table-obj-v7.0 by  doxygen 1.5.1