Solved

Serialization

Posted on 2003-11-03
3
256 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
Comment Utility
>>       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
Comment Utility
(Slaps head) Ahhh...much better.....Hhehehhehe. THanks for the sanity check.
0
 
LVL 16

Expert Comment

by:_nn_
Comment Utility
>> 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 122
Best tools for Backup and restore of Wordpress site 6 53
scoreUp challenge 14 47
Path of Workbook 3 42
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now