Click here to Skip to main content
15,912,329 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to Serialize this? Pin
Blake Miller17-Jun-04 4:00
Blake Miller17-Jun-04 4:00 
GeneralRe: How to Serialize this? Pin
Tcpip200517-Jun-04 5:09
Tcpip200517-Jun-04 5:09 
GeneralSetting Dialog Box position Pin
sschilachi17-Jun-04 2:12
sschilachi17-Jun-04 2:12 
GeneralRe: Setting Dialog Box position Pin
Antony M Kancidrowski17-Jun-04 2:19
Antony M Kancidrowski17-Jun-04 2:19 
GeneralWrite a simple program that can read/write files from/into a CD Pin
ledallam17-Jun-04 2:03
ledallam17-Jun-04 2:03 
GeneralRe: Write a simple program that can read/write files from/into a CD Pin
Henry miller17-Jun-04 3:10
Henry miller17-Jun-04 3:10 
GeneralCObject and CArchive again Pin
Anonymous17-Jun-04 1:53
Anonymous17-Jun-04 1:53 
GeneralRe: CObject and CArchive again Pin
Rodrigo Pinto Pereira de Souza17-Jun-04 2:20
Rodrigo Pinto Pereira de Souza17-Jun-04 2:20 
I suggest you to change the architecture of your class to :

This is corrected way to serialize a List Object.

I Write only the important parts to serialize a list.

//Header File .h
class CBook: public CObject
{
public:
DECLARE_SERIAL(CBook)
CBook();

// You must implement CopyConstructor and = operator.
CBook(const CBook& objSource);
CBook& operator=(const CBook& objSource);

virtual void Serialize(CArchive& ar); // Implement your serialization
public:
CString m_sName;
};

class CBookList: public CList<cbook, cbook&="">
{
public:
CBookList();
virtual ~CBookList();
}

template <> void AFXAPI SerializeElements <cprvfile>
(CArchive& ar, CPrvFile* pNewPrvFile, int nCount);

class CSubject : public CObject
{
public:
DECLARE_SERIAL(CSubject)
CSubject();
virtual void Serialize(CArchive& ar); // Implement your serialization
public:
CString m_sName;
CBookList m_BookList;
};


// Implementation File .cpp

// The Secret of Serialize List Elements !!!!
template <> void AFXAPI SerializeElements <cbook>
(CArchive& ar, CBook* pNewBook, int nCount)
{
for (int i = 0; i < nCount; i++, pNewBook++)
{
// Serialize each CBook object
pNewBook->Serialize(ar);
}
}


Enjoy it Cool | :cool:


Rodrigo Pinho Pereira de Souza
GeneralRe: CObject and CArchive again Pin
Anonymous17-Jun-04 2:54
Anonymous17-Jun-04 2:54 
GeneralRe: CObject and CArchive again Pin
Rodrigo Pinto Pereira de Souza17-Jun-04 7:46
Rodrigo Pinto Pereira de Souza17-Jun-04 7:46 
GeneralRe: CObject and CArchive again Pin
Antony M Kancidrowski17-Jun-04 2:24
Antony M Kancidrowski17-Jun-04 2:24 
GeneralRe: CObject and CArchive again Pin
Anonymous17-Jun-04 2:55
Anonymous17-Jun-04 2:55 
GeneralRe: CObject and CArchive again Pin
Rodrigo Pinto Pereira de Souza17-Jun-04 7:49
Rodrigo Pinto Pereira de Souza17-Jun-04 7:49 
GeneralUnsigned Char to char* Pin
Wender Oliveira17-Jun-04 1:46
Wender Oliveira17-Jun-04 1:46 
GeneralRe: Unsigned Char to char* Pin
Rodrigo Pinto Pereira de Souza17-Jun-04 2:03
Rodrigo Pinto Pereira de Souza17-Jun-04 2:03 
GeneralRe: Unsigned Char to char* Pin
toxcct17-Jun-04 4:21
toxcct17-Jun-04 4:21 
GeneralRe: Unsigned Char to char* Pin
Anonymous17-Jun-04 9:44
Anonymous17-Jun-04 9:44 
GeneralRe: Unsigned Char to char* Pin
John R. Shaw17-Jun-04 12:19
John R. Shaw17-Jun-04 12:19 
GeneralRe: Unsigned Char to char* Pin
John R. Shaw17-Jun-04 12:30
John R. Shaw17-Jun-04 12:30 
GeneralDifference between Structures and Classes Pin
Zeeshan Bilal17-Jun-04 1:32
Zeeshan Bilal17-Jun-04 1:32 
GeneralRe: Difference between Structures and Classes Pin
Trollslayer17-Jun-04 1:38
mentorTrollslayer17-Jun-04 1:38 
GeneralRe: Difference between Structures and Classes Pin
Zeeshan Bilal17-Jun-04 1:52
Zeeshan Bilal17-Jun-04 1:52 
GeneralRe: Difference between Structures and Classes Pin
Antony M Kancidrowski17-Jun-04 2:09
Antony M Kancidrowski17-Jun-04 2:09 
GeneralRe: Difference between Structures and Classes Pin
Zeeshan Bilal17-Jun-04 2:18
Zeeshan Bilal17-Jun-04 2:18 
GeneralRe: Difference between Structures and Classes Pin
Antony M Kancidrowski17-Jun-04 2:40
Antony M Kancidrowski17-Jun-04 2:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.