Isis Developer Reference
ImportPdsTable.h
Go to the documentation of this file.
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;
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);
179 TableField makeFieldFromBinaryTable(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
192 int m_trows;
193 ColumnTypes m_coldesc;
194 Rows m_rows;
195 QString m_pdsTableType;
196 int m_rowBytes;
197 int m_recordBytes;
198 QString m_tableName;
199 QString m_pdsTableFile;
200 int m_pdsTableStart;
201 QString m_byteOrder;
203 };
204
205}
206#endif
Import a PDS table file with a label description.
Definition ImportPdsTable.h:101
ColumnDescr * findColumn(const QString &colName)
Searches internal column descriptors for a named column.
Definition ImportPdsTable.cpp:642
virtual bool processRow(const int &row, const QString &rowdata)
Process a freshly read PDS table line of data.
Definition ImportPdsTable.cpp:1212
void setName(const QString &name="TABLE")
Set the name of the PDS table object.
Definition ImportPdsTable.cpp:98
QString name() const
Return the name of the PDS table.
Definition ImportPdsTable.cpp:89
QString getFormattedName(const QString &colname) const
Converts a column name to a camel-case after it has been cleansed.
Definition ImportPdsTable.cpp:759
int rows() const
Returns the number of rows in the table.
Definition ImportPdsTable.cpp:1011
const ColumnDescr & getColumnDescriptor(const int &nth) const
Retrieve a column description by index.
Definition ImportPdsTable.cpp:614
Table importTable(const QString &isisTableName)
Populate a Table object with the PDS table and return it.
Definition ImportPdsTable.cpp:318
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:690
void load(const QString &pdsLabFile, const QString &pdsTabFile="", const QString &pdsTableName="TABLE")
Loads a PDS table label and (optional) data file.
Definition ImportPdsTable.cpp:132
QList< ColumnDescr > ColumnTypes
Definition ImportPdsTable.h:146
virtual ~ImportPdsTable()
Destructs the ImportPdsTable object.
Definition ImportPdsTable.cpp:84
QStringList Columns
Definition ImportPdsTable.h:147
bool setType(const QString &colName, const QString &dataType)
Change the datatype for a column.
Definition ImportPdsTable.cpp:295
QList< Columns > Rows
Definition ImportPdsTable.h:148
QString getGenericType(const QString &ttype) const
Determine generic data type of a column.
Definition ImportPdsTable.cpp:798
ImportPdsTable()
Default constructor.
Definition ImportPdsTable.cpp:43
QString getType(const QString &colName) const
Get the type associated with the specified column.
Definition ImportPdsTable.cpp:268
bool hasColumn(const QString &colName) const
This method determines whether the PDS table has a column with the given name.
Definition ImportPdsTable.cpp:186
QStringList getColumnNames(const bool &formatted=true) const
Return the names of all the columns.
Definition ImportPdsTable.cpp:242
QString getColumnName(const unsigned int &index=0, const bool &formatted=true) const
Returns the name of the specifed column.
Definition ImportPdsTable.cpp:211
int columns() const
Returns the number of columns in the table.
Definition ImportPdsTable.cpp:999
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:712
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
Definition TableRecord.h:38
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Definition ImportPdsTable.h:135
int m_colnum
Column number.
Definition ImportPdsTable.h:137
int m_startByte
Starting byte of data.
Definition ImportPdsTable.h:139
int m_numBytes
Number bytes in column.
Definition ImportPdsTable.h:140
QString m_dataType
PDS table DATA_TYPE of column.
Definition ImportPdsTable.h:138
int m_itemBytes
Number bytes per item.
Definition ImportPdsTable.h:141
int m_items
Number of items in column.
Definition ImportPdsTable.h:142
QString m_name
Name of column.
Definition ImportPdsTable.h:136