I have parsing code that allows you to enter escape sequences in a line of text:
my_parameter="A setting for the parameter\nthat contains \"escape sequence\" characters"
When I parse it, I process the backslash and add the corresponding character to the string that I create with the instance std::ostringstream. Line feeds, quotation marks, backslashes, etc. Everything is working fine. However, I pondered whether to allow the sequence \bor not, and looked to see if I could “deduce” the last character from mine ostringstream, how you could “disconnect” it from anyone std::istream. Can you do this? If the function does not exist, is there an easy way to move the recording position back one character and just write the next character to overwrite it?
This is not critical or something like that, but I was curious if anyone else had come across this before.
source
share