Hey so i just learned about the i/o part of the STL, more specifically fstream. Although I can now save binary info and classes i've made to the hard drive, i am not sure how to define how the info should be read.
I saw the answer for making a file format from [this][1] post:
Typically you would define a lot of records/structures, such as BITMAPINFOHEADER, and specify in what order they should come, how they should be nestled, and you might need to write a lot of indicies and look-up tables. Such files consists of a number of records (maybe nestled), look-up tables, magic words (indicating structure begin, structures end, etc.) and strings in a custom-defined format.
What i want to know specifcally is how to do this with the STL and C++... Since the format is meant simply for the use of a game i would think it would be much easier though. The format should:
- Be traversable (i can look through it and find the start of structure and maybe check it's name
- Be able to hold multiple classes and data in a single file
- have identifiable starts and ends to sections: such as the space in text files
- Maybe have it's own icon to represent it??
How do i do this in c++ ?
Answer
try using boost serialize! other than that what you are asking for is how to implement serialization and that's a real complicated thing! I've recently implemented an implementation for serialization and it's no easy case to talk about.
there is also another way to only save one class into file which contains all the information you need, which makes saving/loading classes much more simpler.
by the way icon is not anything related to file format it's something OS generates per file, and usually icons are stored somewhere between OS files. except for windows executable files(as far as I know). windows executable files are like a zipped folder, containing the actual binary operations, icon data for some various resolutions, and maybe some other data related to OS itself.
No comments:
Post a Comment