| re: how to check whether istringstream object has empty buffer?
On 7 May 2005 14:50:11 -0700, "mshngo" <mshong@gmail.com> wrote:
[color=blue]
>Hi,
>
>What would be the best way to check whether an istringstream object has
>empty buffer? I wanted to do something like:
>[/color]
Check out basic_ios::rdbuf (which returns a pointer to the stream's
buffer) and basic_streambuf::in_avail (which returns the number of
unread characters in a buffer). Usage looks like:
while (isStr.rdbuf()->in_avail()) {/* do stuff */}
[color=blue]
>istringstream isStr(myStringContent.c_str());
>while (isStr_BUFFER_IS_NOT_EMPTY) {
> //do something
>}
>
>I wanted to know how to implement isStr_BUFFER_IS_NOT_EMPTY. I did some
>research on the google but still couldn't find a direct answer. I very
>much appreciate your help.
>[/color]
I also recommend that you consider the approach Jonne Lehtinen
suggested. Depending on what you hope to accomplish, checking for
error after extraction may be more appropriate than checking for
available characters.
Kanenas |