Solved

Serialization

Posted on 2003-11-03
3
286 Views
Last Modified: 2013-11-20
Could someone tell me what is wrong with the following code. I am getting errors when I try to load prefs. Also...it doesn't look like they are writing correctly either.


m_profIRCProfile is a Pointer to a CUserProfile...

void CGoIRCApp::LoadPrefs(void)
{
      CFileStatus fs;
      if(CFile::GetStatus("userprefs.dat", fs))
      {
        CFile prefFile("userprefs.dat", CArchive::load);
            CArchive arLoad(&prefFile, CArchive::load);

            CUserProfile* ptrProf = (CUserProfile*) arLoad.ReadObject(RUNTIME_CLASS(CUserProfile));
            m_profIRCProfile = new CUserProfile(ptrProf);
      }
}

void CGoIRCApp::StorePrefs(void)
{
      CFile myFile("userprefs.dat", CFile::modeCreate | CFile::modeReadWrite);

      CArchive arStore(&myFile, CArchive::store);

      arStore.WriteObject(m_profIRCProfile);

      arStore.Close();
}

Serialize is not getting called at all. I have DECLARE_SERIAL in the .h and IMPLEMENT_SERIAL in the .cpp. What is going on?

0
Comment
Question by:SGyves
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
_nn_ earned 300 total points
ID: 9674688
>>       CFile prefFile("userprefs.dat", CArchive::load);

Why are you using CArchive::load here ? Shouldn't it be some CFile:: flag like CFile::modeRead ?
0
 

Author Comment

by:SGyves
ID: 9674734
(Slaps head) Ahhh...much better.....Hhehehhehe. THanks for the sanity check.
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9674749
>> Hhehehhehe. THanks for the sanity check.

Welcome :)

>> (Slaps head)

Have a break ;) Had to fight with many of those myself in the past, I know what it is ;)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Hibernate methods 2 83
bigDiff challenge 17 133
withoutTen challenge 14 137
c++  placing data into a form and an editbox 5 21
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question