[C++-sig] Automatic argument conversion
ericjardim at gmail.com
Mon Jul 25 02:23:43 CEST 2005
this may be easy to do, but I don't know how to acomplish it.
If i have a function like:
std::cout << s << std::endl;
And if I declare inside the module:
.def ("my_print", my_print)
it will work correctly, because Boost.Python know how (somehow) to convert
"std::string"s to Python "str" strings and vice-versa.
So in python shell:
>>> import m
>>> c = m.SomeClass()
But if I have a function, like that one, but instead of a known type I have
another string type:
SomeClass::my_print(const QString& s)
How do I say to Boost.Python that everytime it sees a "QString" argument,
and it have a Python "str", I can apply a simple converter, just like
By now, all I can do is write wrappers to method and do the converstion
Besides, I did not find in the rerefence manual a way to it. I was looking
at the Boost.Python include directories for this kind of conversion and
found a interesting named dir:
But then, I realised that these headers are not all documented. Is it right,
or I did not searched correctly?
Thanks for any help.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Cplusplus-sig