14#include "IException.h"
15#include "TableField.h"
20 Table::Table(Blob &blob) {
48 for (
int f = 0; f < rec.Fields(); f++) {
67 Table::Table(
const QString &tableName) {
87 Table::Table(
const QString &tableName,
const QString &file) {
88 Blob blob(tableName,
"Table", file);
108 Table::Table(
const QString &tableName,
const QString &file,
const Pvl &fileHeader) {
109 Blob blob(tableName,
"Table");
110 blob.Read(file, fileHeader);
129 for (
unsigned int i = 0; i < other.p_recbufs.size(); i++) {
133 data[j] = other.p_recbufs[i][j];
166 QString temp = (QString)
p_label[
"Association"];
167 temp = temp.toUpper();
168 if (temp ==
"SAMPLES")
p_assoc = Table::Samples;
169 if (temp ==
"LINES")
p_assoc = Table::Lines;
170 if (temp ==
"BANDS")
p_assoc = Table::Bands;
179 for (
int rec = 0; rec <
p_records; rec++) {
183 memcpy(buf, &blob.getBuffer()[bufferPos],
RecordSize());
209 for (
unsigned int i = 0; i < other.p_recbufs.size(); i++) {
213 data[j] = other.p_recbufs[i][j];
282 return (
p_assoc == Table::Samples);
293 return (
p_assoc == Table::Lines);
304 return (
p_assoc == Table::Bands);
358 IString msg =
"Unable to add records to Isis Table ["
359 +
p_name +
"]. Bytes per record = [0 bytes].";
364 QString msg =
"Unable to add the given record with size = ["
366 +
p_name +
"] with record size = ["
393 vector<char *>::iterator it =
p_recbufs.begin();
394 for (
int i = 0; i < index; i++, it++);
416 PvlObject &blobLabel = tableBlob.Label();
423 blobLabel+=
PvlKeyword(
"ByteOrder", Isis::ByteOrderName(Isis::Lsb));
426 blobLabel+=
PvlKeyword(
"ByteOrder", Isis::ByteOrderName(Isis::Msb));
445 for (
int i = 0; i <
p_label.comments(); i++){
446 blobLabel.addComment(
p_label.comment(i));
454 char *buf =
new char[nbytes];
456 for (
int rec = 0; rec <
Records(); rec++) {
462 tableBlob.takeData(buf, nbytes);
483 tableValues += TableRecord::toString(table[0], fieldDelimiter,
true,
true);
485 for (
int recordIndex = 1; recordIndex < table.
Records(); recordIndex++) {
486 tableValues += TableRecord::toString(table[recordIndex], fieldDelimiter);
@ Unknown
A type of error that cannot be classified as any of the other error types.
Adds specific functionality to C++ strings.
bool isNamed(const QString &match) const
Returns whether the given string is equal to the container name or not.
int keywords() const
Returns the number of keywords contained in the PvlContainer.
QString name() const
Returns the container name.
Container for cube-like labels.
A single keyword-value pair.
Contains Pvl Groups and Pvl Objects.
bool hasKeyword(const QString &kname, FindOptions opts) const
See if a keyword is in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within ...
PvlGroup & group(const int index)
Return the group at the specified index.
int groups() const
Returns the number of groups contained.
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Class for storing an Isis::Table's field information.
Class for storing Table blobs information.
~Table()
Destroys the Table object.
QString p_name
The name of the Table.
int RecordSize() const
Returns the number of bytes per record.
int RecordFields() const
Returns the number of fields per record.
bool IsSampleAssociated()
Checks to see if association is Samples.
Association p_assoc
Association Type of the table.
void Delete(const int index)
Deletes a TableRecord from the Table.
int p_records
Holds record count read from labels, may differ from the size of p_recbufs.
int Records() const
Returns the number of records.
PvlObject & Label()
The Table's label.
void Write(const QString &file)
Write the Table to a file.
bool p_swap
Only used for reading.
void operator+=(TableRecord &rec)
Adds a TableRecord to the Table.
void SetAssociation(const Table::Association assoc)
Sets the association to the input parameter.
TableRecord & operator[](const int index)
Reads a TableRecord from the Table.
QString Name() const
The Table's name.
std::vector< char * > p_recbufs
Buffers containing record values.
TableRecord p_record
The current table record.
bool IsBandAssociated()
Checks to see if association is Bands.
bool IsLineAssociated()
Checks to see if association is Lines.
Table & operator=(const Isis::Table &other)
Sets the Table equal to the input Table object.
void Clear()
Clear the table of all records.
void Update(const TableRecord &rec, const int index)
Updates a TableRecord.
void initFromBlob(Blob &blob)
Initialize a Table from a Blob that has been read from a file.
static QString toString(Table table, QString fieldDelimiter=",")
Convert the data from a Table into a string.
PvlObject p_label
The label for storing additional information.
Blob toBlob() const
Serialze the Table to a Blob that can be written to a file.
void Unpack(const char *buf)
Reads record information from the binary buffer.
int RecordSize() const
Returns the number of bytes per record.
int Fields() const
Returns the number of fields that are currently in the record.
void Swap(char *buf) const
Swaps bytes of the buffer, depending on the TableField::Type.
ByteOrder
Tests the current architecture for byte order.
This is free and unencumbered software released into the public domain.
bool IsLsb()
Return true if this host is an LSB first machine and false if it is not.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
bool IsMsb()
Return true if this host is an MSB first machine and false if it is not.
Namespace for the standard library.