-
March 25th, 2022, 11:40 AM
#1
Table of contents when using ::Serialize()?
Is it possible to set up a table of contents when working with ::Serialize()?
For example, I have a savefile that contains 10.000 objects.
The savefile is rather large, and if possible, I would only like to load specific objects from it.
For example, I only want to load object #651 from the 10.000 objects in the file.
Is there some way of specifying the location of each object in a savefile, and instructing Serialize to move to that location, and load only that specific object?
-
March 25th, 2022, 12:30 PM
#2
Re: Table of contents when using ::Serialize()?
I have no idea what (global) ::Serialize() function you meant, however you may want to have a look at the An Introduction to Object Serialization in C++ and this microsoft topic: Serialization: Making a Serializable Class
Victor Nijegorodov
-
March 27th, 2022, 03:47 PM
#3
Re: Table of contents when using ::Serialize()?
My apologies, I probably didn't explain myself clearly.
Let's say that I have 1000 objects.
I want to store these objects in a savefile, using Serialize.
The code for this will roughly be:
Code:
void MyDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
for(int i = 0; i < 1000; i++)m_MyObject[i].Serialize(ar);
}
else
{
for(int i = 0; i < 1000; i++)m_MyObject[i].Serialize(ar);
}
}
However, in the case that I'm looking at, these savefiles can become huge.
They can be several GB.
Because of this, I was wondering if it was possible to load a specific object from a savefile?
So, let's say that I only want object target_nr = 365.
The code for this would roughly be:
Code:
void MyDoc::Serialize(CArchive& ar, const int & target_nr)
{
if (ar.IsStoring())
{
for(int i = 0; i < 1000; i++)m_MyObject[i].Serialize(ar);
}
else
{
ar.MoveToLocation(365);
m_MyObject[target_nr].Serialize(ar);
}
}
So, my question is, is it possible to instruct the CArchive to move to a specific location in the savefile, and only load a specific object?
-
March 28th, 2022, 09:32 AM
#4
Re: Table of contents when using ::Serialize()?
That's what databases are for
-
March 28th, 2022, 10:41 AM
#5
Re: Table of contents when using ::Serialize()?
I agree with GCDEF! Just use a database.
Victor Nijegorodov
-
April 9th, 2022, 02:57 PM
#6
Re: Table of contents when using ::Serialize()?
Database, should solve your issue.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|