When I try to use hexify multiple time, it seems to hexify the input twice. I believe I need to clear stringstream everytime when I use it. But how? Can anyone help me?
int main() { string s = "My error message\n My error message\n My error message\n My error message"; stringstream ss; cout << for_each(s.begin(), s.end(), hexify<char>(ss)) << endl; cout << for_each(s.begin(), s.end(), hexify<char>(ss)) << endl; // Or, as in your case: // // log4cpp::Category::getRoot() << log4cpp::Priority::DEBUG << for_each(s.begin(), s.end(), hexify<char>(ss)) << endl; return 0;}
Is it right ss(out) like calling fopen? However stringstream::str() really adjust what in the pipeline, in this case, it is string stream. Is this the right way to look at it. That is why you can initialize, before clean up the pipeline.
jkr
Sorry, but either me or you got a bit confused here.. how would 'fopen()' enter the stage?
How can we initialize ss with out like hexify(stringstream& out) : ss(out), .....
And then clear the string. How can that work>