本文整理汇总了C++中CData::data方法的典型用法代码示例。如果您正苦于以下问题:C++ CData::data方法的具体用法?C++ CData::data怎么用?C++ CData::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CData
的用法示例。
在下文中一共展示了CData::data方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadScript
bool loadScript(CFile* f)
{
if( !f->isOpen() )
return false;
CData d;
d.fromFile(f);
d.write("\x0",1);
String s = d.data();
try{
object main_module((
handle<>(borrowed
(PyImport_AddModule("__main__")))));
object main_namespace =
main_module.attr("__dict__");
boost::algorithm::replace_all(s,"\r\n","\n");
handle<> ignored(PyRun_String(
s.c_str()
, Py_file_input
, main_namespace.ptr()
, main_namespace.ptr()
));
} catch(error_already_set)
{
PyErr_Print();
return false;
};
return true;
};
示例2: onLoginSignal
void CPCRCHelloState::onLoginSignal(CData &data)
{
CLog::instance()->log(CLog::msgLvlInfo,_("Sending login request to root server.\n"));
CData request;
request.wrt((ireon::net::commandId)ireon::net::rspcCodes::scHelloLogin);
request.append(data.data(), data.length());
m_ownerConnection->write(request);
}
示例3: onSendVersionSignal
void CPCRCHelloState::onSendVersionSignal(CData &data)
{
CData versionData;
char clientVersion[] = {PRODUCT_VERSION};
for (int i = 0; i < 4; i++)
versionData << clientVersion[i];
CLog::instance()->log(CLog::msgFlagNetwork, CLog::msgLvlInfo,_("Initiating version negotiation.\n"));
CData request;
request.wrt((ireon::net::commandId)ireon::net::rspcCodes::scCheckVersion);
request.write(versionData.data(), versionData.length());
m_ownerConnection->write(request);
};
示例4: processCommand
void CNetConnection::processCommand(ireon::net::commandId id, CData& data, netAddress fromAddress)
{
if (fromAddress.m_type == netAddress::atInternalAddress)
CLog::instance()->log(CLog::msgFlagNetwork,CLog::msgLvlDebug,_("Received internal packet. Id = %d.\n"),id);
else
CLog::instance()->log(CLog::msgFlagNetwork,CLog::msgLvlDebug,_("Received packet. Id = %d.\n"),id);
if( !processSignal(id, fromAddress, data) )
{
if (fromAddress.m_type == netAddress::atExternalAddress)
{
CData response;
response.wrt((ireon::net::commandId) ireon::net::rcCommandNotFound);
response << id;
write(response);
}
CLog::instance()->log(CLog::msgLvlError,_("Can't process packet. Contents:\n"));
CLog::instance()->dump(CLog::msgLvlError,data.data(),data.length());
}
return;
};