Isis 3 Programmer Reference
Isis::TableField Class Reference

Class for storing an Isis::Table's field information. More...

#include <TableField.h>

Collaboration diagram for Isis::TableField:
Collaboration graph

Public Types

enum  Type { Integer , Double , Text , Real }
 This enum describes the value type for the TableField. More...
 

Public Member Functions

 TableField (const QString &name, Type type, int size=1)
 Constructs a TableField object with the given field name, field value type, and field size.
 
 TableField (PvlGroup &field)
 Constructs a TableField object from a PvlGroup.
 
 ~TableField ()
 Destroys the TableField object.
 
QString name () const
 Returns the name of the TableField.
 
Type type () const
 Returns the enumerated value of the TableField value's type.
 
bool isInteger () const
 Determines whether the field type is Integer.
 
bool isDouble () const
 Determines whether the field type is Double.
 
bool isText () const
 Determines whether the field type is Text.
 
bool isReal () const
 Determines whether the field type is Text.
 
int bytes () const
 Returns the number of bytes in the field value.
 
int size () const
 Returns the number of values stored for the field at each record.
 
 operator int () const
 Casts the table field value to int if the type is Integer and the size is.
 
 operator double () const
 Casts the table field value to double if the type is Double and the size is.
 
 operator float () const
 Casts the table field value to float if the type is Real and the size is.
 
 operator QString () const
 Casts the table field value to string if the type is Text.
 
 operator std::vector< int > () const
 Casts the table field value to a vector of ints if the type is Integer.
 
 operator std::vector< double > () const
 Casts the table field value to a vector of doubles if the type is Double.
 
 operator std::vector< float > () const
 Casts the table field value to a vector of floats if the type is Real.
 
void operator= (const int value)
 Sets field value equal to input if TableField::Type is Integer and size is 1.
 
void operator= (const double value)
 Sets field value equal to input if TableField::Type is Double and size is 1.
 
void operator= (const float value)
 Sets field value equal to input if the TableField::Type is Real and the size is 1.
 
void operator= (const QString &value)
 Sets field value equal to input if the TableField::Type is Text.
 
void operator= (const std::vector< int > &values)
 Sets field value equal to input if the TableField::Type is Integer and the input vector size matches the field size.
 
void operator= (const std::vector< double > &values)
 Sets field value equal to the input if the TableField::Type is Double and the input vector size matches the field size.
 
void operator= (const std::vector< float > &value)
 Sets field value equal to the input if the TableField::Type is Real and the input vector size matches the field size.
 
void operator= (const char *buf)
 Sets field value equal to the values found in the character string array if the TableField::Type is Text.
 
void operator= (const void *buf)
 Sets field value equal to the values found in the input binary buffer.
 
PvlGroup pvlGroup ()
 Creates and returns a PvlGroup named "Field" containing the following keywords and their respective values: "Name", "Type", and "Size".
 

Static Public Member Functions

static QString toString (const TableField &field, QString delimiter=",")
 

Private Attributes

QString m_name
 Field name.
 
Type m_type
 Field value type.
 
int m_size
 Field size.
 
int m_bytes
 Number of bytes in field.
 
std::vector< int > m_ivalues
 Vector containing integer field values.
 
std::vector< double > m_dvalues
 Vector containing double field values.
 
std::vector< float > m_rvalues
 Vector containing Real field values.
 
QString m_svalue
 String containing text value of field.
 

Detailed Description

Class for storing an Isis::Table's field information.

This class represents the field values of an Isis table. In Isis3, fields correspond to column values. Each TableField object is a single table entry for a column value at a specific row (or record) of the table.

Be careful to note that the size of a field is the number of array values for a single column entry. It is not the number of rows or records of the table.

Author
2004-09-01 Jeff Anderson
History

2005-03-18 Elizabeth Ribelin - Added documentation to the class

2007-05-28 Steven Lambright - Added 4 byte floating point capabilities

2012-10-04 Jeannie Backer - Added accessor method for FieldType. Moved method implementations to cpp file. Changed member variable prefix to m_. Changed methods to lower camel case. Added documentation. Moved PvlGroup from header include to forward declaration. Added includes to cpp and header. Ordered includes and changed methods to lower camel case in the unitTest. Improved test coverage in all categories. Added padding to control statements. Fixes #1169.

2012-11-21 Jeannie Backer - Added documentation and error message if a Text type field is set to a string value that is longer than the number of allowed bytes for the field. References #700.

2015-10-04 Jeannie Backer Improved coding standards. References #1178

Todo
Finish class documentation

