[C++-sig] enum pickle issue in boost python

Shashank Bapat shashankbapat at hotmail.com
Mon Nov 27 23:46:37 CET 2006


Ralf,

Yes. I am aware of the boost pickle tutorial. It is useful if I have some 
complicated pickle logic in a class.
But if you see enum_ has reduce and reduce_ex already defined in that case I 
shouldnt need to do anything special to get my enum pickled.
ie providing additional methods for each enum_ to ensure correct pickling 
seems unnecessry.

EnumTest is boost wrapper around an enum.
Something like:

namespace
{
   enum Color
   {
      red   = 1,
      green = 2,
      blue  = 4
   };
}

BOOST_PYTHON_MODULE( EnumTest )
{
   boost::python::scope().attr("__doc__") = "Module to test Boost Python 
enums";

   boost::python::enum_<Color>( "Color" )
      .value( "red",   red )
      .value( "green", green )
      .value( "blue",  blue )
      .export_values()
      ;
}


Check how class.cpp is differnt from enum.cpp in a way it processes module 
and name.

I can fix it myself but I was wondering why is enum_ doing things 
differntly. May be this is just a mistake but may be there is a good reason. 
In that case I ll fix it and it will break something else somewhere !

Any case I ll try cvs HEAD and let you know.

-Shashank

_________________________________________________________________
Stay up-to-date with your friends through the Windows Live Spaces friends 
list. 
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mk




More information about the Cplusplus-sig mailing list