本文整理汇总了C++中CStdStringArray::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdStringArray::resize方法的具体用法?C++ CStdStringArray::resize怎么用?C++ CStdStringArray::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdStringArray
的用法示例。
在下文中一共展示了CStdStringArray::resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool CASCIIManager::Convert_BinaryBuffer_2_CStrings(char *pBuf, ULONGLONG nBufLen, CStdStringArray &aRows)
{
int nI, nLen = 0, nCurr = 0;
int nBreakType = 0;
struct sIndType { UINT nPos; int nType; };
std::vector<sIndType> aBreaks;
int nBreaksAllocated = 0, nBreakCurr = 0;
sIndType *pBreaks = NULL;
CStdString strMess;
// 1 - Individuo i caratteri che spezzano le righe (e ci metto al loro posto NULL)
for (nI = 0; nI < nBufLen; nI++)
{
if ((nI < nBufLen - 1) && (pBuf[nI] == 13) && (pBuf[nI + 1] == 10)) // E' un return ? CR+LF (tipo Windows)
{
nBreakType = 1;
pBuf[nI] = 0;
pBuf[nI + 1] = 0;
}
else if (pBuf[nI + 1] == 10) // E' un return ? LF (tipo Unix)
{
nBreakType = 2;
pBuf[nI] = 0;
}
else if (pBuf[nI] == 13) // E' un return ? CR (tipo Macintosh)
{
nBreakType = 3;
pBuf[nI] = 0;
}
if (nBreakType) // Aggiungo il break
{
if (nBreakCurr >= nBreaksAllocated)
{
aBreaks.resize(nBreaksAllocated + 10000);
pBreaks = aBreaks.data();
nBreaksAllocated = (int)aBreaks.size();
ASSERT(nBreakCurr < nBreaksAllocated);
}
pBreaks[nBreakCurr].nPos = nI;
pBreaks[nBreakCurr].nType = nBreakType;
nBreakType = 0;
nBreakCurr++;
}
}
// 2 - Spezzo le varie stringhe
nCurr = 0;
aRows.resize(nBreakCurr);
for (nI = 0; nI < nBreakCurr; nI++)
{
nLen = pBreaks[nI].nPos - nCurr; // Lunghezza della stringa
if ((pBuf + nCurr + nLen)[0] == 0) // So dove deve stare il terminatore
{
CUV_UtilString::Convert_charVet2CString(pBuf + nCurr, strMess, nLen + 2);
aRows[nI] = strMess;
// Incremento per passare al prossimo pezzo
nCurr = pBreaks[nI].nPos;
if (pBreaks[nI].nType == 1)
nCurr += 2;
else if ((pBreaks[nI].nType == 2) || (pBreaks[nI].nType == 3))
nCurr += 1;
else
ASSERT(FALSE);
}
else
{
aRows.resize(nI);
ASSERT(FALSE);
return false;
}
}
return true;
}