当前位置: 首页>>代码示例>>C++>>正文


C++ COleSafeArray类代码示例

本文整理汇总了C++中COleSafeArray的典型用法代码示例。如果您正苦于以下问题:C++ COleSafeArray类的具体用法?C++ COleSafeArray怎么用?C++ COleSafeArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了COleSafeArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetWorldIdList

VARIANT CMUSHclientDoc::GetWorldIdList() 
{
  COleSafeArray sa;   // for list

  CMUSHclientDoc * pDoc;
  long iCount = 0;
  POSITION pos;

  // count number of worlds
  for (pos = App.m_pWorldDocTemplate->GetFirstDocPosition(); pos != NULL; iCount++)
    pDoc = (CMUSHclientDoc *) App.m_pWorldDocTemplate->GetNextDoc(pos);

  if (iCount) // cannot create empty array dimension
    {
    sa.CreateOneDim (VT_VARIANT, iCount);
  
    // put the worlds into the array
    for (iCount = 0, pos = App.m_pWorldDocTemplate->GetFirstDocPosition(); pos != NULL; iCount++)
      {
      pDoc = (CMUSHclientDoc *) App.m_pWorldDocTemplate->GetNextDoc(pos);

      // the array must be a bloody array of variants, or VBscript kicks up
      COleVariant v (pDoc->m_strWorldID);
      sa.PutElement (&iCount, &v);
      }      // end of looping through each world
    } // end of having at least one

	return sa.Detach ();
}   // end of CMUSHclientDoc::GetWorldIdList
开发者ID:RKelson93,项目名称:mushclient,代码行数:29,代码来源:methods_worlds.cpp

示例2: GetActiveCalibration

// returns a new 7-element array of doubles containing Force and Torque measurements
int FTWrapper::GetForcesAndTorques(double output[7])
{
	if (status == ALL_READY) {
		// this array is used to create the COleSafeArray below
		// it is used to indicate that there are 7 elements in the first diemnsion
		DWORD numElements[] = {7};
		COleSafeArray voltages;
		// VT_R8 represents an 8-byte real, i.e. a double in C++
		// there is 1 dimension with a size of 'numElements[0]'
		voltages.Create(VT_R8, 1, numElements);

		double ft_voltages[7];
		int mDAQstatus = mDAQSys->ScanGauges(ft_voltages, false);
		long i;
		for(i=0;i<7;i++) {
			// COleSafeArrays use pass-by-reference methods to read or write
			voltages.PutElement(&i,&(ft_voltages[i]));
		}
		// this method uses the calibration matrix (and possibly temperature compensation)
		// to convert the 6 gauge readings into forces and torques
		COleSafeArray forces = GetActiveCalibration().ConvertToFT(voltages,"lb","in-lb");
		for (i=0; i<6; i++) {
			// COleSafeArrays use pass-by-reference methods to read or write
			forces.GetElement(&i,&(output[i]));
		}
		// copy the thermistor voltage over to the output for display
		output[6] = ft_voltages[6];
		return mDAQstatus;
	}
	else {
		return -2;
	}
}
开发者ID:senlin-hust,项目名称:RB-Robot-test-app,代码行数:34,代码来源:FTWrapper.cpp

示例3: COleSafeArray

/* Called when an instrument update occurs (i.e. LTP changes).
 * @param pInstr Instrument updated
 */
void CSubmitOrderDialog::CInstrNotifySink_Update(XTAPI::ITTInstrObj* pInstr)
{
	long index = 0L;
	_variant_t vData;  

	// extract an array containing all of our required fields.
	COleSafeArray* lpData = new COleSafeArray(pInstr->GetGet((LPCSTR)"Bid,Ask,Last,Change"));

	lpData->GetElement(&index, &vData);	
	m_BidPriceBox = CString(vData); 
	
	lpData->GetElement(&++index, &vData);	
	m_AskPriceBox = CString(vData); 
	
	lpData->GetElement(&++index, &vData);	
	m_LTPBox = CString(vData); 

	lpData->GetElement(&++index, &vData);	
	m_ChangeBox = CString(vData); 

	// Call after updating the AFX_DATA fields
	UpdateData(false);

	// delete the array
	delete lpData;
	lpData = NULL;
}
开发者ID:kshakhna,项目名称:CodeSamples_XTAPI_CPP,代码行数:30,代码来源:SubmitOrderDialog.cpp

示例4: WindowList

