Isis 3 Programmer Reference
ImportPdsTable.h
1#ifndef ImportPdsTable_h
2#define ImportPdsTable_h
8/* SPDX-License-Identifier: CC0-1.0 */
9
10#include <QString>
11#include <QList>
12#include <QStringList>
13
14#include <fstream>
15#include <vector>
16#include <string>
17
18class QString;
19
20namespace Isis {
21 class Table;
22 class TableField;
23 class TableRecord;
24 class PvlObject;
102 public:
104 ImportPdsTable(const QString &pdsLabFile,
105 const QString &pdsTabFile="",
106 const QString &pdsTableName ="TABLE");
107 virtual ~ImportPdsTable();
108
109 QString name() const;
110 void setName(const QString &name = "TABLE");
111
112 int columns() const;
113 int rows() const;
114
115 void load(const QString &pdsLabFile, const QString &pdsTabFile = "",
116 const QString &pdsTableName = "TABLE");
117
118 bool hasColumn(const QString &colName) const;
119 QString getColumnName(const unsigned int &index = 0,
120 const bool &formatted = true) const;
121 QStringList getColumnNames(const bool &formatted = true) const;
122 QString getFormattedName(const QString &colname) const;
123
124 QString getType(const QString &colName) const;
125 bool setType(const QString &colName, const QString &dataType);
126
127 Table importTable(const QString &isisTableName);
128 Table importTable(const QString &colNames,
129 const QString &isisTableName);
130 Table importTable(const QStringList &colNames,
131 const QString &isisTableName);
132
133
134 protected:
144
145 // Internal types
146 typedef QList<ColumnDescr> ColumnTypes;
147 typedef QStringList Columns;
148 typedef QList<Columns> Rows;
149
150 const ColumnDescr &getColumnDescriptor(const int &nth) const;
151 ColumnDescr *findColumn(const QString &colName);
152 const ColumnDescr *findColumn(const QString &colName) const;
153
154
155 QString getColumnValue(const QString &tline,
156 const ColumnDescr &cdesc,
157 const QString &delimiter = "") const;
158 QStringList getColumnFields(const QString &tline,
159 const ColumnDescr &cdesc,
160 const QString &delimiter = "") const;
161
162
163 QString getGenericType(const QString &ttype) const;
164
165 virtual bool processRow(const int &row, const QString &rowdata);
166
167
168 private:
169 void init();
170
171 void loadLabel(const QString &labfile, QString &tblfile,
172 const QString &tblname = "");
173 void loadTable(const QString &tabfile);
174
175 ColumnDescr getColumnDescription(PvlObject &colobj, int nth) const;
176
177 TableRecord makeRecord(const ColumnTypes &ctypes);
178 TableField makeField(const ColumnDescr &cdesc);
180 void setPdsByteOrder(QString byteOrder);
181
182 TableField &extract(const Columns &columns, const ColumnDescr &cdesc,
183 TableField &field) const;
184 TableRecord &extract(const Columns &columns, const ColumnTypes &ctypes,
185 TableRecord &record) const;
186 TableRecord extractBinary(char *rowBuffer, TableRecord &record) const;
187
188 void fillTable(Table &table, const ColumnTypes &columns,
189 TableRecord &record) const;
190
191 //private instance variables
198 QString m_tableName;
201 QString m_byteOrder;
203 };
204
205}
206#endif
Import a PDS table file with a label description.
void init()
Initialize object variables.
ColumnDescr * findColumn(const QString &colName)
Searches internal column descriptors for a named column.
virtual bool processRow(const int &row, const QString &rowdata)
Process a freshly read PDS table line of data.
void setName(const QString &name="TABLE")
Set the name of the PDS table object.
QString name() const
Return the name of the PDS table.
QString getFormattedName(const QString &colname) const
Converts a column name to a camel-case after it has been cleansed.
int rows() const
Returns the number of rows in the table.
void loadLabel(const QString &labfile, QString &tblfile, const QString &tblname="")
Loads the contents of a PDS table label description.
const ColumnDescr & getColumnDescriptor(const int &nth) const
Retrieve a column description by index.
int m_pdsTableStart
The start byte of the PDS table data.
Table importTable(const QString &isisTableName)
Populate a Table object with the PDS table and return it.
QString m_pdsTableFile
The name of the file containing the table data.
QString getColumnValue(const QString &tline, const ColumnDescr &cdesc, const QString &delimiter="") const
Extracts a column from a QString based upon a description.
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.
int m_rowBytes
The number of bytes for one PDS table row.
QString m_pdsTableType
The INTERCHANGE_FORMAT value for the table.
TableField & extract(const Columns &columns, const ColumnDescr &cdesc, TableField &field) const
Extract a TableField from a PDS column in the text row.
TableRecord makeRecord(const ColumnTypes &ctypes)
Creates a TableRecord for columns.
TableRecord extractBinary(char *rowBuffer, TableRecord &record) const
This method is used to set the field values for the given record.
int m_trows
Number rows in table according to label.
QString m_tableName
The name of the PDS table object.
int m_recordBytes
The number of bytes for one Isis table record.
ColumnTypes m_coldesc
Column descriptions.
void loadTable(const QString &tabfile)
Loads the contents of a PDS table data file.
TableField makeFieldFromBinaryTable(const ColumnDescr &cdesc)
Creates an empty TableField with the appropriate type from a binary PDS table column description.
QString m_byteOrder
The byte order of the PDS table file, if binary.
virtual ~ImportPdsTable()
Destructs the ImportPdsTable object.
bool setType(const QString &colName, const QString &dataType)
Change the datatype for a column.
Rows m_rows
Table data.
QString getGenericType(const QString &ttype) const
Determine generic data type of a column.
ColumnDescr getColumnDescription(PvlObject &colobj, int nth) const
Extract a column description from a COLUMN object.
ImportPdsTable()
Default constructor.
QString getType(const QString &colName) const
Get the type associated with the specified column.
bool hasColumn(const QString &colName) const
This method determines whether the PDS table has a column with the given name.
void fillTable(Table &table, const ColumnTypes &columns, TableRecord &record) const
Fill the ISIS Table object with PDS table data.
QStringList getColumnNames(const bool &formatted=true) const
Return the names of all the columns.
QString getColumnName(const unsigned int &index=0, const bool &formatted=true) const
Returns the name of the specifed column.
TableField makeField(const ColumnDescr &cdesc)
Creates a TableField for the column type.
int columns() const
Returns the number of columns in the table.
QStringList getColumnFields(const QString &tline, const ColumnDescr &cdesc, const QString &delimiter="") const
Extracts column fields from a QString based upon a description.
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
Class for storing an Isis::Table's field information.
Definition TableField.h:47
Class for storing Table blobs information.
Definition Table.h:61
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
int m_startByte
Starting byte of data.
int m_numBytes
Number bytes in column.
QString m_dataType
PDS table DATA_TYPE of column.
int m_itemBytes
Number bytes per item.
int m_items
Number of items in column.