Solved

Serialization

Posted on 2003-11-03
3
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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
Turn a spreadsheet into a vba executable. 2 103
bigDiff challenge 17 144
sum28 challenge 31 117
Adjust the codes 3 65
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

710 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