How to separate a specified library from Boost?

I want to use only the random library in Boost, and the whole Boost is too big for me. I remember there seems some tool that can strip off the dependency of the single library on the other libraries in Boost, and extracts it. But unfortunately I cannot recall the name of this tool. Could somebody give me some hints or suggestions on separating a library from Boost? Thanks a lot. Z.L.

Z.L. wrote:
I want to use only the random library in Boost, and the whole Boost is too big for me.
I remember there seems some tool that can strip off the dependency of the single library on the other libraries in Boost, and extracts it. But unfortunately I cannot recall the name of this tool.
Could somebody give me some hints or suggestions on separating a library from Boost?
Thanks a lot.
Boost copy: http://www.boost.org/tools/bcp/bcp.html Jeff

Z.L. wrote:
I want to use only the random library in Boost, and the whole Boost is too big for me.
I remember there seems some tool that can strip off the dependency of the single library on the other libraries in Boost, and extracts it. But unfortunately I cannot recall the name of this tool.
Could somebody give me some hints or suggestions on separating a library from Boost?
Thanks a lot.
Z.L. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi, it's called 'bcp' and you'll find it in boost/tools. -- Regards, dave

Hello,
I am boost-serializing some instances of polymorphic class using their
base class pointer.
I get the 'archive_exception::unregistered_cast' exception at runtime when
serializing one of them. The comment at line 407 of oserializer.hpp (where
the exception is thrown) "convert pointer to more derived type. if this is
thrown it means that the base/derived relationship hasn't be registered".
The code is here below. I think i registered correctly the derived
classes, but I have not been able to make it working: in few words, i
cannot serialize a Serializable class using a pointer to its base
SerializableBase base class. Any suggestion?
TIA,
Luca
using namespace std;
using namespace boost;
using namespace boost::serialization;
struct SerializableBase
{
virtual ~SerializableBase ()
{
}
template<typename Archive>
void serialize (Archive& pAR, unsigned int version)
{
int i (0);
pAR & make_nvp ("doesnotwork", i);
}
};
struct Serializable : public SerializableBase
{
int a;
Serializable () : a (1)
{
}
virtual ~Serializable ()
{
}
template<typename Archive>
void serialize (Archive& pAR, unsigned int version)
{
pAR & BOOST_SERIALIZATION_NVP (a);
pAR & make_nvp ("woowoo", b);
}
};//struct
void save (const Serializable& pS, const char* pFileName)
{
// make an archive
std::ofstream ofs (pFileName);
boost::archive::xml_oarchive oa (ofs);
// Registering a lot of things here!
oa.register_type (static_cast

I took your code and fixed it up to that below and it compile and tests
fine.
Note the usage of BOOST_SERIALIZATION_BASE_OBJECT_NVP
below which is key. This is explained in the documentation.
Robert Ramey
Luca Cappa wrote:
#include

Hello,
I took your code and fixed it up to that below and it compile and tests fine.
Note the usage of BOOST_SERIALIZATION_BASE_OBJECT_NVP below which is key. This is explained in the documentation.
thanks a lot for the answer. Now it works correctly, I still "dare" to
give a suggestion and ask help again:
1) In the documentation I think that the relevant information about how to
serialize properly a derived polymorphic class should stay also in
"Pointers to Objects of Derived Classes -> Registration". In that section
is not mentioned boost::serialization::base_object nor
BOOST_SERIALIZATION_BASE_OBJECT_NVP, and I think it would be helpful to
add an explanation in there: in fact the provided example (class base ...
class derived_one ... derived_two) does not work out of the box.
I think that to the above mentioned section should be added a reference
(or directly the content) of the section
Serializable Concept->Pointers->Pointers of Derived Objects->Runtime
Casting, which explicitly says to call
boost::serialization::base_object<base>(*this), so that the relationship
between a "base/derived pair is added to the table", and make things
working :)
2) Since I do not like to serialize the base object, I do not want to call
boost::serialization::base_object in the derived serializing method, but
instead I wish to just explicitly register base/derived relationship with:
boost::serialization::void_cast_register

Luca Cappa wrote:
2) Since I do not like to serialize the base object, I do not want to call boost::serialization::base_object in the derived serializing method, but instead I wish to just explicitly register base/derived relationship with:
boost::serialization::void_cast_register
();
as the section Runtime Casting tells the reader. But it does not work (compilation fails), I still need to add two NULLs parameters to that function, such as:
This would news to me. As far as I know it works. Send an example. For a working example see boost\serialization\shared_ptr_132.hpp and test_void_castcpp
boost::serialization::void_cast_register
(NULL, NULL); so the code of derived::base::serialize method of the example should be corrected. By the way in file void_cast_fwd.hpp for the method void_caster::void_cast_register the default arguments to NULL appear to be commented out, I wonder why.
Hmmm - I'm not seeing this.
3) What is preferred statement between
oa.register_type (static_cast
(NULL)); and
oa.register_type<Serializable> (); // I don't think this is legal
Some older compilers only work with the former. Modern compilers can use ar.template register_type<T>(); (note the missing _!!!)
? I tested that either works fine with VC8, and I guess they work fine with gcc4 too, but i wonder why I see in the examples of Boost the former used in place of the latter form which is commented out.
Best regards, Luca Cappa

Hello,
notice that I am using Boost version 1.33.1.
On Fri, 20 Apr 2007 07:44:37 +0200, Robert Ramey
Luca Cappa wrote:
But it does not work (compilation fails), I still need to add two NULLs parameters to that function, such as: This would news to me. As far as I know it works. Send an example. For a working example see boost\serialization\shared_ptr_132.hpp and test_void_castcpp
I confirm that the NULLs parameters are required for version 1.33.1: just
looking at the source codes of those two examples, and in the first I do
not see the usage of void_cast_register at all, whilst in the second i
read:
// note that a fundamental feature is that derived/base pairs are
created
// at compiler time so that all are registered before the main program
starts
// so leave the registration here at the end to verify this. Note
bogus arguments
// to workaround msvc 6 bug
boost::serialization::void_cast_register
By the way in file void_cast_fwd.hpp for the method void_caster::void_cast_register the default arguments to NULL appear to be commented out, I wonder why. Hmmm - I'm not seeing this.
I see this code also in the last version of the Boost cvs repository, but
it is also true that in the
last version the NULL parameters are the default arguments, ie:
template
3) What is preferred statement between oa.register_type (static_cast
(NULL)); and oa.register_type<Serializable> (); // I don't think this is legal Some older compilers only work with the former. Modern compilers can use ar.template register_type<T>(); (note the missing _!!!)
Ok, thanks a lot for your time, Greetings, Luca
participants (5)
-
David Klein
-
Jeff Garland
-
Luca Cappa
-
Robert Ramey
-
Z.L.