|
Boost Users : |
Subject: Re: [Boost-users] Serialization: storing different representations in different archive types
From: Robert Ramey (ramey_at_[hidden])
Date: 2008-09-13 17:14:34
use separate specialzations for different archive types:
// default method
template<class Archive>
void serialize(Archive & ar, mydatatype t, const unsigned version){
...
}
// special method for xml_oarchive
void serialize( xml_oarchive & ar, mydatatype t, const unsigned version){
...
}
Robert Ramey
Simon Fraser wrote:
> I have a program that saves program state in both binary and XML
> archives. I'd like to store one of the model objects in my program in
> different formats, depending on whether the output archive is XML or
> binary: for XML archives, I'd like to use a human readable-format, and
> for binary archives I'd like to use a much more compact
> representation.
> I don't see any methods on Archive that let me ask if the output is a
> textual format (text or XML). I could dynamic_cast in my load/save
> methods, but that doesn't extend to new kinds of archives that may be
> implemented in future.
>
> Is there a way to do what I want to do?
>
> Thanks
> Simon
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net