[antlr-interest] small CharInputBuffer class
Ruslan Zasukhin
sunshine at public.kherson.ua
Tue Oct 2 10:48:45 PDT 2001
Hi Ric,
I have look on CharBuffer class...
Yes it want to get istream as parameter, you suugest to use istringstream
class for RAM based string...
But istringstream want to get only std::string class.
But I have just char* or my own string class.
Conclusion: I do not want to use CharBuffer class :-)
This is my implementation of InputBuffer subclass.
Please look if I correctly work with EOF. It must be -1, yes ?
It seems to me, my class will work also faster, than with istream.
--------------------------------------------------------------
class OBL_InputBuffer : : public InputBuffer
{
public://///////////////////////////////////////////////////////////////////
OBL_InputBuffer( char* inStr, ulong inLength ) :
mStrPtr(inStr),
mEndPtr(inStr + inLength)
{
}
virtual int getChar( void )
{
// EOF is -1.
return (mStrPtr < mEndPtr) ? *mStrPtr++ : -1;
}
protected://////////////////////////////////////////////////////////////////
char* mStrPtr;
char* mEndPtr;
};
--
Best regards,
Ruslan Zasukhin
-------------------------
Paradigma.
e-mail: ruslan at paradigmasoft.com
web : http://www.paradigmasoft.com
To subscribe to the Valentina mail list
send a letter to valentina-on at lists.macserve.net
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list