12#include <boost/lexical_cast.hpp>
43 size_t row()
const {
return m_row; }
45 size_t size()
const {
return m_nrows; }
50 void sep(
const std::string &s) { m_sep = s; }
62 if (m_col >= m_columns.size()) {
63 std::stringstream errss;
64 errss <<
"Column index " << m_col <<
" is out of range " << m_columns.
size() <<
" of operator << ";
65 throw std::range_error(errss.str());
68 if (!c->isType<T>()) {
69 std::ostringstream err;
70 err <<
"Type mismatch: " <<
typeid(T).name() <<
" (expected " << c->get_type_info().name() <<
")";
71 throw std::runtime_error(err.str());
73 c->cell<T>(m_row) = t;
93 if (m_col >= m_columns.size()) {
94 std::stringstream errss;
95 errss <<
"Column index " << m_col <<
" is out of range " << m_columns.
size() <<
" of operator >> ";
96 throw std::range_error(errss.str());
99 if (!c->isType<T>()) {
100 throw std::runtime_error(
"TableRow type mismatch.");
102 t = c->cell<T>(m_row);
115 template <
class T> T &
cell(
size_t col) {
116 if (col >= m_columns.size()) {
117 std::stringstream errss;
118 errss <<
"Column index " << m_col <<
" is out of range " << m_columns.size() <<
" of method cell(). ";
119 throw std::range_error(errss.str());
124 return c->cell<T>(m_row);
131 int &
Int(
size_t col) {
return cell<int>(col); }
137 double &
Double(
size_t col) {
return cell<double>(col); }
150 std::string &
String(
size_t col) {
return cell<std::string>(col); }
std::ostream & operator<<(std::ostream &out, const MantidQt::MantidWidgets::IndexType< i > &index)
Helper class used to create TableRow.
TableRow represents a row in a TableWorkspace.
std::string & String(size_t col)
Returns a reference to the element in position col if its type is std::string.
Boolean & Bool(size_t col)
Returns a reference to the element in position col if its type is bool.
std::vector< Column_sptr > m_columns
Pointers to the columns in the ITableWorkspace.
double & Double(size_t col)
Returns a reference to the element in position col if its type is double.
size_t m_col
Current column number (for streaming operations)
int & Int(size_t col)
Returns a reference to the element in position col if its type is int.
size_t m_row
Row number in the TableWorkspace.
TableRow & operator<<(bool t)
Special case of bool.
const TableRow & operator>>(T &t) const
Output streaming operator.
void sep(const std::string &s)
Sets a new separator character(s) between elements in a text output.
size_t row() const
Returns the row number of the TableRow.
TableRow & operator<<(const T &t)
Input streaming operator.
size_t m_nrows
Number of rows in the TableWorkspace.
T & cell(size_t col)
Templated method to access the element col in the row.
TableRow & operator<<(const char *t)
Special case of char*.
std::string m_sep
Separator character(s) between elements in a text output.
size_t size() const
Returns the number of rows in the TableWorkspace.
std::shared_ptr< Column > Column_sptr
MANTID_API_DLL std::ostream & operator<<(std::ostream &, const AlgorithmHistory &)
Prints a text representation.
MANTID_API_DLL std::istream & operator>>(std::istream &istr, API::Boolean &)
Redaing a Boolean from an input stream.
Helper class which provides the Collimation Length for SANS instruments.
As TableColumn stores its data in a std::vector bool type cannot be used in the same way as the other...