Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2008-09-01 12:00:48


This example should probably be

ar << binary_object(i + 1, p); // etc

Robert Ramey

Basilevs wrote:
> On Sat, Aug 30, 2008 at 11:12 AM, Robert Ramey <ramey_at_[hidden]> wrote:
>> I'm suspecting that there is a confusion about how to seriailzation a
>> pointer to
>> a null terminated string. It's natural to want to do something like
>>
>> char *p;
>> ...
>> p = "jsdkfjads"
>> ...
>> ar & p;
>>
>> because the library syntax encourages one to think that way.
>>
>> But in this case, one would want
>>
>> save(...
>> int i = strlen(p);
>> ar << i;
>> ar << binary_object(i, p);
>> }
>>
>> load(...
>> int i;
>> ar >> i;
>> ar >> binary_object(i,p);
>> }
>>
>
> How do we deal with the trailing null?
> In this example trailing null is not saved, and it is a good thing,
> but shouldn't we add it after loading?


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