/[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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

1 astrand 930 /////////////////////////////////////////////////////////////////////////////
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 astrand 933 CTokenizer::CTokenizer(const CStdString & cs,
22     const CStdString & csDelim):m_cs(cs), m_nCurPos(0)
23 astrand 930 {
24 astrand 933 SetDelimiters(csDelim);
25 astrand 930 }
26    
27 astrand 933 void CTokenizer::SetDelimiters(const CStdString & csDelim)
28 astrand 930 {
29 astrand 933 for (int i = 0; i < csDelim.GetLength(); ++i)
30     m_delim.set(static_cast < BYTE > (csDelim[i]));
31 astrand 930 }
32    
33 astrand 933 bool CTokenizer::Next(CStdString & cs)
34 astrand 930 {
35 astrand 933 cs.Empty();
36 astrand 930
37 astrand 933 while (m_nCurPos < m_cs.GetLength()
38     && m_delim[static_cast < BYTE > (m_cs[m_nCurPos])])
39     ++m_nCurPos;
40 astrand 930
41 astrand 933 if (m_nCurPos >= m_cs.GetLength())
42     return false;
43 astrand 930
44 astrand 933 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 astrand 930
49 astrand 933 cs = m_cs.Mid(nStartPos, m_nCurPos - nStartPos);
50    
51     return true;
52 astrand 930 }
53    
54 astrand 933 CStdString CTokenizer::Tail() const const const
55     {
56     int nCurPos = m_nCurPos;
57 astrand 930
58 astrand 933 while (nCurPos < m_cs.GetLength()
59     && m_delim[static_cast < BYTE > (m_cs[nCurPos])])
60     ++nCurPos;
61 astrand 930
62 astrand 933 CStdString csResult;
63 astrand 930
64 astrand 933 if (nCurPos < m_cs.GetLength())
65     csResult = m_cs.Mid(nCurPos);
66 astrand 930
67 astrand 933 return csResult;
68     }

  ViewVC Help
Powered by ViewVC 1.1.26