it's really too bad you're doing all this in c++, since that makes it probably 10 times more complicated than it would be in Java or Python.
to answer your question -- yes, you can "get by" using files. in fact, saving data to a file is the end result of a lot of serialization code to begin with (the other place it often occurs is when bits need to be sent over the wire from one process to another, where the two processes may not even be on the same computer).
as for using ifstream/ofstream -- I'm sure that you'll end up using that in order to actually write the bytes to a file. but before you do that, you still need to address the issue of serialization format -- that is, how you plan to represent the state of your tree into something that can be written onto a file and read back into memory from a file.
but here's a fairly simple serialization protocol for you to consider:
Code
string serialize() {
// takes this current treemap and writes it to a string formatted as such:
// "key1::value1, key2::value2, key3::value3 .... keyN::valueN"
}
void deserialize(string saveString) {
// reads a saveString formatted as such:
// "key1::value1, key2::value2, key3::value3 .... keyN::valueN"
// and populates this current treemap with the key-value pairs in the string
}
from there, you just need to figure out how to convert a string to bytes that can be written to a file, and the reverse of that, which ifstream/ofstream may be able to do for you.
This post was edited by irimi on Nov 9 2012 01:26pm