[C++-sig] Automatic (implicit ?) type conversion for a data member of a struct.

pj pjdurai at hotmail.com
Mon May 19 19:54:14 CEST 2003


Greetings.

Generally how would I enable automatic conversion for a given C++ type ?

To be specific.

I know how to expose this class to Python and exposing a function returning
this struct.
Its pretty easy due to the power of boost-python.

class MyStruct
{
    std::string name;
}

MyStruct fuc1();


What I cant figure out is how would I do this if the 'name' is not a type
understood by boost-python.
say ..

class MyString;

class MyStruct
{
    MyString name;
}

MyStruct fuc1();

I _dont_ want to wrap the whole 'MyString' class to Python.

I would like to expose 'MyStruct' to python so that the 'name' data member
of
MyStruct is _automatically_  _exposed_ as
a python string ?

I have tried the basic documentation and couldnt find the information I
need.

Appreciate your time.

cheers
pj









More information about the Cplusplus-sig mailing list