Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Friends | List of all members
Mantid::API::TableRow Class Reference

TableRow represents a row in a TableWorkspace. More...

#include <TableRow.h>

Public Member Functions

BooleanBool (size_t col)
 Returns a reference to the element in position col if its type is bool. More...
 
template<class T >
T & cell (size_t col)
 Templated method to access the element col in the row. More...
 
double & Double (size_t col)
 Returns a reference to the element in position col if its type is double. More...
 
int & Int (size_t col)
 Returns a reference to the element in position col if its type is int. More...
 
bool next ()
 Steps to the next row in the TableWorkspace if there is one. More...
 
TableRowoperator<< (bool t)
 Special case of bool. More...
 
TableRowoperator<< (const char *t)
 Special case of char*. More...
 
template<class T >
TableRowoperator<< (const T &t)
 Input streaming operator. More...
 
const TableRowoperator>> (bool &t) const
 Special case of bool. More...
 
template<class T >
const TableRowoperator>> (T &t) const
 Output streaming operator. More...
 
bool prev ()
 Steps to the previous row in the TableWorkspace if there is one. More...
 
size_t row () const
 Returns the row number of the TableRow. More...
 
void row (size_t i)
 Makes the TableRow point to i-th row in the TableWorkspace. More...
 
void sep (const std::string &s)
 Sets a new separator character(s) between elements in a text output. More...
 
size_t size () const
 Returns the number of rows in the TableWorkspace. More...
 
std::string & String (size_t col)
 Returns a reference to the element in position col if its type is std::string. More...
 
 TableRow (const TableRowHelper &trh)
 Constructor. More...
 

Private Attributes

size_t m_col
 Current column number (for streaming operations) More...
 
std::vector< Column_sptrm_columns
 Pointers to the columns in the ITableWorkspace. More...
 
size_t m_nrows
 Number of rows in the TableWorkspace. More...
 
size_t m_row
 Row number in the TableWorkspace. More...
 
std::string m_sep
 Separator character(s) between elements in a text output. More...
 

Friends

MANTID_API_DLL std::ostream & operator<< (std::ostream &s, const TableRow &row)
 Output stream operator. More...
 

Detailed Description

TableRow represents a row in a TableWorkspace.

The elements in the row can be accessed through a) tmplated cell method b) streaming operators (<< & >>) c) specialized access function: Int(c), Double(c), Bool(c), String(c)

Author
Roman Tolchenov
Date
13/11/2008

Definition at line 39 of file TableRow.h.

Constructor & Destructor Documentation

◆ TableRow()

Mantid::API::TableRow::TableRow ( const TableRowHelper trh)

Constructor.

Parameters
trh:: TableRowHelper returned by TableWorkspace::getRow

Definition at line 15 of file TableRow.cpp.

References Mantid::API::ITableWorkspace::columnCount(), Mantid::API::ITableWorkspace::getColumn(), m_columns, m_nrows, Mantid::API::TableRowHelper::m_workspace, and size().

Member Function Documentation

◆ Bool()

Boolean & Mantid::API::TableRow::Bool ( size_t  col)
inline

Returns a reference to the element in position col if its type is bool.

Parameters
col:: Position of the element
Returns
Reference to the element

Definition at line 143 of file TableRow.h.

◆ cell()

template<class T >
T & Mantid::API::TableRow::cell ( size_t  col)
inline

Templated method to access the element col in the row.

The internal pointer moves to point to the element after col.

Parameters
col:: Element's position in the row
Returns
cell of the template type

Definition at line 115 of file TableRow.h.

Referenced by Mantid::DataHandling::SaveTBL::findGroups(), and Mantid::DataHandling::LoadDiffCal::makeCalWorkspace().

◆ Double()

double & Mantid::API::TableRow::Double ( size_t  col)
inline

Returns a reference to the element in position col if its type is double.

Parameters
col:: Position of the element
Returns
Reference to the element

Definition at line 137 of file TableRow.h.

Referenced by Mantid::Algorithms::addRowFromGroupedCalibration(), Mantid::Algorithms::CombineDiffCal::exec(), Mantid::Algorithms::CreateUserDefinedBackground::extendBackgroundToData(), MantidQt::MantidWidgets::SequentialFitDialog::getFitResults(), and Mantid::DataHandling::SaveDiffFittingAscii::writeData().

◆ Int()

int & Mantid::API::TableRow::Int ( size_t  col)
inline

Returns a reference to the element in position col if its type is int.

Parameters
col:: Position of the element
Returns
Reference to the element

Definition at line 131 of file TableRow.h.

Referenced by Mantid::Algorithms::addRowFromGroupedCalibration(), Mantid::Algorithms::binarySearchForRow(), Mantid::Algorithms::FilterEvents::createOutputWorkspacesSplitters(), and Mantid::Algorithms::CombineDiffCal::exec().

◆ next()

bool Mantid::API::TableRow::next ( )

