comet::safearray_t< T > Class Template Reference
[Com type wrappers.]

#include <safearray.h>

Inheritance diagram for comet::safearray_t< T >:

Inheritance graph
[legend]
List of all members.

Public Types

typedef impl::sa_traits< T > traits
typedef size_t size_type
 type for sizes (bounds etc).
typedef long index_type
 Type for indexing into the array.
typedef ptrdiff_t difference_type
 Type for pointer differences.
typedef traits::value_type value_type
 The type of the contained value .
typedef traits::reference reference
 Safearray reference type.
typedef traits::const_reference const_reference
 Safearray const reference type.
typedef std::reverse_iterator<
iterator, T > 
reverse_iterator
typedef std::reverse_iterator<
const_iterator, T > 
const_reverse_iterator

Public Member Functions

typedef COMET_SAIT_ITER (safearray_t, traits::iterator, impl::sa_debug_traits< traits >) iterator
 Iterator type.
typedef COMET_SAIT_ITER (safearray_t, traits::const_iterator, impl::sa_const_debug_traits< traits >) const _iterator
 Const iterator type.
size_type size () const
 The number of elements in the array.
bool is_empty () const
 Returns whether the array is empty.
reference operator[] (index_type n)
 Returns element n relative to lower_bound().
const_reference operator[] (index_type n) const
 Returns const element n relative to lower_bound().
reference at (index_type n)
 Returns element n relative to lower_bound().
const_reference at (index_type n) const
 Returns const element n relative to lower_bound().
reference front ()
 The front element.
const_reference front () const
 The front element - const.
reference back ()
 The back element.
const_reference back () const
 The back element - const.
void resize (size_type n)
 Resize the array, preserving lower_bound.
void resize_bound (size_type n, size_type lb)
 Resize the array, specifying the lower_bound.
void resize (size_type n, const T &val)
void resize_bound (size_type n, size_type lb, const T &val)
void assign (size_type n, const T &val)
 Assign the safearray to be v elements of val.
template<typename InputIterator> void assign (InputIterator first, InputIterator last)
 Assign the safearray from a f first and last iterators.
com_ptr< IRecordInfo > get_record_info ()
VARTYPE get_vt ()
uuid_t get_iid ()
void insert (iterator pos, size_type n, const T &val)
 Insert n elements of val at position pos.
template<typename InputIterator> void insert (iterator pos, InputIterator first, InputIterator last)
 Insert elements coppied from iterator first to last at position pos.
void push_back (const T &val, index_type lb)
 Push an element to the back of the list (ensure lower-bound);.
void push_back (const T &val)
 Push an element to the back of the list.
void pop_back ()
 Pop an element from the back of the list.
void push_front (const T &val, index_type lb)
 Push an element to the front of the list (ensure lower-bound).
void push_front (const T &val)
 Push an element to the front of the list.
void pop_front ()
 Pop an element from the front of the list.
iterator erase (iterator it)
 Erase a specified item.
iterator erase (iterator first, iterator second)
 Erase a range of items.
SAFEARRAY * detach ()
 Unlock and detach a raw SAFEARRAY.
void detach_to (variant_t &var)
void detach_from (variant_t &var)
index_type lower_bound () const
 The lower bound of the array.
void lower_bound (index_type lb)
 Change the lower_bound of the array.
void swap (safearray_t &sa) throw ()
Iterator functions
iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
reverse_iterator rbegin ()
reverse_iterator rend ()
const_reverse_iterator rbegin () const
const_reverse_iterator rend () const
Constructors
 safearray_t ()
 Construct a null array.
 safearray_t (const impl::auto_attach_t< SAFEARRAY * > &psa)
 safearray_t (const variant_t &var)
 Copy from a variant, making converting if necessary.
 safearray_t (const safearray_t &sa)
 Copy construction.
 safearray_t (size_type sz, index_type lb)
 Construct a new safearray vector.
 safearray_t (size_type sz, index_type lb, const T &val)
 Construct a new safearray vector.
template<typename InputIterator>  safearray_t (InputIterator first, InputIterator last, index_type lb)
 Construct a safearray from an iterator, specifying the lower bound.
Assignment Operators
safearray_toperator= (const safearray_t &sa)
safearray_toperator= (const variant_t &v)
safearray_toperator= (const impl::auto_attach_t< SAFEARRAY * > &sa)
Access converters
SAFEARRAY * in () const throw ()
SAFEARRAY ** in_ptr () const throw ()
sa_auto_lock_t inout () throw ()
sa_auto_lock_t out () throw ()

Static Public Member Functions

SAFEARRAY * detach (safearray_t &sa)
const impl::safearray_auto_const_ref_t<
T > 
create_const_reference (SAFEARRAY *const &sa)
impl::safearray_auto_ref_t<
T > 
create_reference (SAFEARRAY *&sa)
const impl::safearray_auto_const_ref_t<
T > 
create_const_reference (const variant_t &var)
impl::safearray_auto_ref_t<
T > 
create_reference (variant_t &var)

