root/StrTok.cpp

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. CStrTok
  2. CStrTok
  3. Tokenize

/*
 * Copyright (C) 2002-2003 chik, s.hiranaka
 * For license terms, see the file COPYING in this directory.
 */

// StrTok.cpp: CStrTok クラスのインプリメンテーション
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "StrTok.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// 構築/消滅
//////////////////////////////////////////////////////////////////////

CStrTok::CStrTok()
{

}

CStrTok::~CStrTok()
{

}

CString CStrTok::Tokenize(char *in, char *delimiter)
{
        CString out;
        char *start;
        char *end;

        if(in != NULL) m_buf = in;
        start = m_buf.GetBuffer(0);

        end = strstr(start, delimiter);
        if(end == NULL)
        {
                out = start;
                m_buf = start+strlen(start);
                return out;
        }
        else *end ='\0';

        out = start;
        m_buf = end+1;
        return out;
}

/* [<][>][^][v][top][bottom][index][help] */