Hi,
i am working with MICO and use boost::serialization (XML) for import/export of CORBA functions IN/OUT parameters, because i have an XML formatted configuration for the data to use for CORBA service invocations.
One of the problems was, that some of the MICO are template'd.
E.g. a data type holding a number of digits (e.g. telephone #no) is encoded in MICO as:
template
class BoundedSequenceTmpl {
...
}
... using basic <class T> = CORBA::Short for digits (e.g.).
1st i used ToString(...)/fromString(...) functions to be able to save&load such to/from boost archives. And this worked - though it had the little drawback, that i needed to use additional variables in load() & save() to handle it this way.
But then next it came up, that some other CORBA data types use the BoundedSequenceTempl<> as well, but for _more complex_ <class T> - e.g. BoundedSequenceTempl<> of BoundedSequenceTempl<>.
For that i created a version of serialize(), save() & load() like this:
template
void serialize(Archive & ar,
BoundedSequenceTmpl &p,
const unsigned int version)
{
split_free(ar, p, version);
}
template
void save(Archive & ar,
const BoundedSequenceTmpl &p,
const unsigned int version)
{
unsigned long length = p.length();
ar & make_nvp("length", length);
for (unsigned long i = 0; i < length; ++i) {
std::ostringstream name;
name << "item_" << i;
ar & make_nvp(name.str(), p[i]);
}
}
template
void load(Archive & ar,
BoundedSequenceTmpl &p,
const unsigned int version)
{
unsigned long length;
ar & make_nvp("length", length);
p.length(length);
for (unsigned long i = 0; i < length; ++i) {
std::ostringstream name;
name << "item_" << i;
ar & make_nvp(name.str(), p[i]);
}
}
then i thought i can get rid of the formerly used ToString(...)/FromString(...) helpers and replace them by overloaded versions of the new (more generic) load() & save() variants dedicated for this BoundedSequenceTempl<...>.
Like this:
#if 0
// This was intended to make obsolete MicoVector_to_string(...) &
// MicoVector_from_string(...)
// kind of "template specialization" for the ones above
// for BoundedSequenceTmpl<...> of types, which we don't want
// to be spread out any further
//
// But i couldn't make this work.
// Means: it compiles. But it implies another XML encoding level
// - which is not what i want
template
void serialize(Archive & ar,
BoundedSequenceTmpl &p,
const unsigned int version)
{
split_free(ar, p, version);
}
template
void save (Archive & ar,
const BoundedSequenceTmpl &p,
const unsigned int version)
{
std::ostringstream ostream;
for (unsigned long i=0; i
void load (Archive & ar,
BoundedSequenceTmpl &p,
const unsigned int version)
{
...
}
#endif
But that created me another level of encoding - which i don't want.
E.g. having a superior encoder:
template<class Archive>
void save(Archive & ar,
const DeleteHlrSubscriber_s &pInstance,
const unsigned int version)
{
std::string simsi;
std::string smsisdn;
MicoVector_to_string(pInstance.imsi, simsi);
MicoVector_to_string(pInstance.msisdn, smsisdn);
// ar & make_nvp("imsi", simsi); // replace by the next...
// this worked, but see above (the by "#if 0" disabled stuff)
ar & make_nvp("imsi", pInstance.imsi);
ar & make_nvp("msisdn", smsisdn);
ar & make_nvp( "attach_imsi", pInstance.attach_imsi);
}
using pInstance.imsi directly (which is a BoundedSequenceTmplCORBA::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