<div class="gmail_quote">On Sun, Jul 3, 2011 at 7:19 PM, Robert Ramey <span dir="ltr">&lt;<a href="mailto:ramey@rrsd.com">ramey@rrsd.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Colin Caprani wrote:<br>
&gt; I hope you don&#39;t mind, but I&#39;ve a bit more information on this:<br>
<br>
</div>I&#39;m personally very familiar with MFC and it&#39;s implemenation of<br>
serialization. In fact, it was this system which inspired me to write the<br>
serialization library in the first case.  So here are a couple of<br>
observations.<br>
<br></blockquote><div><br>Robert,<br>
<br>
Firstly thank you for replying. Secondly, a bigger thanks for the library!<br><br></div></div>Since I am not an expert/professional programmer, I wasn&#39;t sure that I wasn&#39;t missing something obvious. Once I read your answer and accepted that for the CMyDoc class itself the serialize(Archive&amp; ar, const unsigned int version) function wasn&#39;t a runner I implemented separate boost_save and boost_load functions. However, contrary to what you mentioned, I had to overload the OnOpenDocument and OnSaveDocument, for example:<br>
<br>BOOL CMyDoc::OnOpenDocument(LPCTSTR lpszPathName)<br>{<br>    clear();<br>    <br>    // Call base class function with empty local Serialize function<br>    // to check file exists etc<br>    if (!CDocument::OnOpenDocument(lpszPathName))<br>
        return FALSE;<br><br>    std::string file( lpszPathName );<br>    boost_load(file);<br>    return TRUE;<br>}<br><br>This is necessary since the MFC CArchive owns the file until the MFC Serialize function exits, disallowing boost::serialization to access the file. Even calling ar.Abort() in the Serialize functions doesn&#39;t work because the CDocument base class assumes the ar exists on returning to the base class Serialize function.<br>
<br>I now have one small(ish) problem: I get a memory exception when I try to delete a pointer to an object created from a load operation in the clear() function. It fails at: _ASSERTE(pHead-&gt;nBlockUse == nBlockUse); I think it&#39;s because the serialization library allocates on a different heap to the local one. This this sound right? I know it&#39;s not great practice but I can probably live with this leak until I implement shared_ptr which should eliminate it - am I right about that?!<br>
<br>Thanks for all the help,<br><br>Colin<br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>

