Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_Parser Class Reference

CP_Parser. More...

List of all members.

Public Member Functions

 CP_Parser (bool inStripQuotes=false)
 CP_Parser (const CP_String &inData, const CP_String &inSeperator=",", bool inStripQuotes=false)
 CP_Parser (const CP_FileSystemSpec &inFile, const CP_String &inSeperator=",", bool inStripQuotes=false)
virtual ~CP_Parser ()
CP_String GetSeperator ()
void SetSeperator (const CP_String &inSeperator)
bool Parse ()
bool Parse (const CP_String &inData, const CP_String &inSeperator=",", bool inStripQuotes=false)
bool ParseFile (const CP_FileSystemSpec &inFileSpec, const CP_String &inSeperator=",")
UInt32 GetCount ()
bool GetFieldData (UInt32 inFieldIndex, CP_String &inFieldData)
bool GetFieldData (UInt32 inFieldIndex, char *inBuffer, SInt32 inMaxBufferLength, SInt32 *inOutActualDataLength)
CP_ParsedFieldGetField (UInt32 inFieldIndex)
void Reset ()

Protected Member Functions

bool IsSeperator (char inchar)
bool LoadFile (const CP_FileSystemSpec &inFileSpec)

Protected Attributes

CP_ParsedField_Array fFields
bool fStripQuotes
CP_String fSeperator
CP_String fData


Detailed Description

A class to parse simple data into seperate fields. For example: this class can be used to seperate comma or tab deleted file data, string data that is seperated by commas, or formatted dates, etc.


Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_Parser::CP_Parser bool  inStripQuotes = false  ) 
 

Constructor.

Parameters:
inStripQuotes - flag to indicate how quotes will be handled. If true they are removed from the parsed data.

CP_Parser::CP_Parser const CP_String inData,
const CP_String inSeperator = ",",
bool  inStripQuotes = false
 

Constructor.

Parameters:
inData - the data to be parsed.
inSeperator - list of valid seperators for the data.
inStripQuotes - flag to indicate how quotes will be handled. If true they are removed from the parsed data.

CP_Parser::CP_Parser const CP_FileSystemSpec inFile,
const CP_String inSeperator = ",",
bool  inStripQuotes = false
 

Constructor.

Parameters:
inFileSpec - a CP_FileSystemSpec for the file to be parsed.
inSeperator - list of valid seperators for the data.
inStripQuotes - flag to indicate how quotes will be handled. If true they are removed from the parsed data.

CP_Parser::~CP_Parser  )  [virtual]
 

Destructor.


Member Function Documentation

CP_String CP_Parser::GetSeperator  ) 
 

Return a CP_String containing the list of seperators that can be used with the data string for this class.

void CP_Parser::SetSeperator const CP_String inSeperator  ) 
 

Sets the seperators that can be recognized between field data.

bool CP_Parser::Parse  ) 
 

Parse the data contained in the data field. This will construct a list of CP_ParsedField object for every field seperated by a valid seperator that is contained in the fSeperator string data. Returns true if we were able to parse the string.

bool CP_Parser::Parse const CP_String inData,
const CP_String inSeperator = ",",
bool  inStripQuotes = false
 

Parse the data contained in the data field. This will construct a list of CP_ParsedField object for every field seperated by a valid seperator that is contained in the inSeperator string data. Returns true if we were able to parse the string.

Parameters:
inData - the data to be parsed.
inSeperator - the valid seperators for this data.
inStripQuotes - if true, then any quotes in the data will be removed.

bool CP_Parser::ParseFile const CP_FileSystemSpec inFileSpec,
const CP_String inSeperator = ","
 

Parse the data contained in the inFileSpec file. This will construct a list of CP_ParsedField object for every field seperated by a valid seperator that is contained in the file. Returns true if we were able to parse the string.

Parameters:
inFileSpec - a CP_FileSystemSpec for the file to be parsed.
inSeperator - the valid seperators for this data.

UInt32 CP_Parser::GetCount  ) 
 

Return the number of fields found.

bool CP_Parser::GetFieldData UInt32  inFieldIndex,
CP_String inFieldData
 

Returns a fields data at inFieldIndex in the passed in CP_String. Returns true if that field exists.

Parameters:
inFieldIndex - index of the field to return.
inFieldData - a CP_String where the result will be placed.

bool CP_Parser::GetFieldData UInt32  inFieldIndex,
char *  inBuffer,
SInt32  inMaxBufferLength,
SInt32 inOutActualDataLength
 

Return the fields data into the passed in buffer. Returns true if the buffer has valid data.

Parameters:
inFieldIndex - index of the field to retrieve.
inBuffer - char * where the results will be placed.
inMaxBufferLength - the maximum length of the buffered data.
inOutActualDataLength - the returned actual length of the data.

CP_ParsedField * CP_Parser::GetField UInt32  inFieldIndex  ) 
 

Return the CP_ParsedField * at inFieldIndex.

Parameters:
inFieldIndex - the index of the field we are looking for.

void CP_Parser::Reset  ) 
 

Delete any previously parsed CP_ParsedField object.

bool CP_Parser::IsSeperator char  inchar  )  [protected]
 

Return true if the passed in char is a valid seperator.

Parameters:
inchar - the char we are checking.

bool CP_Parser::LoadFile const CP_FileSystemSpec inFileSpec  )  [protected]
 

Load the field to be parsed contained in inFileSpec. Returns true if the file was able to be loaded.

Parameters:
inFileSpec - contains a CP_FileSystemSpec to the file we want to load.


Member Data Documentation

CP_ParsedField_Array CP_Parser::fFields [protected]
 

List of the fields found.

bool CP_Parser::fStripQuotes [protected]
 

Flag to indicate how quotes are handled.

CP_String CP_Parser::fSeperator [protected]
 

A CP_String containing all of the valid seperators for the data to be parsed.

CP_String CP_Parser::fData [protected]
 

A CP_String containing the data to parse.


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:01:55 2005 for CPLAT by  doxygen 1.4.0