[C++-sig] custom r-value converters

Nathan Stewart swarfrat at gmail.com
Mon Mar 29 03:08:30 CEST 2010

I have to interface with a custom string class. In my handwritten code, I
had the example from

I'm working with an custom string class. Actually they have a String_mgr
class which derives from a String_val, and exposes the string as  a property
called 'val'. And py++ wraps the String_mgr as an opaque structure with a
working 'val' property. But the String_mgr class in c++ supports assignment
and casting, and that part doesn't work even though I have done an

In my application code I have numerous instances of this String_mgr. I'd
like to be able to contain my interactions with the particulars of
String_mgr to the one definition and not have to do an .add_property('foo',
getter, setter) for each and every occurence of their String_mgr class
(which are quite numerous).  Can I make assignment and casting work in this
way, or must I modify each and every String_mgr occurence as a property?

Just in case it's not clear, I have
struct ClassOne {
   String_mgr name;

struct ClassTwo {
   String_mgr description;

and I want to confine all my handling specific to the String_mgr class to
one location and let the wrapping of String_mgr handle the property get/set
(ClassOne, etc... are IDL generated and numerous.) I can't seem to both wrap
the String_mgr class and have custom converters - I'm told I have a
duplicate registration.  Can I get both automatic conversion and the ability
to treat this wrapped class as a property of other classes? It seems to
trigger on the assignment & casting but I'm just not getting it right now.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100328/f0dbfedd/attachment.html>

More information about the Cplusplus-sig mailing list