annotate src/win32/StringTokenizer.cpp @ 5:8fe0c57e53d2

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