本文整理汇总了C++中V_ARRAY函数的典型用法代码示例。如果您正苦于以下问题:C++ V_ARRAY函数的具体用法?C++ V_ARRAY怎么用?C++ V_ARRAY使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了V_ARRAY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SA_FETCH
zend_object_iterator *php_com_saproxy_iter_get(zend_class_entry *ce, zval *object, int by_ref)
{
php_com_saproxy *proxy = SA_FETCH(object);
php_com_saproxy_iter *I;
int i;
if (by_ref) {
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
return NULL;
}
I = ecalloc(1, sizeof(*I));
I->iter.funcs = &saproxy_iter_funcs;
Z_PTR(I->iter.data) = I;
I->proxy = proxy;
ZVAL_COPY(&I->proxy_obj, object);
I->indices = safe_emalloc(proxy->dimensions + 1, sizeof(LONG), 0);
for (i = 0; i < proxy->dimensions; i++) {
convert_to_long(&proxy->indices[i]);
I->indices[i] = (LONG)Z_LVAL(proxy->indices[i]);
}
SafeArrayGetLBound(V_ARRAY(&proxy->obj->v), proxy->dimensions, &I->imin);
SafeArrayGetUBound(V_ARRAY(&proxy->obj->v), proxy->dimensions, &I->imax);
I->key = I->imin;
return &I->iter;
}
示例2: GetLPBYTEtoOctetString
HRESULT
GetLPBYTEtoOctetString(VARIANT * pVar, LPBYTE * ppByte)
{
HRESULT hr = E_FAIL;
void HUGEP *pArray;
long lLBound, lUBound, cElements;
if ((!pVar) || (!ppByte))
return E_INVALIDARG;
if ((pVar->n1.n2.vt) != (VT_UI1 | VT_ARRAY))
return E_INVALIDARG;
hr = SafeArrayGetLBound(V_ARRAY(pVar), 1, &lLBound);
hr = SafeArrayGetUBound(V_ARRAY(pVar), 1, &lUBound);
cElements = lUBound - lLBound + 1;
hr = SafeArrayAccessData(V_ARRAY(pVar), &pArray);
if (SUCCEEDED(hr)) {
LPBYTE pTemp = (LPBYTE) pArray;
*ppByte = (LPBYTE) CoTaskMemAlloc(cElements);
if (*ppByte)
memcpy(*ppByte, pTemp, cElements);
else
hr = E_OUTOFMEMORY;
}
SafeArrayUnaccessData(V_ARRAY(pVar));
return hr;
}
示例3: GetLPBYTEtoOctetString
//Function for handling Octet Strings returned by variants
//It allocates memory for data, copies the data to the buffer, and returns a pointer to the buffer.
//Caller must free the buffer with CoTaskMemFree.
HRESULT GetLPBYTEtoOctetString(VARIANT *pVar, //IN. Pointer to variant containing the octetstring.
LPBYTE *ppByte //OUT. Return LPBYTE to the data represented in octetstring.
)
{
HRESULT hr = E_FAIL;
//Check args
if ((!pVar)||(!ppByte))
return E_INVALIDARG;
//Check the variant type for unsigned char array (octet string).
if ((pVar->vt)!=(VT_UI1|VT_ARRAY))
return E_INVALIDARG;
void HUGEP *pArray;
long lLBound, lUBound;
hr = SafeArrayGetLBound(V_ARRAY(pVar), 1, &lLBound);
hr = SafeArrayGetUBound(V_ARRAY(pVar), 1, &lUBound);
//Get the count of elements
long cElements = lUBound-lLBound + 1;
hr = SafeArrayAccessData( V_ARRAY(pVar),
&pArray );
if (SUCCEEDED(hr))
{
LPBYTE pTemp = (LPBYTE)pArray;
*ppByte = (LPBYTE) CoTaskMemAlloc(cElements);
if (*ppByte)
memcpy(*ppByte, pTemp, cElements);
else
hr = E_OUTOFMEMORY;
}
SafeArrayUnaccessData( V_ARRAY(pVar) );
return hr;
}
示例4: com_write_dimension
static void com_write_dimension(zval *object, zval *offset, zval *value)
{
php_com_dotnet_object *obj;
zval args[2];
VARIANT v;
HRESULT res;
obj = CDNO_FETCH(object);
if (V_VT(&obj->v) == VT_DISPATCH) {
ZVAL_COPY_VALUE(&args[0], offset);
ZVAL_COPY_VALUE(&args[1], value);
VariantInit(&v);
if (SUCCESS == php_com_do_invoke_by_id(obj, DISPID_VALUE,
DISPATCH_METHOD|DISPATCH_PROPERTYPUT, &v, 2, args, 0, 0)) {
VariantClear(&v);
}
} else if (V_ISARRAY(&obj->v)) {
LONG indices = 0;
VARTYPE vt;
if (SafeArrayGetDim(V_ARRAY(&obj->v)) == 1) {
if (FAILED(SafeArrayGetVartype(V_ARRAY(&obj->v), &vt)) || vt == VT_EMPTY) {
vt = V_VT(&obj->v) & ~VT_ARRAY;
}
convert_to_long(offset);
indices = (LONG)Z_LVAL_P(offset);
VariantInit(&v);
php_com_variant_from_zval(&v, value, obj->code_page);
if (V_VT(&v) != vt) {
VariantChangeType(&v, &v, 0, vt);
}
if (vt == VT_VARIANT) {
res = SafeArrayPutElement(V_ARRAY(&obj->v), &indices, &v);
} else {
res = SafeArrayPutElement(V_ARRAY(&obj->v), &indices, &v.lVal);
}
VariantClear(&v);
if (FAILED(res)) {
php_com_throw_exception(res, NULL);
}
} else {
php_com_throw_exception(DISP_E_BADINDEX, "this variant has multiple dimensions; you can't set a new value without specifying *all* dimensions");
}
} else {
php_com_throw_exception(E_INVALIDARG, "this variant is not an array type");
}
}
示例5: vtSize
unsigned vtSize(VARIANT &vt) {
if (V_VT(&vt) != (VT_ARRAY | VT_UI1))
return 0;
long lb,ub;
if (FAILED(SafeArrayGetLBound(V_ARRAY(&vt),1,&lb)) ||
FAILED(SafeArrayGetUBound(V_ARRAY(&vt),1,&ub)))
return 0;
return ub - lb + 1;
}
示例6: DEVENUM_IPropertyBag_Write
static HRESULT WINAPI DEVENUM_IPropertyBag_Write(
LPPROPERTYBAG iface,
LPCOLESTR pszPropName,
VARIANT* pVar)
{
RegPropBagImpl *This = impl_from_IPropertyBag(iface);
LPVOID lpData = NULL;
DWORD cbData = 0;
DWORD dwType = 0;
HRESULT res = S_OK;
TRACE("(%p)->(%s, %p)\n", This, debugstr_w(pszPropName), pVar);
switch (V_VT(pVar))
{
case VT_BSTR:
case VT_LPWSTR:
TRACE("writing %s\n", debugstr_w(V_BSTR(pVar)));
lpData = V_BSTR(pVar);
dwType = REG_SZ;
cbData = (lstrlenW(V_BSTR(pVar)) + 1) * sizeof(WCHAR);
break;
case VT_I4:
case VT_UI4:
TRACE("writing %u\n", V_UI4(pVar));
lpData = &V_UI4(pVar);
dwType = REG_DWORD;
cbData = sizeof(DWORD);
break;
case VT_ARRAY | VT_UI1:
{
LONG lUbound = 0;
LONG lLbound = 0;
dwType = REG_BINARY;
res = SafeArrayGetLBound(V_ARRAY(pVar), 1, &lLbound);
res = SafeArrayGetUBound(V_ARRAY(pVar), 1, &lUbound);
cbData = (lUbound - lLbound + 1) /* * sizeof(BYTE)*/;
TRACE("cbData: %d\n", cbData);
res = SafeArrayAccessData(V_ARRAY(pVar), &lpData);
break;
}
default:
FIXME("Variant type %d not handled\n", V_VT(pVar));
return E_FAIL;
}
if (RegSetValueExW(This->hkey,
pszPropName, 0,
dwType, lpData, cbData) != ERROR_SUCCESS)
res = E_FAIL;
if (V_VT(pVar) & VT_ARRAY)
res = SafeArrayUnaccessData(V_ARRAY(pVar));
return res;
}
示例7: vtCopy
void vtCopy(VARIANT& vt,void *dest) {
unsigned sz = vtSize(vt);
if (sz > 0) {
void *vp;
if (SUCCEEDED(SafeArrayAccessData(V_ARRAY(&vt),&vp))) {
memcpy(dest,vp,sz);
SafeArrayUnaccessData(V_ARRAY(&vt));
}
}
}
示例8: WebBrowser_Navigate2
static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
{
WebBrowser *This = WEBBROWSER_THIS(iface);
PBYTE post_data = NULL;
ULONG post_data_len = 0;
LPWSTR headers = NULL;
HRESULT hres;
TRACE("(%p)->(%p %p %p %p %p)\n", This, URL, Flags, TargetFrameName, PostData, Headers);
if(!This->client)
return E_FAIL;
if((Flags && V_VT(Flags) != VT_EMPTY)
|| (TargetFrameName && V_VT(TargetFrameName) != VT_EMPTY))
FIXME("Unsupported arguments\n");
if(!URL)
return S_OK;
if(V_VT(URL) != VT_BSTR)
return E_INVALIDARG;
if(PostData && V_VT(PostData) != VT_EMPTY) {
if(V_VT(PostData) != (VT_ARRAY | VT_UI1)
|| V_ARRAY(PostData)->cDims != 1) {
WARN("Invalid PostData\n");
return E_INVALIDARG;
}
SafeArrayAccessData(V_ARRAY(PostData), (void**)&post_data);
post_data_len = V_ARRAY(PostData)->rgsabound[0].cElements;
}
if(Headers && V_VT(Headers) != VT_EMPTY) {
if(V_VT(Headers) != VT_BSTR)
return E_INVALIDARG;
headers = V_BSTR(Headers);
TRACE("Headers: %s\n", debugstr_w(headers));
}
hres = navigate_url(&This->doc_host, V_BSTR(URL), post_data, post_data_len, headers);
if(post_data)
SafeArrayUnaccessData(V_ARRAY(PostData));
return hres;
}
示例9: folevariant_s_array
/*
* call-seq:
* WIN32OLE_VARIANT.array(ary, vt)
*
* Returns Ruby object wrapping OLE variant whose variant type is VT_ARRAY.
* The first argument should be Array object which specifies dimensions
* and each size of dimensions of OLE array.
* The second argument specifies variant type of the element of OLE array.
*
* The following create 2 dimensions OLE array. The first dimensions size
* is 3, and the second is 4.
*
* ole_ary = WIN32OLE_VARIANT.array([3,4], VT_I4)
* ruby_ary = ole_ary.value # => [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
*
*/
static VALUE
folevariant_s_array(VALUE klass, VALUE elems, VALUE vvt)
{
VALUE obj = Qnil;
VARTYPE vt;
struct olevariantdata *pvar;
SAFEARRAYBOUND *psab = NULL;
SAFEARRAY *psa = NULL;
UINT dim = 0;
UINT i = 0;
ole_initialize();
vt = RB_NUM2UINT(vvt);
vt = (vt | VT_ARRAY);
Check_Type(elems, T_ARRAY);
obj = folevariant_s_allocate(klass);
TypedData_Get_Struct(obj, struct olevariantdata, &olevariant_datatype, pvar);
dim = RARRAY_LEN(elems);
psab = ALLOC_N(SAFEARRAYBOUND, dim);
if(!psab) {
rb_raise(rb_eRuntimeError, "memory allocation error");
}
for (i = 0; i < dim; i++) {
psab[i].cElements = RB_FIX2INT(rb_ary_entry(elems, i));
psab[i].lLbound = 0;
}
psa = SafeArrayCreate((VARTYPE)(vt & VT_TYPEMASK), dim, psab);
if (psa == NULL) {
if (psab) free(psab);
rb_raise(rb_eRuntimeError, "memory allocation error(SafeArrayCreate)");
}
V_VT(&(pvar->var)) = vt;
if (vt & VT_BYREF) {
V_VT(&(pvar->realvar)) = (vt & ~VT_BYREF);
V_ARRAY(&(pvar->realvar)) = psa;
V_ARRAYREF(&(pvar->var)) = &(V_ARRAY(&(pvar->realvar)));
} else {
V_ARRAY(&(pvar->var)) = psa;
}
if (psab) free(psab);
return obj;
}
示例10: saproxy_count_elements
static int saproxy_count_elements(zend_object *object, zend_long *count)
{
php_com_saproxy *proxy = (php_com_saproxy*) object;
LONG ubound, lbound;
if (!V_ISARRAY(&proxy->obj->v)) {
return FAILURE;
}
SafeArrayGetLBound(V_ARRAY(&proxy->obj->v), proxy->dimensions, &lbound);
SafeArrayGetUBound(V_ARRAY(&proxy->obj->v), proxy->dimensions, &ubound);
*count = ubound - lbound + 1;
return SUCCESS;
}
示例11: SafeArrayCreateVector
STDMETHODIMP CComDigiDocLib::getSupportedFormats(VARIANT *ret)
{
const char** pArr = ::getSupportedFormats();
unsigned int nElems = 0;
SAFEARRAY* pSArr;
BSTR HUGEP* pData;
// detect number of elements
for(; *pArr != NULL; pArr++, nElems++);
// initialize SAFEARRAY
pSArr = SafeArrayCreateVector(VT_BSTR, 0, nElems);
if (pSArr == NULL) {
return E_OUTOFMEMORY;
}
// init variant
V_ARRAY(ret) = pSArr;
V_VT(ret) = (VT_ARRAY | VT_BSTR);
// copy data to variant
pArr = ::getSupportedFormats();
SafeArrayAccessData(pSArr, (void HUGEP**)&pData);
long lArr[1];
USES_CONVERSION;
ddocDebug(1, "getSupportedFormats", "num formats: %d", nElems);
for(lArr[0] = 0; lArr[0] < (long)nElems; lArr[0]++) {
ddocDebug(1, "getSupportedFormats", "format: %d - %s", lArr[0], pArr[lArr[0]]);
pData[lArr[0]] = SysAllocString(A2OLE(pArr[lArr[0]]));
}
SafeArrayUnaccessData(pSArr);
return S_OK;
}
示例12: ZVAL_NULL
static zval *com_read_dimension(zval *object, zval *offset, int type, zval *rv)
{
php_com_dotnet_object *obj;
VARIANT v;
ZVAL_NULL(rv);
obj = CDNO_FETCH(object);
if (V_VT(&obj->v) == VT_DISPATCH) {
VariantInit(&v);
if (SUCCESS == php_com_do_invoke_by_id(obj, DISPID_VALUE,
DISPATCH_METHOD|DISPATCH_PROPERTYGET, &v, 1, offset, 0, 0)) {
php_com_zval_from_variant(rv, &v, obj->code_page);
VariantClear(&v);
}
} else if (V_ISARRAY(&obj->v)) {
convert_to_long(offset);
if (SafeArrayGetDim(V_ARRAY(&obj->v)) == 1) {
if (php_com_safearray_get_elem(&obj->v, &v, (LONG)Z_LVAL_P(offset))) {
php_com_wrap_variant(rv, &v, obj->code_page);
VariantClear(&v);
}
} else {
php_com_saproxy_create(object, rv, offset);
}
} else {
php_com_throw_exception(E_INVALIDARG, "this variant is not an array type");
}
return rv;
}
示例13: Java_com_tangram_Variant_isVariantConsideredNull
/**
* this is a big cover method that returns TRUE if
* the variant type is
* VT_EMPTY, VT_NULL, VT_ERROR or VT_DISPATCH with no dispatch object
* */
JNIEXPORT jboolean JNICALL Java_com_tangram_Variant_isVariantConsideredNull(JNIEnv *env, jobject _this)
{
VARIANT *v = extractVariant(env, _this);
if (!v) return JNI_TRUE;
if ((V_VT(v) & VT_ARRAY))
{
// is it a null safearray
// prior to 4 Dec 2005 the squiggle brackets were missing
// so this did the wrong thing for the else statement
if ((V_VT(v) & VT_BYREF)) {
if (!V_ARRAYREF(v)) return JNI_TRUE;
}
else {
if (!V_ARRAY(v)) return JNI_TRUE;
}
}
switch (V_VT(v))
{
case VT_EMPTY:
case VT_NULL:
case VT_ERROR:
return JNI_TRUE;
// is it a null dispatch (Nothing in VB)
case VT_DISPATCH:
if (!V_DISPATCH(v)) return JNI_TRUE;
}
return JNI_FALSE;
}
示例14: ChkComBstrArgN
/*----------------------------------------------------------------------------------------------
Generate the sort key as a "SAFEARRAY".
----------------------------------------------------------------------------------------------*/
STDMETHODIMP LgIcuCollator::get_SortKeyVariant(BSTR bstrValue, LgCollatingOptions colopt,
VARIANT * psaKey)
{
BEGIN_COM_METHOD;
ChkComBstrArgN(bstrValue);
ChkComArgPtr(psaKey);
psaKey->vt = VT_NULL;
EnsureCollator();
int32_t cbKey = keySize;
byte rgbKey[keySize+1];
Vector<byte> vbKey;
byte * pbKey = GetSortKey(bstrValue, rgbKey, &cbKey, vbKey);
// Allocate the safe array.
SAFEARRAYBOUND rgsabound[1];
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = cbKey;
SAFEARRAY FAR * psa = ::SafeArrayCreate(VT_UI1, 1, rgsabound);
// Copy the key data to the safe array.
byte * pbOut;
CheckHr(::SafeArrayAccessData(psa, (void HUGEP **)&pbOut));
memcpy(pbOut, pbKey, cbKey);
CheckHr(::SafeArrayUnaccessData(psa));
// Push the safe array to the output pointer.
psaKey->vt = VT_UI1 | VT_ARRAY;
V_ARRAY(psaKey) = psa;
return S_OK;
END_COM_METHOD(g_fact, IID_ILgCollatingEngine);
}
示例15: DAQ_CHECK
STDMETHODIMP CLabInput::GetSingleValues(VARIANT* values)
{
AUTO_LOCK; // Should not be needed inserted on a whim
if (!_isConfig)
DAQ_CHECK(Configure(FORSINGLEVALUE));
// 3 SCANS IS THE MIN with scan_op
SAFEARRAY *ps = SafeArrayCreateVector(VT_I2, 0, _nChannels*2);
if (ps==NULL) return E_SAFEARRAY_ERR;
// set the data type and values
V_ARRAY(values)=ps;
V_VT(values)=VT_ARRAY | VT_I2;
TSafeArrayAccess <short > binarray(values);
if (_nChannels<=2)
{
for (int i=0; i<_nChannels; i++)
{
DAQ_CHECK(AI_Read(_id, _chanList[i], _gainList[i], &binarray[i]));
}
}
else
{
// setup the channels to read and scan them
DAQ_TRACE(Set_DAQ_Device_Info(_id, ND_DATA_XFER_MODE_AI, ND_INTERRUPTS));
short *dummy=(short*)_alloca(_nChannels*sizeof(short));
DAQ_CHECK(Lab_ISCAN_Op(_id,static_cast<i16>(_nChannels),_gainList[0],&binarray[0],
_nChannels, 1.0/_chanSkew,0,dummy));
}
return S_OK;
}