f



RE: [SPAM] - Re: [SPAM] - Re: Serialize wxList - Found word(s) list error in the Text body - Found word(s) list error in the subject

Hi Jorgen

your approach is modelled along the MFC serialization idea, the approach =
I mentioned is based on the XTI metadata provided for an object. So the =
streaming itself is not coded anymore, but the metadata for a new class =
is.

The streaming process now iterates over the attributes, processes =
callbacks that avoid streaming out undesired attributes (eg x and y in a =
sizer dialog), suppresses default values etc. This also means that the =
streaming in survives missing attributes, as long as they are either not =
mandatory params for ::Create or have a default value.

Best,

Stefan =20

> -----Original Message-----
> From: Jorgen Bodde [mailto:solidstl@xs4all.nl]=20
> Sent: Donnerstag, 15. September 2005 22:26
> To: wx-users@lists.wxwidgets.org
> Subject: [SPAM] - Re: [SPAM] - Re: Serialize wxList - Found=20
> word(s) list error in the Text body - Found word(s) list=20
> error in the subject
>=20
> Hi Stephan!
>=20
> Well streaming without a lot of hassle has my preference. My=20
> streaming is as compact as:
>=20
> if(a.IsStoring())
> {
>     a << m_name << m_age << m_number;
> }
> else
> {
>     a >> m_name >> m_age >> m_number;
> }
>=20
> I grew very accustomed to this way of serializing my objects,=20
> found wxDataOutputStream and unfortunately it did not have=20
> type safety, or a lot of possibilities ..
>=20
> See when I read the wrong order like;
>=20
>     a >> m_age >> m_number >> m_name;
>=20
> It logs an error on the first var, telling the developer a=20
> string is expected but an int is read. It will not read any=20
> more data, leaving all future read values deterministic. You=20
> can default them and check later.
>=20
> The only disadvantage of streams *was* that once a streamed=20
> data object is in the field, and you add members to the=20
> class, the old streams get incompatible with the new ones. I=20
> solved this by using this construction;
>=20
> a.EnterObject();
> if(a.IsStoring())
> {
>     a << m_name << m_age << m_number;
> }
> else
> {
>     a >> m_name >> m_age >> m_number;
> }
> a.LeaveObject();
>=20
> Now, when the class expands in the future but older data=20
> needs to be read back, it will still work. Even old programs=20
> can read newer streams.=20
> For example when I add a few member vars and suppose I am=20
> reading an old stream that does not have them:
>=20
> a.EnterObject();
> if(a.IsStoring())
> {
>     a << m_name << m_age << m_number;
>     // writing new data
>     a << m_alternateName;
> }
> else
> {
>     a >> m_name >> m_age >> m_number;
>     // reading new data
>     a >> m_alternateName;
> }
> a.LeaveObject();
>=20
> When in an old stream, the end marker comes first and I=20
> attempt to read the alternate name, it will simply not write=20
> the data in the m_alternateName string, but also give no=20
> error. At the next
> LeaveObject() the stream will sync again. This also works in=20
> the old program where the newly added member m_alternateName=20
> was not there, it will simply go find the end of the section=20
> and happily continue.
>=20
> Ok, it is not as elegant as using XML but I hate to use all=20
> those naming and heavy duty processing on very trivial=20
> objects. It is fairly extendable because you can still add or=20
> again remove data this way.
>=20
> I also added a version number in the stream, if you read back=20
> a stream which you expect to be e.g. 1000 and it is a stream=20
> that has version of 1002, it will log an error because the=20
> code does not support versions higher then you expect. Also,=20
> I added a header string that can be used as extra check which=20
> makes it even more reliable..
>=20
> hmm this concludes my shameless self-advertisment for now ;-)=20
> I wanted to explain why I chose to develop this, and why it=20
> differs from what is already around to store objects on disk.
>=20
> If the streaming method you mentioned can be this compact,=20
> and also robust for binary data, it's a bloody shame I=20
> already am that far (nearly done) ... :-)
>=20
> Regards,
> - Jorgen
>=20
> Stefan Csomor wrote:
>=20
> >Hi Jorgen
> >
> >a lot of the base would be available in the XTI sources,=20
> have a look at=20
> >the XML streamer classes
> >
> >Best,
> >
> >Stefan
> >
> > =20
> >
> >>-----Original Message-----
> >>From: Jorgen Bodde [mailto:solidstl@xs4all.nl]
> >>Sent: Donnerstag, 15. September 2005 21:30
> >>To: wx-users@lists.wxwidgets.org
> >>Subject: [SPAM] - Re: Serialize wxList - Found word(s) list=20
> error in=20
> >>the Text body
> >>
> >>Well the boost library adds another depency on my work. And=20
> this class=20
> >>I wrote before boost ever came with one. I am merely adapting it to=20
> >>wxWidgets.
> >>
> >>Anyway, if I cannot please anyone with it, at least I can please=20
> >>myself as I am using it for my own projects ;-)
> >>
> >>- Jorgen
> >>
> >>scott wrote:
> >>
> >>   =20
> >>
> >>>Jorgen Bodde wrote:
> >>>
> >>>     =20
> >>>
> >>>>There is wxDataOutputStream / wxDataInputStream.
> >>>>
> >>>>I am currently in the process making wxArchive which is a=20
> clone of=20
> >>>>MFC's CArchive. It has type safe serializing (error
> >>>>       =20
> >>>>
> >>checking on every
> >>   =20
> >>
> >>>>read, version and header check, etc)..
> >>>>
> >>>>The streams mentioned above are pretty basic in their
> >>>>       =20
> >>>>
> >>behaviour and
> >>   =20
> >>
> >>>>do not provide anything more but serializing int8, int16, 32, 64,=20
> >>>>double and string. I am planning to also provide
> >>>>       =20
> >>>>
> >>serializing wxWindow
> >>   =20
> >>
> >>>>dervied classes, and implement methods to serialize the
> >>>>       =20
> >>>>
> >>size of the
> >>   =20
> >>
> >>>>dialog to and back an archive, etc.
> >>>>
> >>>>So, when you're patient, I can send you the source when
> >>>>       =20
> >>>>
> >>it's done. If
> >>   =20
> >>
> >>>>not, the streams above are also a solution..
> >>>>
> >>>>- Jorgen
> >>>>
> >>>>Daniel R=F6nnqvist wrote:
> >>>>
> >>>>       =20
> >>>>
> >>>>>Hello.
> >>>>>
> >>>>>I'm wondering if anyone know if there's a built in way to
> >>>>>         =20
> >>>>>
> >>serialize
> >>   =20
> >>
> >>>>>wxLists so that I can save and load them binary as a
> >>>>>         =20
> >>>>>
> >>file. If not,
> >>   =20
> >>
> >>>>>is there an implementation of this anywhere I can use as a guide?
> >>>>>I'm trying to achieve a general way of doing this so I
> >>>>>         =20
> >>>>>
> >>don't have to
> >>   =20
> >>
> >>>>>create a serialize class for each type of list I have=20
> implemented.
> >>>>>Maybe I can do this with the RTTI system?
> >>>>>
> >>>>>Any information would be greatly appreciated.
> >>>>>
> >>>>>/ Daniel R=F6nnqvist
> >>>>>
> >>>>>
> >>>>>         =20
> >>>>>
> >>--------------------------------------------------------------------
> >>   =20
> >>
> >>>>>- To unsubscribe, e-mail:=20
> wx-users-unsubscribe@lists.wxwidgets.org
> >>>>>For additional commands, e-mail:=20
> wx-users-help@lists.wxwidgets.org
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>         =20
> >>>>>
> >>>I doubt anyone wants to go to the trouble of duplicating
> >>>     =20
> >>>
> >>it, but the
> >>   =20
> >>
> >>>Boost serialization library is one of the best I've run across. It=20
> >>>works with standard containers such as std::vector and=20
> std::list. I=20
> >>>tried the CArchive class years ago but found it was lacking
> >>>     =20
> >>>
> >>too much
> >>   =20
> >>
> >>>to be truly useful. Since then, I've created my own storage
> >>>     =20
> >>>
> >>formats as
> >>   =20
> >>
> >>>needed or used the Boost library.
> >>>
> >>>Scott
> >>>
> >>>
> >>>
> >>>     =20
> >>>
> >>------------------------------------------------------------
> ---------
> >>   =20
> >>
> >>>To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
> >>>For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
> >>>
> >>>
> >>>
> >>>
> >>>     =20
> >>>
> >>------------------------------------------------------------
> ---------
> >>To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
> >>For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
> >>
> >>
> >>   =20
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
> >For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
> >
> >
> >
> >
> >
> > =20
> >
>=20
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
>=20
>=20

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wx-users-help@lists.wxwidgets.org

