Isis 3 Developer Reference
ImportPdsTable.h
Go to the documentation of this file.
1 #ifndef ImportPdsTable_h
2 #define ImportPdsTable_h
3 
25 #include <QString>
26 #include <QList>
27 #include <QStringList>
28 
29 #include <fstream>
30 #include <vector>
31 #include <string>
32 
33 class QString;
34 
35 namespace Isis {
36  class Table;
37  class TableField;
38  class TableRecord;
39  class PvlObject;
117  public:
118  ImportPdsTable();
119  ImportPdsTable(const QString &pdsLabFile,
120  const QString &pdsTabFile="",
121  const QString &pdsTableName ="TABLE");
122  virtual ~ImportPdsTable();
123 
124  QString name() const;
125  void setName(const QString &name = "TABLE");
126 
127  int columns() const;
128  int rows() const;
129 
130  void load(const QString &pdsLabFile, const QString &pdsTabFile = "",
131  const QString &pdsTableName = "TABLE");
132 
133  bool hasColumn(const QString &colName) const;
134  QString getColumnName(const unsigned int &index = 0,
135  const bool &formatted = true) const;
136  QStringList getColumnNames(const bool &formatted = true) const;
137  QString getFormattedName(const QString &colname) const;
138 
139  QString getType(const QString &colName) const;
140  bool setType(const QString &colName, const QString &dataType);
141 
142  Table importTable(const QString &isisTableName);
143  Table importTable(const QString &colNames,
144  const QString &isisTableName);
145  Table importTable(const QStringList &colNames,
146  const QString &isisTableName);
147 
148 
149  protected:
150  struct ColumnDescr {
151  QString m_name;
152  int m_colnum;
153  QString m_dataType;
157  int m_items;
158  };
159 
160  // Internal types
164 
165  const ColumnDescr &getColumnDescriptor(const int &nth) const;
166  ColumnDescr *findColumn(const QString &colName);
167  const ColumnDescr *findColumn(const QString &colName) const;
168 
169 
170  QString getColumnValue(const QString &tline,
171  const ColumnDescr &cdesc,
172  const QString &delimiter = "") const;
173  QStringList getColumnFields(const QString &tline,
174  const ColumnDescr &cdesc,
175  const QString &delimiter = "") const;
176 
177 
178  QString getGenericType(const QString &ttype) const;
179 
180  virtual bool processRow(const int &row, const QString &rowdata);
181 
182 
183  private:
184  void init();
185 
186  void loadLabel(const QString &labfile, QString &tblfile,
187  const QString &tblname = "");
188  void loadTable(const QString &tabfile);
189 
190  ColumnDescr getColumnDescription(PvlObject &colobj, int nth) const;
191 
192  TableRecord makeRecord(const ColumnTypes &ctypes);
193  TableField makeField(const ColumnDescr &cdesc);
194  TableField makeFieldFromBinaryTable(const ColumnDescr &cdesc);
195  void setPdsByteOrder(QString byteOrder);
196 
197  TableField &extract(const Columns &columns, const ColumnDescr &cdesc,
198  TableField &field) const;
199  TableRecord &extract(const Columns &columns, const ColumnTypes &ctypes,
200  TableRecord &record) const;
201  TableRecord extractBinary(char *rowBuffer, TableRecord &record) const;
202 
203  void fillTable(Table &table, const ColumnTypes &columns,
204  TableRecord &record) const;
205 
206  //private instance variables
207  int m_trows;
208  ColumnTypes m_coldesc;
209  Rows m_rows;
210  QString m_pdsTableType;
211  int m_rowBytes;
212  int m_recordBytes;
213  QString m_tableName;
214  QString m_pdsTableFile;
215  int m_pdsTableStart;
216  QString m_byteOrder;
218  };
219 
220 }
221 #endif
222 
QStringList Columns
Definition: ImportPdsTable.h:162
virtual bool processRow(const int &row, const QString &rowdata)
Process a freshly read PDS table line of data.
Definition: ImportPdsTable.cpp:1227
int m_colnum
Column number.
Definition: ImportPdsTable.h:152
int rows() const
Returns the number of rows in the table.
Definition: ImportPdsTable.cpp:1026
QString getGenericType(const QString &ttype) const
Determine generic data type of a column.
Definition: ImportPdsTable.cpp:813
Table importTable(const QString &isisTableName)
Populate a Table object with the PDS table and return it.
Definition: ImportPdsTable.cpp:333
int m_itemBytes
Number bytes per item.
Definition: ImportPdsTable.h:156
QString name() const
Return the name of the PDS table.
Definition: ImportPdsTable.cpp:104
QString m_name
Name of column.
Definition: ImportPdsTable.h:151
QString getType(const QString &colName) const
Get the type associated with the specified column.
Definition: ImportPdsTable.cpp:283
Definition: ImportPdsTable.h:150
QStringList getColumnNames(const bool &formatted=true) const
Return the names of all the columns.
Definition: ImportPdsTable.cpp:257
QStringList getColumnFields(const QString &tline, const ColumnDescr &cdesc, const QString &delimiter="") const
Extracts column fields from a QString based upon a description.
Definition: ImportPdsTable.cpp:727
void load(const QString &pdsLabFile, const QString &pdsTabFile="", const QString &pdsTableName="TABLE")
Loads a PDS table label and (optional) data file.
Definition: ImportPdsTable.cpp:147
virtual ~ImportPdsTable()
Destructs the ImportPdsTable object.
Definition: ImportPdsTable.cpp:99
QString getColumnName(const unsigned int &index=0, const bool &formatted=true) const
Returns the name of the specifed column.
Definition: ImportPdsTable.cpp:226
int columns() const
Returns the number of columns in the table.
Definition: ImportPdsTable.cpp:1014
QList< ColumnDescr > ColumnTypes
Definition: ImportPdsTable.h:161
QList< Columns > Rows
Definition: ImportPdsTable.h:163
void setName(const QString &name="TABLE")
Set the name of the PDS table object.
Definition: ImportPdsTable.cpp:113
bool hasColumn(const QString &colName) const
This method determines whether the PDS table has a column with the given name.
Definition: ImportPdsTable.cpp:201
int m_items
Number of items in column.
Definition: ImportPdsTable.h:157
QString getColumnValue(const QString &tline, const ColumnDescr &cdesc, const QString &delimiter="") const
Extracts a column from a QString based upon a description.
Definition: ImportPdsTable.cpp:705
bool setType(const QString &colName, const QString &dataType)
Change the datatype for a column.
Definition: ImportPdsTable.cpp:310
Class for storing Table blobs information.
Definition: Table.h:77
QString getFormattedName(const QString &colname) const
Converts a column name to a camel-case after it has been cleansed.
Definition: ImportPdsTable.cpp:774
int m_startByte
Starting byte of data.
Definition: ImportPdsTable.h:154
ImportPdsTable()
Default constructor.
Definition: ImportPdsTable.cpp:58
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Class for storing an Isis::Table&#39;s field information.
Definition: TableField.h:63
int m_numBytes
Number bytes in column.
Definition: ImportPdsTable.h:155
Definition: TableRecord.h:54
QString m_dataType
PDS table DATA_TYPE of column.
Definition: ImportPdsTable.h:153
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
const ColumnDescr & getColumnDescriptor(const int &nth) const
Retrieve a column description by index.
Definition: ImportPdsTable.cpp:629
Import a PDS table file with a label description.
Definition: ImportPdsTable.h:116
ColumnDescr * findColumn(const QString &colName)
Searches internal column descriptors for a named column.
Definition: ImportPdsTable.cpp:657