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


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

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


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

示例1: HandleNodeRes

void CKadHandler::HandleNodeRes(const CVariant& NodeRes, CKadNode* pNode, CComChannel* pChannel)
{
	if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRT"))
		LogLine(LOG_DEBUG, L"Recived 'Node Response' from %s", pNode->GetID().ToHex().c_str());

	CVariant List = NodeRes["LIST"];
	if(List.Count() > (uint32)GetParent<CKademlia>()->Cfg()->GetInt("NodeReqCount"))
		throw CException(LOG_ERROR, L"Node returned more nodes than requested (spam)");
	
	SKadData* pData = pChannel->GetData<SKadData>();
	// Note: if pData->pLookup is NULL this was just a bootstrap request

	NodeMap Nodes;
	for(uint32 i = 0; i<List.Count(); i++)
	{
		CPointer<CKadNode> pNewNode = new CKadNode(GetParent<CKademlia>()->Root());
		pNewNode->Load(List.At(i));
		if(GetParent<CKademlia>()->Root()->AddNode(pNewNode) && pData->pLookup)
		{
			CUInt128 uDistance = pData->pLookup->GetID() ^ pNewNode->GetID();
			Nodes.insert(NodeMap::value_type(uDistance, pNewNode));
		}
	}

	if(pData->pLookup)
		GetParent<CKademlia>()->Manager()->AddNodes(pData->pLookup, pNode, pChannel, Nodes);
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:27,代码来源:KadHandler.cpp

示例2: RecivedTraceResults

void CLookupHistory::RecivedTraceResults(const CVariant& Trace)
{
	if(Trace.Count() < 1)
		return;

	CUInt128 PrevID = Trace.At(Trace.Count()-1);
	for(int i=Trace.Count()-2; i >= 0; i--)
	{
		CUInt128 CurID = Trace.At(i);
		RecivedTraceResults(CurID, PrevID);
		PrevID = CurID;
	}
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:13,代码来源:LookupHistory.cpp

示例3: AddCallReq

CVariant CLookupProxy::AddCallReq(const CVariant& Requests)
{
	CVariant Results(CVariant::EList);

	for(uint32 i=0; i<Requests.Count(); i++)
	{
		const CVariant& Request = Requests[i];
		if(!m_CallMap.insert(TCallOpMap::value_type(Request["XID"], SCallOp(Request))).second)
			continue; // we already got this request, ignore it

		if(m_pOperator && m_pOperator->IsValid())
		{
			try
			{
				m_pOperator->AddCallReq(Request["FX"], Request["ARG"], Request["XID"]);
			}
			catch(const CJSException& Exception)
			{
				LogReport(Exception.GetFlag(), Exception.GetLine(), Exception.GetError());

				CKadOperation::SOpStatus &Progress = m_CallMap[Request["XID"]].Status;
				Progress.Done = true; // this one is finished

				CVariant Result;
				Result["XID"] = Request["XID"];
				Result["ERR"] = Exception.GetError();
				Results.Append(Result);
			}
		}
	}

	if(m_pOperator)
		Results.Merge(m_pOperator->GetResponses());
	return Results;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:35,代码来源:KadOperation.cpp

示例4: LogReport

void CKadOperation::LogReport(UINT Flags, const wstring& ErrorMessage, const string& Error, const CVariant& Trace)
{
	wstring Operation = L"Kad Operation";
	if(m_pOperator)
	{
		CKadScript* pKadScript = m_pOperator->GetScript();
		ASSERT(pKadScript);

		Operation += L" (" + pKadScript->GetName() + L" v" + CKadScript::GetVersion(pKadScript->GetVersion()) + L")";
	}
	
	if(Trace.Count() > 0) // remote result
	{
		wstring Sender = CUInt128(Trace.At((uint32)0)).ToHex();
		if(!Error.empty())
			LogLine(LOG_DEBUG | Flags, L"%s recived an Error: %s from %s", Operation.c_str(), ErrorMessage.c_str(), Sender.c_str());
		else
			LogLine(LOG_DEBUG | Flags, L"%s recived a Report: %s from %s", Operation.c_str(), ErrorMessage.c_str(), Sender.c_str());
	}
	else
	{
		if(!Error.empty())
			LogLine(LOG_DEBUG | Flags, L"%s caused an Error: %s", Operation.c_str(), ErrorMessage.c_str());
		else
			LogLine(LOG_DEBUG | Flags, L"%s Reports: %s", Operation.c_str(), ErrorMessage.c_str());
	}
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:27,代码来源:KadOperation.cpp

示例5: CallLoadClBk

bool CKadOperator::CallLoadClBk(const CVariant& XID, const CVariant& Payloads)
{
	map<CVariant, uint32>::iterator I = m_LoadClBks.find(XID); 
	if(I == m_LoadClBks.end())
		return false;

	if(I->second == 0)
		return true;

	ASSERT(m_pJSScript); // WARNING: this is a week pointer
	if(!m_pJSScript)
		return false;
	CKadOperation* pOperation = GetParent<CKadOperation>();
	ASSERT(pOperation);

	CDebugScope Debug(m_pKadScript, pOperation);

	for(uint32 j=0; j < Payloads.Count(); j++)
	{
		const CVariant& Payload = Payloads[j];

		vector<CPointer<CObject> > Parameters;
		Parameters.push_back(pOperation); // lookup
		Parameters.push_back(new CVariantPrx(Payload["DATA"]));
		Parameters.push_back(new CVariantPrx(Payload["PATH"]));
		Parameters.push_back(new CVariantPrx(Payload["RELD"]));
		CPointer<CObject> Return;
		m_pJSScript->Callback(I->second, Parameters, Return, false, pOperation);
	}

	return true;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:32,代码来源:KadOperator.cpp

示例6: HandleHello

void CKadHandler::HandleHello(const CVariant& Hello, CKadNode* pNode, CComChannel* pChannel, bool bReq)
{
	if(GetParent<CKademlia>()->Cfg()->GetBool("DebugRT"))
		LogLine(LOG_DEBUG, L"Recived 'Hello %s' to %s", bReq ? L"Request" : L"Response", pNode->GetID().ToHex().c_str());

	SKadData* pData = pChannel->GetData<SKadData>();

	CVariant Addr = Hello["ADDR"];
	vector<CNodeAddress> AuthAddress;
	for(uint32 i=0; i < Addr.Count(); i++)
	{
		AuthAddress.push_back(CNodeAddress());
		AuthAddress.back().FromVariant(Addr.At(i));
	}

	// update node addresses
	for(vector<CNodeAddress>::iterator I = AuthAddress.begin(); I != AuthAddress.end(); I++)
	{
		if(pData->Authenticated)
			I->SetVerifyed();
		pNode->UpdateAddress(*I);
	}

	if(bReq)
		SendHello(pNode, pChannel, false);
		
	SetLastContact();
	pNode->UpdateClass(true, pChannel->GetAddress());
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:29,代码来源:KadHandler.cpp

示例7: Load

void CKadNode::Load(const CVariant& Node, bool bFull)
{
	m_Protocol = Node["PROT"];
	m_ID.SetValue(CUInt128(Node["NID"]));

	CVariant Addr = Node["ADDR"];
	for(uint32 i=0; i < Addr.Count(); i++)
	{
		CNodeAddress Address;
		if(bFull)
			Address.FromExtVariant(Addr.At(i));
		else
			Address.FromVariant(Addr.At(i));
		InsertAddress(Address);
	}

	if(bFull)
	{
		m_Version = Node["VER"].To<string>();
		m_uFirstSeen = Node["FSEN"];
		m_uLastSeen = Node["LSEN"];

		if(IsFading())
		{
			for(AddressMap::iterator I = m_AddressMap.begin(); I != m_AddressMap.end(); I++)
				I->second.SetClass(NODE_DEFAULT_CLASS);
			m_uLastSeen = GetTime();
		}
	}
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:30,代码来源:KadNode.cpp

示例8: AddLoadReq

void CLookupProxy::AddLoadReq(const CVariant& LoadReq)
{
	for(int i=0; i < LoadReq.Count(); i++)
	{
		const CVariant& Load = LoadReq.At(i);
		if(!m_LoadMap.insert(TLoadOpMap::value_type(Load["XID"], SLoadOp(Load["PATH"]))).second)
			continue;
	}
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:9,代码来源:KadOperation.cpp

示例9: AddStoreReq

void CLookupProxy::AddStoreReq(const CVariant& StoreReq) 
{
	for(int i=0; i < StoreReq.Count(); i++)
	{
		const CVariant& Store = StoreReq.At(i);
		if(!m_StoreMap.insert(TStoreOpMap::value_type(Store["XID"], SStoreOp(Store["PLD"]))).second)
			continue;
	}
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:9,代码来源:KadOperation.cpp

示例10: FlushCaches

void CLookupProxy::FlushCaches()
{
	if(m_pOperator)
	{
		CVariant Results = m_pOperator->GetResponses();
		if(Results.Count() > 0)
			GetParent<CKademlia>()->Handler()->SendExecuteRes(this, Results);
	}
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:9,代码来源:KadOperation.cpp

示例11: Execute

CVariant CKadScript::Execute(const CVariant& Requests, const CUInt128& TargetID, CReportLogger* pLogger)
{
	KeepAlive();

	m_pLogger = CPointer<CReportLogger>(pLogger, true); // this is a week pointer and it gets cleared when the caller exits

	CVariant Results(CVariant::EList);
	for(uint32 i=0; i < Requests.Count(); i++)
	{
		const CVariant& Request = Requests.At(i);
		Results.Append(Call(Request["FX"], Request["ARG"], TargetID, Request["XID"]));
	}
	return Results;
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:14,代码来源:KadScript.cpp

示例12: SendRequests

void CKadOperation::SendRequests(CKadNode* pNode, CComChannel* pChannel, SOpProgress* pProgress, bool bStateless)
{
	CKadHandler* pHandler = GetParent<CKademlia>()->Handler();

	CVariant Calls;
	if(m_pOperator)
	{
		const CKadOperator::TRequestMap& ResuestMap = m_pOperator->GetRequests();
		for(CKadOperator::TRequestMap::const_iterator I = ResuestMap.begin(); I != ResuestMap.end(); I++)
		{
			CKadRequest* pRequest = I->second.pRequest;
			if(pProgress->Calls.insert(TStatusMap::value_type(pRequest->GetXID(), SOpStatus())).second) // check if we already dealed this task
			{
				CVariant Call;
				Call["FX"] = pRequest->GetName();
				Call["ARG"] = pRequest->GetArguments();
				Call["XID"] = pRequest->GetXID();
				Calls.Append(Call);
			}
		}
	}
	else
	{
		for(TCallOpMap::const_iterator I = m_CallMap.begin(); I != m_CallMap.end(); I++)
		{
			CVariant Call = I->second.Call;
			if(pProgress->Calls.insert(TStatusMap::value_type(Call["XID"], SOpStatus())).second) // check if we already dealed this task
				Calls.Append(Call);
		}
	}
	if(Calls.Count() > 0)
		pHandler->SendExecuteReq(pNode, pChannel, this, Calls, bStateless);

	CVariant Stores;
	for(TStoreOpMap::const_iterator I = m_StoreMap.begin(); I != m_StoreMap.end(); I++)
	{
		if(pProgress->Stores.insert(TStatusMap::value_type(I->first, SOpStatus())).second) // check if we already dealed this task
		{
			CVariant Store;
			Store["XID"] = I->first;
			Store["PLD"] = I->second.Payload;
			Stores.Append(Store);
		}
	}
	if(Stores.Count() > 0)
		pHandler->SendStoreReq(pNode, pChannel, this, Stores, bStateless);
			
	CVariant Loads;
	for(TLoadOpMap::const_iterator I = m_LoadMap.begin(); I != m_LoadMap.end(); I++)
	{
		if(pProgress->Loads.insert(TStatusMap::value_type(I->first, SOpStatus())).second) // check if we already dealed this task
		{
			CVariant Load;
			Load["XID"] = I->first;
			Load["PATH"] = I->second.Path;
			Loads.Append(Load);
		}
	}
	if(Loads.Count() > 0)
		pHandler->SendLoadReq(pNode, pChannel, this, Loads, bStateless);
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:61,代码来源:KadOperation.cpp


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