From Cinder Asset to ifstream

For those interested, I had some minor issues actually getting saving/loading a vector<vector<float>> to and from a file on disk, but I eventually got that sorted. Here’s the complete code which should work:

void SaveFeaturesFile( std::vector<std::vector<float>> const& features, std::string filename )
{
	std::ofstream out( filename.c_str(), std::ios::binary );
	boost::archive::binary_oarchive oa( out );
	oa << features;
	out.close();
}

void LoadFeaturesFileFromFile( std::vector<std::vector<float>> &features, std::string filename )
{
	std::ifstream in( filename.c_str(), std::ios::binary );
	boost::archive::binary_iarchive ia( in );
	ia >> features;
	in.close();
}

Note, this is platform dependent due to the data being stored in binary!

I also came across this previous topic which elaborates a bit on how to create std::stringstream from a cinder buffer, but I’ve yet to grasp how to work things out for binary data.

Cheers,
Gazoo