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


C++ CVariant::Clone方法代码示例

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


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

示例1: AddLoadRes

CVariant CKadOperation::AddLoadRes(const CVariant& LoadRes, CKadNode* pNode)
{
	SOpProgress* pProgress = GetProgress(pNode);

	CVariant FilteredRes = LoadRes.Clone(false); // Make a Shellow Copy
	const CVariant& LoadedList = LoadRes["RES"];

	CVariant FilteredList;
	for(uint32 i=0; i < LoadedList.Count(); i++)
	{
		CVariant Loaded = LoadedList.At(i).Clone(false); // Make a Shellow Copy
		const CVariant& XID = Loaded["XID"];

		// Counting
		if(pProgress) // might be NULL if we filter our own index response right now
		{
			SOpStatus &Status = pProgress->Loads[XID];
			Status.Results++;
			if(!Loaded.Get("MORE"))
				Status.Done = true; // this marks that no more results are to be expected form this node
		}

		SOpStatus* pStatus = &m_LoadMap[XID].Status;
		pStatus->Results++;
		if(!pStatus->Done)
			pStatus->Done = IsDone(SOpProgress::GetLoads, XID);
		
		if(!pStatus->Done)
			Loaded.Insert("MORE", true);
		else
			Loaded.Remove("MORE");
		//

		if(Loaded.Has("ERR"))
		{
			FilteredList.Append(Loaded);
			continue;
		}

		// Filtering
		CVariant UniquePayloads;
		const CVariant& Payloads = Loaded["PLD"];
		for(uint32 j=0; j < Payloads.Count(); j++)
		{
			const CVariant& Payload = Payloads.At(j);
			if(m_LoadFilter[XID].insert(Payload["DATA"].GetFP()).second)
				UniquePayloads.Append(Payload);
		}

		// Note: we must add this even if UniquePayloads is empty or else we will misscount replys
		CVariant NewLoaded;
		NewLoaded["XID"] = XID;
		NewLoaded["PLD"] = UniquePayloads;
		FilteredList.Append(NewLoaded);
		//
	}

	FilteredRes.Insert("RES", FilteredList);
	return FilteredRes;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:60,代码来源:KadOperation.cpp

示例2: AddStoreRes

CVariant CKadOperation::AddStoreRes(const CVariant& StoreRes, CKadNode* pNode)
{
	SOpProgress* pProgress = GetProgress(pNode);

	CVariant FilteredRes = StoreRes.Clone(false); // Make a Shellow Copy
	const CVariant& StoredList = StoreRes["RES"];

	CVariant FilteredList;
	for(uint32 i=0; i < StoredList.Count(); i++)
	{
		CVariant Stored = StoredList.At(i).Clone(false); // Make a Shellow Copy
		const CVariant& XID = Stored["XID"];

		// Counting
		if(pProgress) // might be NULL if we filter our own index response right now
		{
			SOpStatus &Status = pProgress->Stores[XID];
			Status.Results++;
			if(!Stored.Get("MORE"))
				Status.Done = true; // this marks that no more results are to be expected form this node
		}

		SOpStatus* pStatus = &m_StoreMap[XID].Status;
		pStatus->Results++;
		if(!pStatus->Done)
			pStatus->Done = IsDone(SOpProgress::GetStores, XID);

		if(!pStatus->Done)
			Stored.Insert("MORE", true);
		else
			Stored.Remove("MORE");
		//

		//m_StoredCounter[Stored["XID"]].push_back(Stored.Get("EXP", 0)); // on error there is no EXP

		FilteredList.Append(Stored);
	}
	
	FilteredRes.Insert("RES", FilteredList);
	return FilteredRes;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:41,代码来源:KadOperation.cpp

示例3: AddCallRes

CVariant CKadOperation::AddCallRes(const CVariant& CallRes, CKadNode* pNode)
{
	SOpProgress* pProgress = GetProgress(pNode);

	CVariant FilteredRes = CallRes.Clone(false); // Make a Shellow Copy
	const CVariant& Results = CallRes["RET"];

	CVariant Filtered;
	for(uint32 i=0; i < Results.Count(); i++)
	{
        CVariant Result = Results.At(i).Clone(false); // Make a Shellow Copy
		const CVariant& XID = Result["XID"];

		// this checks if this particular response is the last and and if this node is done
		if(pProgress) // might be NULL if we filter our own index response right now
		{
			SOpStatus &Status = pProgress->Calls[XID];
			Status.Results++;
			if(!Result.Get("MORE"))
				Status.Done = true; // this marks that no more results are to be expected form this node
		}

		SOpStatus* pStatus = NULL;
		TCallOpMap::iterator I = m_CallMap.find(XID);
		if(I != m_CallMap.end())
		{
			pStatus = &I->second.Status;
			pStatus->Results++; // count the response even if it gets filtered lateron
			if(!pStatus->Done)
				pStatus->Done = IsDone(SOpProgress::GetCalls, XID);
		}

		if(m_pOperator)
		{
			CKadOperator::TRequestMap& ResuestMap = m_pOperator->GetRequests();
			CKadOperator::TRequestMap::iterator I = ResuestMap.find(XID);
			if(I != ResuestMap.end()) // this should not fail
			{
				SOpStatus* pAuxStatus = &I->second.Status;
				pAuxStatus->Results++; // count the response even if it gets filtered lateron
				if(!pAuxStatus->Done)
					pAuxStatus->Done = IsDone(SOpProgress::GetCalls, XID);
			}
		}

		if(!Result.Has("ERR"))
		{
			if(m_pOperator && m_pOperator->IsValid())
			{
				try
				{
					if(m_pOperator->AddCallRes(Result["RET"], XID))
						continue; // intercepted response - Note: if we add a response to this request now it wil be marked as no more results if thats so
				}
				catch(const CJSException& Exception)
				{
					LogReport(Exception.GetFlag(), Exception.GetLine(), Exception.GetError());
				}
			}
		}
		//else 
		//	LogLine(LOG_ERROR | LOG_DEBUG, L"Got Execution Error %s", Result["ERR"].To<wstring>().c_str());

		// check if this is a call we issued, that is one not present in the call map, in that case its never to be relayed
		if(pStatus)
		{
			// UpdateMore sets the "MORE" flag on the packet we relay further down to the source, and checks if we considder this request done
			if(!pStatus->Done)
				Result.Insert("MORE", true);
			else
				Result.Remove("MORE");

			Filtered.Append(Result);
		}
	}

	if(m_pOperator) // add new result to the filtered list
		Filtered.Merge(m_pOperator->GetResponses());
	FilteredRes.Insert("RET", Filtered);
	return FilteredRes;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:81,代码来源:KadOperation.cpp


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