Introduction
Synopsis
Members
Example
Frequently Asked Questions
This class allows to treat XLOPER structure as a read-only two-dimensional array. The type of array elements is specified via template argument. It is possible to specify boost::any as an element type.
namespace xll { // Excel Range as it's seen from XLL API (type "P") template <typename T> class Matrix : protected XLOPER, private boost::noncopyable { protected: //Constructors: this class is not supposed to be constructed by users explicitly, // so no public constructors are available Matrix () { } public: // Standard types typedef T value_type; typedef const Cell<T> * const_iterator; typedef std::reverse_iterator < const Cell<T> * > const_reverse_iterator; //Destructor: cannot be virtual - we need to keep sizeof equals to XLOPER to make sure pointer arithmetic is correct; // no virtual functions is allowed for this class for the same reason. ~Matrix () { } // Read-only access to XLOPER: never throws operator const XLOPER &() const { return *this; } // number of rows size_t nrows() const { return val.array.rows; } // number of columns size_t ncols() const { return val.array.columns; } // number of elements size_t size1d() const { return val.array.rows * val.array.columns; } // number of rows size_t size() const { return nrows(); } // Returns the beginning of row n const_iterator operator[] (size_t n) const; // Checked access to an elemnt const value_type & at (size_t nRow, size_t nCol) const; // begin of Matrix const_iterator begin() const; // end of Matrix const_iterator end() const; // implemenattion of std::reverse_iterator concept: const_reverse_iterator rbegin() const; const_reverse_iterator rend() const; // begin of row n const_iterator begin_row(size_t n) const; // end of row n const_iterator end_row(size_t n) const; // reverse... const_reverse_iterator rbegin_row(size_t n) const; const_reverse_iterator rend_row(size_t n) const; // column based iterators: // iterators along a specific column: typedef details::array_column_iteratorconst_column_iterator; typedef std::reverse_iterator const_reverse_column_iterator; // iterators along the whole Matrix column-wise: typedef details::array_column_flat_iterator const_column_flat_iterator; typedef std::reverse_iterator const_reverse_column_flat_iterator; // begin of column n const_column_iterator begin_column (size_t n) const; // end of column n const_column_iterator end_column (size_t n) const; // reverse... const_reverse_column_iterator rbegin_column (size_t n) const; const_reverse_column_iterator rend_column (size_t n) const; // begin of Matrix to iterate column-wise const_column_flat_iterator beginc() const; // end of Matrix to iterate column-wise const_column_flat_iterator endc() const; // reverse... const_reverse_column_flat_iterator rbeginc() const; const_reverse_column_flat_iterator rendc() const; protected: // pointer to the beginning of Matrix const XLOPER * array () const { return val.array.lparray; } // smart pointer to Matrix - a natural friend friend class details::ExcelObjPtr < const Matrix<T>, const XLOPER, boost::intrusive_ptr <; }; }
typedef T value_type;
Provides the type of the template parameter T.
typedef const Cell<T> * const_iterator;
Provides a means for iteration through the Matrix.
typedef std::reverse_iterator < const Cell<T> * > const_reverse_iterator;
Provides a means for backward iteration through the Matrix.
Matrix(); // never called
Effects: none
Postconditions: none
Throws: nothing.
[This class is not supposed to be constructed. Access to its features should be done via dereferenciang of corresponding pointer.]
~Matrix(); // never throws
Effects: none.
Throws: nothing.
Notes: Destructor is not virtual since we want to keep the size of this object equal to
sizeof(XLOPER)
.
operator const XLOPER &() const; // never throws
Returns: static cast to XLOPER of
*this
Throws: nothing
Notes: Provides read-only access to XLOPER.
size_t nrows() const;
Returns: the number of rows.
Throws: nothing
$Date: 2007/04/18 20:01:34 $
Copyright 2007 ---