📄 tokenizer.h
字号:
// Tokenizer.h: interface for the CTokenizer class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TOKENIZER_H__508A9DAF_C77F_4BA0_9077_96D3121D6319__INCLUDED_)
#define AFX_TOKENIZER_H__508A9DAF_C77F_4BA0_9077_96D3121D6319__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <math.h>
#if !defined(_BITSET_)
# include <bitset>
#endif // !defined(_BITSET_
class CTokenizer
{
public:
CTokenizer(const CString& cs, const CString& csDelim) : m_cs(cs), m_nCurPos(0)
{
SetDelimiters(csDelim);
}
void SetDelimiters(const CString& csDelim)
{
for(int i = 0; i < csDelim.GetLength(); ++i)
m_sDelimiter.set(static_cast<BYTE>(csDelim[i]));
}
BOOL Next(CString& cs)
{
cs.Empty();
while(m_nCurPos < m_cs.GetLength() && m_sDelimiter[static_cast<BYTE>(m_cs[m_nCurPos])])
++m_nCurPos;
if(m_nCurPos >= m_cs.GetLength())
return FALSE;
int nStartPos = m_nCurPos;
while(m_nCurPos < m_cs.GetLength() && !m_sDelimiter[static_cast<BYTE>(m_cs[m_nCurPos])])
++m_nCurPos;
cs = m_cs.Mid(nStartPos, m_nCurPos - nStartPos);
return TRUE;
}
CString Tail() const
{
int nCurPos = m_nCurPos;
while(nCurPos < m_cs.GetLength() && m_sDelimiter[static_cast<BYTE>(m_cs[nCurPos])])
++nCurPos;
CString csResult;
if(nCurPos < m_cs.GetLength())
csResult = m_cs.Mid(nCurPos);
return csResult;
}
private:
CString m_cs;
std::bitset<256> m_sDelimiter;
int m_nCurPos;
};
#endif // !defined(AFX_TOKENIZER_H__508A9DAF_C77F_4BA0_9077_96D3121D6319__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -