本文整理汇总了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();
}
}
}
示例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;
}
}
示例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());
}
}
示例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());
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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;
}