Steps to the next row in the TableWorkspace if there is one.

Returns
true if the row changed and false if the TableRow is already at the end of the TableWorkspace

Definition at line 40 of file TableRow.cpp.

References m_col, m_nrows, and m_row.

Referenced by Mantid::Algorithms::CombineDiffCal::exec().

◆ operator<<() [1/3]

TableRow & Mantid::API::TableRow::operator<< ( bool  t)
inline

Special case of bool.

Definition at line 81 of file TableRow.h.

References operator<<().

Referenced by operator<<().

◆ operator<<() [2/3]

TableRow & Mantid::API::TableRow::operator<< ( const char *  t)
inline

Special case of char*.

Definition at line 79 of file TableRow.h.

References operator<<().

Referenced by operator<<().

◆ operator<<() [3/3]

template<class T >
TableRow & Mantid::API::TableRow::operator<< ( const T &  t)
inline

Input streaming operator.

Makes TableRow look like a standard input stream. Every << operatr moves an internal pointer to the next element in the row. If the types of the input value and the current element don't match an exception is thrown.

Parameters
t:: Input value
Returns
Self reference

Definition at line 61 of file TableRow.h.

References size().

◆ operator>>() [1/2]

const TableRow & Mantid::API::TableRow::operator>> ( bool &  t) const

Special case of bool.

Definition at line 63 of file TableRow.cpp.

References operator>>().

◆ operator>>() [2/2]

template<class T >
const TableRow & Mantid::API::TableRow::operator>> ( T &  t) const
inline

Output streaming operator.

Makes TableRow look like a standard output stream. Every >> operatr moves an internal pointer to the next element in the row. If the types of the receiving variable and the current element don't match an exception is thrown.

Parameters
t:: Variable for output
Returns
Self reference

Definition at line 92 of file TableRow.h.

References size().

Referenced by operator>>().

◆ prev()

bool Mantid::API::TableRow::prev ( )

Steps to the previous row in the TableWorkspace if there is one.

Returns
true if the row changed and false if the TableRow is already at the beginning of the TableWorkspace

Definition at line 53 of file TableRow.cpp.

References m_col, and m_row.

◆ row() [1/2]

size_t Mantid::API::TableRow::row ( ) const
inline

Returns the row number of the TableRow.

Definition at line 43 of file TableRow.h.

Referenced by Mantid::Algorithms::populateTable().

◆ row() [2/2]

void Mantid::API::TableRow::row ( size_t  i)

Makes the TableRow point to i-th row in the TableWorkspace.

Parameters
i:: New row number

Definition at line 27 of file TableRow.cpp.

References m_col, m_nrows, and m_row.

◆ sep()

void Mantid::API::TableRow::sep ( const std::string &  s)
inline

Sets a new separator character(s) between elements in a text output.

Definition at line 50 of file TableRow.h.

◆ size()

size_t Mantid::API::TableRow::size ( ) const
inline

Returns the number of rows in the TableWorkspace.

Definition at line 45 of file TableRow.h.

Referenced by operator<<(), operator>>(), Mantid::DataHandling::SaveGSASInstrumentFile::parseProfileTableWorkspace(), and TableRow().

◆ String()

std::string & Mantid::API::TableRow::String ( size_t  col)
inline

Returns a reference to the element in position col if its type is std::string.

Parameters
col:: Position of the element
Returns
Reference to the element

Definition at line 150 of file TableRow.h.

Referenced by Mantid::Algorithms::FilterEvents::createOutputWorkspacesSplitters(), and Mantid::DataHandling::SaveTBL::exec().

Friends And Related Function Documentation

◆ operator<<

MANTID_API_DLL std::ostream & operator<< ( std::ostream &  s,
const TableRow row 
)
friend

Output stream operator.

Parameters
s:: Output stream
row:: The TableRow
Returns
stream representation of row

Definition at line 75 of file TableRow.cpp.

Member Data Documentation

◆ m_col

size_t Mantid::API::TableRow::m_col
mutableprivate

Current column number (for streaming operations)

Definition at line 156 of file TableRow.h.

Referenced by next(), prev(), and row().

◆ m_columns

std::vector<Column_sptr> Mantid::API::TableRow::m_columns
private

Pointers to the columns in the ITableWorkspace.

Definition at line 154 of file TableRow.h.

Referenced by TableRow().

◆ m_nrows

size_t Mantid::API::TableRow::m_nrows
private

Number of rows in the TableWorkspace.

Definition at line 157 of file TableRow.h.

Referenced by next(), row(), and TableRow().

◆ m_row

size_t Mantid::API::TableRow::m_row
private

Row number in the TableWorkspace.

Definition at line 155 of file TableRow.h.

Referenced by next(), prev(), and row().

◆ m_sep

std::string Mantid::API::TableRow::m_sep
private

Separator character(s) between elements in a text output.

Definition at line 158 of file TableRow.h.


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