MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / WizStringArrayToText

Function WizStringArrayToText

src/share/WizMisc.cpp:1231–1280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1229
1230
1231void WizStringArrayToText(const CWizStdStringArray& arrayText, CString& strText, const CString& strSplitter)
1232{
1233 size_t nSplitterLen = 0;
1234 if (!strSplitter.isEmpty())
1235 {
1236 nSplitterLen = strSplitter.getLength();
1237 }
1238 //
1239 int nTextLen = 0;
1240 //
1241 int nLineCount = (int)arrayText.size();
1242 //
1243 for (int i = 0; i < nLineCount; i++)
1244 {
1245 nTextLen += arrayText[i].getLength();
1246 }
1247 //
1248 size_t nCharCount = nSplitterLen * nLineCount + nTextLen + 1024;
1249 //
1250 int nBufferSize = int(nCharCount * sizeof(unsigned short));
1251 //
1252 WizBufferAlloc ba(nBufferSize);
1253 unsigned short* pBuffer = (unsigned short *)ba.getBuffer();
1254 if (!pBuffer)
1255 return;
1256 //
1257 unsigned short* pBufferEnd = pBuffer + nCharCount;
1258 //
1259 unsigned short* p = pBuffer;
1260 //
1261 for (int i = 0; i < nLineCount; i++)
1262 {
1263 const CString& strLine = arrayText[i];
1264 //
1265 ATLASSERT(p < pBufferEnd);
1266 memcpy(p, strLine.utf16(), strLine.getLength() * sizeof(unsigned short));
1267 //
1268 p += strLine.getLength();
1269 //
1270 if (i < nLineCount - 1)
1271 {
1272 ATLASSERT(p < pBufferEnd);
1273 memcpy(p, strSplitter.utf16(), nSplitterLen * sizeof(unsigned short));
1274 //
1275 p += nSplitterLen;
1276 }
1277 }
1278 //
1279 strText = pBuffer;
1280}
1281
1282int WizFindInArray(const CWizStdStringArray& arrayText, const CString& strFind)
1283{

Callers 15

onClickedImageMethod · 0.85
WizToolsChinese2PinYinExFunction · 0.85
getFoldersMethod · 0.85
initDocumentExFieldsMethod · 0.85
getDocumentTagsTextMethod · 0.85
getDocumentsByGuidsMethod · 0.85
TagArrayToSQLFunction · 0.85
FileTypeArrayToSQLFunction · 0.85
TitleToSQLFunction · 0.85

Calls 4

isEmptyMethod · 0.80
getLengthMethod · 0.80
sizeMethod · 0.80
getBufferMethod · 0.80

Tested by

no test coverage detected