|
//------------------------------------------------------------------------------
// FILE NAME: StringParser.h
//
// PURPOSE: Definition of the CStringParser class.
//
// DESCRIPTION: This class acepts a string and immediately parses it into
// separate fields based on the delimiter character specified by
// the programmer. The separated fields are stored in a
// CStringArray, and the 0th element in the array contains the
// original string. Access to the separated fields is 1-based
// (the first field is in index 1, and so on).
//
// REVISION LOG:
// DATE INIT REVISION COMMENT
// -------- ---- -------- ---------------------------------------------------
//
// CHANGE HISTORY:
// DATE INIT CHANGE DESCRIPTION
// -------- ---- -------------------------------------------------------------
// 07/15/00 jms New file
//------------------------------------------------------------------------------
#ifndef __STRINGPARSER_H
#define __STRINGPARSER_H
#include <afxcoll.h>
const int SP_NOTFOUND = -1;
class CStringParser: public CObject
{
private:
// data members
CStringArray m_aStrings;
int m_nCount;
char m_cDelimiter;
char m_cQuoter;
// methods
int ParseString();
int ParseStringWithQuoter();
public:
// data members
// ctor/dtor
CStringParser(CString sString, char cDelimiter);
CStringParser(CString sString, char cDelimiter, char cQuoter);
~CStringParser();
// methods
void Clear ();
CString GetField (int nIndex);
int GetCount () { return m_nCount; };
CString GetOriginalString () { return m_aStrings.GetAt(0); };
void ResetOriginalString(CString sString, char cDelimiter);
void ResetOriginalString(CString sString, char cDelimiter, char cQuoter);
CString FindExact (CString sText, int* nElement, BOOL bCaseSensitive=FALSE);
CString Find (CString sText, int* nElement, BOOL bCaseSensitive=FALSE);
};
#endif
|
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.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
I've been paid as a programmer since 1982 with experience in Pascal, and C++ (both self-taught), and began writing Windows programs in 1991 using Visual C++ and MFC. In the 2nd half of 2007, I started writing C# Windows Forms and ASP.Net applications, and have since done WPF, Silverlight, WCF, web services, and Windows services.
My weakest point is that my moments of clarity are too brief to hold a meaningful conversation that requires more than 30 seconds to complete. Thankfully, grunts of agreement are all that is required to conduct most discussions without committing to any particular belief system.