// return list of windows we have made
VARIANT CMUSHclientDoc::WindowList() 
{
  COleSafeArray sa;   // for array list

  long iCount = 0;
  
  // put the arrays into the array
  if (!m_MiniWindows.empty ())    // cannot create empty dimension
    {
    sa.CreateOneDim (VT_VARIANT, m_MiniWindows.size ());

    for (MiniWindowMapIterator it = m_MiniWindows.begin (); 
         it != m_MiniWindows.end ();
         it++)
           {
            // the array must be a bloody array of variants, or VBscript kicks up
            COleVariant v (it->first.c_str ());
            sa.PutElement (&iCount, &v);
            iCount++;
           }

    } // end of having at least one

	return sa.Detach ();
}    // end of CMUSHclientDoc::WindowList
开发者ID:salmonrose,项目名称:mushclient,代码行数:26,代码来源:methods_miniwindows.cpp

示例5: GetPluginList

VARIANT CMUSHclientDoc::GetPluginList() 
{
  COleSafeArray sa;   // for variable list

  CString strVariableName;

  long iCount = 0;
  
  // put the plugins into the array
  if (!m_PluginList.empty ())    // cannot create empty dimension
    {
    sa.CreateOneDim (VT_VARIANT, m_PluginList.size ());

    for (PluginListIterator pit = m_PluginList.begin (); 
         pit != m_PluginList.end (); 
         ++pit)
      {
      CPlugin * p = *pit;

      // the array must be a bloody array of variants, or VBscript kicks up
      COleVariant v (p->m_strID);
      sa.PutElement (&iCount, &v);
      iCount++;
      }      // end of looping through each plugin
    } // end of having at least one

	return sa.Detach ();
}   // end of CMUSHclientDoc::GetPluginList
开发者ID:salmonrose,项目名称:mushclient,代码行数:28,代码来源:methods_plugins.cpp

示例6: Bias

// specifies whether force/torque and voltages will be biased or not
void FTWrapper::Bias(bool newbias)
{
	bias = newbias;
	if (status & DAQ_READY) {
		if (bias == true) {
			// this array is used to create the COleSafeArray below
			// it is used to indicate that there are 7 elements in the first diemnsion
			DWORD numElements[] = {7};
			COleSafeArray voltages;
			// VT_R8 represents an 8-byte real, i.e. a double in C++
			// there is 1 dimension with a size of 'numElements[0]'
			voltages.Create(VT_R8, 1, numElements);

			mDAQSys->ScanGauges(biasVoltage, true);
//			if (mDAQstatus) {
				// bad bias!
//			}
			for(long i=0;i<7;i++) {
				// COleSafeArrays use pass-by-reference methods to read or write
				voltages.PutElement(&i,&(biasVoltage[i]));
			}
			// check the bits that indicate that the calibration file has been loaded and the DAQ is ready
			if (status == ALL_READY) {
				GetActiveCalibration().Bias(voltages);
			}
		}
		else {
			// check the bit that indicates that the calibration file has been loaded
			if (status & CALFILE_LOADED) {
				GetActiveCalibration().ClearBias();
			}
		}
	}
}
开发者ID:senlin-hust,项目名称:RB-Robot-test-app,代码行数:35,代码来源:FTWrapper.cpp

示例7: GetGlobalOptionList

VARIANT CMUSHclientApp::GetGlobalOptionList() 
{
  COleSafeArray sa;   // for list
  long i, count = 0;

  // count them
  for (i = 0; GlobalOptionsTable [i].pName; i++)
    count++;

  for (i = 0; AlphaGlobalOptionsTable [i].pName; i++)
    count++;

  sa.CreateOneDim (VT_VARIANT, count);
  count = 0;

  // put the numeric option names into the array
  for (i = 0; GlobalOptionsTable [i].pName; i++)
    {
    // the array must be a bloody array of variants, or VBscript kicks up
    COleVariant v ((LPCTSTR) GlobalOptionsTable [i].pName);
    sa.PutElement (&count, &v);
    count++;
    }      // end of looping through each option

  // put the alpha option names into the array
  for (i = 0; AlphaGlobalOptionsTable [i].pName; i++)
    {
    // the array must be a bloody array of variants, or VBscript kicks up
    COleVariant v ((LPCTSTR) AlphaGlobalOptionsTable [i].pName);
    sa.PutElement (&count, &v);
    count++;
    }      // end of looping through each option

	return sa.Detach ();
}
开发者ID:WillFa,项目名称:mushclient,代码行数:35,代码来源:globalregistryoptions.cpp

示例8: GetTriggerList

VARIANT CMUSHclientDoc::GetTriggerList() 
{
  COleSafeArray sa;   // for wildcard list

  CString strTriggerName;
  CTrigger * trigger_item;
  long iCount = 0;
  POSITION pos;

  iCount = GetTriggerMap ().GetCount ();

  if (iCount) // cannot create empty array dimension
    {
    sa.CreateOneDim (VT_VARIANT, iCount);
  
    for (iCount = 0, pos = GetTriggerMap ().GetStartPosition(); pos; iCount++)
      {
      GetTriggerMap ().GetNextAssoc (pos, strTriggerName, trigger_item);

      // the array must be a bloody array of variants, or VBscript kicks up
      COleVariant v (strTriggerName);
      sa.PutElement (&iCount, &v);
      }      // end of looping through each trigger
    } // end of having at least one

	return sa.Detach ();
}    // end of CMUSHclientDoc::GetTriggerList
开发者ID:RKelson93,项目名称:mushclient,代码行数:27,代码来源:methods_triggers.cpp

