Re: [Boost-users] [serialization] Wrapper + make_nvp woes

Thank you for the fast reply, Robert.
Another idea is to cast your character array to a ... character array - like static_cast< int [64] &>(my array address) but that would require a constant size which might not work for you.
I'm not certain I quite understand this. Perhaps I didn't get my thoughts down coherently. I'm seeking to write my serialization like this (sorry I forgot to include this in my initial msg): char some_array[5] = "test"; .... ar & make_nvp("some_array", make_char_array(some_array, 5)); And obtain the following output: output.xml: ... <some_array>test</some_array> output.txt: .... 4 test .... --------------------------- My aforementioned make_char_array() works fine for text archives--just not when the result is composed with make_nvp().
Finally you can use the blunt instrument approach.
save(.... std::string temp_string; // copy data into temp_string ar << temp_string
load .. do the opposite.
Which is pretty much what my serialization wrapper is doing (this is in fact, what I wrote initially, before trying to make it a serialization wrapper). While I can certainly do the blunt approach, it will require me to split my serialization function :(

Hmmm - I think I understand better what you want. I'm not sure the easiest way to do it. Maybe one might specialize nvp<char [] &>(... The "standard" way would be to make a derivation of xml_archive But I would have to think about it some more. Robert Ramey Dan Thill wrote:
Thank you for the fast reply, Robert.
Another idea is to cast your character array to a ... character array - like static_cast< int [64] &>(my array address) but that would require a constant size which might not work for you.
I'm not certain I quite understand this. Perhaps I didn't get my thoughts down coherently. I'm seeking to write my serialization like this (sorry I forgot to include this in my initial msg):
char some_array[5] = "test"; .... ar & make_nvp("some_array", make_char_array(some_array, 5));
And obtain the following output:
output.xml: ... <some_array>test</some_array>
output.txt: .... 4 test .... ---------------------------
My aforementioned make_char_array() works fine for text archives--just not when the result is composed with make_nvp().
Finally you can use the blunt instrument approach.
save(.... std::string temp_string; // copy data into temp_string ar << temp_string
load .. do the opposite.
Which is pretty much what my serialization wrapper is doing (this is in fact, what I wrote initially, before trying to make it a serialization wrapper). While I can certainly do the blunt approach, it will require me to split my serialization function :(

Maybe one might specialize nvp<char [] &>(...
I hadn't thought of this. I'm just now getting the opportunity to use a modern compiler, so I'm feeling my way through all these new template abilities.
The "standard" way would be to make a derivation of xml_archive
Actually, that was the direction I was just starting to investigate this morning. Thanks for all your ideas. I feel certain I'll be able to get something going now. -Dan
participants (2)
-
Dan Thill
-
Robert Ramey