📄 parsecstring.cpp
字号:
// Parsecstring.cpp: implementation of the CParsecstring class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Parsecstring.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CParsecstring::CParsecstring(CString *strtoparse)
{
m_strtoparse = strtoparse;
m_strToken = ",";
m_iCurTKPos = 0;//Cur Token pos
m_iNextTKPos = 0;//next token pos
}
CParsecstring::~CParsecstring()
{
}
void CParsecstring::SetTocken(CString strToken)
{
m_strToken = strToken;
}
////////////////////////////////////////////////////////
//ret value:-1:get nothing,then the caller must reset this calss' instances
// 0:get ok
// 1:get the last substr
////////////////////////////////////////////////////////
int CParsecstring::GetNextStr(CString &strnext)
{
strnext = "";
while(strnext == "")
{
if(m_iNextTKPos == -1)
{
return -1;
}
m_iNextTKPos = m_strtoparse->Find(m_strToken,m_iCurTKPos+1);
if(m_iNextTKPos == -1)
{
if(m_iCurTKPos == 0)
{
strnext = m_strtoparse->Mid(m_iCurTKPos,m_strtoparse->GetLength() - m_iCurTKPos);
}
else
{
strnext = m_strtoparse->Mid(m_iCurTKPos+1,m_strtoparse->GetLength() - m_iCurTKPos-1);
}
strnext.TrimLeft();
strnext.TrimRight();
return 1;
}
else
{
if(m_iCurTKPos == 0)
{
strnext = m_strtoparse->Mid(m_iCurTKPos,m_iNextTKPos - m_iCurTKPos);
}
else
{
strnext = m_strtoparse->Mid(m_iCurTKPos+1,m_iNextTKPos - m_iCurTKPos-1);
}
m_iCurTKPos = m_iNextTKPos;
strnext.TrimLeft();
strnext.TrimRight();
}
}
return 0;
}
void CParsecstring::Reset()
{
m_iCurTKPos = 0;//Cur Token pos
m_iNextTKPos = 0;//next token pos
}
void CParsecstring::SetParsestr(CString *strtoparse)
{
m_strtoparse = strtoparse;
m_iCurTKPos = 0;//Cur Token pos
m_iNextTKPos = 0;//next token pos
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -