thomasmoelhave / tpie

Templated Portable I/O Environment
Other
112 stars 24 forks source link

peek_back #187

Open Mortal opened 9 years ago

Mortal commented 9 years ago

Right now, TPIE streams support forward read/can_read, forward peek/can_peek/skip, backward read_back/can_read_back.

In my application, I need peek/skip backwards, so I implement it using this workaround:

bool canPeek; T peekItem;
// initialization skip macro:
canPeek = fs.can_read_back();
if (canPeek) peekItem = fs.read_back();

while (canPeek && peekItem.useful()) {
    // Use peekItem ...
    // skip macro:
    canPeek = fs.can_read_back();
    if (canPeek) peekItem = fs.read_back();
}

I request this being possible in file_stream. (I'm not sure if it's a reasonable request -- it's been a while since I've meddled with its implementation.)

SSoelvsten commented 2 years ago

I have the very same workaround inside of my BDD library. Hence, I would be interested (if possible) that this 7 year old issue was looked at again.

I'm open to give it a shot myself.