What's new

modifying istream using streambuf overloading?

Cyberman

Moderator
Moderator
This might be a bit on the odd side of things (scary enough it even has to do with emulation).
I would like to be able to open 'files' in an ISO image for reading, my problem is I prefer to do this using NORMAL C++ stream operators.

I've been reading this bit of information but it's a bit weak on the example side of things.
I prefer to examine more complete code or have a more detailed explanation of something that provided.
Mostly I want to use a stream buffer passed to an istream. that is streambuf created by a function copying the behaviour of fstream's open method.

Anyhow anyone here over load ye olde stream buff (ever?)

Cyb
 

smcd

Active member
I've done some very simple overloading the << in a class to be able to say std :: cout << myObject; but nothing as complex as trying to make the streams work on a file format. Where are you getting stuck?
 
OP
Cyberman

Cyberman

Moderator
Moderator
I've done some very simple overloading the << in a class to be able to say std :: cout << myObject; but nothing as complex as trying to make the streams work on a file format. Where are you getting stuck?
Well let me put things in perspective

Overloading various >> operators individually takes quite a bit of work. In fact repeating 30 or so operators is insane. Those operators work using a stream buffer for input why not over load the stream buffer object, using the same interface as all other C++ istream to it. You only then need to overload a couple virtual methods at least that's what it looks like. I think that is simpler and more portable.
That is why I just want to overload a stream buffer instead.
The operators then have no need to be overloaded (rewritten) and made buggy again (seriously), one can read formatted and raw data as much as one wants (it's going to be an istream only).
I got the idea from this article on overloading a stream buffer for ostream.

Now the reason for that is the overloaded ostream will be an object referencing a ISO image supporting both mode 1 and mode 2 (type 1 and 2). I'm working on the opendir, closedir etc methods on the iso object right now. By creating an iso_object that contains the image file and opening the file through the iso_object one can directly read data on the disk image as if one had mounted it.

The 'fun' part is that I may have to repeat the same process AGAIN. For example FF8 has a container file system in the playstation version. The game data is contained in a single image. Picking off individual file data is a pain because the sector sizes vary between mode 1 and mode 2. So you have your 2048 'data' sectors and your 2304 video sectors and your 2304 audio (which really only uses 2048 ... sigh). All mashed together in one big mess. Being able to read the ACTUAL data that's there is important so I need something that gracefully handles 'what kind of data are we' looking at sector by sector while deciphering the 'single file mass' design Square used for FF8's data.

That's kind of a simplification.

Cyb
 

Top