Writing my own iostream utility class: Is this a good idea?
- by Alex
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?