46 if (m_type == TableField::Integer) {
48 m_ivalues.resize(m_size);
50 else if (m_type == TableField::Double) {
52 m_dvalues.resize(m_size);
54 else if (m_type == TableField::Text) {
56 m_svalue.resize(m_size);
58 else if (m_type == TableField::Real) {
60 m_rvalues.resize(m_size);
76 m_name = (QString) field[
"Name"];
77 m_size = (int) field[
"Size"];
78 if ((QString) field[
"Type"] ==
"Integer") {
79 m_type = TableField::Integer;
81 m_ivalues.resize(m_size);
83 else if ((QString) field[
"Type"] ==
"Double") {
84 m_type = TableField::Double;
86 m_dvalues.resize(m_size);
88 else if ((QString) field[
"Type"] ==
"Text") {
89 m_type = TableField::Text;
91 m_svalue.resize(m_size);
93 else if ((QString) field[
"Type"] ==
"Real") {
94 m_type = TableField::Real;
96 m_rvalues.resize(m_size);
99 QString msg =
"Field [" + m_name +
"] has invalid type.";
105 TableField::~TableField() {
113 QString TableField::name()
const {
138 bool TableField::isInteger()
const {
139 return (m_type == TableField::Integer);
148 bool TableField::isDouble()
const {
149 return (m_type == TableField::Double);
157 bool TableField::isText()
const {
158 return (m_type == TableField::Text);
166 bool TableField::isReal()
const {
167 return (m_type == TableField::Real);
175 int TableField::bytes()
const {
184 int TableField::size()
const {
204 TableField::operator int()
const {
205 if (m_type != TableField::Integer) {
206 QString msg =
"Field [" + m_name +
"] is not Integer.";
209 if (m_ivalues.size() > 1) {
210 QString msg =
"Field [" + m_name +
"] has multiple Integer values. " 211 "Use std::vector<int>().";
233 TableField::operator double()
const {
234 if (m_type != TableField::Double) {
235 QString msg =
"Field [" + m_name +
"] is not a Double.";
238 if (m_dvalues.size() > 1) {
239 QString msg =
"Field [" + m_name +
"] has multiple Double values. " 240 "Use std::vector<double>().";
262 TableField::operator float()
const {
263 if (m_type != TableField::Real) {
264 QString msg =
"Field [" + m_name +
"] is not Real.";
267 if (m_rvalues.size() > 1) {
268 QString msg =
"Field [" + m_name +
"] has multiple Real values. " 269 "Use std::vector<float>().";
289 TableField::operator QString()
const {
290 if (m_type != TableField::Text) {
291 QString msg =
"Field [" + m_name +
"] is not Text.";
294 return QString(m_svalue.toLatin1().data());
309 TableField::operator std::vector<int>()
const {
310 if (m_type != TableField::Integer) {
311 QString msg =
"Field [" + m_name +
"] is not an Integer array.";
329 TableField::operator std::vector<double>()
const {
330 if (m_type != TableField::Double) {
331 QString msg =
"Field [" + m_name +
"] is not a Double array.";
349 TableField::operator std::vector<float>()
const {
350 if (m_type != TableField::Real) {
351 QString msg =
"Field [" + m_name +
"] is not a Real array.";
366 void TableField::operator=(
const int value) {
367 if (m_type != TableField::Integer) {
368 QString msg =
"Unable to set field to the given int value. Field [" 369 + m_name +
"] Type is not Integer.";
373 QString msg =
"Unable to set field to the given int value. " 375 "Integer values. Use operator=(vector<int>).";
378 m_ivalues[0] = value;
390 void TableField::operator=(
const double value) {
391 if (m_type != TableField::Double) {
392 QString msg =
"Unable to set field to the given double value. Field [" 393 + m_name +
"] Type is not Double.";
397 QString msg =
"Unable to set field to the given double value. " 399 "Double values. Use operator=(vector<double>).";
402 m_dvalues[0] = value;
414 void TableField::operator=(
const float value) {
415 if (m_type != TableField::Real) {
416 QString msg =
"Unable to set field to the given float value. Field [" 417 + m_name +
"] Type is not Real.";
421 QString msg =
"Unable to set field to the given float value. " 423 "Real values. Use operator=(vector<float>).";
426 m_rvalues[0] = value;
436 void TableField::operator=(
const QString &value) {
438 if (m_type != TableField::Text) {
439 QString msg =
"Unable to set field to the given string value. Field [" 440 + m_name +
"] Type is not Text.";
443 if (m_size < (
int) val.size()) {
444 for (
int i = m_size; i < val.size(); i++) {
446 if (val[i] !=
' ' && val[i] !=
'\0') {
447 QString msg =
"Unable to set the Text TableField to the given string. " 448 "The number of bytes allowed for this field value [" 450 "given string [" + value +
"].";
469 void TableField::operator=(
const std::vector<int> &values) {
470 if (m_type != TableField::Integer) {
471 QString msg =
"Unable to set field to the given vector of int values. " 472 "Field [" + m_name +
"] Type is not Integer.";
475 else if ((
int) values.size() != m_size) {
476 QString msg =
"Unable to set field to the given vector of int values. " 477 "Field [" + m_name +
"] values has size [" 493 void TableField::operator=(
const std::vector<double> &values) {
494 if (m_type != TableField::Double) {
495 QString msg =
"Unable to set field to the given vector of double values. " 496 "Field [" + m_name +
"] Type is not Double.";
499 else if ((
int) values.size() != m_size) {
500 QString msg =
"Unable to set field to the given vector of double values. " 501 "Field [" + m_name +
"] values has size [" 518 void TableField::operator=(
const std::vector<float> &values) {
519 if (m_type != TableField::Real) {
520 QString msg =
"Unable to set field to the given vector of float values. " 521 "Field [" + m_name +
"] Type is not Real.";
524 else if ((
int) values.size() != m_size) {
525 QString msg =
"Unable to set field to the given vector of float values. " 526 "Field [" + m_name +
"] values has size [" 544 void TableField::operator=(
const void *ibuf) {
545 char *buf = (
char *) ibuf;
546 if (m_type == TableField::Double) {
547 for (
unsigned int i = 0; i < m_dvalues.size(); i++) {
550 memmove(&bufDouble, buf + i * 8, 8);
551 m_dvalues[i] = bufDouble;
554 else if (m_type == TableField::Integer) {
555 for (
unsigned int i = 0; i < m_ivalues.size(); i++) {
558 memmove(&bufInt, buf + i * 4, 4);
559 m_ivalues[i] = bufInt;
562 else if (m_type == TableField::Text) {
563 m_svalue.resize(bytes());
564 for (
int i = 0; i < bytes(); i++) {
565 m_svalue[i] = buf[i];
568 else if (m_type == TableField::Real) {
569 for (
unsigned int i = 0; i < m_rvalues.size(); i++) {
572 memmove(&bufFloat, buf + i * 4, 4);
573 m_rvalues[i] = bufFloat;
577 string msg =
"Undefined field type [" +
IString(m_type) +
"].";
591 void TableField::operator=(
const char *buf) {
592 if (m_type != TableField::Text) {
593 QString msg =
"Unable to set field to the given string value. Field [" + m_name +
"] Type is not Text.";
608 if (m_type == TableField::Double) {
611 else if (m_type == TableField::Integer) {
614 else if (m_type == TableField::Text) {
617 else if (m_type == TableField::Real) {
627 QString fieldValues =
"";
628 if (field.
size()== 1){
630 fieldValues = (QString)field;
645 fieldValues +=(QString)field;
648 vector< int > currField = field;
649 for (
int i = 0;i <(int)currField.size();i++){
651 if (i <(
int)currField.size()- 1){
653 fieldValues += delimiter;
658 vector< double > currField = field;
659 for (
int i = 0;i <(int)currField.size();i++){
661 if (i <(
int)currField.size()- 1){
662 fieldValues += delimiter;
667 vector< float > currField = field;
668 for (
int i = 0;i <(int)currField.size();i++){
670 if (i <(
int)currField.size()- 1){
671 fieldValues += delimiter;
Namespace for the standard library.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Contains multiple PvlContainers.
bool isInteger() const
Determines whether the field type is Integer.
#define _FILEINFO_
Macro for the filename and line number.
A single keyword-value pair.
int size() const
Returns the number of values stored for the field at each record.
Adds specific functionality to C++ strings.
Namespace for ISIS/Bullet specific routines.
bool isText() const
Determines whether the field type is Text.
Class for storing an Isis::Table's field information.
bool isDouble() const
Determines whether the field type is Double.
Type
This enum describes the value type for the TableField.