?? vb6functions.cpp
字號:
#include "stdafx.h"
#include "VB6functions.h"
namespace VB6
{
CString ReadUntil(CString &sIn,const CString &sDelim,bool &bFound);
CString Join(const std::vector<CString> &source,const CString sDelim)
{
CString sOut; long iC,Ubound;
Ubound = source.size()-1;
for(iC=0; iC<=Ubound-1; iC++)
sOut += source.at(iC) + sDelim;
sOut += source.at(iC);
return sOut;
}
// split sIn using the delimeter sDelim. Put result array into vector
std::vector<CString> Split(CString sIn,const CString sDelim,const long nLimit)
{
CString sRead; std::vector<CString> vecOut;
long nC = 0; bool bFound;
while(1)
{
nC++;
sRead = ReadUntil(sIn,sDelim,bFound);
if(!bFound)
break;
vecOut.push_back(sRead);
if(nLimit != -1 && nC >= nLimit)
return vecOut;
};
vecOut.push_back(sIn);
return vecOut;
}
CString ReadUntil(CString &sIn,const CString &sDelim,bool &bFound)
{
long nPos; CString sOut;
nPos = sIn.Find(sDelim);
if(nPos>-1)
{
sOut = sIn.Left(nPos);
sIn = sIn.Mid(nPos + sDelim.GetLength());
bFound = true;
}
else bFound = false;
return sOut;
}
// Replace sFind with sReplace
// nStart can be 0 - sIn.GetLength()-1 (char indexes start from 0 in VC, not 1 as in VB)
CString Replace(const CString sIn,const CString sFind, const CString sReplace,
const long nStart, const long nCount)
{
CString sOut; long nC=0,nPos;
sOut = sIn;
nPos = sOut.Find(sFind,nStart); //we miss vbCombare :(
if(nPos<0)
return sOut;
do {
nC++;
sOut = sOut.Left(nPos) + sReplace + sOut.Mid(nPos + sFind.GetLength());
if(nCount != -1 && nC >= nCount)
break;
nPos = sOut.Find(sFind,nStart);
} while(nPos>-1);
return sOut;
}
} // namespace
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -