Isis Developer Reference
Table.h
Go to the documentation of this file.
1 #ifndef Table_h
2 #define Table_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 #include "Pvl.h"
10 #include <vector>
11 #include "TableRecord.h"
12 
13 namespace Isis {
14  class Blob;
61  class Table {
62  public:
66  enum Association {
70  Bands
71  };
72 
73  // Constructors and Destructors
74  Table();
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;
90  PvlObject &Label();
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 
128  int p_records;
132  bool p_swap;
133 
134  QString p_name;
136  };
137 };
138 
139 #endif
Isis::TableRecord::Pack
void Pack(char *buf) const
Writes record information into the binary buffer.
Definition: TableRecord.cpp:100
Table.h
Isis::Blob::takeData
void takeData(char *buffer, int nbytes)
Set the data stored in the BLOB without copying it.
Definition: Blob.cpp:398
Isis::PvlObject::group
PvlGroup & group(const int index)
Return the group at the specified index.
Definition: PvlObject.cpp:452
Isis::PvlObject
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:61
Isis::Table::Bands
@ Bands
Definition: Table.h:70
Isis::Table::initFromBlob
void initFromBlob(Blob &blob)
Initialize a Table from a Blob that has been read from a file.
Definition: Table.cpp:146
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
TableField.h
Isis::Table::Samples
@ Samples
Definition: Table.h:68
Isis::Table::Label
PvlObject & Label()
The Table's label.
Definition: Table.cpp:260
Isis::Table::IsLineAssociated
bool IsLineAssociated()
Checks to see if association is Lines.
Definition: Table.cpp:292
Isis::IsLsb
bool IsLsb()
Return true if this host is an LSB first machine and false if it is not.
Definition: Endian.h:67
Isis::Table::p_assoc
Association p_assoc
Association Type of the table.
Definition: Table.h:131
Isis::Table::Update
void Update(const TableRecord &rec, const int index)
Updates a TableRecord.
Definition: Table.cpp:382
Isis::Table::p_label
PvlObject p_label
The label for storing additional information.
Definition: Table.h:135
Isis::Table::toString
static QString toString(Table table, QString fieldDelimiter=",")
Convert the data from a Table into a string.
Definition: Table.cpp:480
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::Table::Write
void Write(const QString &file)
Write the Table to a file.
Definition: Table.cpp:236
Isis::Table::operator=
Table & operator=(const Isis::Table &other)
Sets the Table equal to the input Table object.
Definition: Table.cpp:200
Isis::Table::RecordSize
int RecordSize() const
Returns the number of bytes per record.
Definition: Table.cpp:333
Isis::TableRecord
Definition: TableRecord.h:38
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::ByteOrder
ByteOrder
Tests the current architecture for byte order.
Definition: Endian.h:42
Isis::Blob::Write
void Write(const QString &file)
Write the blob data out to a file.
Definition: Blob.cpp:417
Isis::Table::p_records
int p_records
Holds record count read from labels, may differ from the size of p_recbufs.
Definition: Table.h:128
Isis::ByteOrderEnumeration
Isis::ByteOrder ByteOrderEnumeration(const QString &order)
Definition: Endian.h:55
Isis::Table::Association
Association
Definition: Table.h:66
Endian.h
Isis::TableRecord::RecordSize
int RecordSize() const
Returns the number of bytes per record.
Definition: TableRecord.cpp:87
Isis::Blob::Read
void Read(const QString &file, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >())
This method reads Pvl values from a specified file.
Definition: Blob.cpp:255
Isis::IsMsb
bool IsMsb()
Return true if this host is an MSB first machine and false if it is not.
Definition: Endian.h:83
Isis::Table::SetAssociation
void SetAssociation(const Table::Association assoc)
Sets the association to the input parameter.
Definition: Table.cpp:270
Pvl.h
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::Table::Table
Table()
Isis::Blob::getBuffer
char * getBuffer()
Get the internal data buff of the Blob.
Definition: Blob.cpp:546
Isis::Blob::Label
PvlObject & Label()
Accessor method that returns a PvlObject containing the Blob label.
Definition: Blob.cpp:151
Isis::Table::toBlob
Blob toBlob() const
Serialze the Table to a Blob that can be written to a file.
Definition: Table.cpp:414
Isis::PvlObject::hasKeyword
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 ...
Definition: PvlObject.cpp:236
Blob.h
Isis::Table::Clear
void Clear()
Clear the table of all records.
Definition: Table.cpp:403
Isis::Table
Class for storing Table blobs information.
Definition: Table.h:61
Isis::Table::Name
QString Name() const
The Table's name.
Definition: Table.cpp:247
Isis::Msb
@ Msb
Definition: Endian.h:45
Isis::Table::~Table
~Table()
Destroys the Table object.
Definition: Table.cpp:224
Isis::Table::IsBandAssociated
bool IsBandAssociated()
Checks to see if association is Bands.
Definition: Table.cpp:303
Isis::Table::Lines
@ Lines
Definition: Table.h:69
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::PvlContainer::addComment
void addComment(const QString &comment)
Definition: PvlContainer.h:269
Isis::TableRecord::Unpack
void Unpack(const char *buf)
Reads record information from the binary buffer.
Definition: TableRecord.cpp:152
IException.h
std
Namespace for the standard library.
Isis::Table::None
@ None
Definition: Table.h:67
TableRecord.h
Isis::ByteOrderName
QString ByteOrderName(Isis::ByteOrder byteOrder)
Definition: Endian.h:48
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis::Table::RecordFields
int RecordFields() const
Returns the number of fields per record.
Definition: Table.cpp:323
Isis::Table::p_swap
bool p_swap
Only used for reading.
Definition: Table.h:132
Isis::Table::Delete
void Delete(const int index)
Deletes a TableRecord from the Table.
Definition: Table.cpp:392
Isis::Table::p_recbufs
std::vector< char * > p_recbufs
Buffers containing record values.
Definition: Table.h:126
Isis::Table::Records
int Records() const
Returns the number of records.
Definition: Table.cpp:313
Isis::Lsb
@ Lsb
Definition: Endian.h:44
Isis::Table::p_name
QString p_name
The name of the Table.
Definition: Table.h:134
Isis::Table::p_record
TableRecord p_record
The current table record.
Definition: Table.h:125
Isis::Blob
Definition: Blob.h:51
Isis::Table::operator[]
TableRecord & operator[](const int index)
Reads a TableRecord from the Table.
Definition: Table.cpp:345
Isis::Table::operator+=
void operator+=(TableRecord &rec)
Adds a TableRecord to the Table.
Definition: Table.cpp:356
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::Table::IsSampleAssociated
bool IsSampleAssociated()
Checks to see if association is Samples.
Definition: Table.cpp:281
Isis::TableField
Class for storing an Isis::Table's field information.
Definition: TableField.h:47
Isis::None
@ None
Definition: PixelType.h:28