Isis Developer Reference
ImportPdsTable.h
Go to the documentation of this file.
1 #ifndef ImportPdsTable_h
2 #define ImportPdsTable_h
3 
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 
18 class QString;
19 
20 namespace Isis {
21  class Table;
22  class TableField;
23  class TableRecord;
24  class PvlObject;
102  public:
103  ImportPdsTable();
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:
135  struct ColumnDescr {
136  QString m_name;
137  int m_colnum;
138  QString m_dataType;
142  int m_items;
143  };
144 
145  // Internal types
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
Isis::ImportPdsTable::getColumnName
QString getColumnName(const unsigned int &index=0, const bool &formatted=true) const
Returns the name of the specifed column.
Definition: ImportPdsTable.cpp:211
FileName.h
Table.h
Isis::ImportPdsTable::Columns
QStringList Columns
Definition: ImportPdsTable.h:147
Isis::PvlObject
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:61
Isis::ImportPdsTable
Import a PDS table file with a label description.
Definition: ImportPdsTable.h:101
Isis::ImportPdsTable::load
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 >
TableField.h
Isis::FileName::name
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
Definition: FileName.cpp:162
Isis::ImportPdsTable::ColumnDescr::m_items
int m_items
Number of items in column.
Definition: ImportPdsTable.h:142
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::FileName::fileExists
bool fileExists() const
Returns true if the file exists; false otherwise.
Definition: FileName.cpp:449
Isis::ImportPdsTable::ColumnDescr
Definition: ImportPdsTable.h:135
Isis::ImportPdsTable::getColumnDescriptor
const ColumnDescr & getColumnDescriptor(const int &nth) const
Retrieve a column description by index.
Definition: ImportPdsTable.cpp:614
Isis::ImportPdsTable::ColumnDescr::m_colnum
int m_colnum
Column number.
Definition: ImportPdsTable.h:137
Isis::ImportPdsTable::processRow
virtual bool processRow(const int &row, const QString &rowdata)
Process a freshly read PDS table line of data.
Definition: ImportPdsTable.cpp:1212
Isis::ImportPdsTable::ColumnDescr::m_startByte
int m_startByte
Starting byte of data.
Definition: ImportPdsTable.h:139
Isis::ImportPdsTable::ColumnDescr::m_numBytes
int m_numBytes
Number bytes in column.
Definition: ImportPdsTable.h:140
Isis::TableRecord::Fields
int Fields() const
Returns the number of fields that are currently in the record.
Definition: TableRecord.cpp:78
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::ImportPdsTable::rows
int rows() const
Returns the number of rows in the table.
Definition: ImportPdsTable.cpp:1011
Isis::ImportPdsTable::getFormattedName
QString getFormattedName(const QString &colname) const
Converts a column name to a camel-case after it has been cleansed.
Definition: ImportPdsTable.cpp:759
Isis::ImportPdsTable::getGenericType
QString getGenericType(const QString &ttype) const
Determine generic data type of a column.
Definition: ImportPdsTable.cpp:798
Isis::TableRecord
Definition: TableRecord.h:38
QStringList
Isis::ImportPdsTable::getColumnValue
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
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::ImportPdsTable::ImportPdsTable
ImportPdsTable()
Default constructor.
Definition: ImportPdsTable.cpp:43
IString.h
Isis::ImportPdsTable::~ImportPdsTable
virtual ~ImportPdsTable()
Destructs the ImportPdsTable object.
Definition: ImportPdsTable.cpp:84
Isis::ImportPdsTable::Rows
QList< Columns > Rows
Definition: ImportPdsTable.h:148
Isis::ImportPdsTable::setType
bool setType(const QString &colName, const QString &dataType)
Change the datatype for a column.
Definition: ImportPdsTable.cpp:295
Isis::FileName::baseName
QString baseName() const
Returns the name of the file without the path and without extensions.
Definition: FileName.cpp:145
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::Double
@ Double
Definition: PixelType.h:36
Pvl.h
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::toInt
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:93
EndianSwapper.h
TextFile.h
Isis::Table
Class for storing Table blobs information.
Definition: Table.h:61
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::ImportPdsTable::getColumnNames
QStringList getColumnNames(const bool &formatted=true) const
Return the names of all the columns.
Definition: ImportPdsTable.cpp:242
std
Namespace for the standard library.
Isis::ImportPdsTable::ColumnDescr::m_name
QString m_name
Name of column.
Definition: ImportPdsTable.h:136
Isis::ImportPdsTable::ColumnDescr::m_dataType
QString m_dataType
PDS table DATA_TYPE of column.
Definition: ImportPdsTable.h:138
Isis::ImportPdsTable::getColumnFields
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
Isis::EndianSwapper
Byte swapper.
Definition: EndianSwapper.h:38
PvlObject.h
Isis::ImportPdsTable::importTable
Table importTable(const QString &isisTableName)
Populate a Table object with the PDS table and return it.
Definition: ImportPdsTable.cpp:318
Isis::ImportPdsTable::name
QString name() const
Return the name of the PDS table.
Definition: ImportPdsTable.cpp:89
TableRecord.h
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis::ImportPdsTable::hasColumn
bool hasColumn(const QString &colName) const
This method determines whether the PDS table has a column with the given name.
Definition: ImportPdsTable.cpp:186
ImportPdsTable.h
Isis::ImportPdsTable::findColumn
ColumnDescr * findColumn(const QString &colName)
Searches internal column descriptors for a named column.
Definition: ImportPdsTable.cpp:642
Isis::ImportPdsTable::ColumnDescr::m_itemBytes
int m_itemBytes
Number bytes per item.
Definition: ImportPdsTable.h:141
Isis::ImportPdsTable::setName
void setName(const QString &name="TABLE")
Set the name of the PDS table object.
Definition: ImportPdsTable.cpp:98
Isis::FileName::path
QString path() const
Returns the path of the file name.
Definition: FileName.cpp:103
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ImportPdsTable::getType
QString getType(const QString &colName) const
Get the type associated with the specified column.
Definition: ImportPdsTable.cpp:268
Isis::ImportPdsTable::columns
int columns() const
Returns the number of columns in the table.
Definition: ImportPdsTable.cpp:999
Isis::Real
@ Real
Definition: PixelType.h:35
Isis::TableField
Class for storing an Isis::Table's field information.
Definition: TableField.h:47
Isis::ImportPdsTable::ColumnTypes
QList< ColumnDescr > ColumnTypes
Definition: ImportPdsTable.h:146

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 USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 03/21/2022 06:50:54