|
Boost Users : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2007-03-09 23:29:02
Bill Lear wrote:
> On Friday, March 9, 2007 at 11:47:21 (-0800) Robert Ramey writes:
>>
>> Second I would make this a "helper class" . Your
>> special "Lear Archive" would be derived from
>> an existing archive and the helper class using
>> multiple inheritance. Look at the implemenation
>> of shared_ptr checked into the HEADof CVS
>> to see how to do this. ...
>
> I checked out the head of CVS, but did not see anything relating
> to a helper class in shared_ptr.hpp. Not sure if I'm looking
> in the right place. This is how I checked it out:
>
> % cvs -z3
> -d:pserver:anonymous_at_[hidden]:/cvsroot/boost
> checkout boost
Its in boost/archive/binary_iarchive.hpp
You don't have to check out, you can always use the web
browser interface to browser though the library. Its much
better in that it gives a "3 dimensional" view so you can
see changes that have been made and differences between
versions.
The relevant section looks like:
65 class binary_iarchive :
66 public binary_iarchive_impl<
67 boost::archive::binary_iarchive,
68 std::istream::char_type,
69 std::istream::traits_type
70 >,
71 public detail::shared_ptr_helper
72 {
73 public:
...
The shared_ptr_helper creates and destroy
an extra tracking object that shared_ptr
requires. This is similar to your case.
> I'm not sure I need to use a cache of strings when saving, in fact,
> I think not, but I went ahead and more-or-less followed your
> instructions.
lol - well good luck with that!!!. Actually, now that I think
about it. I guess we only need the cache of strings on input.
>
> I can't seem to get this to compile, but it's getting closer.
>
> The complete code is below my sig.
>
> The compiler (gcc) complains:
>
> error: 'class boost::archive::text_iarchive' has no member named
> 'cache'
> error: 'class boost::archive::text_oarchive' has no member named
> 'cache'
try changing
> class ll_text_iarchive: public text_iarchive_impl<text_iarchive>,
> public ll_cache {
> public:
> ll_text_iarchive(std::istream& is, unsigned int flags = 0)
> : text_iarchive_impl<text_iarchive>(is, flags) {}
> };
>
to
> class ll_text_iarchive: public text_iarchive_impl<ll_text_iarchive>,
> public ll_cache {
> public:
> ll_text_iarchive(std::istream& is, unsigned int flags = 0)
> : text_iarchive_impl<ll_text_iarchive>(is, flags) {}
> };
Note that the argumetn to text_iarchive_impl should be the MOST
DERIVED class
> Also, for some reason, I can't use this idiom:
>
> ar << ll_string(s);
>
> In fact, this won't work, either:
>
> ar << string("foo");
My guess is that is the is the "const" trap which using is_wrapper
will get around. But this only works in 1.35. So for now do
one of the following:
use & instead of <<
or use a const_cast which will be somewhat complex.
The "const" trap is also explained in the documentation under
the section "rationale"
>
> Finally, I really have no idea how to use the reset_object_address()
> method. I looked through the boost code, but couldn't decipher it.
Did you find anything about it in the documentation?
>
> Any help appreciated.
You're welcome.
Robert Ramey
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