diff 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
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/StringTokenizer.cpp	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,44 @@
     1.4 +// StringTokenizer.cpp: implementation of the StringTokenizer class.
     1.5 +//
     1.6 +//////////////////////////////////////////////////////////////////////
     1.7 +
     1.8 +#include "stdafx.h"
     1.9 +#include "StringTokenizer.h"
    1.10 +
    1.11 +//////////////////////////////////////////////////////////////////////
    1.12 +// Construction/Destruction
    1.13 +//////////////////////////////////////////////////////////////////////
    1.14 +
    1.15 +StringTokenizer::StringTokenizer(CString str, CString del)
    1.16 +{
    1.17 +	m_right = str;
    1.18 +	m_delim = del;
    1.19 +}
    1.20 +
    1.21 +StringTokenizer::~StringTokenizer()
    1.22 +{}
    1.23 +
    1.24 +const char *StringTokenizer::next()
    1.25 +{
    1.26 +	int index = m_right.FindOneOf(m_delim);
    1.27 +
    1.28 +	while (index == 0)
    1.29 +	{
    1.30 +		m_right = m_right.Right(m_right.GetLength()-1);
    1.31 +		index   = m_right.FindOneOf(m_delim);
    1.32 +	}
    1.33 +	if (index == -1)
    1.34 +	{
    1.35 +		if (m_right.IsEmpty())
    1.36 +			return NULL;
    1.37 +		m_token = m_right;
    1.38 +		m_right.Empty();
    1.39 +		return m_token;
    1.40 +	}
    1.41 +
    1.42 +	m_token = m_right.Left(index);
    1.43 +	m_right = m_right.Right(m_right.GetLength()-(1+index));
    1.44 +
    1.45 +	return m_token;
    1.46 +}
    1.47 +