Static Protected Member Functions

void sanity_check (SAFEARRAY *psa)
 Make sure the passed in safearray agrees with the type of the safearray_t.

Protected Attributes

SAFEARRAY * psa_

Detailed Description

template<typename T>
class comet::safearray_t< T >

STL container compatible wrapper for a safearray. Provides forwards and reverse iterators.


Constructor & Destructor Documentation

template<typename T>
comet::safearray_t< T >::safearray_t const impl::auto_attach_t< SAFEARRAY * > &  psa  )  [inline]
 

Attach to (and take ownership of) an existing array.

                  SAFEARRAY *psa = SafeArrayCreateVectorEx(VT_BSTR, 0, 5, NULL);
                  safearray_t<bstr_t> sa(auto_attach(psa));

template<typename T>
comet::safearray_t< T >::safearray_t size_type  sz,
index_type  lb
[inline, explicit]
 

Construct a new safearray vector.

Parameters:
sz Size of the vector.
lb Lower bound for the vector.

template<typename T>
comet::safearray_t< T >::safearray_t size_type  sz,
index_type  lb,
const T &  val
[inline]
 

Construct a new safearray vector.

Parameters:
sz Size of the vector.
lb Lower bound for the vector.
val Initial value for the elements.

template<typename T>
template<typename InputIterator>
comet::safearray_t< T >::safearray_t InputIterator  first,
InputIterator  last,
index_type  lb
[inline]
 

Construct a safearray from an iterator, specifying the lower bound.

Parameters:
first First element of the container.
last Beyond the last element of the container.
lb Lower bound of the new safearray_t.


Member Function Documentation

template<typename T>
const_reference comet::safearray_t< T >::at index_type  n  )  const [inline]
 

Returns const element n relative to lower_bound().

Exceptions:
out_of_range The index is out of range.

template<typename T>
reference comet::safearray_t< T >::at index_type  n  )  [inline]
 

Returns element n relative to lower_bound().

Exceptions:
out_of_range The index is out of range.

template<typename T>
const impl::safearray_auto_const_ref_t< T > comet::safearray_t< T >::create_const_reference const variant_t var  )  [static]
 

Create a reference to a safearray from a variant.

                         function( const variant_t &var)
                         {
                                const safe_array<bstr_t> &stringarray = safe_array<bstr_t>::create_reference( var );
                         }

template<typename T>
const impl::safearray_auto_const_ref_t< T > comet::safearray_t< T >::create_const_reference SAFEARRAY *const &  sa  )  [static]
 

Create a reference to a safearray from a raw SAFEARRAY pointer. Mainly used by the implementation wrappers.

template<typename T>
impl::safearray_auto_ref_t< T > comet::safearray_t< T >::create_reference variant_t var  )  [static]
 

Create c const reference to a safearray from a variant.

template<typename T>
SAFEARRAY* comet::safearray_t< T >::detach safearray_t< T > &  sa  )  [inline, static]
 

Detach a raw SAFEARRAY pointer from a safearray_t.

template<typename T>
void comet::safearray_t< T >::detach_from variant_t var  )  [inline]
 

Detach a safearray from the variant var. An attempt is made to cast the type of the variant before attaching.

template<typename T>
void comet::safearray_t< T >::detach_to variant_t var  )  [inline]
 

Detach the safearray to the variant var. The safearray becomes invalid after this point.

                          safe_array_t<int> ints(2,0);
                          variant_t var;
                          ints.detach_to(var);

template<typename T>
iterator comet::safearray_t< T >::erase iterator  first,
iterator  second
[inline]
 

Erase a range of items.

Parameters:
first Item to erase from
second Item after range to be erased.
Returns:
Item beyond erased range.

template<typename T>
iterator comet::safearray_t< T >::erase iterator  it  )  [inline]
 

Erase a specified item.

Parameters:
it Item to erase
Returns:
Item beyond erased item.

template<typename T>
uuid_t comet::safearray_t< T >::get_iid  )  [inline]
 

Return interface-id of the members of the array.

template<typename T>
com_ptr<IRecordInfo> comet::safearray_t< T >::get_record_info  )  [inline]
 

Return the IRecordInfo struct for the array for VT_RECORD.

template<typename T>
VARTYPE comet::safearray_t< T >::get_vt  )  [inline]
 

Get the Variant Type of the members of the array.

template<typename T>
index_type comet::safearray_t< T >::lower_bound  )  const [inline]
 

The lower bound of the array.

See also:
get_at

template<typename T>
void comet::safearray_t< T >::resize size_type  n,
const T &  val
[inline]
 

Resize the array, preserving lower_bound and specifying an initial value for uninitialised values.

template<typename T>
void comet::safearray_t< T >::resize size_type  n  )  [inline]
 

Resize the array, preserving lower_bound.

If the array is null, uses 0.

template<typename T>
void comet::safearray_t< T >::resize_bound size_type  n,
size_type  lb,
const T &  val
[inline]
 

Resize the array, specifying lower_bound and specifying an initial value for uninitialised values.


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