Isis 3.0 Programmer Reference
Back | Home
Table.h
Go to the documentation of this file.
1 #ifndef Table_h
2 #define Table_h
3 
25 #include "Blob.h"
26 #include <vector>
27 #include "TableRecord.h"
28 
29 namespace Isis {
30  class Pvl;
74  class Table : public Isis::Blob {
75  public:
79  enum Association {
80  None,
81  Samples,
82  Lines,
83  Bands
84  };
85 
86  // Constructors and Destructors
87  Table(const QString &tableName, TableRecord &rec);
88  Table(const QString &tableName);// Only use this constructor for reading in an existing table
89  Table(const QString &tableName, const QString &file);
90  Table(const QString &tableName, const QString &file,
91  const Pvl &fileHeader);
92  Table(const Table &other);
93  Table &operator=(const Isis::Table &other);
94 
95  ~Table();
96 
97 
98  friend std::istream&operator>>(std::istream &is, Table &table);
99  friend std::ostream&operator<<(std::ostream &os, Table &table);
100 
101  void SetAssociation(const Table::Association assoc);
102  bool IsSampleAssociated();
103  bool IsLineAssociated();
104  bool IsBandAssociated();
105 
106  int Records() const;
107  int RecordFields() const;
108  int RecordSize() const;
109 
110  // Read a record
111  TableRecord &operator[](const int index);
112 
113  // Add a record
114  void operator+=(TableRecord &rec);
115 
116  // Update a record
117  void Update(const TableRecord &rec, const int index);
118 
119  // Delete a record
120  void Delete(const int index);
121 
122  void Clear();
123 
124 
125  static QString toString(Table table, QString fieldDelimiter=",");
126 
127  protected:
128  void ReadInit();
129  void ReadData(std::istream &stream);
130  void WriteInit();
131  void WriteData(std::fstream &os);
132 
134  std::vector<char *> p_recbufs;
135 
136  int p_records;
139  Association p_assoc;
140  bool p_swap;
141  };
142 };
143 
144 #endif
145 
void WriteInit()
Virtual Function to prepare labels for writing.
Definition: Table.cpp:376
int Records() const
Returns the number of records.
Definition: Table.cpp:224
bool IsBandAssociated()
Checks to see if association is Bands.
Definition: Table.cpp:215
TableRecord p_record
The current table record.
Definition: Table.h:133
int RecordFields() const
Returns the number of fields per record.
Definition: Table.cpp:233
bool IsLineAssociated()
Checks to see if association is Lines.
Definition: Table.cpp:205
void WriteData(std::fstream &os)
Virtual function to write the data.
Definition: Table.cpp:406
int p_records
Holds record count read from labels, may differ from the size of p_recbufs.
Definition: Table.h:136
~Table()
Destroys the Table object.
Definition: Table.cpp:176
std::vector< char * > p_recbufs
Buffers containing record values.
Definition: Table.h:134
Association p_assoc
Association Type of the table.
Definition: Table.h:139
void Clear()
Clear the table of all records.
Definition: Table.cpp:307
int RecordSize() const
Returns the number of bytes per record.
Definition: Table.cpp:242
Table(const QString &tableName, TableRecord &rec)
This constructor creates a new table using the given name and record.
Definition: Table.cpp:54
void Delete(const int index)
Deletes a TableRecord from the Table.
Definition: Table.cpp:297
Container for cube-like labels.
Definition: Pvl.h:135
void Update(const TableRecord &rec, const int index)
Updates a TableRecord.
Definition: Table.cpp:288
void SetAssociation(const Table::Association assoc)
Sets the association to the input parameter.
Definition: Table.cpp:185
Table & operator=(const Isis::Table &other)
Sets the Table equal to the input Table object.
Definition: Table.cpp:154
Class for storing Table blobs information.
Definition: Table.h:74
void operator+=(TableRecord &rec)
Adds a TableRecord to the Table.
Definition: Table.cpp:263
TableRecord & operator[](const int index)
Reads a TableRecord from the Table.
Definition: Table.cpp:253
void ReadInit()
Virtual function to validate PVL table information.
Definition: Table.cpp:313
bool IsSampleAssociated()
Checks to see if association is Samples.
Definition: Table.cpp:195
void ReadData(std::istream &stream)
Virtual function to Read the data.
Definition: Table.cpp:351
bool p_swap
Only used for reading.
Definition: Table.h:140

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:30:21