| Version: 3.0.5

- Main Page
- Related Pages
- Categories
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
wxVariantDataSafeArray Class Reference
Class List by Category » Data Structures

`#include <wx/msw/ole/automtn.h>`

Inheritance diagram for wxVariantDataSafeArray:
[legend]

## Detailed Description

This class represents a thin wrapper for Microsoft Windows SAFEARRAY type.

It is used for converting between wxVariant and OLE VARIANT with type set to VT_ARRAY, which has more than one dimension. When wxVariant stores wxVariantDataSafeArray, it returns "safearray" as its type.

wxVariantDataSafeArray does NOT manage the SAFEARRAY it points to. If you want to pass it to a wxAutomationObject as a parameter:

1. Assign a SAFEARRAY pointer to it and store it in a wxVariant.
2. Call the wxAutomationObject method (CallMethod(), SetProperty() or Invoke())
3. wxAutomationObject will destroy the array after the approapriate automation call.

An example of creating a 2-dimensional SAFEARRAY containing VARIANTs and storing it in a wxVariant

SAFEARRAYBOUND bounds[2]; // 2 dimensions
wxSafeArray<VT_VARIANT> safeArray;
unsigned rowCount = 1000;
unsigned colCount = 20;
bounds[0].lLbound = 0; // elements start at 0
bounds[0].cElements = rowCount;
bounds[1].lLbound = 0; // elements start at 0
bounds[1].cElements = colCount;
if ( !safeArray.Create(bounds, 2) )
return false;
long indices[2];
for ( unsigned row = 0; row < rowCount; row++ )
{
indices[0] = row;
for ( unsigned col = 0; col < colCount; col++ )
{
indices[1] = col;
if ( !safeArray.SetElement(indices, wxString::Format("R%u C%u", row+1, col+1)) )
return false;
}
}
range.PutProperty("Value", wxVariant(new wxVariantDataSafeArray(sa.Detach())));

If you you received wxVariantDataSafeArray as a result of wxAutomationObject method call: (1) Get the data out of the array. (2) Destroy the array.

wxVariant result;
result = range.GetProperty("Value");
if ( result.GetType() == "safearray" )
{
wxSafeArray<VT_VARIANT> safeArray;
wxVariantDataSafeArray* const
sa = wxStaticCastVariantData(variant.GetData(), wxVariantDataSafeArray);
if ( !safeArray.Attach(sa.GetValue() )
{
if ( !safeArray.HasArray() )
SafeArrayDestroy(sa.GetValue()); // we have to dispose the SAFEARRAY ourselves
return false;
}
// get the data from the SAFEARRAY using wxSafeArray::GetElement()
// SAFEARRAY will be disposed by safeArray's dtor
}
Availability: only available for the wxMSW port.

Since
  2.9.5

##

Library: wxCore
Category: Data Structures

See also
  wxAutomationObject, wxVariant, wxVariantData, wxVariantDataErrorCode

Include file:

    #include <wx/msw/ole/oleutils.h>

## Public Member Functions

| wxVariantDataSafeArray (SAFEARRAY *value=NULL)
| Constructor initializes the object to value. More...
SAFEARRAY * | GetValue () const
| Returns the stored array. More...
void | SetValue (SAFEARRAY *value)
| Set the stored array. More...
virtual bool | Eq (wxVariantData &data) const
| Returns true if data is of wxVariantDataSafeArray type and contains the same SAFEARRAY* value. More...
virtual bool | Write (wxString &str) const
| Fills the provided string with the textual representation of this object. More...
wxVariantData * | Clone () const
| Returns a copy of itself. More...
virtual wxString | GetType () const
| Returns "safearray". More...
virtual bool | GetAsAny (wxAny *any) const
| Converts the value of this object to wxAny. More...
Public Member Functions inherited from wxVariantData
| wxVariantData ()
| Default constructor. More...
void | DecRef ()
| Decreases reference count. More...
virtual bool | GetAny (wxAny *any) const
| Converts value to wxAny, if possible. More...
virtual wxClassInfo * | GetValueClassInfo ()
| If the data is a wxObject returns a pointer to the objects wxClassInfo structure, if the data isn't a wxObject the method returns NULL. More...
void | IncRef ()
| Increases reference count. More...
virtual bool | Read (istream &stream)
| Reads the data from stream. More...
virtual bool | Read (wxString &string)
| Reads the data from string. More...
virtual bool | Write (ostream &stream) const
| Writes the data to stream. More...

## Constructor & Destructor Documentation

wxVariantDataSafeArray::wxVariantDataSafeArray | ( | SAFEARRAY * | value = `NULL` | ) |

explicit

Constructor initializes the object to value.

## Member Function Documentation

wxVariantData* wxVariantDataSafeArray::Clone | ( |  | ) | const

virtual

Returns a copy of itself.

Reimplemented from wxVariantData.

virtual bool wxVariantDataSafeArray::Eq | ( | wxVariantData & | data | ) | const

virtual

Returns true if data is of wxVariantDataSafeArray type and contains the same SAFEARRAY* value.

Implements wxVariantData.

virtual bool wxVariantDataSafeArray::GetAsAny | ( | wxAny * | any | ) | const

virtual

Converts the value of this object to wxAny.

virtual wxString wxVariantDataSafeArray::GetType | ( |  | ) | const

virtual

Returns "safearray".

Implements wxVariantData.

SAFEARRAY* wxVariantDataSafeArray::GetValue | ( |  | ) | const

Returns the stored array.

void wxVariantDataSafeArray::SetValue | ( | SAFEARRAY * | value | ) |

Set the stored array.

virtual bool wxVariantDataSafeArray::Write | ( | wxString & | str | ) | const

virtual

Fills the provided string with the textual representation of this object.

Only the address of SAFEARRAY pointer is output.

Reimplemented from wxVariantData.