[C++-sig] using boost::python v1

Srivatsan Raghavan vraghavan at cnmnetwork.com
Thu Jul 25 06:07:28 CEST 2002


hello all.. i've got some questions about using bpl, and i've searched 
the docs & the examples, and
i can find no answer

this example illustrates the issues i'm having

<cpp>
   class B ;
   class C ;

   class A
   {
   public:
        A() ;
       virtual bool func1 ( ) ;
       virtual bool func2 ( ) = 0 ;
       virtual ~A() ;
       virtual int  func3 ( std::list<C> ) ;   
   protected :
       B  m_Bobj ;
       std::string  m_Aname ;
    } ;
</cpp>

now , i know how to expose the virtual and pure virtual functions to pyhon,
i just write a  derived class A_callback, and write some static default 
functions that forward
the impl to the virtual function in A .
my problem is in the func3() and the protected members
do i need to write my own wrapper functions to python for mapping a 
list<C> ?
or does bpl do this itself in some way?

and how do i expose the protected members to python?
if i do something like this :
<cpp>
   boost::python::class_builder<A , A_callback> a_class ( this_module , 
"A" ) ;
   a_class.def ( &A::m_Bobj , "m_Bobj" ) ;
</cpp>
that line of code gets me this error (in msvc 6 : sp 5 )  :
 error C2248: 'm_Bobj': cannot access protected member declared in class 
'Logging::Endpoint'
<file-name> : see declaration of 'm_Bobj'

how can i get this to work?










More information about the Cplusplus-sig mailing list