Isis Developer Reference
Table.h
Go to the documentation of this file.
1#ifndef Table_h
2#define Table_h
8/* SPDX-License-Identifier: CC0-1.0 */
9#include "Pvl.h"
10#include <vector>
11#include "TableRecord.h"
12
13namespace Isis {
14 class Blob;
61 class Table {
62 public:
72
73 // Constructors and Destructors
75 Table(Blob &blob);
76 Table(const QString &tableName, TableRecord &rec);
77 Table(const QString &tableName);// Only use this constructor for reading in an existing table
78 Table(const QString &tableName, const QString &file);
79 Table(const QString &tableName, const QString &file,
80 const Pvl &fileHeader);
81 Table(const Table &other);
82 Table &operator=(const Isis::Table &other);
83
84 ~Table();
85
86
87 void Write(const QString &file);
88
89 QString Name() const;
91
92 void SetAssociation(const Table::Association assoc);
93 bool IsSampleAssociated();
94 bool IsLineAssociated();
95 bool IsBandAssociated();
96
97 int Records() const;
98 int RecordFields() const;
99 int RecordSize() const;
100
101 // Read a record
102 TableRecord &operator[](const int index);
103
104 // Add a record
105 void operator+=(TableRecord &rec);
106
107 // Update a record
108 void Update(const TableRecord &rec, const int index);
109
110 // Delete a record
111 void Delete(const int index);
112
113 void Clear();
114
115 Blob toBlob() const;
116
117
118 static QString toString(Table table, QString fieldDelimiter=",");
119
120
121 protected:
122
123 void initFromBlob(Blob &blob);
124
126 std::vector<char *> p_recbufs;
127
132 bool p_swap;
133
134 QString p_name;
136 };
137};
138
139#endif
Definition Blob.h:51
Container for cube-like labels.
Definition Pvl.h:119
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
Class for storing Table blobs information.
Definition Table.h:61
~Table()
Destroys the Table object.
Definition Table.cpp:224
QString p_name
The name of the Table.
Definition Table.h:134
int RecordSize() const
Returns the number of bytes per record.
Definition Table.cpp:333
int RecordFields() const
Returns the number of fields per record.
Definition Table.cpp:323
bool IsSampleAssociated()
Checks to see if association is Samples.
Definition Table.cpp:281
Association p_assoc
Association Type of the table.
Definition Table.h:131
void Delete(const int index)
Deletes a TableRecord from the Table.
Definition Table.cpp:392
int p_records
Holds record count read from labels, may differ from the size of p_recbufs.
Definition Table.h:128
int Records() const
Returns the number of records.
Definition Table.cpp:313
PvlObject & Label()
The Table's label.
Definition Table.cpp:260
void Write(const QString &file)
Write the Table to a file.
Definition Table.cpp:236
bool p_swap
Only used for reading.
Definition Table.h:132
void operator+=(TableRecord &rec)
Adds a TableRecord to the Table.
Definition Table.cpp:356
void SetAssociation(const Table::Association assoc)
Sets the association to the input parameter.
Definition Table.cpp:270
TableRecord & operator[](const int index)
Reads a TableRecord from the Table.
Definition Table.cpp:345
QString Name() const
The Table's name.
Definition Table.cpp:247
std::vector< char * > p_recbufs
Buffers containing record values.
Definition Table.h:126
TableRecord p_record
The current table record.
Definition Table.h:125
bool IsBandAssociated()
Checks to see if association is Bands.
Definition Table.cpp:303
bool IsLineAssociated()
Checks to see if association is Lines.
Definition Table.cpp:292
Table & operator=(const Isis::Table &other)
Sets the Table equal to the input Table object.
Definition Table.cpp:200
void Clear()
Clear the table of all records.
Definition Table.cpp:403
Association
Definition Table.h:66
@ Lines
Definition Table.h:69
@ Samples
Definition Table.h:68
@ Bands
Definition Table.h:70
@ None
Definition Table.h:67
void Update(const TableRecord &rec, const int index)
Updates a TableRecord.
Definition Table.cpp:382
void initFromBlob(Blob &blob)
Initialize a Table from a Blob that has been read from a file.
Definition Table.cpp:146
static QString toString(Table table, QString fieldDelimiter=",")
Convert the data from a Table into a string.
Definition Table.cpp:480
PvlObject p_label
The label for storing additional information.
Definition Table.h:135
Blob toBlob() const
Serialze the Table to a Blob that can be written to a file.
Definition Table.cpp:414
Definition TableRecord.h:38
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16