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


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

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


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

示例1: 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

示例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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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


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