Definition at line 47 of file TableField.h.

Member Enumeration Documentation

◆ Type

This enum describes the value type for the TableField.

Enumerator
Integer 

The values in the field are 4 byte integers.

Double 

The values in the field are 8 byte doubles.

Text 

The values in the field are text strings with 1 byte per character.

Real 

The values in the field are 4 byte reals or floats.

Definition at line 52 of file TableField.h.

Constructor & Destructor Documentation

◆ TableField() [1/2]

Isis::TableField::TableField ( const QString & name,
TableField::Type type,
int size = 1 )

Constructs a TableField object with the given field name, field value type, and field size.

The size defaults to 1 entry value per field.

Parameters
nameThe name of the field.
typeThe type of the field value.
sizeThe size of the field. This is the number of values for a single table entry. Defaults to 1.

Definition at line 25 of file TableField.cpp.

References Double, Integer, m_bytes, m_dvalues, m_ivalues, m_name, m_rvalues, m_size, m_svalue, m_type, name(), Real, size(), Text, and type().

◆ TableField() [2/2]

Isis::TableField::TableField ( PvlGroup & field)

Constructs a TableField object from a PvlGroup.

The given group must contain the PvlKeywords "Name", "Size", and "Type". "Size" must be an integer value and valid values for "Type" are "Integer", "Double", "Text", or "Real".

Parameters
fieldPvlGroup containing Name, Size, and Type for new TableField object
Exceptions
IException::Programmer- Invalid field type

Definition at line 59 of file TableField.cpp.

References Double, Integer, m_bytes, m_dvalues, m_ivalues, m_name, m_rvalues, m_size, m_svalue, m_type, Isis::IException::Programmer, Real, and Text.

◆ ~TableField()

Isis::TableField::~TableField ( )

Destroys the TableField object.

Definition at line 89 of file TableField.cpp.

Member Function Documentation

◆ bytes()

int Isis::TableField::bytes ( ) const

Returns the number of bytes in the field value.

Returns
int The number of bytes in the TableField

Definition at line 159 of file TableField.cpp.

References m_bytes.

Referenced by operator=(), Isis::TableRecord::Swap(), and Isis::TableRecord::Unpack().

◆ isDouble()

bool Isis::TableField::isDouble ( ) const

Determines whether the field type is Double.

Returns
bool Returns true if field type is Double, and false if it is not.

Definition at line 132 of file TableField.cpp.

References Double, and m_type.

Referenced by Isis::Blobber::load().

◆ isInteger()

bool Isis::TableField::isInteger ( ) const

Determines whether the field type is Integer.

Returns
bool Returns true if field type is Integer, and false if it is not.

Definition at line 122 of file TableField.cpp.

References Integer, and m_type.

Referenced by Isis::Blobber::load().

◆ isReal()

bool Isis::TableField::isReal ( ) const

Determines whether the field type is Text.

Returns
bool Returns true if field type is Text, and false if it is not.

Definition at line 150 of file TableField.cpp.

References m_type, and Real.

◆ isText()

bool Isis::TableField::isText ( ) const

Determines whether the field type is Text.

Returns
bool Returns true if field type is Text, and false if it is not.

Definition at line 141 of file TableField.cpp.

References m_type, and Text.

◆ name()

QString Isis::TableField::name ( ) const

Returns the name of the TableField.

Returns
string Name of TableField

Definition at line 97 of file TableField.cpp.

References m_name.

Referenced by TableField().

◆ operator double()

Isis::TableField::operator double ( ) const

Casts the table field value to double if the type is Double and the size is.

TableField field("Field 1", FieldType::Double, 1); // The following lines are equivalent double value = double(field); double value = (double) field;

Returns
double The value of the field.
Exceptions
IException::Programmer- Field is not a Double
IException::Programmer- Field has multiple Double values

Definition at line 217 of file TableField.cpp.

References Double, and Isis::IException::Programmer.

◆ operator float()

Isis::TableField::operator float ( ) const

Casts the table field value to float if the type is Real and the size is.

TableField field("Field 1", FieldType::Real, 1); // The following lines are equivalent float value = float(field); float value = (float) field;

Returns
float The value of the field.
Exceptions
IException::Programmer- Field is not a Real
IException::Programmer- Field has multiple Real values

Definition at line 246 of file TableField.cpp.

References Isis::IException::Programmer, and Real.

◆ operator int()

Isis::TableField::operator int ( ) const

Casts the table field value to int if the type is Integer and the size is.

TableField field("Field 1", FieldType::Integer, 1); // The following lines are equivalent int value = int(field); int value = (int) field;

