[C++-sig] Can boost python do these 2 things automatically?

Chang Chen Chang_Chen at sonic.com
Thu Oct 11 07:44:52 CEST 2007


Hi All

 

I am new to boost python. I have 2 questions for using boost python to
wrap C++ API

 

Our C++ API looks like this:

 

class BImpl;

Class B

{

  public:

   B(){}

   Error DoSomething();

private:

  BImpl*; mpBImpl         

}

class A

{

  public:

   A(){}

   Error CreateB(B& bObj);

  private:

    ...

}

 

Our error handle strategy is returning an error code other than throwing
exception. This is because throwing an exception across the DLL boundary
is not safe.

 

I want to wrap A and B with same C++ public interface in python, but 

 

#1 I want to return real object rather than return an error code. i.e.
in python

 

aObject = A()

*bObject = aObject.CreateB()*

 

#2 I want to throw an *python* exception rather than return an error
code like c++.

 

I do not know how to do it in Boost Python.

 

Any suggestion?

 

Chang

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20071011/f2b4d5fe/attachment.htm>


More information about the Cplusplus-sig mailing list