casa
$Rev:20696$
|
Holds a potentially multi-dimensional array. More...
#include <TBArray.h>
Public Member Functions | |
TBArray (int row, int col, String type, String array) | |
Constructor for a data array (in other words, an array found in the data of a table). | |
TBArray (int keywordIndex, String type, String array) | |
Constructor for a table keyword array (in other words, an array found in the table keywords). | |
TBArray (String col, int index, String type, String array) | |
Constructor for a field keyword array (in other words, an array found in the field keywords). | |
TBArray (String type, String array) | |
Constructor for a non-specific array. | |
~TBArray () | |
bool | isValid () |
Returns true if the array is valid, false otherwise. | |
vector< int > | getDimensions () |
Returns the dimensions of the array in list format. | |
unsigned int | dim () |
Returns the dimensionality of the array. | |
int | dimensionAt (unsigned int i) |
If the dimensions are thought of as a list (e.g., 2x4x2), then this method returns the ith dimension in the list. | |
bool | isOneDimensional () |
Returns true if the array is one-dimensional, false otherwise. | |
String | getType () |
Returns the type of the array. | |
vector< void * > * | getData () |
Returns the data representation. | |
int | getRow () |
Returns the row of the table where the array is located. | |
int | getCol () |
Returns the column of the table where the array is located. | |
bool | sameLocationAs (TBArray *array) |
Returns true if the given array is in the same location as this array, false otherwise. | |
String | getName (TBTable *table) |
Returns the name of this array, assuming that it belongs to the given table. | |
String | dataAt (vector< int > d) |
Returns the data at the given coordinates, or blank if the coordinates are invalid. | |
void | setDataAt (vector< int > d, String newVal) |
Sets the data at the given coordinates to the given value. | |
bool | dimensionIsValid (vector< int > d) |
Returns true if the given coordinates are valid for this array, false otherwise. | |
String | toFlattenedString () |
Returns a "flattened" String representation of this array. | |
bool | contains (String value) |
Returns true if this array contains the given value, false otherwise. | |
bool | containsBetween (String value1, String value2) |
Returns true if this array contains any value that is between the two given values, false otherwise. | |
bool | containsLessThan (String value) |
Returns true if this array contains any value that is less than the given value, false otherwise. | |
bool | containsGreaterThan (String value) |
Returns true if this array contains any value that is greater than the given value, false otherwise. | |
Private Member Functions | |
void | parseArray (String *table) |
Parses the given String into the array. | |
String | parseRow (String &str, vector< void * > *r, vector< int > d, int x) |
Helper for parseArray(). | |
void | parseMultidimensionalTable (String str) |
Helper for parseArray(). | |
void | insertPlaceholders (vector< void * > *r, vector< int > d, int x) |
Helper for parseArray(). | |
String | toFlattenedString (vector< void * > *row, int d) |
Helper method for toFlattenedString();. | |
bool | contains (vector< void * > *data, int n, String v) |
Helper method for contains(). | |
bool | containsBetween (vector< void * > *data, int n, double v1, double v2) |
Helper method for containsBetween(). | |
bool | containsLessThan (vector< void * > *data, int n, double v) |
Helper method for containsLessThan(). | |
bool | containsGreaterThan (vector< void * > *data, int n, double v) |
Helper method for containsGreaterThan(). | |
void | deleteData (vector< void * > *data, int n) |
Deletes the data in the given row. | |
Private Attributes | |
vector< int > | dimensions |
Holds the dimensions of this array. | |
vector< void * > | data |
Data representation. | |
bool | valid |
Indicates whether the array is valid or not. | |
String | type |
The type of the array. | |
int | row |
The row of the array for data arrays, or the keyword index for other arrays. | |
int | col |
The column of the array for data arrays, invalid for other arrays. | |
bool | oneDim |
Indicates whether this array is one-dimensional or not. | |
bool | isData |
Indicates whether this is a data array or not. | |
bool | isColKeyword |
Indicates whether this is a field keyword array or not. | |
String | field |
Holds the field name for a field keyword array, empty otherwise. |
Holds a potentially multi-dimensional array.
A TBArray holds a array object as used by the table browser. The data is represented by String values, while the array structure is represented by vectors of void*s. For all but the "last" dimension, the void*s point to other vector<void*>s, and on the last dimension the void*s point to Strings. NOTE: this class is mostly obsolete now that the browser uses the TBData structure.
casa::TBArray::TBArray | ( | int | row, |
int | col, | ||
String | type, | ||
String | array | ||
) |
Constructor for a data array (in other words, an array found in the data of a table).
Takes as input the row and column of the array in table, the type of table, and the String holding the values of the array which need to be parsed.
casa::TBArray::TBArray | ( | int | keywordIndex, |
String | type, | ||
String | array | ||
) |
Constructor for a table keyword array (in other words, an array found in the table keywords).
Takes as input the index of the keyword in the table keywords list, the type of the array, and the String holding the values of the array which need to be parsed.
casa::TBArray::TBArray | ( | String | col, |
int | index, | ||
String | type, | ||
String | array | ||
) |
Constructor for a field keyword array (in other words, an array found in the field keywords).
Takes as input the name of the field, the index of the keyword in the field keywords list, the type of the array, and the String holding the values of the array which need to be parsed.
casa::TBArray::TBArray | ( | String | type, |
String | array | ||
) |
Constructor for a non-specific array.
Takes as input the type of the array and the String holding the values of the array which need to be parsed.
bool casa::TBArray::contains | ( | String | value | ) |
Returns true if this array contains the given value, false otherwise.
bool casa::TBArray::contains | ( | vector< void * > * | data, |
int | n, | ||
String | v | ||
) | [private] |
Helper method for contains().
bool casa::TBArray::containsBetween | ( | String | value1, |
String | value2 | ||
) |
Returns true if this array contains any value that is between the two given values, false otherwise.
bool casa::TBArray::containsBetween | ( | vector< void * > * | data, |
int | n, | ||
double | v1, | ||
double | v2 | ||
) | [private] |
Helper method for containsBetween().
bool casa::TBArray::containsGreaterThan | ( | String | value | ) |
Returns true if this array contains any value that is greater than the given value, false otherwise.
bool casa::TBArray::containsGreaterThan | ( | vector< void * > * | data, |
int | n, | ||
double | v | ||
) | [private] |
Helper method for containsGreaterThan().
bool casa::TBArray::containsLessThan | ( | String | value | ) |
Returns true if this array contains any value that is less than the given value, false otherwise.
bool casa::TBArray::containsLessThan | ( | vector< void * > * | data, |
int | n, | ||
double | v | ||
) | [private] |
Helper method for containsLessThan().
String casa::TBArray::dataAt | ( | vector< int > | d | ) |
Returns the data at the given coordinates, or blank if the coordinates are invalid.
void casa::TBArray::deleteData | ( | vector< void * > * | data, |
int | n | ||
) | [private] |
Deletes the data in the given row.
unsigned int casa::TBArray::dim | ( | ) |
Returns the dimensionality of the array.
For example, a 4x4 array would return 2 while a 4x4x4 array would return 3.
int casa::TBArray::dimensionAt | ( | unsigned int | i | ) |
If the dimensions are thought of as a list (e.g., 2x4x2), then this method returns the ith dimension in the list.
bool casa::TBArray::dimensionIsValid | ( | vector< int > | d | ) |
Returns true if the given coordinates are valid for this array, false otherwise.
int casa::TBArray::getCol | ( | ) |
Returns the column of the table where the array is located.
This is only valid for data arrays.
vector<void*>* casa::TBArray::getData | ( | ) |
Returns the data representation.
In all but the last dimension, the void*s point to vector<void*>s; in the last dimension the void*s point to Strings.
vector<int> casa::TBArray::getDimensions | ( | ) |
Returns the dimensions of the array in list format.
String casa::TBArray::getName | ( | TBTable * | table | ) |
Returns the name of this array, assuming that it belongs to the given table.
For data arrays: "[table name][[row],[col]]"; for table keyword arrays: "[table name] [keyword name]"; for field keyword arrays: "[table name] [field name, keyword name]".
int casa::TBArray::getRow | ( | ) |
Returns the row of the table where the array is located.
This is only valid for data arrays.
Returns the type of the array.
void casa::TBArray::insertPlaceholders | ( | vector< void * > * | r, |
vector< int > | d, | ||
int | x | ||
) | [private] |
Helper for parseArray().
Creates placeholder objects (such as empty Strings and vectors) into the given row.
bool casa::TBArray::isOneDimensional | ( | ) |
Returns true if the array is one-dimensional, false otherwise.
bool casa::TBArray::isValid | ( | ) |
Returns true if the array is valid, false otherwise.
void casa::TBArray::parseArray | ( | String * | table | ) | [private] |
Parses the given String into the array.
void casa::TBArray::parseMultidimensionalTable | ( | String | str | ) | [private] |
Helper for parseArray().
Parses a table with dimension > 1.
String casa::TBArray::parseRow | ( | String & | str, |
vector< void * > * | r, | ||
vector< int > | d, | ||
int | x | ||
) | [private] |
Helper for parseArray().
Parses a single row into the given vector.
bool casa::TBArray::sameLocationAs | ( | TBArray * | array | ) |
Returns true if the given array is in the same location as this array, false otherwise.
For data arrays: true if the row and col values are equal; for table keyword arrays: true if they refer to the same keyword index; for field keyword arrays: true if the fields are the same and the keyword indices are the same.
void casa::TBArray::setDataAt | ( | vector< int > | d, |
String | newVal | ||
) |
Sets the data at the given coordinates to the given value.
This call does NOT write through to the underlying table; it only updates the data representation.
String casa::TBArray::toFlattenedString | ( | vector< void * > * | row, |
int | d | ||
) | [private] |
Helper method for toFlattenedString();.
int casa::TBArray::col [private] |
vector<void*> casa::TBArray::data [private] |
vector<int> casa::TBArray::dimensions [private] |
String casa::TBArray::field [private] |
bool casa::TBArray::isColKeyword [private] |
bool casa::TBArray::isData [private] |
bool casa::TBArray::oneDim [private] |
int casa::TBArray::row [private] |
String casa::TBArray::type [private] |
bool casa::TBArray::valid [private] |