comparison src/win32/StringTokenizer.cpp @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
comparison
equal deleted inserted replaced
0:8ced16adf2e1 1:f9f4f1b99eed
1 // StringTokenizer.cpp: implementation of the StringTokenizer class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #include "stdafx.h"
6 #include "StringTokenizer.h"
7
8 //////////////////////////////////////////////////////////////////////
9 // Construction/Destruction
10 //////////////////////////////////////////////////////////////////////
11
12 StringTokenizer::StringTokenizer(CString str, CString del)
13 {
14 m_right = str;
15 m_delim = del;
16 }
17
18 StringTokenizer::~StringTokenizer()
19 {}
20
21 const char *StringTokenizer::next()
22 {
23 int index = m_right.FindOneOf(m_delim);
24
25 while (index == 0)
26 {
27 m_right = m_right.Right(m_right.GetLength()-1);
28 index = m_right.FindOneOf(m_delim);
29 }
30 if (index == -1)
31 {
32 if (m_right.IsEmpty())
33 return NULL;
34 m_token = m_right;
35 m_right.Empty();
36 return m_token;
37 }
38
39 m_token = m_right.Left(index);
40 m_right = m_right.Right(m_right.GetLength()-(1+index));
41
42 return m_token;
43 }
44