Returns
int The value of the field.
Exceptions
IException::Programmer- Field is not an Integer
IException::Programmer- Field has multiple Integer values

Definition at line 188 of file TableField.cpp.

References Integer, and Isis::IException::Programmer.

◆ operator QString()

Isis::TableField::operator QString ( ) const

Casts the table field value to string if the type is Text.

TableField field("Field 1", FieldType::Text, 9); // The following lines are equivalent string value = QString(field); string value = (QString) field;

Returns
string The value of the field.
Exceptions
IException::Programmer- Field is not a string

Definition at line 273 of file TableField.cpp.

References Isis::IException::Programmer, and Text.

◆ operator std::vector< double >()

Isis::TableField::operator std::vector< double > ( ) const

Casts the table field value to a vector of doubles if the type is Double.

TableField field("Field 1", FieldType::Double, 3); vector<double> values = std::vector<double>(field);

Returns
The value of the field.
Exceptions
IException::Programmer- Field is not a Double array

Definition at line 313 of file TableField.cpp.

References Double, and Isis::IException::Programmer.

◆ operator std::vector< float >()

Isis::TableField::operator std::vector< float > ( ) const

Casts the table field value to a vector of floats if the type is Real.

TableField field("Field 1", FieldType::Real, 3); vector<float> values = std::vector<float>(field);

Returns
The value of the field.
Exceptions
IException::Programmer- Field is not an Integer array

Definition at line 333 of file TableField.cpp.

References Isis::IException::Programmer, and Real.

◆ operator std::vector< int >()

Isis::TableField::operator std::vector< int > ( ) const

Casts the table field value to a vector of ints if the type is Integer.

TableField field("Field 1", FieldType::Integer, 3); vector<int> values = std::vector<int>(field);

Returns
The value of the field.
Exceptions
IException::Programmer- Field is not an Integer array

Definition at line 293 of file TableField.cpp.

References Integer, and Isis::IException::Programmer.

◆ operator=() [1/9]

void Isis::TableField::operator= ( const char * buf)

Sets field value equal to the values found in the character string array if the TableField::Type is Text.

Parameters
bufCharacter array conataining text values to be assigned to the field value.
Exceptions
IException::Programmer- Field is not Text

Definition at line 575 of file TableField.cpp.

References m_name, m_svalue, m_type, Isis::IException::Programmer, and Text.

◆ operator=() [2/9]

void Isis::TableField::operator= ( const double value)

Sets field value equal to input if TableField::Type is Double and size is 1.

Parameters
valueDouble to be assigned to field value
Exceptions
IException::Programmer- Field is not a Double
IException::Programmer- Field has multiple Double values

Definition at line 374 of file TableField.cpp.

References Double, m_dvalues, m_name, m_size, m_type, Isis::IException::Programmer, and Isis::toString().

◆ operator=() [3/9]

void Isis::TableField::operator= ( const float value)

Sets field value equal to input if the TableField::Type is Real and the size is 1.

Parameters
valuefloat to be assigned to field value
Exceptions
IException::Programmer- Field is not a Real
IException::Programmer- Field has multiple Real values

Definition at line 398 of file TableField.cpp.

References m_name, m_rvalues, m_size, m_type, Isis::IException::Programmer, Real, and Isis::toString().

◆ operator=() [4/9]

void Isis::TableField::operator= ( const int value)

Sets field value equal to input if TableField::Type is Integer and size is 1.

Parameters
valueInteger to be assigned to field value
Exceptions
IException::Programmer- Field is not an Integer
IException::Programmer- Field has multiple Integer values

Definition at line 350 of file TableField.cpp.

References Integer, m_ivalues, m_name, m_size, m_type, Isis::IException::Programmer, and Isis::toString().

◆ operator=() [5/9]

void Isis::TableField::operator= ( const QString & value)

Sets field value equal to input if the TableField::Type is Text.

Parameters
valuestring to be assigned to field value
Exceptions
IException::Programmer- Field is not a string

Definition at line 420 of file TableField.cpp.

References m_name, m_size, m_svalue, m_type, Isis::IException::Programmer, Text, Isis::toString(), and Isis::IException::Unknown.

◆ operator=() [6/9]

void Isis::TableField::operator= ( const std::vector< double > & values)

Sets field value equal to the input if the TableField::Type is Double and the input vector size matches the field size.

Parameters
valuesDouble vector of values to be assigned to field value
Exceptions
IException::Programmer- Field is not a Double
IException::Programmer- Vector is not the correct size

Definition at line 477 of file TableField.cpp.

