Introduction
Synopsis
Members
Example
Frequently Asked Questions
This class hides members of XLOPER structure and provides an interface instead.
namespace xll { // Excel cell - a simple wrapper around XLOPER structure template <typename T> class Cell : protected XLOPER, private boost::noncopyable { protected: //Constructors: this class is not supposed to be constructed by users explicitly, // so no public constructors are available Cell () { } public: // Standard types typedef T value_type; //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. ~Cell() { } // Implicit conversion to type T: throws bad_cast if conversion fails operator T () const; // Read-only access to XLOPER: never throws operator const XLOPER &() const { return *this; } bool is_numeric () const {return (xltype & xltypeNum) == xltypeNum;} bool is_string () const {return (xltype & xltypeStr) == xltypeStr;} bool is_bool() const {return (xltype & xltypeBool) == xltypeBool;} bool is_missing_arg () const {return xltype == xltypeMissing;} bool is_empty () const {return xltype == xltypeNil;} bool is_array () const { return (xltype & xltypeMulti) == xltypeMulti; } bool is_error () const { return (xltype & xltypeErr) == xltypeErr; } bool is_ref () const { return (xltype & xltypeRef) == xltypeRef; } size_t type () const { return xltype; } friend class details::ExcelObjPtr <const Cell<T>, const XLOPER, boost::intrusive_ptr >; }; }
typedef T value_type;
Provides the type of the template parameter T.
Cell(); // 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.]
~Cell(); // 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.
operator T () const; // throws std::bad_cast
Returns: a fully constructed object of type T.
Throws:
std::bad_cast
Notes: This operator tries to build an object of type T out of information in XLOPER. If it deems impossible it throws
std::bad_cast
. Conversions like string to numeric and back are permissible. If type T is a boost::any this operator never throws and returns an empty object if conversion is not defined.
$Date: 2007/04/18 20:01:34 $
Copyright 2007 ---