示例9: strURL

HRESULT CHtmlCtrl::Navigate(LPCTSTR lpszURL, 
			    DWORD dwFlags /*= 0*/,
			    LPCTSTR lpszTargetFrameName /*= NULL*/,
			    LPCTSTR lpszHeaders /*= NULL*/, 
			    LPVOID lpvPostData /*= NULL*/,
			    DWORD dwPostDataLen /*= 0*/)
{
    CString strURL(lpszURL);
    BSTR bstrURL = strURL.AllocSysString();

    COleSafeArray vPostData;
    if (lpvPostData != NULL)
    {
        if (dwPostDataLen == 0)
            dwPostDataLen = lstrlen((LPCTSTR) lpvPostData);

        vPostData.CreateOneDim(VT_UI1, dwPostDataLen, lpvPostData);
    }

    return m_pBrowser->Navigate(bstrURL,
        COleVariant((long) dwFlags, VT_I4),
        COleVariant(lpszTargetFrameName, VT_BSTR),
        vPostData,
        COleVariant(lpszHeaders, VT_BSTR));
}
开发者ID:hpc,项目名称:mvapich-cce,代码行数:25,代码来源:HtmlCtrl.cpp

示例10: mesage_AddFieldBinary

int mesage_AddFieldBinary(lua_State* L) {
	CMessage* msg = cmessage_arg(L, "mesage_AddFieldBinary");
	CString fldName = luaL_checkstring(L, 2);
	CString path = luaL_checkstring(L, 3); 
	int err;
	char *description;

	int charsLen = ::MultiByteToWideChar(CP_UTF8, 0, path, lstrlen(path), NULL, 0);
	std::wstring characters(charsLen, '\0');
	::MultiByteToWideChar(CP_UTF8, 0, path, lstrlen(path), &characters[0], charsLen);

	int pf;
	char *b = NULL;
	err = _wsopen_s(&pf, characters.c_str(), _O_BINARY | _O_RDONLY, _SH_DENYWR, _S_IREAD);
	if (err) {
		description = "Open File error";
		goto err;
	}

	DWORD l = _filelength(pf);

	b = new char[l];


	if (l != _read(pf, b, l)) {
		err = -1;
		description = "Read File error";
		goto err;
	}
	err = _close(pf);
	if (err) {
		description = "Close File error";
		goto err;
	}
	{
		COleSafeArray arr;
		arr.Create(VT_UI1, 1, &l);

		for (DWORD i = 0; i < l; i++) {

			arr.PutElement((long*)&i, &b[i]);
		}

		msg->AddDatum(fldName, arr);
	}

err:
	if (b)
		delete []b;
	lua_pushinteger(L, err);
	if (err)
		lua_pushstring(L, description);
	else
		lua_pushinteger(L, l);
	return 2;
}
开发者ID:mwoz,项目名称:Hildim.Source,代码行数:56,代码来源:mblua.cpp

示例11: __declspec

void __declspec(dllexport) __stdcall FillLocalArray(SequenceContext *seqContext,  short *errorOccurred,  long *errorCode,  char errorMsg[1024])
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    double *        numArray = NULL;
    unsigned int    numElements;
    double          numCycles = 2.0;
    PropertyObjectPtr   seqContextPOPtr;

    TRY
        // Set sequence context as a property object
    seqContextPOPtr = seqContext->AsPropertyObject();
   
        // The following code shows how to accesses properties via the ActiveX Automation API
    if (seqContextPOPtr->Exists("Locals.NumericArray",0)) 
        {
            // Create a Safe Array from the VARIANT which contains a
            // copy of the Locals.NumericArray. 
        COleSafeArray safeArray;
        safeArray.Attach(seqContextPOPtr->GetValVariant("Locals.NumericArray",0));
    
            // Check the size of the array of data - assuming 1D array  
        numElements = safeArray.GetOneDimSize();

            // Lock array for data access and get a pointer to the data.
            // (assuming it's an array of doubles)
        safeArray.AccessData((void**)&numArray);
        

            // Create sine pattern
        for (unsigned int i=0; i<numElements; i++)
            numArray[i] = sin((2*3.14) * i *numCycles/ numElements);

            // unlock array 
        safeArray.UnaccessData();

            // Set the value of the property the lookupString parameter specifies with a variant.  
            // Use this method to set the value of an entire array at once.                         
        seqContextPOPtr->SetValVariant("Locals.NumericArray", 0, safeArray);

        }
    
    CATCH(COleDispatchException, e) 
        *errorOccurred = TRUE;
        _mbsnbcpy_s((unsigned char *)errorMsg, 1024, (unsigned char *)LPCTSTR(e->m_strDescription), 1024 - 1);
        *(errorMsg + (1024 - 1)) = '\0';
        *errorCode = e->m_scError;

    AND_CATCH(CMemoryException, e)
        *errorOccurred = TRUE;
        e->GetErrorMessage(errorMsg, 1024);
        *(errorMsg + (1024 - 1)) = '\0';
        *errorCode = TS_Err_OutOfMemory;

    END_CATCH 
}
开发者ID:afeique,项目名称:ni-training-july-2016,代码行数:56,代码来源:AccessingArrays.cpp