References Double, m_dvalues, m_name, m_size, m_type, Isis::IException::Programmer, and Isis::toString().

◆ operator=() [7/9]

void Isis::TableField::operator= ( const std::vector< float > & values)

Sets field value equal to the input if the TableField::Type is Real and the input vector size matches the field size.

Parameters
valuesFloat vector of values to be assigned to field value
Exceptions
IException::Programmer- Field is not a Real
IException::Programmer- Vector is not the correct size

Definition at line 502 of file TableField.cpp.

References m_name, m_rvalues, m_size, m_type, Isis::IException::Programmer, Real, and Isis::toString().

◆ operator=() [8/9]

void Isis::TableField::operator= ( const std::vector< int > & values)

Sets field value equal to input if the TableField::Type is Integer and the input vector size matches the field size.

Parameters
valuesInteger vector of values to be assigned to field value
Exceptions
IException::Programmer- Field is not an Integer
IException::Programmer- Vector is not the correct size

Definition at line 453 of file TableField.cpp.

References Integer, m_ivalues, m_name, m_size, m_type, Isis::IException::Programmer, and Isis::toString().

◆ operator=() [9/9]

void Isis::TableField::operator= ( const void * ibuf)

Sets field value equal to the values found in the input binary buffer.

This method reads the buffer by assuming that the buffer values are stored in the same number of bytes as the TableField::Type.

Parameters
ibufBinary buffer containing values to be assigned to the field value.
Exceptions
iException::Programmer- Undefined field type.

Definition at line 528 of file TableField.cpp.

References bytes(), Double, Integer, m_dvalues, m_ivalues, m_rvalues, m_svalue, m_type, Isis::IException::Programmer, Real, and Text.

◆ pvlGroup()

PvlGroup Isis::TableField::pvlGroup ( )

Creates and returns a PvlGroup named "Field" containing the following keywords and their respective values: "Name", "Type", and "Size".

Returns
PvlGroup containing field Name, Type, and Size

Definition at line 589 of file TableField.cpp.

References Double, Integer, m_name, m_size, m_type, Real, Text, and Isis::toString().

◆ size()

int Isis::TableField::size ( ) const

Returns the number of values stored for the field at each record.

Returns
int The size of the TableField

Definition at line 168 of file TableField.cpp.

References m_size.

Referenced by TableField().

◆ toString()

QString Isis::TableField::toString ( const TableField & field,
QString delimiter = "," )
static

Definition at line 610 of file TableField.cpp.

◆ type()

TableField::Type Isis::TableField::type ( ) const

Returns the enumerated value of the TableField value's type.

  • 0 = Integer
  • 1 = Double
  • 2 = Text
  • 3 = Real
Returns
TableField::Type Name of TableField

Definition at line 112 of file TableField.cpp.

References m_type.

Referenced by TableField().

Member Data Documentation

◆ m_bytes

int Isis::TableField::m_bytes
private

Number of bytes in field.

Definition at line 102 of file TableField.h.

Referenced by bytes(), TableField(), and TableField().

◆ m_dvalues

std::vector<double> Isis::TableField::m_dvalues
private

Vector containing double field values.

If the field Type is not Double, this vector will be empty.

Definition at line 106 of file TableField.h.

Referenced by operator=(), operator=(), operator=(), TableField(), and TableField().

◆ m_ivalues

std::vector<int> Isis::TableField::m_ivalues
private

Vector containing integer field values.

If the field Type is not Integer, this vector will be empty.

Definition at line 103 of file TableField.h.

Referenced by operator=(), operator=(), operator=(), TableField(), and TableField().

◆ m_name

QString Isis::TableField::m_name
private

◆ m_rvalues

std::vector<float> Isis::TableField::m_rvalues
private

Vector containing Real field values.

If the field Type is not Real, this vector will be empty.

Definition at line 109 of file TableField.h.

Referenced by operator=(), operator=(), operator=(), TableField(), and TableField().

◆ m_size

int Isis::TableField::m_size
private

Field size.

This is the number of values per field entry of the table.

Definition at line 100 of file TableField.h.

Referenced by operator=(), operator=(), operator=(), operator=(), operator=(), operator=(), operator=(), pvlGroup(), size(), TableField(), and TableField().

◆ m_svalue

QString Isis::TableField::m_svalue
private

String containing text value of field.

If the field Type is not Text, this string will be empty.

Definition at line 112 of file TableField.h.

Referenced by operator=(), operator=(), operator=(), TableField(), and TableField().

◆ m_type

Type Isis::TableField::m_type
private

The documentation for this class was generated from the following files: