[serialization] Making a "new" primitive type

In a project using JUCE (http://www.rawmaterialsoftware.com) I want to serialize the juce::String, preferably so it's equivalent of serializing std::wstring. How would I go about doing a wrapper for it so boost::serialization can serialize it nicely? TIA /Rob

would need more details on the internals ? is your juice::String
internally using char[] or std::(w)string? you have a choice or
writing a un-intrusive or in-class serialization routines. can't
reallly say anything more without knowing what juice::String exactly
is.
-ravi
On Nov 13, 2007 7:40 PM, Robert Bielik
In a project using JUCE (http://www.rawmaterialsoftware.com) I want to serialize the juce::String, preferably so it's equivalent of serializing std::wstring. How would I go about doing a wrapper for it so boost::serialization can serialize it nicely?
TIA /Rob _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Ravi Chemudugunta skrev:
would need more details on the internals ? is your juice::String internally using char[] or std::(w)string? you have a choice or writing a un-intrusive or in-class serialization routines. can't reallly say anything more without knowing what juice::String exactly is.
Rather than me explaining, here is a pointer to the actual source files. The one I'm interested in serializing is in juce_String.h/cpp At row 1025 (of juce_String.h) you'll see the internal representation. /R

ok, this is going to sound like a lame excuse :|
Tried to compile juce on my ubuntu setup ... failed - complaining
about some alsa headers. However looking at the source, it looks like
the class is able to share a buffer [insert pattern name here] (i.e.
when the class is copied, the reference to the buffer is the same -
its not a deep copy) ... you would need to be careful here not to de
serialize into a class with refcount that is more than one;
on initial inspection text->text seems to me like where the actual
text is stored, so you could possibly use this for serializing, and I
would suggest using the operator= function when de-serializing as it
seems to encapsulate the functionality of maintaining unique
references etc.
was hoping to post a snippet for you but unfortunately it won't
compile and I couldn't find the ?build-deps for juce?
-ravi
On Nov 13, 2007 8:11 PM, Robert Bielik
Ravi Chemudugunta skrev:
would need more details on the internals ? is your juice::String internally using char[] or std::(w)string? you have a choice or writing a un-intrusive or in-class serialization routines. can't reallly say anything more without knowing what juice::String exactly is.
Rather than me explaining, here is a pointer to the actual source files. The one I'm interested in serializing is in juce_String.h/cpp
At row 1025 (of juce_String.h) you'll see the internal representation.
/R
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

ok, this is going to sound like a lame excuse :|
Tried to compile juce on my ubuntu setup ... failed - complaining about some alsa headers.
You can config juce (juce_config.h) not to use ALSA. Maybe that'll make it go further...
However looking at the source, it looks like the class is able to share a buffer [insert pattern name here] (i.e. when the class is copied, the reference to the buffer is the same - its not a deep copy) ... you would need to be careful here not to de serialize into a class with refcount that is more than one;
on initial inspection text->text seems to me like where the actual text is stored, so you could possibly use this for serializing, and I would suggest using the operator= function when de-serializing as it seems to encapsulate the functionality of maintaining unique references etc.
Yes, would probably need to. Anyway I did a first attempt at making a wrapper for String that exposes the methods as needed by the deprecated implementation of boost/serialization/string.hpp (in the #if 0 clause), but I got a vector with items instead of a plain string in the output (using the xml oarchive) which is not what I wanted... :(

Is this not covered in the serialization documentation? YWIA Robert Ramey Robert Bielik wrote:
In a project using JUCE (http://www.rawmaterialsoftware.com) I want to serialize the juce::String, preferably so it's equivalent of serializing std::wstring. How would I go about doing a wrapper for it so boost::serialization can serialize it nicely?
TIA /Rob
participants (3)
-
Ravi Chemudugunta
-
Robert Bielik
-
Robert Ramey