NetlistTokenizer Class Reference

NetlistTokenizer is a simple string tokenizer, which usings C strtok () function from. More...

#include <NetlistParser.h>

List of all members.

Public Member Functions

 NetlistTokenizer (const char *fileName, const char *delim, const char *comments)
 Constructor.
const std::string nextToken ()
 returns the next token from the file
bool hasMoreTokens () const

Private Member Functions

bool isCommentBegin () const
char * getNextLine ()
 read next line from the file and return it as a C string
char * readNextToken ()
 read next token as a C string

Private Attributes

std::ifstream ifs
 correct way to use is to first check if hasMoreTokens and then call nextToken
const char * delim
 what characters mark end of a token
const char * comments
 string representing beginning of a line comment
char * linePtr
 current line read from the file
char * nextTokPtr
 ptr to next token
char * currTokPtr
 ptr to current token, returned on a call to nextToken ()

Detailed Description

NetlistTokenizer is a simple string tokenizer, which usings C strtok () function from.

cstring

Constructor & Destructor Documentation

NetlistTokenizer::NetlistTokenizer ( const char *  fileName,
const char *  delim,
const char *  comments 
) [inline]

Constructor.

Parameters:
fileName,: the file to read from
delim,: a string containing characters that mark end of a token
comments,: a string that contains beginning of a comment

Member Function Documentation

char* NetlistTokenizer::getNextLine (  )  [inline, private]

read next line from the file and return it as a C string

bool NetlistTokenizer::hasMoreTokens (  )  const [inline]
bool NetlistTokenizer::isCommentBegin (  )  const [inline, private]
Returns:
true if nextTokPtr starts with comment pattern
const std::string NetlistTokenizer::nextToken (  )  [inline]

returns the next token from the file

char* NetlistTokenizer::readNextToken (  )  [inline, private]

read next token as a C string


Member Data Documentation

const char* NetlistTokenizer::comments [private]

string representing beginning of a line comment

ptr to current token, returned on a call to nextToken ()

const char* NetlistTokenizer::delim [private]

what characters mark end of a token

std::ifstream NetlistTokenizer::ifs [private]

correct way to use is to first check if hasMoreTokens and then call nextToken

need to read one token ahead so because hasMoreTokens is called before nextToken

basic algorithm

initially currTokPtr = NULL, nextTokPtr = nextTokenInt

In nextToken return string at currTokPtr currTokPtr = nextTokPtr nextTokPtr = read next token

algorithm for reading next token read next token (with NULL) while next token is null or beginning of comment { read next line (break out the loop if file has ended) read first token } create a string and return

things to check for

  • end of file, reading error (in this case getNextLine() should return NULL)

initialization:

  • initially nextTokPtr should be NULL and this fine because reading nextTok with null should return null; file handle for input stream
char* NetlistTokenizer::linePtr [private]

current line read from the file

ptr to next token


The documentation for this class was generated from the following file:
Generated on Tue Aug 2 11:51:27 2011 for Galois by  doxygen 1.6.3