Exemple #1
0
HRESULT CMethodInfo::GetEnumString(ITypeInfo* ppEnumInfo, TSTR& str)
{
	str = _T("");
	HRESULT hr = E_FAIL;
	if (ppEnumInfo != NULL)
	{
		CSmartTypeAttr pta(ppEnumInfo);
		hr = ppEnumInfo->GetTypeAttr(&pta);
		if (FAILED(hr)) return hr;
		
		if(pta->typekind == TKIND_ENUM)
		{
			VARDESC* pvd=NULL;
			str = _T("( ");
			for (int i=0; i<pta->cVars; i++)
			{ 
				ppEnumInfo->GetVarDesc(i, &pvd);
				DISPID idMember = pvd->memid;
				CComBSTR bstrName;
				ppEnumInfo->GetDocumentation(idMember, &bstrName, NULL, NULL, NULL);
				str += _T("#");
				str += TSTR::FromOLESTR(bstrName);
				if (i < (pta->cVars-1)) str += _T(" | ");
				ppEnumInfo->ReleaseVarDesc(pvd);
			}
			str += _T(" )");
			hr = S_OK;
		}		
	}
	return hr;
}
Exemple #2
0
VARTYPE CMethodInfo::GetUserDefinedType(ITypeInfo *pTI, HREFTYPE hrt)
{
	CComPtr<ITypeInfo> spTypeInfo;
	VARTYPE vt = VT_USERDEFINED;
	HRESULT hr = E_FAIL;
	hr = pTI->GetRefTypeInfo(hrt, &spTypeInfo);
	if(FAILED(hr))
		return vt;
	CSmartTypeAttr pta(spTypeInfo);
	spTypeInfo->GetTypeAttr(&pta);

	if(&pta && pta->typekind == TKIND_ALIAS)
	{
		if (pta->tdescAlias.vt == VT_USERDEFINED)
			GetUserDefinedType(spTypeInfo,pta->tdescAlias.hreftype);
		else
			vt = pta->tdescAlias.vt;
	}
	return vt;
}
Exemple #3
0
HRESULT CMethodInfo::GetEnumTypeInfo(ITypeInfo *pTI, HREFTYPE hrt, ITypeInfo** ppEnumInfo)
{
	CComPtr<ITypeInfo> spTypeInfo;
	HRESULT hr = E_FAIL;
	hr = pTI->GetRefTypeInfo(hrt, &spTypeInfo);
	if(FAILED(hr)) return hr;
	
	CSmartTypeAttr pta(spTypeInfo);
	hr = spTypeInfo->GetTypeAttr(&pta);
	if(FAILED(hr)) return hr;
	
	if (pta->typekind == TKIND_ALIAS)
	{
		if (pta->tdescAlias.vt == VT_USERDEFINED)
			return GetEnumTypeInfo(spTypeInfo,pta->tdescAlias.hreftype, ppEnumInfo);
	}
	else if (pta->typekind == TKIND_ENUM)
		spTypeInfo.CopyTo(ppEnumInfo);
	
	return (*ppEnumInfo != NULL) ? S_OK : E_FAIL;
}
Exemple #4
0
void Client::handle_read(const boost::system::error_code& e, const size_t size)
{
    if(!e)
    {
        std::istream bufReader(&_buf);
        std::string buf;
        std::getline(bufReader, buf, '\n');
        char packetType;
        bufReader >> packetType;
        switch((Packet::PacketType)packetType)
        {
        case Packet::Task:
        {
            Packet::PacketTask pt;
            {
                boost::archive::text_iarchive tia(bufReader);
                tia >> pt;
            }
            std::cout << "new task!" << std::endl;
            ProcessResults pr = processTask(pt.programs());
            Packet::PacketTaskAchieved pta(pr.scores, pr.newPrograms);
            {
                std::ostream bufWriter(&_responseBuf);
                {
                    boost::archive::text_oarchive toa(bufWriter);
                    toa << pta;
                }
                bufWriter << "\n"; // the end delimiter
            }
            boost::asio::write(_sock, _responseBuf);
        }
        break;
        case Packet::Stop:
            _state = Quitting;
            return;
            break;
        default: // if the packetType is not recognized
            break;
        }
    }