0
csomor
9/16/2005 4:41:05 AM
comp.soft-sys.wxwindows 21076 articles. 0 followers. Post Follow

1 Replies
1283 Views

Similar Articles

[PageSpeed] 39

Sounds interesting Stephan, I will take a look at it..

Well mine is not modelled around CArchive, the only thing that is the 
same are the method names to make it easier for people to port their MFC 
serializing to wxWidgets ..

Maybe it is time to introduce serializing as more present in the help ? 
I have not found a clear 'serializer' class, someone pointed out 
wxDataOutputStream which was too slim in my case ...

- Jorgen

Stefan Csomor wrote:

>Hi Jorgen
>
>your approach is modelled along the MFC serialization idea, the approach I mentioned is based on the XTI metadata provided for an object. So the streaming itself is not coded anymore, but the metadata for a new class is.
>
>The streaming process now iterates over the attributes, processes callbacks that avoid streaming out undesired attributes (eg x and y in a sizer dialog), suppresses default values etc. This also means that the streaming in survives missing attributes, as long as they are either not mandatory params for ::Create or have a default value.
>
>Best,
>
>Stefan  
>
>  
>
>>-----Original Message-----
>>From: Jorgen Bodde [mailto:solidstl@xs4all.nl] 
>>Sent: Donnerstag, 15. September 2005 22:26
>>To: wx-users@lists.wxwidgets.org
>>Subject: [SPAM] - Re: [SPAM] - Re: Serialize wxList - Found 
>>word(s) list error in the Text body - Found word(s) list 
>>error in the subject
>>
>>Hi Stephan!
>>
>>Well streaming without a lot of hassle has my preference. My 
>>streaming is as compact as:
>>
>>if(a.IsStoring())
>>{
>>    a << m_name << m_age << m_number;
>>}
>>else
>>{
>>    a >> m_name >> m_age >> m_number;
>>}
>>
>>I grew very accustomed to this way of serializing my objects, 
>>found wxDataOutputStream and unfortunately it did not have 
>>type safety, or a lot of possibilities ..
>>
>>See when I read the wrong order like;
>>
>>    a >> m_age >> m_number >> m_name;
>>
>>It logs an error on the first var, telling the developer a 
>>string is expected but an int is read. It will not read any 
>>more data, leaving all future read values deterministic. You 
>>can default them and check later.
>>
>>The only disadvantage of streams *was* that once a streamed 
>>data object is in the field, and you add members to the 
>>class, the old streams get incompatible with the new ones. I 
>>solved this by using this construction;
>>
>>a.EnterObject();
>>if(a.IsStoring())
>>{
>>    a << m_name << m_age << m_number;
>>}
>>else
>>{
>>    a >> m_name >> m_age >> m_number;
>>}
>>a.LeaveObject();
>>
>>Now, when the class expands in the future but older data 
>>needs to be read back, it will still work. Even old programs 
>>can read newer streams. 
>>For example when I add a few member vars and suppose I am 
>>reading an old stream that does not have them:
>>
>>a.EnterObject();
>>if(a.IsStoring())
>>{
>>    a << m_name << m_age << m_number;
>>    // writing new data
>>    a << m_alternateName;
>>}
>>else
>>{
>>    a >> m_name >> m_age >> m_number;
>>    // reading new data
>>    a >> m_alternateName;
>>}
>>a.LeaveObject();
>>
>>When in an old stream, the end marker comes first and I 
>>attempt to read the alternate name, it will simply not write 
>>the data in the m_alternateName string, but also give no 
>>error. At the next
>>LeaveObject() the stream will sync again. This also works in 
>>the old program where the newly added member m_alternateName 
>>was not there, it will simply go find the end of the section 
>>and happily continue.
>>
>>Ok, it is not as elegant as using XML but I hate to use all 
>>those naming and heavy duty processing on very trivial 
>>objects. It is fairly extendable because you can still add or 
>>again remove data this way.
>>
>>I also added a version number in the stream, if you read back 
>>a stream which you expect to be e.g. 1000 and it is a stream 
>>that has version of 1002, it will log an error because the 
>>code does not support versions higher then you expect. Also, 
>>I added a header string that can be used as extra check which 
>>makes it even more reliable..
>>
>>hmm this concludes my shameless self-advertisment for now ;-) 
>>I wanted to explain why I chose to develop this, and why it 
>>differs from what is already around to store objects on disk.
>>
>>If the streaming method you mentioned can be this compact, 
>>and also robust for binary data, it's a bloody shame I 
>>already am that far (nearly done) ... :-)
>>
>>Regards,
>>- Jorgen
>>
>>Stefan Csomor wrote:
>>
>>    
>>
>>>Hi Jorgen
>>>
>>>a lot of the base would be available in the XTI sources, 
>>>      
>>>
>>have a look at 
>>    
>>
>>>the XML streamer classes
>>>
>>>Best,
>>>
>>>Stefan
>>>
>>> 
>>>
>>>      
>>>
>>>>-----Original Message-----
>>>>From: Jorgen Bodde [mailto:solidstl@xs4all.nl]
>>>>Sent: Donnerstag, 15. September 2005 21:30
>>>>To: wx-users@lists.wxwidgets.org
>>>>Subject: [SPAM] - Re: Serialize wxList - Found word(s) list 
>>>>        
>>>>
>>error in 
>>    
>>
>>>>the Text body
>>>>
>>>>Well the boost library adds another depency on my work. And 
>>>>        
>>>>
>>this class 
>>    
>>
>>>>I wrote before boost ever came with one. I am merely adapting it to 
>>>>wxWidgets.
>>>>
>>>>Anyway, if I cannot please anyone with it, at least I can please 
>>>>myself as I am using it for my own projects ;-)
>>>>
>>>>- Jorgen
>>>>
>>>>scott wrote:
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>>>Jorgen Bodde wrote:
>>>>>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>>>There is wxDataOutputStream / wxDataInputStream.
>>>>>>
>>>>>>I am currently in the process making wxArchive which is a 
>>>>>>            
>>>>>>
>>clone of 
>>    
>>
>>>>>>MFC's CArchive. It has type safe serializing (error
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>checking on every
>>>>   
>>>>
>>>>        
>>>>
>>>>>>read, version and header check, etc)..
>>>>>>
>>>>>>The streams mentioned above are pretty basic in their
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>behaviour and
>>>>   
>>>>
>>>>        
>>>>
>>>>>>do not provide anything more but serializing int8, int16, 32, 64, 
>>>>>>double and string. I am planning to also provide
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>serializing wxWindow
>>>>   
>>>>
>>>>        
>>>>
>>>>>>dervied classes, and implement methods to serialize the
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>size of the
>>>>   
>>>>
>>>>        
>>>>
>>>>>>dialog to and back an archive, etc.
>>>>>>
>>>>>>So, when you're patient, I can send you the source when
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>it's done. If
>>>>   
>>>>
>>>>        
>>>>
>>>>>>not, the streams above are also a solution..
>>>>>>
>>>>>>- Jorgen
>>>>>>
>>>>>>Daniel R�nnqvist wrote:
>>>>>>
>>>>>>       
>>>>>>
>>>>>>            
>>>>>>
>>>>>>>Hello.
>>>>>>>
>>>>>>>I'm wondering if anyone know if there's a built in way to
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>serialize
>>>>   
>>>>
>>>>        
>>>>
>>>>>>>wxLists so that I can save and load them binary as a
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>file. If not,
>>>>   
>>>>
>>>>        
>>>>
>>>>>>>is there an implementation of this anywhere I can use as a guide?
>>>>>>>I'm trying to achieve a general way of doing this so I
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>don't have to
>>>>   
>>>>
>>>>        
>>>>
>>>>>>>create a serialize class for each type of list I have 
>>>>>>>              
>>>>>>>
>>implemented.
>>    
>>
>>>>>>>Maybe I can do this with the RTTI system?
>>>>>>>
>>>>>>>Any information would be greatly appreciated.
>>>>>>>
>>>>>>>/ Daniel R�nnqvist
>>>>>>>
>>>>>>>
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>--------------------------------------------------------------------
>>>>   
>>>>
>>>>        
>>>>
>>>>>>>- To unsubscribe, e-mail: 
>>>>>>>              
>>>>>>>
>>wx-users-unsubscribe@lists.wxwidgets.org
>>    
>>
>>>>>>>For additional commands, e-mail: 
>>>>>>>              
>>>>>>>
>>wx-users-help@lists.wxwidgets.org
>>    
>>
>>>>>>>
>>>>>>>
>>>>>>>         
>>>>>>>
>>>>>>>              
>>>>>>>
>>>>>I doubt anyone wants to go to the trouble of duplicating
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>it, but the
>>>>   
>>>>
>>>>        
>>>>
>>>>>Boost serialization library is one of the best I've run across. It 
>>>>>works with standard containers such as std::vector and 
>>>>>          
>>>>>
>>std::list. I 
>>    
>>
>>>>>tried the CArchive class years ago but found it was lacking
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>too much
>>>>   
>>>>
>>>>        
>>>>
>>>>>to be truly useful. Since then, I've created my own storage
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>formats as
>>>>   
>>>>
>>>>        
>>>>
>>>>>needed or used the Boost library.
>>>>>
>>>>>Scott
>>>>>
>>>>>
>>>>>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>------------------------------------------------------------
>>>>        
>>>>
>>---------
>>    
>>
>>>>   
>>>>
>>>>        
>>>>
>>>>>To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
>>>>>For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>>------------------------------------------------------------
>>>>        
>>>>
>>---------
>>    
>>
>>>>To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
>>>>For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
>>>>
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
>>>For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
>>>
>>>
>>>
>>>
>>>
>>> 
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
>>For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
>For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
>
>
>
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wx-users-help@lists.wxwidgets.org

0
solidstl
9/16/2005 5:54:41 AM
Reply: