Writing my own iostream utility class: Is this a good idea?

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-03-14T04:42:50Z Indexed on 2010/03/14 4:45 UTC
Read the original article Hit count: 265

Filed under:
|

I have an application that wants to read word by word, delimited by whitespace, from a file. I am using code along these lines:

std::istream in;
string word;
while (in.good()) {
    in>>word;
    // Processing, etc. 
    ...
}

My issue is that the processing on the words themselves is actually rather light. The major time consumer is a set of mySQL queries I run.

What I was thinking is writing a buffered class that reads something like a kilobyte from the file, initializes a stringstream as a buffer, and performs extraction from that transparently to avoid a great many IO operations.

Thoughts and advice?

© Stack Overflow or respective owner

Related posts about c++

Related posts about iostream