So I have a database class that I want to handle all the writing to disk of the objects in my program. All the objects will have a customized serialize function that will write all the necessary information to disk, the saving function looks like this:
Code:
class Database
{
friend class boost::serialization::access;
void Save_to_Disk(std::string Filename, CObject Data)
{
std::ofstream ofs(Filename.c_str());
boost::archive::text_oarchive oa(ofs);
// write class instance to archive
oa << Data;
// archive and stream closed when destructors are called
}
private:
Object_Manager Menu_Objects;
};
Unfortunately this isn't working as described in the boost tutorials, I'm getting this error:
Code:
------ Build started: Project: TextGame, Configuration: Debug Win32 ------
Compiling...
Main.cpp
c:\program files\microsoft visual studio 8\vc\boost_1_34_0\boost\archive\detail\oserializer.hpp(566) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>'
with
[
x=false
]
c:\program files\microsoft visual studio 8\vc\boost_1_34_0\boost\archive\detail\common_oarchive.hpp(62) : see reference to function template instantiation 'void boost::archive::save<Archive,T>(Archive &,T &)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=CObject
]
c:\program files\microsoft visual studio 8\vc\boost_1_34_0\boost\archive\basic_text_oarchive.hpp(75) : see reference to function template instantiation 'void boost::archive::detail::common_oarchive<Archive>::save_override<T>(T &,int)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=CObject
]
c:\program files\microsoft visual studio 8\vc\boost_1_34_0\boost\archive\detail\interface_oarchive.hpp(79) : see reference to function template instantiation 'void boost::archive::basic_text_oarchive<Archive>::save_override<T>(T &,int)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=CObject
]
c:\documents and settings\home\my documents\visual studio 2005\projects\textgame\textgame\database.h(13) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<CObject>(T &)' being compiled
with
[
Archive=boost::archive::text_oarchive,
T=CObject
]
Build log was saved at "file://c:\Documents and Settings\Home\My Documents\Visual Studio 2005\Projects\TextGame\TextGame\Debug\BuildLog.htm"
TextGame - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
As far as I know ofs << Data is the line that actually saves the data to the file, but I might be doing something wrong, I'm not sure what...
Any suggestions?