TTable.h

Go to the documentation of this file.
00001 //$$FILE$$
00002 //$$VERSION$$
00003 //$$DATE$$
00004 //$$LICENSE$$
00005 
00006 
00014 #ifndef TTABLE_H
00015 #define TTABLE_H
00016 
00017 
00018 #include <string>
00019 #include <vector>
00020 
00021 #include "GenString.h"
00022 #include "TableError.h"
00023 #include "Serializer.h"
00024 
00025 
00026 using namespace std;
00027 
00028 
00043 class TTable
00044 {
00045   public:
00059     TTable();
00060 
00077     TTable(const TTable& inTable);
00078 
00092     virtual ~TTable();
00093 
00108     TTable& operator=(const TTable& inTable);
00109 
00123     void Clear();
00124 
00138     inline unsigned int GetNumTuples() const;
00139 
00140     /* \todo Re-use much of the comment of InsertTuple() */
00141     unsigned int AddTuple(const vector<string>& tuple = vector<string> (0));
00142 
00179     void InsertTuple(const unsigned int tupleIndex,
00180       const vector<string>& tuple = vector<string> (0));
00181 
00182     void InsertTuple(const unsigned int tupleIndex,
00183       vector<string>::const_iterator tupleBeg,
00184       vector<string>::const_iterator tupleEnd);
00185 
00219     void FillTuple(const unsigned int tupleIndex, const vector<string>& tuple,
00220       const unsigned int fromColIndex = 0);
00221 
00222     void GetTuple(vector<string>& tuple, const unsigned int tupleIndex,
00223       const unsigned int fromColIndex, unsigned int toColIndex);
00224 
00225     const vector<string>& GetTuple(const unsigned int tupleIndex);
00226 
00243     void ClearTuple(const unsigned int tupleIndex);
00244 
00261     void DeleteTuple(const unsigned int tupleIndex);
00262 
00274     inline unsigned int GetNumColumns() const;
00275 
00305     unsigned int AddColumn(const vector<string>& col = vector<string> (0));
00306 
00347     unsigned int InsertColumn(const unsigned int atColIndex,
00348       const vector<string>& col = vector<string> (0));
00349 
00350     void InsertColumn(const unsigned int atColIndex,
00351       vector<string>::const_iterator colBeg,
00352       vector<string>::const_iterator colEnd);
00353 
00378     void FillColumn(const unsigned int colIndex, const vector<string>& col,
00379       const unsigned int fromTupleIndex = 0);
00380 
00381     void FillColumn(const unsigned int colIndex,
00382       vector<string>::const_iterator colBeg,
00383       vector<string>::const_iterator colEnd,
00384       const unsigned int fromTupleIndex = 0);
00385 
00425     void GetColumn(vector<string>& col, const unsigned int colIndex,
00426       const unsigned int fromTupleIndex, unsigned int toTupleIndex);
00427 
00443     void ClearColumn(const unsigned int colIndex);
00444 
00462     void DeleteColumn(const unsigned int colIndex);
00463 
00485     string& operator()(const unsigned int tupleIndex,
00486       const unsigned int colIndex);
00487 
00509     const string& operator()(const unsigned int tupleIndex,
00510       const unsigned int colIndex) const;
00511 
00512     int Write(Serializer* ser, unsigned int& size);
00513     int Read(UInt32 index, Serializer* ser);
00514 
00515   private:
00516     unsigned int _numCols;
00517 
00518     vector<vector<string>*> _tuples;
00519 
00520     inline unsigned int IntColIndex(const unsigned int colIndex) const;
00521 
00522 #ifndef TTABLE_COLUMN_DELETE_AS_REMOVE
00523     unsigned int _numDelCols;
00524     vector<unsigned int> _delColMap;
00525 
00526     void EnlargeColMap(const unsigned int numCols);
00527     void ReduceColMap(const unsigned int numCols);
00528     void MarkColDeleted(const unsigned int colIndex);
00529     void UnMarkColDeleted(const unsigned int colIndex);
00530 #endif
00531 
00532 };
00533 
00534 
00535 ostream& operator<<(ostream& out, const TTable& sTable);
00536 
00537 
00538 inline unsigned int TTable::GetNumTuples() const
00539 {
00540     return(_tuples.size());
00541 }
00542 
00543 
00544 inline unsigned int TTable::GetNumColumns() const
00545 {
00546 #ifndef TTABLE_COLUMN_DELETE_AS_REMOVE
00547     return(_numCols - _numDelCols);
00548 #else
00549     return(_numCols);
00550 #endif
00551 }
00552 
00553 inline unsigned int TTable::IntColIndex(const unsigned int colIndex) const
00554 {
00555 
00556     // Returns the TTable internal column index
00557 #ifndef TTABLE_COLUMN_DELETE_AS_REMOVE
00558     return(_delColMap[colIndex]);
00559 #else
00560     return(colIndex);
00561 #endif
00562 }
00563 
00564 #endif // TTABLE_H

Generated on Tue Feb 5 09:01:26 2008 for tables-v8.0 by  doxygen 1.5.1