Click here to Skip to main content
15,891,431 members
Articles / Programming Languages / C++

Simple string parsing in nested loops

Rate me:
Please Sign up or sign in to vote.
4.71/5 (19 votes)
14 Dec 2004CPOL2 min read 108.5K   855   19  
Fast string parsing in nested loops.
// StrTok.h
//
//////////////////////////////////////////////////////////////////////

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CStrTok
{
public:
	CStrTok();
	virtual ~CStrTok();

	// Attributes
public:
	bool m_bDelimiterAsToken;
	bool m_bOneByOneDelimiter;
	bool m_bDelimitersInSequence;

	char* m_lpszNext;
	char m_chDelimiter;
	// Operations
public:
	char* GetFirst(char* lpsz, const char* lpcszDelimiters);
	char* GetNext(const char* lpcszDelimiters);
	void SetNext(const char* lpcszNext);
	bool IsEOB();
	void Break();
	void TrimLeft(char* &lpsz, const char* lpcszDelimiters = NULL);
	void TrimRight(const char* lpcszDelimiters = NULL);

	static bool IsDelimiter(char ch, const char* lpcszDelimiters);
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Egypt Egypt

Comments and Discussions