Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Serialization

Posted on 2003-11-03
3
Medium Priority
?
309 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 1200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

722 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