std::map and serialization

From: cks2k2 (cks2k2_at_discussions.microsoft.com)
Date: 12/23/04


Date: Wed, 22 Dec 2004 21:27:01 -0800

MFC n00b here, I'm trying to serialize a std::map obj into disk. I keep
getting compile errors with the code:

ar<<storeIt

in which ar is a CArchive obj and storeIt is the map obj's iterator (the
code above is inside a for loop that loops through the elements in the map).
My map is like this:
std::map<CString,CGPoint> with CGPoint being a class with 2 float members X
and Y. When I change my code to:

ar<<(*storeIt).first;
ar<<(*storeIt).second.X;
ar<<(*storeIt).second.Y;

it works. Is it because MFC can't serialize std::map objects directly to
file (1st code snippet) and requires each part of the map to be serialized
individually (2nd code snippet)?



Relevant Pages

  • Re: Problem with accessint to private fields :)
    ... I used it to serialize automaticaly generated objects. ... protected object obj; ... Type type = obj.GetType; ... FieldInfofia = type.GetFields( ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Efficient hashmap serialization?
    ... > objects in that map, grouped in a threaded message fashion. ... > I serialize this map to send it over RMI, ... or are you using a proper message abstraction type? ...
    (comp.lang.java.programmer)
  • Re: Referenced object versus copy of object
    ... Actually I had in mind a binary serialization: I would like to try both ... To copy an object completely you can serialize and deserialize it. ... reference to the object. ... Dim obj as Object = Activator.CreateInstance) ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Referenced object versus copy of object
    ... To copy an object completely you can serialize and deserialize it. ... Dim obj as Object = Activator.CreateInstance) ... When I say that obj = Me.Tag, then it only provides a reference to the ... object in the Tag property. ...
    (microsoft.public.dotnet.languages.vb)
  • Efficient hashmap serialization?
    ... I have a a hash map full of objects that contain references to other ... grouped in a threaded message fashion. ... linked list style previous messages and next message. ... I serialize this map to send it over RMI, ...
    (comp.lang.java.programmer)

Loading