|
Boost Users : |
From: Frank Bergemann (FBergemann_at_[hidden])
Date: 2007-03-22 15:23:38
Robert Ramey schrieb:
> What you want to do is to derive your own variation of xml_oarchive with
> special handling for this special type. Actually I'm amazed you've
> got this far trying to match an external format without doing this.
me too :-)
> Look in the document under Case Studies/deriving from an archive
> and the example demo_fast_archive which shows how to do this.
- thanks for the hint, i'll check this.
Up to now i could at least get rid of the separate ToString()
FromString() functions - temporary accepting the additional nesting level.
BTW:
Another way, which i tried to fix the originally reported problem, was
to public derive from class boost::serialization::nvp and using a
conversion constructor in the derived one for my data type:
// a sub-class to nvp, which has a conversion c'tor for my troublesome
// BoundedSequenceTmpl<CORBA::Short, TID, max>
class MyNVP : public boost::serialization::nvp<std::string>
{
public:
template <int TID, int max>
MyNVP(const char *name,
BoundedSequenceTmpl<CORBA::Short, TID, max> &p)
{
LOG_DEBUG("### enter conversion c'tor");
// try to make it work _somehow_
// - don't care about performance yet
std::string stringified;
std::ostringstream ostream;
for (unsigned long i=0; i<p.length(); ++i) {
ostream << p[i];
}
stringified = ostream.str();
boost::serialization::nvp<std::string>(name, stringified);
};
} ;
I thought the idea is ok - but the compiler disagreed
- i couldn't create an instance of MyNVP(?!)
Best regards!
Frank
> Robert Ramey
>
>
> Frank Bergemann wrote:
>> using pInstance.imsi directly (which is a
>> BoundedSequenceTmpl<CORBA::Short>()) resulted in:
>>
>> <imsi> // dropped boost::serializations internal XML attributes here
>> <hallo>SomeString</hallo>
>> </imsi>
>>
>> But I would like to have this one
>>
>> <imsi>SomeString</imsi>
>>
>> How can i do that?
>>
>> Thanks!
>>
>> Best regards!
>>
>> Frank
>>
>>
>>
>> _______________________________________________________________
>> SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
>> kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192
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