/[rdesktop]/sourceforge.net/trunk/seamlessrdp/ClientDLL/tokenizer.cpp
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /sourceforge.net/trunk/seamlessrdp/ClientDLL/tokenizer.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 933 - (show annotations)
Thu Jun 30 14:46:14 2005 UTC (18 years, 10 months ago) by astrand
File size: 1583 byte(s)
Fixed indentation, by running indent-all.

1 /////////////////////////////////////////////////////////////////////////////
2 // Tokenizer.cpp
3 //
4 // Date: Thursday, November 18, 1999
5 // Autor: Eduardo Velasquez
6 // Description: Tokenizer class for CStrings. Works like strtok().
7 ///////////////
8
9 //#include "atlstr.h"
10
11
12
13 #include "Tokenizer.h"
14
15 #ifdef _DEBUG
16 #define new DEBUG_NEW
17 #undef THIS_FILE
18 static char THIS_FILE[] = __FILE__;
19 #endif
20
21 CTokenizer::CTokenizer(const CStdString & cs,
22 const CStdString & csDelim):m_cs(cs), m_nCurPos(0)
23 {
24 SetDelimiters(csDelim);
25 }
26
27 void CTokenizer::SetDelimiters(const CStdString & csDelim)
28 {
29 for (int i = 0; i < csDelim.GetLength(); ++i)
30 m_delim.set(static_cast < BYTE > (csDelim[i]));
31 }
32
33 bool CTokenizer::Next(CStdString & cs)
34 {
35 cs.Empty();
36
37 while (m_nCurPos < m_cs.GetLength()
38 && m_delim[static_cast < BYTE > (m_cs[m_nCurPos])])
39 ++m_nCurPos;
40
41 if (m_nCurPos >= m_cs.GetLength())
42 return false;
43
44 int nStartPos = m_nCurPos;
45 while (m_nCurPos < m_cs.GetLength()
46 && !m_delim[static_cast < BYTE > (m_cs[m_nCurPos])])
47 ++m_nCurPos;
48
49 cs = m_cs.Mid(nStartPos, m_nCurPos - nStartPos);
50
51 return true;
52 }
53
54 CStdString CTokenizer::Tail() const const const
55 {
56 int nCurPos = m_nCurPos;
57
58 while (nCurPos < m_cs.GetLength()
59 && m_delim[static_cast < BYTE > (m_cs[nCurPos])])
60 ++nCurPos;
61
62 CStdString csResult;
63
64 if (nCurPos < m_cs.GetLength())
65 csResult = m_cs.Mid(nCurPos);
66
67 return csResult;
68 }

  ViewVC Help
Powered by ViewVC 1.1.26