I have an application in C++ VS2010.
I have a vector of integers
0=93823
1=987283
2=3183723
3=8892328
4=98382391
etc...
Is there a way to quickly serialize/deserialize this vector to a file in one rush (with the deserialization being cross platform) without having to write each value individually?
Thank you for the help.
Edit:
I am posting some code how I currently serialize and deserialize my vector. I feel that my way is highly inefficient.
void CCompiler::CompileVector(FILE *outfile)
{
int iSize = nMap.Content().size();
fwrite(&iSize,sizeof(int),1,outfile);
for (int i=0;i<nMap.Content().size();i++)
{
fwrite( &nMap.Content()[i], sizeof(int), 1, outfile);
}
}
void CBinLoader::LoadVector(clsMapping &uMapping)
{
int iSizeMap = 0;
fread(&iSizeMap,sizeof(int),1,m_infile);
for(int i = 0; i < iSizeMap; i++)
{
int iByteStart=0;
fread(&iByteStart,sizeof(int),1,m_infile);
uMapping.Add(iByteStart);
}
}
ps: In my class clsMapping there are some voids. However, "Content" simply is a vector .