在此函数中,string
作为参数传递(将大量数据作为字符串)...
SendBytes 方法是这样定义的
bool NetOutputBuffer_c::SendBytes ( const void * pBuf, int iLen )
{
BYTE * pMy = (BYTE*)pBuf;
while ( iLen>0 && !m_bError )
{
int iLeft = m_iBufferSize - ( m_pBufferPtr-m_pBuffer );
if ( iLen<=iLeft )
{
printf("iLen is %d\n",iLen);
memcpy ( m_pBufferPtr, pMy, iLen );
m_pBufferPtr += iLen;
break;
}
ResizeIf ( iLen );
}
return !m_bError;
}
bool NetOutputBuffer_c::SendCompressedString ( std::string sStr )
{
std::cout << sStr << endl;
const char *cStr = sStr.c_str();
std::cout << cStr <<endl;
int iLen = cStr ? strlen(cStr) : 0;
SendInt ( iLen );
return SendBytes ( cStr, iLen );
}
尝试打印 sStr 的值以检查它是否具有正确的数据。
然后转换std::string
为const char *
转换后,尝试打印 cStr 的值。但它(cStr)实际上包含实际数据的 5%(sStr)......
为了获得整个数据,我需要做什么?
有人可以在这方面指导我吗?