35 std::ostringstream oss;
36 oss << message <<
": " << ce.ErrorMessage();
44 _snprintf(buffer,
sizeof(buffer),
"Win32StructuredException code 0x%x pExpCode 0x%x pExpAddress %p", code, pExp->ExceptionRecord->ExceptionCode, pExp->ExceptionRecord->ExceptionAddress);
45 buffer[
sizeof(buffer)-1] =
'\0';
46 return std::string(buffer);
54 V_VT(v) = VT_ARRAY | v_type;
55 SAFEARRAYBOUND* sab =
new SAFEARRAYBOUND[ndims];
61 for(i=0; i<ndims; i++)
64 sab[i].cElements = dims_array[ndims-i-1];
66 V_UNION(v,parray) = SafeArrayCreate(v_type, ndims, sab);
68 if (V_UNION(v,parray) == NULL)
81 hr = SafeArrayGetVartype(V_UNION(v,parray), &vtt);
86 hr = SafeArrayAccessData(V_UNION(v,parray), values);
87 if ( FAILED(hr) || (*values == NULL) )
122 HRESULT hr = SafeArrayUnaccessData(V_UNION(v,parray));
133 if (!(V_VT(v) & VT_ARRAY))
137 SAFEARRAY* psa = V_UNION(v,parray);
142 int ndims = SafeArrayGetDim(psa);
147 long lbounds, ubounds;
150 for(i=0; i<ndims; i++)
152 lbounds = ubounds = 0;
153 SafeArrayGetLBound(psa, i+1, &lbounds);
154 SafeArrayGetUBound(psa, i+1, &ubounds);
155 len *= (ubounds - lbounds + 1);
164 if (!(V_VT(v) & VT_ARRAY))
168 SAFEARRAY* psa = V_UNION(v,parray);
173 ndims = SafeArrayGetDim(psa);
174 long lbounds, ubounds;
175 for(
int i=0; i<ndims; i++)
177 lbounds = ubounds = 0;
178 SafeArrayGetLBound(psa, i+1, &lbounds);
179 SafeArrayGetUBound(psa, i+1, &ubounds);
180 dims_array[i] = ubounds - lbounds + 1;
185 template <
typename T>
194 int n =
static_cast<int>(the_array.size());
196 BSTR* v_array = NULL;
198 for(
int i=0; i<n; ++i)
200 CComBSTR bstr_wrapper(the_array[i].c_str());
201 v_array[i] = bstr_wrapper.Detach();
208 template <const VARTYPE vt>
226 template <
typename T>
229 VARTYPE vt_type = CVarTypeInfo<T>::VT;
233 for(
int i=0; i<n; ++i)
235 v_array[i] = the_array[i];
int arrayVariantDimensions(VARIANT *v, int dims_array[], int &ndims)
int unaccessArrayVariant(VARIANT *v)
Header file for various COM utilities.
int allocateArrayVariant(VARIANT *v, VARTYPE v_type, int *dims_array, int ndims)
static int accessArrayVariant(VARIANT *v, void **values, VARTYPE vt)
int makeVariantFromArray(VARIANT *v, const std::vector< T > &the_array)
static std::string win32_message(unsigned int code, EXCEPTION_POINTERS *pExp)
int arrayVariantLength(VARIANT *v)
static std::string com_message(const std::string &message, HRESULT hr)