[C++-sig] Keyed properties?
Jakob van Santen
jvansanten at gmail.com
Tue Aug 4 15:23:06 CEST 2009
Hello,
I'm in the process of hiding the unnecessarily verbose parts of a C++
interface behind Python properties, and I've run in to a slight
problem. We have a bunch of classes that expose private std::vectors
via Get(int index) and Set(int index, value_type& val) methods.
Ideally, I'd like to replace
thingy.GetATWDGain(1)
thingy.SetATWDGain(1, 254.5)
with
thingy.atwd_gain[1]
thingy.atwd_gain[1] = 254.5
I know how I would solve this in pure Python (something similar to
this: http://code.activestate.com/recipes/440514/), but I'm wondering
if there's a clever way to do this in Boost.Python without messing
around with the library itself. If anyone has done this already, I'd
be curious to know how.
Cheers,
Jakob van Santen
More information about the Cplusplus-sig
mailing list