Isis 3.0 Programmer Reference
Back | Home
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;
115  public:
116  ImportPdsTable();
117  ImportPdsTable(const QString &pdsLabFile,
118  const QString &pdsTabFile="",
119  const QString &pdsTableName ="TABLE");
120  virtual ~ImportPdsTable();
121 
122  QString name() const;
123  void setName(const QString &name = "TABLE");
124 
125  int columns() const;
126  int rows() const;
127 
128  void load(const QString &pdsLabFile, const QString &pdsTabFile = "",
129  const QString &pdsTableName = "TABLE");
130 
131  bool hasColumn(const QString &colName) const;
132  QString getColumnName(const unsigned int &index = 0,
133  const bool &formatted = true) const;
134  QStringList getColumnNames(const bool &formatted = true) const;
135  QString getFormattedName(const QString &colname) const;
136 
137  QString getType(const QString &colName) const;
138  bool setType(const QString &colName, const QString &dataType);
139 
140  Table importTable(const QString &isisTableName);
141  Table importTable(const QString &colNames,
142  const QString &isisTableName);
143  Table importTable(const QStringList &colNames,
144  const QString &isisTableName);
145 
146 
147  protected:
148  struct ColumnDescr {
149  QString m_name;
150  int m_colnum;
151  QString m_dataType;
155  int m_items;
156  };
157 
158  // Internal types
160  typedef QStringList Columns;
161  typedef QList<Columns> Rows;
162 
163  const ColumnDescr &getColumnDescriptor(const int &nth) const;
164  ColumnDescr *findColumn(const QString &colName);
165  const ColumnDescr *findColumn(const QString &colName) const;
166 
167 
168  QString getColumnValue(const QString &tline,
169  const ColumnDescr &cdesc,
170  const QString &delimiter = "") const;
171  QStringList getColumnFields(const QString &tline,
172  const ColumnDescr &cdesc,
173  const QString &delimiter = "") const;
174 
175 
176  QString getGenericType(const QString &ttype) const;
177 
178  virtual bool processRow(const int &row, const QString &rowdata);
179 
180 
181  private:
182  void init();
183 
184  void loadLabel(const QString &labfile, QString &tblfile,
185  const QString &tblname = "");
186  void loadTable(const QString &tabfile);
187 
188  ColumnDescr getColumnDescription(PvlObject &colobj, int nth) const;
189 
190  TableRecord makeRecord(const ColumnTypes &ctypes);
191  TableField makeField(const ColumnDescr &cdesc);
193  void setPdsByteOrder(QString byteOrder);
194 
195  TableField &extract(const Columns &columns, const ColumnDescr &cdesc,
196  TableField &field) const;
197  TableRecord &extract(const Columns &columns, const ColumnTypes &ctypes,
198  TableRecord &record) const;
199  TableRecord extractBinary(char *rowBuffer, TableRecord &record) const;
200 
201  void fillTable(Table &table, const ColumnTypes &columns,
202  TableRecord &record) const;
203 
204  //private instance variables
205  int m_trows;
208  QString m_pdsTableType;
211  QString m_tableName;
212  QString m_pdsTableFile;
214  QString m_byteOrder;
216  };
217 
218 }
219 #endif
220 
TableRecord extractBinary(char *rowBuffer, TableRecord &record) const
This method is used to set the field values for the given record.
int columns() const
Returns the number of columns in the table.
virtual bool processRow(const int &row, const QString &rowdata)
Process a freshly read PDS table line of data.
ColumnDescr getColumnDescription(PvlObject &colobj, int nth) const
Extract a column description from a COLUMN object.
QStringList getColumnFields(const QString &tline, const ColumnDescr &cdesc, const QString &delimiter="") const
Extracts column fields from a QString based upon a description.
Table importTable(const QString &isisTableName)
Populate a Table object with the PDS table and return it.
int m_rowBytes
The number of bytes for one PDS table row.
int m_itemBytes
Number bytes per item.
QString getFormattedName(const QString &colname) const
Converts a column name to a camel-case after it has been cleansed.
void loadTable(const QString &tabfile)
Loads the contents of a PDS table data file.
QString m_name
Name of column.
int m_pdsTableStart
The start byte of the PDS table data.
void load(const QString &pdsLabFile, const QString &pdsTabFile="", const QString &pdsTableName="TABLE")
Loads a PDS table label and (optional) data file.
void setPdsByteOrder(QString byteOrder)
Sets the byte order for BINARY PDS table files.
virtual ~ImportPdsTable()
Destructs the ImportPdsTable object.
void init()
Initialize object variables.
const ColumnDescr & getColumnDescriptor(const int &nth) const
Retrieve a column description by index.
QStringList getColumnNames(const bool &formatted=true) const
Return the names of all the columns.
Rows m_rows
Table data.
void setName(const QString &name="TABLE")
Set the name of the PDS table object.
TableField & extract(const Columns &columns, const ColumnDescr &cdesc, TableField &field) const
Extract a TableField from a PDS column in the text row.
QString name() const
Return the name of the PDS table.
TableRecord makeRecord(const ColumnTypes &ctypes)
Creates a TableRecord for columns.
QString getColumnValue(const QString &tline, const ColumnDescr &cdesc, const QString &delimiter="") const
Extracts a column from a QString based upon a description.
QString getColumnName(const unsigned int &index=0, const bool &formatted=true) const
Returns the name of the specifed column.
QString m_pdsTableType
The INTERCHANGE_FORMAT value for the table.
ColumnTypes m_coldesc
Column descriptions.
int rows() const
Returns the number of rows in the table.
QString m_pdsTableFile
The name of the file containing the table data.
int m_items
Number of items in column.
bool setType(const QString &colName, const QString &dataType)
Change the datatype for a column.
TableField makeFieldFromBinaryTable(const ColumnDescr &cdesc)
Creates an empty TableField with the appropriate type from a binary PDS table column description...
int m_trows
Number rows in table according to label.
Class for storing Table blobs information.
Definition: Table.h:74
QString m_tableName
The name of the PDS table object.
QString getType(const QString &colName) const
Get the type associated with the specified column.
void loadLabel(const QString &labfile, QString &tblfile, const QString &tblname="")
Loads the contents of a PDS table label description.
int m_startByte
Starting byte of data.
ImportPdsTable()
Default constructor.
TableField makeField(const ColumnDescr &cdesc)
Creates a TableField for the column type.
QString m_byteOrder
The byte order of the PDS table file, if binary.
Class for storing an Isis::Table&#39;s field information.
Definition: TableField.h:63
int m_numBytes
Number bytes in column.
QString m_dataType
PDS table DATA_TYPE of column.
QString getGenericType(const QString &ttype) const
Determine generic data type of a column.
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
Import a PDS table file with a label description.
int m_recordBytes
The number of bytes for one Isis table record.
void fillTable(Table &table, const ColumnTypes &columns, TableRecord &record) const
Fill the ISIS Table object with PDS table data.
ColumnDescr * findColumn(const QString &colName)
Searches internal column descriptors for a named column.
bool hasColumn(const QString &colName) const
This method determines whether the PDS table has a column with the given name.

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:20:27