示例12: AFX_MANAGE_STATE

COleVariant CLispEng::ToOleVariant(CP p) {
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

#ifdef X_DEBUG
	static ofstream os("c:\\out\\lisp.log");
	Print(os, p);
	os << endl;
#endif
	COleVariant r;
	switch (Type(p)) {
	case TS_CONS:
		if (!p)
			r.vt = VT_NULL;
		else
			E_Error();
		break;
	case TS_FIXNUM:
		return COleVariant((long)AsNumber(p));
	case TS_BIGNUM:
		{
			__int64 n;
			if (!ToBigInteger(p).AsInt64(n))
				E_Error();
			return COleVariant((long)n); // only lower 32 bits
		}
	case TS_SYMBOL:
		if (p == V_T)
			return COleVariant(true);
		E_Error();
	case TS_ARRAY:
		if (StringP(p))
			return COleVariant(AsString(p));
		else if (VectorP(p))
		{
			CArrayValue *av = ToVector(p);
			COleSafeArray sa;
			size_t len = av->GetVectorLength();
			sa.CreateOneDim(VT_VARIANT, (DWORD)len);
			for (long i=0; i<(long)len; ++i) {
				COleVariant v = ToOleVariant(av->GetElement(i));
				sa.PutElement(&i, &v);
			}
			return sa;
		}
		E_Error();
	default:
		E_Error();
	}
	return r;
}
开发者ID:ufasoft,项目名称:lisp,代码行数:50,代码来源:ffi.cpp

示例13: pre_load_sheet

	void pre_load_sheet(CWorksheet &sheet, COleSafeArray &safe_array)
	{
        ///当前的操作区域  
        CRange excel_current_range;
        excel_current_range.AttachDispatch(sheet.get_Cells(), true);  

		CRange used_range = sheet.get_UsedRange();    

		VARIANT ret_ary = used_range.get_Value2();
		if (!(ret_ary.vt & VT_ARRAY)){
			return;
		}

		safe_array.Clear();
		safe_array.Attach(ret_ary); 
	}
开发者ID:no2key,项目名称:tokit,代码行数:16,代码来源:excel_tool.cpp

示例14: get_cell_int

	int get_cell_int(COleSafeArray &ole_safe_array, int row, int col)
	{
		COleVariant vResult ;
		int ret;

		//字符串
		long read_address[2];
		VARIANT val;
		read_address[0] = row;
		read_address[1] = col;
		ole_safe_array.GetElement(read_address, &val);
		vResult = val;

		//整数
		switch(vResult.vt)
		{
		case VT_INT:
			ret = vResult.intVal;
			break;

		case VT_R8:
			ret = (int)vResult.dblVal;
			break;

		default:
			ret = 0;
			break;
		}

		return ret;
	}
开发者ID:no2key,项目名称:tokit,代码行数:31,代码来源:excel_tool.cpp

示例15: bstrURL

HRESULT CWebCtrl::Navigate(LPCTSTR lpszURL, DWORD dwFlags, LPCTSTR lpszTargetFrameName, LPCTSTR lpszHeaders, LPVOID lpvPostData, DWORD dwPostDataLen)
{
	if ( m_pBrowser == NULL ) return E_UNEXPECTED;

	CComBSTR bstrURL( lpszURL );

	COleSafeArray vPostData;
	if ( lpvPostData != NULL )
	{
		if ( dwPostDataLen == 0 ) dwPostDataLen = lstrlen( (LPCTSTR)lpvPostData );
		vPostData.CreateOneDim( VT_UI1, dwPostDataLen, lpvPostData );
	}

	return m_pBrowser->Navigate( bstrURL, COleVariant( (long) dwFlags, VT_I4 ),
		COleVariant( lpszTargetFrameName, VT_BSTR ), vPostData,
		COleVariant( lpszHeaders, VT_BSTR ) );
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:17,代码来源:CtrlWeb.cpp


注:本文中的COleSafeArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。